grail.widgets.garrow module

Version: 16.2

Table of Contents

Description

Contains the GArrow widget commonly used in the GComboBox and GSpinner widgets.

Example

The following example illustrates how the GArrow widget is used to help create a simplified version of the GSpinner widget.

from grail.rtv import IntegerRTV
from grail.widgets import GTextEntry

var = IntegerRTV(name="__garrow_test")

# event handlers
def _onup():
    
var.set(var.get() + 1)
def _ondown():
    
var.set(var.get() - 1)


root = Tkinter.Tk()
up = GArrow(root, height=7, width=14, direction='up')
down = GArrow(root, height=7, width=14, direction='down')
objsignal.listen(down, const.sigON_CLICK, None, _ondown)
objsignal.listen(up, const.sigON_CLICK, None, _onup)
te = GTextEntry(root, rtv=var)

te.grid(row=0, column=0, rowspan=2, sticky=Tkinter.NSEW)
up.grid(row=0, column=1, sticky=Tkinter.NSEW)
down.grid(row=1, column=1, sticky=Tkinter.NSEW)
root.mainloop()

GArrow Widget

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

Draws a simple arrow on a canvas widget. This widget attempts to encapsulate all the logic necessary for drawing an arrow button.

Examples of an arrow button are on the spinners and comboboxes.

Keywords:

Inherits all the Tkinter.Canvas keywords. The most important of Tkinter.Canvas keywords are height and width.

Additional keywords are as follows,

direction
The direction the arrow points, either const.strUP, const.strDOWN, const.strLEFT, const.strRIGHT.
fg, foreground
Specifies the color of the arrow. Defaults to const.colorENABLED_FOREGROUND.
Signal:
const.sigON_CLICK
Generated whenever the arrow button is clicked by the user.
Components:
None.
bindarrow()
Internal usage only. Binds the arrow to the windows events.
disable()
Set the arrow to ignore user events.
enable()
Allow the arrow to respond to user events.
invoke()
Causes the arrow to perform an a button down then up event.
unbindarrow()
Internal usage only. Unbinds the arrows to the windows events.
updatevars()
No RTVs on this widget; always returns 1.