grail.widgets.glabel module

Version: 16.2

Table of Contents

Description

Contains the GLabel widget. This widget provides the user the ability to associate a run-time variable (RTV) from the grail.rtv module with a label. Whenever the variable changes, the contents of the GLabel will change.

Example

The following sample script illustrates creating a GLabel widget and associating a run-time variable (RTV) with the widget.

import Tkinter

from grail.widgets import *
from grail import rtv

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

var = rtv.StringRTV(name="example_var", value="Hello World!")
label = GLabel(root, rtv=var, relief=Tkinter.GROOVE)
label.pack(expand=1, fill=Tkinter.X)

root.mainloop()

If you changed the value of var via its set function, then you would automatically change the text displayed within the GLabel widget.

The example code shown above will generate the following window,

Screen shot of the GLabel widget.

Example of the GLabel widget.

GLabel Widget

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

Creates a Label that has can use a run-time variable (RTV).

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

All keywords usable with the Tkinter.Label [1] widget are usable with the GLabel widget. In addition the following keyword is also defined,

rtv : StringRTV
Associates a run-time variable (grail.rtv) with the GLabel widget's text.
Components:
None.
destroy()
Handle the Tkinter de-allocation request.
disable()
Set the label to ignore user events. That is the GLabel widgets's natural state, so this does nothing.
enable()
Set the label to respond to user events. In this case we don't do anything.
updatevars()
Ensure variable is synchronized with GUI. In this case its always in synchronized.

[1]John W. Shipman. "The Label widget." Tkinter Reference: a GUI for Python. 2004 June 6. 2004 June 16. <http://infohost.nmt.edu/tcc/help/pubs/tkinter/ar01s10.html>