Previous topic

control

Next topic

gui

panel

GUI widgets for grouping Controls together and defining layout.

class Label(text='', justify='left', image_file='', image_width=0, image_height=0)

A widget with a text label.

Create a Label with the given text.

text
String to appear in the Label
justify
Text justification: ‘left’, ‘center’, or ‘right’
image_file
Full path to image file. May be in any format that ‘convert’ supports.
image_width
Width in pixels to resize the image to
image_height
Height in pixels to resize the image to

Width and height may be used to scale the image in different ways:

width == 0, height == 0
Preserve the original image’s size
width > 0, height == 0
Resize to the given width; height automatically adjusts to maintain aspect ratio
width == 0, height > 0
Resize to the given height; width automatically adjusts to maintain aspect ratio
width > 0, height > 0
Resize to exactly the given dimensions
draw(master, **kwargs)

Draw the Label in the given master.

class Panel(name='', *widgets, **kwargs)

A group of Widgets in a rectangular frame, with an optional label.

Create a Panel containing one or more widgets or sub-panels.

name
Name (label) for panel, or ‘’ for no label
widgets
One or more Widgets (Controls, Panels, Drawers etc.)
draw(master, **kwargs)

Draw the Panel, but not any contained widgets.

labeled
True (default) to use a LabelFrame with the panel’s name, False to draw the panel without a label.

Panel subclasses must pack the contained widgets, or call draw_widgets to pack them.

draw_widgets(side='top', expand=False)

Draw contained widgets in self.frame.

side
‘top’ or ‘left’, to pack widgets on that side
expand
True to make widgets fill all available space

Panel subclasses may call this method to pack widgets, or do custom packing (and not call this method).

enable(enabled=True)

Enable all widgets in the Panel.

get_args()

Return a list of all command-line options from contained widgets.

set_args(args)

Set panel options from the given list of command-line arguments, and remove any successfully parsed options and arguments from args.

class HPanel(name='', *widgets, **kwargs)

A group of widgets or sub-panels, packed horizontally (left-to-right).

For example:

HPanel("General",
    Filename(...),
    Flag(...),
    Number(...)
    )

Create an HPanel to show the given widgets in a horizontal layout.

draw(master, **kwargs)

Draw the HPanel and its contained widgets in the given master.

class VPanel(name='', *widgets, **kwargs)

A group of widgets or sub-panels, packed vertically (top-to-bottom).

For example:

VPanel("General",
    Filename(...),
    Flag(...),
    Number(...)
    )

Create a VPanel to show the given widgets in a vertical layout.

draw(master, **kwargs)

Draw the VPanel and its contained widgets in the given master.

class Dropdowns(name='', *controls, **kwargs)

A Panel with Controls that are shown/hidden using a dropdown list.

The Dropdowns panel initially displays a single dropdown list, with one entry for each Control. When a dropdown entry is selected, the corresponding Control is displayed, along with a “remove” button to discard the control.

choose_new(event=None)

Create and display the chosen control.

draw(master, **kwargs)

Draw the Dropdowns widget in the given master.

get_args()

Return a list of command-line options from all active Controls.

remove(control_label)

Remove a given Control from the interface.

class Drawer(name='', *widgets, **kwargs)

A Panel that may be hidden or “closed” like a drawer.

Create a Drawer containing the given widgets.

draw(master, **kwargs)

Draw the Drawer, with contained widgets initially hidden.

show_hide()

Show or hide the widgets in the Drawer.

class Tabs(name='', *widgets, **kwargs)

A Panel with tab buttons that switch between several widgets.

Create a tabbed panel that switch between several widgets.

activate(tab)

Display the given tab (either by index or Widget instance).

change()

Event handler for switching tabs

draw(master, **kwargs)

Draw the Tabs widget in the given master.

class FlagGroup(name='', kind='normal', *flags, **kwargs)

A Panel that shows a group of several Flag controls, optionally making them mutually-exclusive.

Create a FlagGroup with the given label and state.

name
Name/label for the group
kind
‘normal’ for independent Flags, ‘exclusive’ for mutually-exclusive Flags (more like a Choice)
flags
One or more Flag controls to include in the group

These keyword arguments are accepted:

side
‘top’ or ‘left’, to pack Flags vertically or horizontally
rows
For ‘left’ packing, number of rows to split flags into
columns
For ‘top’ packing, number of columns to split flags into
draw(master, **kwargs)

Draw the FlagGroup in the given master widget.

get_args()

Return a list of arguments for setting the relevant flag(s).

modified(flag)

Called when a flag is modified.