campy.gui.ginteractors module¶
Graphical interactors.
This module provides five types of interactors:
GButton
: A clickable button.GCheckBox
: A checkable box.GSlider
: A slider between numeric values.GChooser
: A list of selectable items.GTextField
: A single-line string entry.
-
class
campy.gui.ginteractors.
GButton
(label)[source]¶ Bases:
campy.gui.ginteractors.GInteractor
An onscreen, clickable button.
The following program displays a button that, when pressed, generates the message: “Please do not press this button again!” (credit Douglas Adams):
window = GWindow() button = GButton('RED BUTTON') window.add_to_region(button, Region.NORTH) @button.onclick def chastise(event): event.button.label = 'Please do not press this button again!' event.button.disable()
-
class
campy.gui.ginteractors.
GCheckBox
(label)[source]¶ Bases:
campy.gui.ginteractors.GInteractor
An onscreen check box.
Clicking once on the check box selects it; clicking again removes the selection.
Clicking on the box generates a GActionEvent.
-
class
campy.gui.ginteractors.
GChooser
(*items)[source]¶ Bases:
campy.gui.ginteractors.GInteractor
A list of selectable items.
You can construct a
GChooser
with an ordered collection of items, oradd()
andremove()
items after construction:size_chooser = GChooser('Small', 'Medium', 'Large') size_chooser.add_item('X-Large') size_chooser.remove_item('Medium')
To get the selected item:
size_chooser = GChooser('Small', 'Medium', 'Large') selected = size_chooser.selected_item
-
add_item
(item)[source]¶ Add a new option to this
GChooser
.Parameters: item – The new item to add to this GChooser
.
-
-
class
campy.gui.ginteractors.
GInteractor
(command='')[source]¶ Bases:
campy.graphics.gobjects.GObject
Superclass of all graphical interactors.
In most applications, interactors will be added to one region in a
GWindow
, but interactors can also be placed in specific positions in aGCompound
(or theGWindow
’s default topGCompound
) just like any otherGObject
.-
command
¶ Get or set the action command for this interactor.
-
-
class
campy.gui.ginteractors.
GSlider
(min_value=0, max_value=100, starting_value=50)[source]¶ Bases:
campy.gui.ginteractors.GInteractor
An onscreen slider.
Dragging
-
class
campy.gui.ginteractors.
GTextField
(width=10)[source]¶ Bases:
campy.gui.ginteractors.GInteractor
An onscreen text field for entering short text strings.
Hitting RETURN in a text field generates a
GActionEvent
.-
text
¶ Get or set the contents of this
GTextField
.
-