grail.widgets.gminmax module

Version: 16.2

Table of Contents

Description

The GMinMax widget is useful for asking users for a minimum and maximum integer range. The widget has error checking to ensure that the maximum value is always greater than the minimum value. You may also attach IntegerRTV variables to both the minimum and maximum value fields to provide instant update of your local data when the user updates this widget.

Example

The following example creates a window that will have two IntegerRTV objects associated with it. When the window is closed, the contents of the IntegerRTV objects will be printed out.

from grail.widgets import *
from grail.rtv import IntegerRTV

root = gwidgetinit()
root.title("GMinMax Example")

minrtv = IntegerRTV(name='__gminmax_test_min')
maxrtv = IntegerRTV(name='__gminmax_test_max')
mm = GMinMax(root, group_text="Example min/max entry",
             
rtv_min=minrtv, rtv_max=maxrtv,
             
min=0, max=10)
mm.pack()
root.mainloop()

print "minimum: %d." % (minrtv.get())
print "maximum: %d." % (maxrtv.get())

The above script will create a window that will appear as follows,

Screen shot of the GMinMax widget.

Example of the GMinMax widget.

GMinMax Widget

The GMinMax widget inherits from,
class GMinMax([parent, **keywords])

Widget used to collect minimum-maximum data via spinners.

Arguments:
parent : Tkinter.Frame
Parent widget, widget we insert into.
keywords
Variable keyword list defined below.
Keywords:
min : integer
Smallest valid value (default is -sys.maxint).
max : integer
Largest valid value (default is sys.maxint).
rtv_min : IntegerRTV
Attaches a grail.rtv variable with the minimum value box.
rtv_max : IntegerRTV
Attaches a grail.rtv variable with the maximum value box.
Components:
minlabel_text
Label for the minimum entry.
maxlabel_text
Label for the maximum entry.
minspinner
Spinner for the minimum entry.
maxspinner
Spinner for the maximum entry.
Signals:
const.sigON_MIN_CHANGE
Emitted when the minimum entry changes.
const.sigON_MAX_CHANGE
Emitted when the maximum entry changes.
destroy()
Cleans up listner's and destroys the widget.
disable()
Set the GMinMax widget to ignore user events.
enable()
Set the GMinMax widget to respond to user events.
updatevars()
Force all vars to synchronize with the user's input.