Update of /cvsroot/wpdev/xmlscripts/python-lib/Pmw/Pmw_1_2/lib
In directory sc8-pr-cvs1:/tmp/cvs-serv17003/Pmw_1_2/lib
Added Files:
__init__.py Pmw.def PmwAboutDialog.py PmwBalloon.py PmwBase.py
PmwBlt.py PmwButtonBox.py PmwColor.py PmwComboBox.py
PmwComboBoxDialog.py PmwCounter.py PmwCounterDialog.py
PmwDialog.py PmwEntryField.py PmwGroup.py PmwHistoryText.py
PmwLabeledWidget.py PmwLoader.py PmwLogicalFont.py
PmwMainMenuBar.py PmwMenuBar.py PmwMessageBar.py
PmwMessageDialog.py PmwNoteBook.py PmwOptionMenu.py
PmwPanedWidget.py PmwPromptDialog.py PmwRadioSelect.py
PmwScrolledCanvas.py PmwScrolledField.py PmwScrolledFrame.py
PmwScrolledListBox.py PmwScrolledText.py PmwSelectionDialog.py
PmwTextDialog.py PmwTimeCounter.py PmwTimeFuncs.py
Log Message:
pmw class wrapers for Tkinter
--- NEW FILE: __init__.py ---
# File to allow this directory to be treated as a python package.
--- NEW FILE: Pmw.def ---
# [Emacs: -*- python -*-]
# --- This is the Pmw definition file ---
#
# It is invoked by the Pmw dynamic loader in Pmw.__init__.
#
# widgets : tuple with the names of those widget classes that are
# stacked in a module of the same name.
# widgetclasses : dictionary from names of widget classes to module names.
# functions : dictionary from function names to modules names.
# modules : tuple of module names that don't contain widget classes
# of the same name.
#
# Widgets whose name is the same as its module.
_widgets = (
'AboutDialog', 'Balloon', 'ButtonBox', 'ComboBox',
'ComboBoxDialog', 'Counter', 'CounterDialog', 'Dialog',
'EntryField', 'Group', 'HistoryText', 'LabeledWidget',
'MainMenuBar', 'MenuBar', 'MessageBar',
'MessageDialog', 'NoteBook', 'OptionMenu', 'PanedWidget',
'PromptDialog', 'RadioSelect', 'ScrolledCanvas', 'ScrolledField',
'ScrolledFrame', 'ScrolledListBox', 'ScrolledText', 'SelectionDialog',
'TextDialog', 'TimeCounter',
)
# Widgets whose name is not the same as its module.
_extraWidgets = {
}
_functions = {
'logicalfont' : 'LogicalFont',
'logicalfontnames' : 'LogicalFont',
'aboutversion' : 'AboutDialog',
'aboutcopyright' : 'AboutDialog',
'aboutcontact' : 'AboutDialog',
'datestringtojdn' : 'TimeFuncs',
'timestringtoseconds' : 'TimeFuncs',
'setyearpivot' : 'TimeFuncs',
'ymdtojdn' : 'TimeFuncs',
'jdntoymd' : 'TimeFuncs',
'stringtoreal' : 'TimeFuncs',
'aligngrouptags' : 'Group',
'OK' : 'EntryField',
'ERROR' : 'EntryField',
'PARTIAL' : 'EntryField',
'numericvalidator' : 'EntryField',
'integervalidator' : 'EntryField',
'hexadecimalvalidator' : 'EntryField',
'realvalidator' : 'EntryField',
'alphabeticvalidator' : 'EntryField',
'alphanumericvalidator' : 'EntryField',
'timevalidator' : 'EntryField',
'datevalidator' : 'EntryField',
}
_modules = (
'Color', 'Blt',
)
--- NEW FILE: PmwAboutDialog.py ---
import Pmw
class AboutDialog(Pmw.MessageDialog):
# Window to display version and contact information.
# Class members containing resettable 'default' values:
_version = ''
_copyright = ''
_contact = ''
def __init__(self, parent = None, **kw):
# Define the megawidget options.
INITOPT = Pmw.INITOPT
optiondefs = (
('applicationname', '', INITOPT),
('iconpos', 'w', None),
('icon_bitmap', 'info', None),
('buttons', ('Close',), None),
('defaultbutton', 0, None),
)
self.defineoptions(kw, optiondefs)
# Initialise the base class (after defining the options).
Pmw.MessageDialog.__init__(self, parent)
applicationname = self['applicationname']
if not kw.has_key('title'):
self.configure(title = 'About ' + applicationname)
if not kw.has_key('message_text'):
text = applicationname + '\n\n'
if AboutDialog._version != '':
text = text + 'Version ' + AboutDialog._version + '\n'
if AboutDialog._copyright != '':
text = text + AboutDialog._copyright + '\n\n'
if AboutDialog._contact != '':
text = text + AboutDialog._contact
self.configure(message_text=text)
# Check keywords and initialise options.
self.initialiseoptions()
def aboutversion(value):
AboutDialog._version = value
def aboutcopyright(value):
AboutDialog._copyright = value
def aboutcontact(value):
AboutDialog._contact = value
--- NEW FILE: PmwBalloon.py ---
import os
import string
import Tkinter
import Pmw
class Balloon(Pmw.MegaToplevel):
def __init__(self, parent = None, **kw):
# Define the megawidget options.
optiondefs = (
('initwait', 500, None), # milliseconds
('label_background', 'lightyellow', None),
('label_foreground', 'black', None),
('label_justify', 'left', None),
('master', 'parent', None),
('relmouse', 'none', self._relmouse),
('state', 'both', self._state),
('statuscommand', None, None),
('xoffset', 20, None), # pixels
('yoffset', 1, None), # pixels
('hull_highlightthickness', 1, None),
('hull_highlightbackground', 'black', None),
)
self.defineoptions(kw, optiondefs)
# Initialise the base class (after defining the options).
Pmw.MegaToplevel.__init__(self, parent)
self.withdraw()
self.overrideredirect(1)
# Create the components.
interior = self.interior()
self._label = self.createcomponent('label',
(), None,
Tkinter.Label, (interior,))
self._label.pack()
# The default hull configuration options give a black border
# around the balloon, but avoids a black 'flash' when the
# balloon is deiconified, before the text appears.
if not kw.has_key('hull_background'):
self.configure(hull_background = \
str(self._label.cget('background')))
# Initialise instance variables.
self._timer = None
# The widget or item that is currently triggering the balloon.
# It is None if the balloon is not being displayed. It is a
# one-tuple if the balloon is being displayed in response to a
# widget binding (value is the widget). It is a two-tuple if
# the balloon is being displayed in response to a canvas or
# text item binding (value is the widget and the item).
self._currentTrigger = None
# Check keywords and initialise options.
self.initialiseoptions()
def destroy(self):
if self._timer is not None:
self.after_cancel(self._timer)
self._timer = None
Pmw.MegaToplevel.destroy(self)
def bind(self, widget, balloonHelp, statusHelp = None):
# If a previous bind for this widget exists, remove it.
self.unbind(widget)
if balloonHelp is None and statusHelp is None:
return
if statusHelp is None:
statusHelp = balloonHelp
enterId = widget.bind('<Enter>',
lambda event, self = self, w = widget,
sHelp = statusHelp, bHelp = balloonHelp:
self._enter(event, w, sHelp, bHelp, 0))
# Set Motion binding so that if the pointer remains at rest
# within the widget until the status line removes the help and
# then the pointer moves again, then redisplay the help in the
# status line.
# Note: The Motion binding only works for basic widgets, and
# the hull of megawidgets but not for other megawidget components.
motionId = widget.bind('<Motion>',
lambda event = None, self = self, statusHelp = statusHelp:
self.showstatus(statusHelp))
leaveId = widget.bind('<Leave>', self._leave)
buttonId = widget.bind('<ButtonPress>', self._buttonpress)
# Set Destroy binding so that the balloon can be withdrawn and
# the timer can be cancelled if the widget is destroyed.
destroyId = widget.bind('<Destroy>', self._destroy)
# Use the None item in the widget's private Pmw dictionary to
# store the widget's bind callbacks, for later clean up.
if not hasattr(widget, '_Pmw_BalloonBindIds'):
widget._Pmw_BalloonBindIds = {}
widget._Pmw_BalloonBindIds[None] = \
(enterId, motionId, leaveId, buttonId, destroyId)
def unbind(self, widget):
if hasattr(widget, '_Pmw_BalloonBindIds'):
if widget._Pmw_BalloonBindIds.has_key(None):
(enterId, motionId, leaveId, buttonId, destroyId) = \
widget._Pmw_BalloonBindIds[None]
# Need to pass in old bindings, so that Tkinter can
# delete the commands. Otherwise, memory is leaked.
widget.unbind('<Enter>', enterId)
widget.unbind('<Motion>', motionId)
widget.unbind('<Leave>', leaveId)
widget.unbind('<ButtonPress>', buttonId)
widget.unbind('<Destroy>', destroyId)
del widget._Pmw_BalloonBindIds[None]
if self._currentTrigger is not None and len(self._currentTrigger) == 1:
# The balloon is currently being displayed and the current
# trigger is a widget.
triggerWidget = self._currentTrigger[0]
if triggerWidget == widget:
if self._timer is not None:
self.after_cancel(self._timer)
self._timer = None
self.withdraw()
self.clearstatus()
self._currentTrigger = None
def tagbind(self, widget, tagOrItem, balloonHelp, statusHelp = None):
# If a previous bind for this widget's tagOrItem exists, remove it.
self.tagunbind(widget, tagOrItem)
if balloonHelp is None and statusHelp is None:
return
if statusHelp is None:
statusHelp = balloonHelp
enterId = widget.tag_bind(tagOrItem, '<Enter>',
lambda event, self = self, w = widget,
sHelp = statusHelp, bHelp = balloonHelp:
self._enter(event, w, sHelp, bHelp, 1))
motionId = widget.tag_bind(tagOrItem, '<Motion>',
lambda event = None, self = self, statusHelp = statusHelp:
self.showstatus(statusHelp))
leaveId = widget.tag_bind(tagOrItem, '<Leave>', self._leave)
buttonId = widget.tag_bind(tagOrItem, '<ButtonPress>', self._buttonpress)
# Use the tagOrItem item in the widget's private Pmw dictionary to
# store the tagOrItem's bind callbacks, for later clean up.
if not hasattr(widget, '_Pmw_BalloonBindIds'):
widget._Pmw_BalloonBindIds = {}
widget._Pmw_BalloonBindIds[tagOrItem] = \
(enterId, motionId, leaveId, buttonId)
def tagunbind(self, widget, tagOrItem):
if hasattr(widget, '_Pmw_BalloonBindIds'):
if widget._Pmw_BalloonBindIds.has_key(tagOrItem):
(enterId, motionId, leaveId, buttonId) = \
widget._Pmw_BalloonBindIds[tagOrItem]
widget.tag_unbind(tagOrItem, '<Enter>', enterId)
widget.tag_unbind(tagOrItem, '<Motion>', motionId)
widget.tag_unbind(tagOrItem, '<Leave>', leaveId)
widget.tag_unbind(tagOrItem, '<ButtonPress>', buttonId)
del widget._Pmw_BalloonBindIds[tagOrItem]
if self._currentTrigger is None:
# The balloon is not currently being displayed.
return
if len(self._currentTrigger) == 1:
# The current trigger is a widget.
return
if len(self._currentTrigger) == 2:
# The current trigger is a canvas item.
(triggerWidget, triggerItem) = self._currentTrigger
if triggerWidget == widget and triggerItem == tagOrItem:
if self._timer is not None:
self.after_cancel(self._timer)
self._timer = None
self.withdraw()
self.clearstatus()
self._currentTrigger = None
else: # The current trigger is a text item.
(triggerWidget, x, y) = self._currentTrigger
if triggerWidget == widget:
currentPos = widget.index('@%d,%d' % (x, y))
currentTags = widget.tag_names(currentPos)
if tagOrItem in currentTags:
if self._timer is not None:
self.after_cancel(self._timer)
self._timer = None
self.withdraw()
self.clearstatus()
self._currentTrigger = None
def showstatus(self, statusHelp):
if self['state'] in ('status', 'both'):
cmd = self['statuscommand']
if callable(cmd):
cmd(statusHelp)
def clearstatus(self):
self.showstatus(None)
def _state(self):
if self['state'] not in ('both', 'balloon', 'status', 'none'):
raise ValueError, 'bad state option ' + repr(self['state']) + \
': should be one of \'both\', \'balloon\', ' + \
'\'status\' or \'none\''
def _relmouse(self):
if self['relmouse'] not in ('both', 'x', 'y', 'none'):
raise ValueError, 'bad relmouse option ' + repr(self['relmouse'])+ \
': should be one of \'both\', \'x\', ' + '\'y\' or \'none\''
def _enter(self, event, widget, statusHelp, balloonHelp, isItem):
# Do not display balloon if mouse button is pressed. This
# will only occur if the button was pressed inside a widget,
# then the mouse moved out of and then back into the widget,
# with the button still held down. The number 0x1f00 is the
# button mask for the 5 possible buttons in X.
buttonPressed = (event.state & 0x1f00) != 0
if not buttonPressed and balloonHelp is not None and \
self['state'] in ('balloon', 'both'):
if self._timer is not None:
self.after_cancel(self._timer)
self._timer = None
self._timer = self.after(self['initwait'],
lambda self = self, widget = widget, help = balloonHelp,
isItem = isItem:
self._showBalloon(widget, help, isItem))
if isItem:
if hasattr(widget, 'canvasx'):
# The widget is a canvas.
item = widget.find_withtag('current')
if len(item) > 0:
item = item[0]
else:
item = None
self._currentTrigger = (widget, item)
else:
# The widget is a text widget.
self._currentTrigger = (widget, event.x, event.y)
else:
self._currentTrigger = (widget,)
self.showstatus(statusHelp)
def _leave(self, event):
if self._timer is not None:
self.after_cancel(self._timer)
self._timer = None
self.withdraw()
self.clearstatus()
self._currentTrigger = None
def _destroy(self, event):
# Only withdraw the balloon and cancel the timer if the widget
# being destroyed is the widget that triggered the balloon.
# Note that in a Tkinter Destroy event, the widget field is a
# string and not a widget as usual.
if self._currentTrigger is None:
# The balloon is not currently being displayed
return
if len(self._currentTrigger) == 1:
# The current trigger is a widget (not an item)
triggerWidget = self._currentTrigger[0]
if str(triggerWidget) == event.widget:
if self._timer is not None:
self.after_cancel(self._timer)
self._timer = None
self.withdraw()
self.clearstatus()
self._currentTrigger = None
def _buttonpress(self, event):
if self._timer is not None:
self.after_cancel(self._timer)
self._timer = None
self.withdraw()
self._currentTrigger = None
def _showBalloon(self, widget, balloonHelp, isItem):
self._label.configure(text = balloonHelp)
# First, display the balloon offscreen to get dimensions.
screenWidth = self.winfo_screenwidth()
screenHeight = self.winfo_screenheight()
self.geometry('+%d+0' % (screenWidth + 1))
self.update_idletasks()
if isItem:
# Get the bounding box of the current item.
bbox = widget.bbox('current')
if bbox is None:
# The item that triggered the balloon has disappeared,
# perhaps by a user's timer event that occured between
# the <Enter> event and the 'initwait' timer calling
# this method.
return
# The widget is either a text or canvas. The meaning of
# the values returned by the bbox method is different for
# each, so use the existence of the 'canvasx' method to
# distinguish between them.
if hasattr(widget, 'canvasx'):
# The widget is a canvas. Place balloon under canvas
# item. The positions returned by bbox are relative
# to the entire canvas, not just the visible part, so
# need to convert to window coordinates.
leftrel = bbox[0] - widget.canvasx(0)
toprel = bbox[1] - widget.canvasy(0)
bottomrel = bbox[3] - widget.canvasy(0)
else:
# The widget is a text widget. Place balloon under
# the character closest to the mouse. The positions
# returned by bbox are relative to the text widget
# window (ie the visible part of the text only).
leftrel = bbox[0]
toprel = bbox[1]
bottomrel = bbox[1] + bbox[3]
else:
leftrel = 0
toprel = 0
bottomrel = widget.winfo_height()
xpointer, ypointer = widget.winfo_pointerxy() # -1 if off screen
if xpointer >= 0 and self['relmouse'] in ('both', 'x'):
x = xpointer
else:
x = leftrel + widget.winfo_rootx()
x = x + self['xoffset']
if ypointer >= 0 and self['relmouse'] in ('both', 'y'):
y = ypointer
else:
y = bottomrel + widget.winfo_rooty()
y = y + self['yoffset']
edges = (string.atoi(str(self.cget('hull_highlightthickness'))) +
string.atoi(str(self.cget('hull_borderwidth')))) * 2
if x + self._label.winfo_reqwidth() + edges > screenWidth:
x = screenWidth - self._label.winfo_reqwidth() - edges
if y + self._label.winfo_reqheight() + edges > screenHeight:
if ypointer >= 0 and self['relmouse'] in ('both', 'y'):
y = ypointer
else:
y = toprel + widget.winfo_rooty()
y = y - self._label.winfo_reqheight() - self['yoffset'] - edges
Pmw.setgeometryanddeiconify(self, '+%d+%d' % (x, y))
--- NEW FILE: PmwBase.py ---
# Pmw megawidget base classes.
# This module provides a foundation for building megawidgets. It
# contains the MegaArchetype class which manages component widgets and
# configuration options. Also provided are the MegaToplevel and
# MegaWidget classes, derived from the MegaArchetype class. The
# MegaToplevel class contains a Tkinter Toplevel widget to act as the
# container of the megawidget. This is used as the base class of all
# megawidgets that are contained in their own top level window, such
# as a Dialog window. The MegaWidget class contains a Tkinter Frame
# to act as the container of the megawidget. This is used as the base
# class of all other megawidgets, such as a ComboBox or ButtonBox.
#
# Megawidgets are built by creating a class that inherits from either
# the MegaToplevel or MegaWidget class.
import os
import string
import sys
[...1894 lines suppressed...]
text = self._errorQueue[0]
del self._errorQueue[0]
self._display(text)
self._updateButtons()
def _display(self, text):
self._errorCount = self._errorCount + 1
text = 'Error: %d\n%s' % (self._errorCount, text)
self._text.delete('1.0', 'end')
self._text.insert('end', text)
def _updateButtons(self):
numQueued = len(self._errorQueue)
if numQueued > 0:
self._label.configure(text='%d more errors' % numQueued)
self._nextError.configure(state='normal')
else:
self._label.configure(text='No more errors')
self._nextError.configure(state='disabled')
--- NEW FILE: PmwBlt.py ---
# Python interface to some of the commands of the 2.4 version of the
# BLT extension to tcl.
import string
import types
import Tkinter
# Supported commands:
_busyCommand = '::blt::busy'
_vectorCommand = '::blt::vector'
_graphCommand = '::blt::graph'
_testCommand = '::blt::*'
_chartCommand = '::blt::stripchart'
_tabsetCommand = '::blt::tabset'
_haveBlt = None
_haveBltBusy = None
def _checkForBlt(window):
global _haveBlt
global _haveBltBusy
# Blt may be a package which has not yet been loaded. Try to load it.
try:
window.tk.call('package', 'require', 'BLT')
except Tkinter.TclError:
# Another way to try to dynamically load blt:
try:
window.tk.call('load', '', 'Blt')
except Tkinter.TclError:
pass
_haveBlt= (window.tk.call('info', 'commands', _testCommand) != '')
_haveBltBusy = (window.tk.call('info', 'commands', _busyCommand) != '')
def haveblt(window):
if _haveBlt is None:
_checkForBlt(window)
return _haveBlt
def havebltbusy(window):
if _haveBlt is None:
_checkForBlt(window)
return _haveBltBusy
def _loadBlt(window):
if _haveBlt is None:
if window is None:
window = Tkinter._default_root
if window is None:
window = Tkinter.Tk()
_checkForBlt(window)
def busy_hold(window, cursor = None):
_loadBlt(window)
if cursor is None:
window.tk.call(_busyCommand, 'hold', window._w)
else:
window.tk.call(_busyCommand, 'hold', window._w, '-cursor', cursor)
def busy_release(window):
_loadBlt(window)
window.tk.call(_busyCommand, 'release', window._w)
def busy_forget(window):
_loadBlt(window)
window.tk.call(_busyCommand, 'forget', window._w)
#=============================================================================
# Interface to the blt vector command which makes it look like the
# builtin python list type.
# The -variable, -command, -watchunset creation options are not supported.
# The dup, merge, notify, offset, populate, seq and variable methods
# and the +, -, * and / operations are not supported.
# Blt vector functions:
def vector_expr(expression):
tk = Tkinter._default_root.tk
strList = tk.splitlist(tk.call(_vectorCommand, 'expr', expression))
return tuple(map(string.atof, strList))
def vector_names(pattern = None):
tk = Tkinter._default_root.tk
return tk.splitlist(tk.call(_vectorCommand, 'names', pattern))
class Vector:
_varnum = 0
def __init__(self, size=None, master=None):
# <size> can be either an integer size, or a string "first:last".
_loadBlt(master)
if master:
self._master = master
else:
self._master = Tkinter._default_root
self.tk = self._master.tk
self._name = 'PY_VEC' + str(Vector._varnum)
Vector._varnum = Vector._varnum + 1
if size is None:
self.tk.call(_vectorCommand, 'create', self._name)
else:
self.tk.call(_vectorCommand, 'create', '%s(%s)' % (self._name, size))
def __del__(self):
self.tk.call(_vectorCommand, 'destroy', self._name)
def __str__(self):
return self._name
def __repr__(self):
return '[' + string.join(map(str, self), ', ') + ']'
def __cmp__(self, list):
return cmp(self[:], list)
def __len__(self):
return self.tk.getint(self.tk.call(self._name, 'length'))
def __getitem__(self, key):
oldkey = key
if key < 0:
key = key + len(self)
try:
return self.tk.getdouble(self.tk.globalgetvar(self._name, str(key)))
except Tkinter.TclError:
raise IndexError, oldkey
def __setitem__(self, key, value):
if key < 0:
key = key + len(self)
return self.tk.globalsetvar(self._name, str(key), float(value))
def __delitem__(self, key):
if key < 0:
key = key + len(self)
return self.tk.globalunsetvar(self._name, str(key))
def __getslice__(self, start, end):
length = len(self)
if start < 0:
start = 0
if end > length:
end = length
if start >= end:
return []
end = end - 1 # Blt vector slices include end point.
text = self.tk.globalgetvar(self._name, str(start) + ':' + str(end))
return map(self.tk.getdouble, self.tk.splitlist(text))
def __setslice__(self, start, end, list):
if start > end:
end = start
self.set(self[:start] + list + self[end:])
def __delslice__(self, start, end):
if start < end:
self.set(self[:start] + self[end:])
def __add__(self, list):
return self[:] + list
def __radd__(self, list):
return list + self[:]
def __mul__(self, n):
return self[:] * n
__rmul__ = __mul__
# Python builtin list methods:
def append(self, *args):
self.tk.call(self._name, 'append', args)
def count(self, obj):
return self[:].count(obj)
def index(self, value):
return self[:].index(value)
def insert(self, index, value):
self[index:index] = [value]
def remove(self, value):
del self[self.index(value)]
def reverse(self):
s = self[:]
s.reverse()
self.set(s)
def sort(self, *args):
s = self[:]
s.sort()
self.set(s)
# Blt vector instance methods:
# append - same as list method above
def clear(self):
self.tk.call(self._name, 'clear')
def delete(self, *args):
self.tk.call((self._name, 'delete') + args)
def expr(self, expression):
self.tk.call(self._name, 'expr', expression)
def length(self, newSize=None):
return self.tk.getint(self.tk.call(self._name, 'length', newSize))
def range(self, first, last=None):
# Note that, unlike self[first:last], this includes the last
# item in the returned range.
text = self.tk.call(self._name, 'range', first, last)
return map(self.tk.getdouble, self.tk.splitlist(text))
def search(self, start, end=None):
return self._master._getints(self.tk.call(
self._name, 'search', start, end))
def set(self, list):
if type(list) != types.TupleType:
list = tuple(list)
self.tk.call(self._name, 'set', list)
# The blt vector sort method has different semantics to the python
# list sort method. Call these blt_sort:
def blt_sort(self, *args):
self.tk.call((self._name, 'sort') + args)
def blt_sort_reverse(self, *args):
self.tk.call((self._name, 'sort', '-reverse') + args)
# Special blt vector indexes:
def min(self):
return self.tk.getdouble(self.tk.globalgetvar(self._name, 'min'))
def max(self):
return self.tk.getdouble(self.tk.globalgetvar(self._name, 'max'))
# Method borrowed from Tkinter.Var class:
def get(self):
return self[:]
#=============================================================================
# This is a general purpose configure routine which can handle the
# configuration of widgets, items within widgets, etc. Supports the
# forms configure() and configure('font') for querying and
# configure(font = 'fixed', text = 'hello') for setting.
def _doConfigure(widget, subcommand, option, kw):
if not option and not kw:
# Return a description of all options.
ret = {}
options = widget.tk.splitlist(widget.tk.call(subcommand))
for optionString in options:
optionInfo = widget.tk.splitlist(optionString)
option = optionInfo[0][1:]
ret[option] = (option,) + optionInfo[1:]
return ret
if option:
# Return a description of the option given by <option>.
if kw:
# Having keywords implies setting configuration options.
# Can't set and get in one command!
raise ValueError, 'cannot have option argument with keywords'
option = '-' + option
optionInfo = widget.tk.splitlist(widget.tk.call(subcommand + (option,)))
return (optionInfo[0][1:],) + optionInfo[1:]
# Otherwise, set the given configuration options.
widget.tk.call(subcommand + widget._options(kw))
#=============================================================================
class Graph(Tkinter.Widget):
# Wrapper for the blt graph widget, version 2.4.
def __init__(self, master=None, cnf={}, **kw):
_loadBlt(master)
Tkinter.Widget.__init__(self, master, _graphCommand, cnf, kw)
def bar_create(self, name, **kw):
self.tk.call((self._w, 'bar', 'create', name) + self._options(kw))
def line_create(self, name, **kw):
self.tk.call((self._w, 'line', 'create', name) + self._options(kw))
def extents(self, item):
return self.tk.getint(self.tk.call(self._w, 'extents', item))
def invtransform(self, winX, winY):
return self._getdoubles(
self.tk.call(self._w, 'invtransform', winX, winY))
def inside(self, x, y):
return self.tk.getint(self.tk.call(self._w, 'inside', x, y))
def snap(self, photoName):
self.tk.call(self._w, 'snap', photoName)
def transform(self, x, y):
return self._getdoubles(self.tk.call(self._w, 'transform', x, y))
def axis_cget(self, axisName, key):
return self.tk.call(self._w, 'axis', 'cget', axisName, '-' + key)
def axis_configure(self, axes, option=None, **kw):
# <axes> may be a list of axisNames.
if type(axes) == types.StringType:
axes = [axes]
subcommand = (self._w, 'axis', 'configure') + tuple(axes)
return _doConfigure(self, subcommand, option, kw)
def axis_create(self, axisName, **kw):
self.tk.call((self._w, 'axis', 'create', axisName) + self._options(kw))
def axis_delete(self, *args):
self.tk.call((self._w, 'axis', 'delete') + args)
def axis_invtransform(self, axisName, value):
return self.tk.getdouble(self.tk.call(
self._w, 'axis', 'invtransform', axisName, value))
def axis_limits(self, axisName):
return self._getdoubles(self.tk.call(
self._w, 'axis', 'limits', axisName))
def axis_names(self, *args):
...
[truncated message content] |