grail.widgets.gradio module

Version: 16.2

Table of Contents

Description

The GRadio widget provides the script write with the ability to present a set mutually exclusive options. This widget functions much the same as the Tkinter.Radiobutton. However this allows you to attach a run-time variable from grail.rtv; as well as, group all your options under one single widget.

Example

The following example presents the user with three options. When the user closes the dialog the chosen option will be written to the console.

import Tkinter

from grail.widgets import *
from grail import rtv

root = gwidgetinit()
items = ("Gaussian Distribution", "Normalized Distribution",
        
"Constant Distribution",)
var = rtv.IntegerRTV(name="option")
var.set(0)

radio = GRadio(root, align="vertical", items=items, rtv=var)
radio.pack(anchor="nw")
root.title("Demo - GRadio")
root.mainloop()

print "You selected: '%s'." % (items[var.get()])

The script above will generate a widget that is shown in the figure below,

Example of GRadio widget.

Example of the GRadio widget.

GRadio Widget

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

Creates a set of radio buttons. This allows a script writer to present the user with a mutual exclusive list of options.

Arguments:
parent : Tkinter.Frame
Parent widget, widget we insert into.
keywords
Variable keyword list defined below.
Keywords:

The keyword variable is ignored.

align: ['horizontal'|'vertical']
Indicates the direction to align the GRadio options.
items: list
A list of strings for each radio button.
rtv : RTV
A run-time variable that will hold the value for the most recently selected value.
Components:
None.
Signal:
const.sigON_SELECT
Emitted when the user or run-time variable changes. The receiver function will need to receive an index argument. The index corresponds to the value selected in the items list.
destroy()
Handles the Tkinter de-allocation.
disable()
Set the radio buttons to ignore the user events.
enable()
Set the radio buttons to respond to user events.
getselected()
Return the index to the selected radio button.
select(index)
Selects a radio button based on the given index.
updatevars()
Always in a synchronized state; always returns 1.