rox.OptionsBox
index

The OptionsBox widget is used to edit an OptionGroup.
For simple applications, rox.edit_options() provides an
easy way to edit the options.
 
You can add new types of option by appending to widget_registry (new
in ROX-Lib 1.9.13). Return a list of widgets (which are packed into either an
HBox or a VBox). For example, to add a button widget:
 
def build_button(box, node, label):
        button = g.Button(label)
        box.may_add_tip(button, node)
        button.connect('clicked', my_button_handler)
        return [button]
OptionsBox.widget_registry['button'] = build_button
 
You can then create such a button in Options.xml with:
 
  <button label='...'>Tooltip</button>
 
Any element may have a 'size-group' attribute. Certain widgets (labels in
particular) in the same size group all have the same size.
 
For widgets that have options, your build function will be called with
the option as a third parameter. You should register get and set methods,
and arrange for box.check_widget to be called when the user changes the
value:
 
def build_toggle(box, node, label, option):
        toggle = g.CheckButton(label)
        box.may_add_tip(toggle, node)
 
        box.handlers[option] = (
                lambda: str(toggle.get_active()),
                lambda: toggle.set_active(option.int_value))
 
        toggle.connect('toggled', lambda w: box.check_widget(option))
 
        return [toggle]
OptionsBox.widget_registry['mytoggle'] = build_toggle

 
Classes
       
gtk.Button(gtk.Bin)
ColourButton
FontButton
gtk.Dialog(gtk.Window)
OptionsBox

 
class ColourButton(gtk.Button)
      A button that opens a GtkColorSelectionDialog
 
  Methods defined here:
__init__(self, option_box, option, title)
clicked(self, button)
expose(self, widget, event)
get(self)
set(self, c=None)

 
class FontButton(gtk.Button)
      A button that opens a GtkFontSelectionDialog
 
  Methods defined here:
__init__(self, option_box, option, title)
clicked(self, button)
get(self)
set(self)

 
class OptionsBox(gtk.Dialog)
      A dialog box which lets the user edit the options. The file
Options.xml specifies the layout of this box.
 
  Methods defined here:
__init__(self, options_group, options_xml, translation=None)
options_xml is an XML file, usually <app_dir>/Options.xml,
which defines the layout of the OptionsBox.
 
It contains an <options> root element containing (nested)
<section> elements. Each <section> contains a number of widgets,
some of which correspond to options. The build_* functions are
used to create them.
 
Example:
 
<?xml version='1.0'?>
<options>
  <section title='First section'>
    <label>Here are some options</label>
    <entry name='default_name' label='Default file name'>
      When saving an untitled file, use this name as the default.
    </entry>
    <section title='Nested section'>
      ...
    </section>
  </section>
</options>
build_colour(self, node, label, option)
<colour name='...' label='...'>Tooltip</colour>
build_entry(self, node, label, option)
<entry name='...' label='...'>Tooltip</entry>
build_filechooser(self, node, label, option)
<filechooser name='...' label='...'/>Tooltip</filechooser>.
Lets the user choose a file (using a GtkFileChooser or by drag-and-drop).
Note: requires GTK >= 2.6
build_fixedlist(self, node, label, option)
<fixedlist name='...' label='...' selection='single|none|multiple'>Tooltip<listitem label='...'/><listitem label='...'/></fixedlist>
build_font(self, node, label, option)
<font name='...' label='...'>Tooltip</font>
build_frame(self, node, label)
<frame label='Title'>...</frame> to group options under a heading.
build_hbox(self, node, label)
<hbox>...</hbox> to layout child widgets horizontally.
build_label(self, node, label)
build_menu(self, node, label, option)
Build an OptionMenu widget, only one item of which may be selected.
<menu name='...' label='...'>
  <item value='...' label='...'/>
  <item value='...' label='...'/>
</menu>
build_numentry(self, node, label, option)
<numentry name='...' label='...' min='0' max='100' step='1'>Tooltip</numentry>.
Lets the user choose a number from min to max.
build_radio_group(self, node, label, option)
Build a list of radio buttons, only one of which may be selected.
<radio-group name='...'>
  <radio value='...' label='...'>Tooltip</radio>
  <radio value='...' label='...'>Tooltip</radio>
</radio-group>
build_secretentry(self, node, label, option)
<secretentry name='...' label='...' char='*'>Tooltip</secretentry>
build_section(self, section, parent)
Create a new page for the notebook and a new entry in the
sections tree, and build all the widgets inside the page.
build_slider(self, node, label, option)
build_spacer(self, node, label)
<spacer/>
build_toggle(self, node, label, option)
<toggle name='...' label='...'>Tooltip</toggle>
build_unknown(self, node, label, option=None)
build_varlist(self, node, label, option)
<varlist name='...' label='...' edit='yes|no' extend='yes|no' selection='single|none|multiple'>Tooltip</varlist>
build_vbox(self, node, label)
<vbox>...</vbox> to layout child widgets vertically.
build_widget(self, node, box)
Dispatches the job of dealing with a DOM Node to the
appropriate build_* function.
build_window_frame(self, add_frame=True)
Create the main structure of the window.
changed(self)
Check whether any options have different values (ie, whether Revert
will do anything).
check_widget(self, option)
A widgets call this when the user changes its value.
do_box(self, node, label, widget)
Helper function for building hbox, vbox and frame widgets.
do_entry(self, node, label, option)
Helper function for entry and secretentry widgets
get_size_group(self, name)
Return the GtkSizeGroup for this name, creating one
if it doesn't currently exist.
make_sized_label(self, label, suffix='')
Create a GtkLabel and add it to the current size-group, if any
may_add_tip(self, widget, node)
If 'node' contains any text, use that as the tip for 'widget'.
open(self)
Show the window, updating all the widgets at the same
time. Use this instead of show().
update_revert(self)
Shade/unshade the Revert button. Internal.
update_widgets(self)
Make widgets show current values. Internal.

 
Functions
       
bool_attr(node, name, val=False)
Interpret node attribute as a boolean value
data(node)
Return all the text directly inside this DOM Node.
str_attr(node, name, val='')
Get string value of node attribute