.
D 2017-02-20T15:16:38.755
L api-uikit
N text/html
P 561fd5696ec6bec29696826ceee336c68769803a
U mario
W 21680
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>uikit</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="streamtuner2/uikit.py"> streamtuner2/uikit.py</a></font></td></tr></table>
<p><tt># encoding: UTF-8<br>
# api: python<br>
# type: functions<br>
# title: <a href="#uikit">uikit</a> helper functions<br>
# description: simplify usage of some gtk widgets<br>
# version: 2.0<br>
# author: mario<br>
# license: public domain<br>
#<br>
# Wrappers around gtk methods. The TreeView method .columns() allows<br>
# to fill a treeview. It adds columns and data rows with a mapping<br>
# dictionary (which specifies many options and data positions).<br>
#<br>
# The .tree() method is a trimmed-down variant of that, creates a<br>
# single column, but has threaded entries.<br>
#<br>
# With the methodes .app_state() and .app_restore() named gtk widgets<br>
# can be queried for attributes. The methods return a saveable dict,<br>
# which contain current layout options for a few Widget types. Saving<br>
# and restoring must be handled elsewhere.</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="gtk.gdk.html">gtk.gdk</a><br>
<a href="https://docs.python.org/3/library/base64.html">base64</a><br>
<a href="https://docs.python.org/3/library/copy.html">copy</a><br>
</td><td width="25%" valign=top><a href="https://docs.python.org/3/library/gobject.html">gobject</a><br>
<a href="https://docs.python.org/3/library/gtk.html">gtk</a><br>
<a href="https://docs.python.org/3/library/inspect.html">inspect</a><br>
</td><td width="25%" valign=top><a href="https://docs.python.org/3/library/os.html">os</a><br>
<a href="https://docs.python.org/3/library/pygtk.html">pygtk</a><br>
<a href="https://docs.python.org/3/library/re.html">re</a><br>
</td><td width="25%" valign=top><a href="https://docs.python.org/3/library/sys.html">sys</a><br>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="#AuxiliaryWindow">AuxiliaryWindow</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="#AboutStreamtuner2">AboutStreamtuner2</a>
</font></dt></dl>
</dd>
</dl>
</dd>
<dt><font face="helvetica, arial"><a href="gtk.html#ComboBox">gtk.ComboBox</a>(<a href="gtk.html#Bin">gtk.Bin</a>, <a href="gtk.html#CellEditable">gtk.CellEditable</a>, <a href="gtk.html#CellLayout">gtk.CellLayout</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="#ComboBoxText">ComboBoxText</a>
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="#uikit">uikit</a>
</font></dt></dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="AboutStreamtuner2">class <strong>AboutStreamtuner2</strong></a>(<a href="#AuxiliaryWindow">AuxiliaryWindow</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt># Auxiliary window: about dialog<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="#AboutStreamtuner2">AboutStreamtuner2</a></dd>
<dd><a href="#AuxiliaryWindow">AuxiliaryWindow</a></dd>
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="AboutStreamtuner2-__init__"><strong>__init__</strong></a>(self, parent)</dt></dl>
<hr>
Methods inherited from <a href="#AuxiliaryWindow">AuxiliaryWindow</a>:<br>
<dl><dt><a name="AboutStreamtuner2-__getattr__"><strong>__getattr__</strong></a>(self, name)</dt></dl>
<hr>
Data descriptors inherited from <a href="#AuxiliaryWindow">AuxiliaryWindow</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="AuxiliaryWindow">class <strong>AuxiliaryWindow</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt># Encapsulates references to gtk objects AND properties in main window,<br>
# which allows to use self. and main. almost interchangably.<br>
#<br>
# This is a kludge to keep gtkBuilder widgets accessible; so just one<br>
# instance has to be built. Also ties main.channels{} or .features{}<br>
# dicts together for feature windows. Used by search, config, streamedit.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="AuxiliaryWindow-__getattr__"><strong>__getattr__</strong></a>(self, name)</dt></dl>
<dl><dt><a name="AuxiliaryWindow-__init__"><strong>__init__</strong></a>(self, parent)</dt></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="ComboBoxText">class <strong>ComboBoxText</strong></a>(<a href="gtk.html#ComboBox">gtk.ComboBox</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt># Text-only dropdown list.<br>
#<br>
# Necessary because gtk.<a href="#ComboBoxText">ComboBoxText</a> binding is absent in debian packages<br>
# https://bugzilla.gnome.org/show_bug.cgi?id=660659<br>
#<br>
# This one implements a convenience method `.<a href="#ComboBoxText-set_default">set_default</a>()` to define the active<br>
# selection by value, rather than by index.<br>
#<br>
# Can use a list[] of entries or a key->value dict{}, where the value becomes<br>
# display text, and the key the internal value.<br> </tt></td></tr>
<tr><td>
Methods defined here:<br>
<dl><dt><a name="ComboBoxText-__init__"><strong>__init__</strong></a>(self, entries, no_scroll<font color="#909090">=1</font>)</dt></dl>
<dl><dt><a name="ComboBoxText-get_active_text"><strong>get_active_text</strong></a>(self)</dt><dd><tt># fetch currently selected text entry</tt></dd></dl>
<dl><dt><a name="ComboBoxText-no_scroll"><strong>no_scroll</strong></a>(self, widget, event, data<font color="#909090">=None</font>)</dt><dd><tt># Signal/Event callback to prevent hover scrolling of <a href="gtk.html#ComboBox">ComboBox</a> widgets</tt></dd></dl>
<dl><dt><a name="ComboBoxText-set_default"><strong>set_default</strong></a>(self, value)</dt><dd><tt># activate dropdown of given value</tt></dd></dl>
<hr>
Static methods defined here:<br>
<dl><dt><a name="ComboBoxText-parse_options"><strong>parse_options</strong></a>(opts, sep<font color="#909090">='|'</font>, assoc<font color="#909090">='='</font>)</dt><dd><tt># Expand A=a|B=b|C=c option list into (key,value) tuple list, or A|B|C just into a list.</tt></dd></dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>ls</strong> = None</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="uikit">class <strong>uikit</strong></a></font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt># simplified gtk constructors ---------------------------------------------<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Static methods defined here:<br>
<dl><dt><a name="uikit-add_menu"><strong>add_menu</strong></a>(menuwidget, label, action, insert<font color="#909090">=None</font>)</dt><dd><tt># Attach textual menu entry and callback</tt></dd></dl>
<dl><dt><a name="uikit-add_signals"><strong>add_signals</strong></a>(builder, map)</dt><dd><tt># manual signal binding with a dict of { (widget, signal): callback }</tt></dd></dl>
<dl><dt><a name="uikit-app_bin_check"><strong>app_bin_check</strong></a>(v)</dt><dd><tt># return OK or CANCEL depending on availability of app</tt></dd></dl>
<dl><dt><a name="uikit-app_restore"><strong>app_restore</strong></a>(wTree, r<font color="#909090">=None</font>)</dt><dd><tt>#-- restore window and widget properties<br>
#<br>
# requires only the previously saved widget state dict</tt></dd></dl>
<dl><dt><a name="uikit-app_state"><strong>app_state</strong></a>(wTree, widgetnames<font color="#909090">=['window1', 'treeview2', 'vbox17']</font>)</dt><dd><tt>#-- save window size and widget properties<br>
#<br>
# needs a list of widgetnames<br>
# e.g. pickle.dump(<a href="#uikit">uikit</a>.<a href="#uikit-app_state">app_state</a>(...), open(os.environ["HOME"]+"/.config/app_winstate", "w"))</tt></dd></dl>
<dl><dt><a name="uikit-bg"><strong>bg</strong></a>(w, color<font color="#909090">=''</font>, where<font color="#909090">=['bg']</font>, wrap<font color="#909090">=1</font>)</dt><dd><tt>this method should be called after widget creation, and before .add()ing it to container</tt></dd></dl>
<dl><dt><a name="uikit-columns"><strong>columns</strong></a>(widget, datamap<font color="#909090">=[]</font>, entries<font color="#909090">=None</font>, show_favicons<font color="#909090">=True</font>, pix_entry<font color="#909090">=False</font>, fixed_size<font color="#909090">=24</font>)</dt><dd><tt>#-- fill a treeview<br>
#<br>
# Adds treeviewcolumns/cellrenderers and liststore from a data dictionary.<br>
# Its datamap and the table contents can be supplied in one or two steps.<br>
# When new data gets applied, the columns aren't recreated.<br>
#<br>
# The columns are created according to the datamap, which describes cell<br>
# mapping and layout. Columns can have multiple cellrenderers, but usually<br>
# there is a direct mapping to a data source key from entries.<br>
#<br>
# datamap = [ # title width dict-key type, renderer, attrs <br>
# ["Name", 150, ["titlerow", str, "text", {} ] ],<br>
# [False, 0, ["interndat", int, None, {} ] ],<br>
# ["Desc", 200, ["descriptn", str, "text", {} ], ["icon",str,"pixbuf",{}] ],<br>
#<br>
# An according entries list then would contain a dictionary for each row:<br>
# entries = [ {"titlerow":"first", "interndat":123}, {"titlerow":"..."}, ]<br>
# Keys not mentioned in the datamap get ignored, and defaults are applied<br>
# for missing cols. All values must already be in the correct type however.</tt></dd></dl>
<dl><dt><a name="uikit-config_treeview"><strong>config_treeview</strong></a>(opt, columns<font color="#909090">=['Icon', 'Command']</font>)</dt><dd><tt># Config win table (editable dictionary, two columns w/ executable indicator pixbuf)</tt></dd></dl>
<dl><dt><a name="uikit-do"><strong>do</strong></a>(callback, *args, **kwargs)</dt><dd><tt># Spool gtk update calls from non-main threads (optional immediate=1 flag to run task next, not last)</tt></dd></dl>
<dl><dt><a name="uikit-hbox"><strong>hbox</strong></a>(w1, w2, exr<font color="#909090">=True</font>, spacing<font color="#909090">=5</font>)</dt><dd><tt># Wrap two widgets in horizontal box</tt></dd></dl>
<dl><dt><a name="uikit-idle_do"><strong>idle_do</strong></a>()</dt><dd><tt># Execute UI updating tasks in order</tt></dd></dl>
<dl><dt><a name="uikit-label"><strong>label</strong></a>(text, size<font color="#909090">=305</font>, markup<font color="#909090">=0</font>)</dt><dd><tt># Create GtkLabel</tt></dd></dl>
<dl><dt><a name="uikit-liststore_edit"><strong>liststore_edit</strong></a>(cell, row, text, user_data)</dt><dd><tt># Generic Gtk callback to update ListStore when entries get edited.<br>
# where user_data = (liststore, column #id)</tt></dd></dl>
<dl><dt><a name="uikit-msg"><strong>msg</strong></a>(text, style<font color="#909090">=<enum GTK_MESSAGE_INFO of type GtkMessageType></font>, buttons<font color="#909090">=<enum GTK_BUTTONS_CLOSE of type GtkButtonsType></font>, yes<font color="#909090">=None</font>)</dt><dd><tt># gtk.messagebox</tt></dd></dl>
<dl><dt><a name="uikit-pixbuf"><strong>pixbuf</strong></a>(buf, fmt<font color="#909090">='png'</font>, decode<font color="#909090">=True</font>, gzip<font color="#909090">=False</font>)</dt><dd><tt># Pixbug loader (from inline string, as in `logo.png`, automatic base64 decoding, and gunzipping of raw data)</tt></dd></dl>
<dl><dt><a name="uikit-save_file"><strong>save_file</strong></a>(title<font color="#909090">='Save As'</font>, parent<font color="#909090">=None</font>, fn<font color="#909090">=''</font>, formats<font color="#909090">=None</font>, action<font color="#909090">=<enum GTK_FILE_CHOOSER_ACTION_SAVE of type GtkFileChooserAction></font>, action_btn<font color="#909090">='gtk-save'</font>)</dt></dl>
<dl><dt><a name="uikit-save_file_filterchange"><strong>save_file_filterchange</strong></a>(c)</dt><dd><tt># Callback for changed FileFilter, updates current filename extension</tt></dd></dl>
<dl><dt><a name="uikit-tree"><strong>tree</strong></a>(widget, entries, title<font color="#909090">='category'</font>, icon<font color="#909090">='gtk-directory'</font>)</dt><dd><tt>#-- treeview for categories<br>
#<br>
# simple two-level treeview display in one column<br>
# with entries = [main,[sub,sub], title,[...],...]</tt></dd></dl>
<dl><dt><a name="uikit-tree_column"><strong>tree_column</strong></a>(widget, title<font color="#909090">='Category'</font>)</dt></dl>
<dl><dt><a name="uikit-wrap"><strong>wrap</strong></a>(widgetstore<font color="#909090">=None</font>, id<font color="#909090">=None</font>, w<font color="#909090">=None</font>, label<font color="#909090">=None</font>, color<font color="#909090">=None</font>, image<font color="#909090">=None</font>, align<font color="#909090">=1</font>, label_size<font color="#909090">=305</font>, label_markup<font color="#909090">=0</font>)</dt><dd><tt># Wrap entries/checkboxes with extra label, background, images, etc.</tt></dd></dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>gtk_position_type_enum</strong> = [<enum GTK_POS_LEFT of type GtkPositionType>, <enum GTK_POS_RIGHT of type GtkPositionType>, <enum GTK_POS_TOP of type GtkPositionType>, <enum GTK_POS_BOTTOM of type GtkPositionType>]</dl>
<dl><dt><strong>idle_tasks</strong> = []</dl>
<dl><dt><strong>in_idle</strong> = False</dl>
<dl><dt><strong>save_formats</strong> = [('*.pls', '*.pls'), ('*.xspf', '*.xpsf'), ('*.m3u', '*.m3u'), ('*.jspf', '*.jspf'), ('*.asx', '*.asx'), ('*.json', '*.json'), ('*.smil', '*.smil'), ('*.desktop', '*.desktop'), ('*', '*')]</dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt><a name="-gui_startup"><strong>gui_startup</strong></a>(p<font color="#909090">=0.0</font>, msg<font color="#909090">='streamtuner2 is starting'</font>)</dt></dl>
<dl><dt><a name="-treepath"><strong>treepath</strong></a>(ls)</dt><dd><tt># Use a str of "1:2:3" as treepath,<br>
# literally in Gtk2, TreePath-wrapped for Gtk3</tt></dd></dl>
<dl><dt><a name="-treepath_to_str"><strong>treepath_to_str</strong></a>(tp)</dt></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
<td width="100%"><strong>PY3</strong> = 0<br>
<strong>conf</strong> = {u'filter_walledgardens': True, u'radionomy_page...e/mario/.config/streamtuner2', u'history': u'20'}<br>
<strong>empty_pixbuf</strong> = <gtk.gdk.Pixbuf object at 0x7fe51185d820 (GdkPixbuf at 0x18dd190)><br>
<strong>log</strong> = <config.log_printer object><br>
<strong>progressbar</strong> = None<br>
<strong>progresswin</strong> = None<br>
<strong>ui_xml</strong> = u'<?xml version="1.0" encoding="UTF-8"?><font color="#c040c0">\n</font><!-- Gene... </object><font color="#c040c0">\n</font> </child><font color="#c040c0">\n</font> </object><font color="#c040c0">\n</font></interface><font color="#c040c0">\n</font>'<br>
<strong>ver</strong> = 2</td></tr></table>
Z 2adb1e72f80b4da1a7e77020a569be1e