gaupol.util¶
Source: gaupol/util.py
Miscellaneous functions and decorators.
Functions¶
- gaupol.util.char_to_px(nchar, font=None)¶
Convert characters to pixels.
- gaupol.util.delay_add(delay, function, *args, **kwargs)¶
Call function with args and kwargs once after delay (ms).
Return integer ID of the event source from GLib.timeout_add().
- gaupol.util.document_to_text_field(doc)¶
Return gaupol.fields item corresponding to doc.
- gaupol.util.flash_dialog(dialog)¶
Run dialog, destroy it and return response.
flash_dialog() or run_dialog() should be used always when a Gtk.Dialog is run so that unit tests can monkey patch this function with one that returns a specified response without waiting for user input.
- gaupol.util.get_content_size(widget)¶
Return the width and height desired by widget.
- gaupol.util.get_font()¶
Return custom font or blank string.
- gaupol.util.get_gst_version()¶
Return Gst version number as string or None.
- gaupol.util.get_icon_image(name, fallback, size)¶
Return icon image from name or fallback in theme.
- gaupol.util.get_preview_command()¶
Return command to use for lauching video player.
- gaupol.util.get_text_view_size(text_view, font=None)¶
Return the width and height desired by text_view.
- gaupol.util.get_tree_view_size(tree_view)¶
Return the width and height desired by tree_view.
- gaupol.util.get_zebra_color(tree_view)¶
Return background color to use for tree view zebra-stripes.
- gaupol.util.gst_available()¶
Return True if Gst module is available.
Also check that required elements from gst-plugins-base and gst-plugins-good are available.
- gaupol.util.gtkspell_available()¶
Return True if GtkSpell module is available.
- gaupol.util.hex_to_rgba(string)¶
Return a Gdk.RGBA for hexadecimal string.
Raise ValueError if parsing string fails.
- gaupol.util.idle_add(function, *args, **kwargs)¶
Call function with args and kwargs when idle.
Return integer ID of the event source from GLib.idle_add().
- gaupol.util.install_module(name, obj)¶
Install obj‘s module into the gaupol namespace.
Typical call is of form:
gaupol.util.install_module("foo", lambda: None)
- gaupol.util.iterate_main()¶
Iterate the GTK+ main loop while events are pending.
- gaupol.util.lines_to_px(nlines, font=None)¶
Convert lines to pixels.
- gaupol.util.new_hbox(spacing)¶
Return a new horizontal Gtk.Box.
- gaupol.util.new_vbox(spacing)¶
Return a new vertical Gtk.Box.
- gaupol.util.pack_start(box, widget, padding=0)¶
Pack widget to box without fill or expand.
- gaupol.util.pack_start_expand(box, widget, padding=0)¶
Pack widget to box with fill and expand.
- gaupol.util.pack_start_fill(box, widget, padding=0)¶
Pack widget to box with fill, but no expand.
- gaupol.util.prepare_text_view(text_view)¶
Set spell-check, line-length margin and font properties.
- gaupol.util.raise_default(expression)¶
Raise gaupol.Default if expression evaluates to True.
- gaupol.util.rgba_to_hex(color)¶
Return hexadecimal string for Gdk.RGBA color.
- gaupol.util.run_dialog(dialog)¶
Run dialog and return response.
run_dialog() or flash_dialog() should be used always when a Gtk.Dialog is run so that unit tests can monkey patch this function with one that returns a specified response without waiting for user input.
- gaupol.util.scale_to_content(widget, min_nchar=0, max_nchar=32768, min_nlines=0, max_nlines=32768, font=None)¶
Set widget’s size by content, but limited by min and max.
- gaupol.util.scale_to_size(widget, nchar, nlines, font=None)¶
Set widget‘s size to nchar and nlines.
- gaupol.util.separate_combo(store, itr, data=None)¶
Separator function for combo box models.
- gaupol.util.set_cursor_busy(window)¶
Set mouse pointer busy when above window.
- gaupol.util.set_cursor_normal(window)¶
Set mouse pointer normal when above window.
- gaupol.util.set_widget_font(widget, font)¶
Use font for widget.
- gaupol.util.show_exception(exctype, value, tb)¶
Show exception traceback in gaupol.DebugDialog.
This function can be set as a sys.excepthook().
- gaupol.util.show_uri(uri)¶
Open uri in default application.
- gaupol.util.text_field_to_document(field)¶
Return aeidon.documents item corresponding to field.
- gaupol.util.tree_path_to_row(path)¶
Convert path to a list row integer.
path can be either a Gtk.Treepath instance or a string representation of it (as commonly used by various callbacks).
- gaupol.util.tree_row_to_path(row)¶
Convert list row integer to a Gtk.TreePath.