grail.widgets.gbutton module

Version: 16.2

Table of Contents

Description

Basically adds the semantics to treat a Tkinter.Button as a MineSight® Grail button within the MineSight® Grail widget library.

Example

The following segment of code illustrates how a GButton behaves. The event chain button illustrates how you can use both the command keyword or the const.sigON_CLICK signal to handle a user button click.

# event handlers
def _onDisabledClicked():
    
print "Called _onDisabledClicked()"

def _onEnabledClicked():
    
print "Called _onEnabledClicked()"

def _onCommand(event=None):
    
print "Called _onCommand() (specified via keyword)"

def _onClickSignal():
    
print "Called _onClickSignal() (specified via ObjSig)"

root = Tkinter.Tk()
buttons = []
btn = GButton(root, text="disabled")
objsignal.listen(btn, "onClick()", None, _onDisabledClicked)
btn.disable()
btn.focus_set()
buttons.append(btn)

btn = GButton(root, text="enabled")
objsignal.listen(btn, "onClick()", None, _onEnabledClicked)
buttons.append(btn)

btn = GButton(root, text="event chain", command=_onCommand)
objsignal.listen(btn, "onClick()", None, _onClickSignal)
buttons.append(btn)

for btn in buttons:
    
btn.pack(fill='both', expand=1)

root.title("Demo - GButton")
root.geometry("%dx%d+%d+%d" % (200, 80, 150, 150))
root.mainloop()

GButton Widget

The GButton widget inherits from,
class GButton([parent, **kws])

Takes the Tkinter.Button and adds the enable() and disable() functions.

Keywords:
Same as Tkinter.Button.
Signal:
const.sigON_CLICK
Generated when the user clicks the button widget.
Component:
None.
disable()
Set the button to ignore user events.
enable()
Set the button to respond to user events.
updatevars()
No RTVs; always returns 1.