[Patches] Tkinter with doc string

Fischbeck Nils Nils.Fischbeck@icn.siemens.de
Fri, 23 Jun 2000 08:26:21 +0200


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01BFDCDB.F3B3F44E
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello Guido,

I've finished to document the Tkinter-module. It is based on version =
1.138. Martin von  L=F6wis has reviewed it. Please check it in if you =
like.

Regards

Nils
 <<Tkinter1_138a.py>>=20

---
Nils Fischbeck			+49 03834 555 8178
SIEMENS AG, ICN WN AN AM46
New E-mail address: Nils.Fischbeck@icn.siemens.de


------_=_NextPart_000_01BFDCDB.F3B3F44E
Content-Type: application/octet-stream;
	name="Tkinter1_138a.py"
Content-Disposition: attachment;
	filename="Tkinter1_138a.py"
Content-Transfer-Encoding: quoted-printable

"""Wrapper functions for Tcl/Tk.=0A=
=0A=
Tkinter provides classes which allow the display, positioning and=0A=
control of widgets. Toplevel widgets are Tk and Toplevel. Other=0A=
widgets are Frame, Label, Entry, Text, Canvas, Button, Radiobutton,=0A=
Checkbutton, Scale, Listbox, Scrollbar, OptionMenu. Properties of the =
widgets are=0A=
specified with keyword arguments.  Keyword arguments have the same=0A=
name as the corresponding resource under Tk.=0A=
=0A=
Widgets are positioned with one of the geometry managers Place, Pack=0A=
or Grid. These managers can be called with methods place, pack, grid=0A=
available in every Widget.=0A=
=0A=
Actions are bound to events by resources (e.g. keyword argument =
command) or=0A=
with the method bind.=0A=
=0A=
Example (Hello, World):=0A=
import Tkinter=0A=
from Tkconstants import *=0A=
tk =3D Tkinter.Tk()=0A=
frame =3D Tkinter.Frame(tk, relief=3DRIDGE, borderwidth=3D2)=0A=
frame.pack(fill=3DBOTH,expand=3D1)=0A=
label =3D Tkinter.Label(frame, text=3D"Hello, World")=0A=
label.pack(fill=3DX, expand=3D1)=0A=
button =3D Tkinter.Button(frame,text=3D"Exit",command=3Dtk.destroy)=0A=
button.pack(side=3DBOTTOM)=0A=
tk.mainloop()=0A=
"""=0A=
=0A=
__version__ =3D "$Revision: 1.138 $"=0A=
=0A=
import sys=0A=
if sys.platform =3D=3D "win32":=0A=
	import FixTk # Attempt to configure Tcl/Tk without requiring PATH=0A=
import _tkinter # If this fails your Python may not be configured for =
Tk=0A=
tkinter =3D _tkinter # b/w compat for export=0A=
TclError =3D _tkinter.TclError=0A=
from types import *=0A=
from Tkconstants import *=0A=
import string; _string =3D string; del string=0A=
try:=0A=
	import MacOS; _MacOS =3D MacOS; del MacOS=0A=
except ImportError:=0A=
	_MacOS =3D None=0A=
=0A=
TkVersion =3D _string.atof(_tkinter.TK_VERSION)=0A=
TclVersion =3D _string.atof(_tkinter.TCL_VERSION)=0A=
=0A=
READABLE =3D _tkinter.READABLE=0A=
WRITABLE =3D _tkinter.WRITABLE=0A=
EXCEPTION =3D _tkinter.EXCEPTION=0A=
=0A=
# These are not always defined, e.g. not on Win32 with Tk 8.0 :-(=0A=
try: _tkinter.createfilehandler=0A=
except AttributeError: _tkinter.createfilehandler =3D None=0A=
try: _tkinter.deletefilehandler=0A=
except AttributeError: _tkinter.deletefilehandler =3D None=0A=
    =0A=
    =0A=
def _flatten(tuple):=0A=
	"""Internal function."""=0A=
	res =3D ()=0A=
	for item in tuple:=0A=
		if type(item) in (TupleType, ListType):=0A=
			res =3D res + _flatten(item)=0A=
		elif item is not None:=0A=
			res =3D res + (item,)=0A=
	return res=0A=
=0A=
try: _flatten =3D _tkinter._flatten=0A=
except AttributeError: pass=0A=
=0A=
def _cnfmerge(cnfs):=0A=
	"""Internal function."""=0A=
	if type(cnfs) is DictionaryType:=0A=
		return cnfs=0A=
	elif type(cnfs) in (NoneType, StringType):=0A=
		return cnfs=0A=
	else:=0A=
		cnf =3D {}=0A=
		for c in _flatten(cnfs):=0A=
			try:=0A=
				cnf.update(c)=0A=
			except (AttributeError, TypeError), msg:=0A=
				print "_cnfmerge: fallback due to:", msg=0A=
				for k, v in c.items():=0A=
					cnf[k] =3D v=0A=
		return cnf=0A=
=0A=
try: _cnfmerge =3D _tkinter._cnfmerge=0A=
except AttributeError: pass=0A=
=0A=
class Event:=0A=
        """Container for the properties of an event.=0A=
=0A=
	Instances of this type are generated if one of the following events =
occurs:=0A=
		=0A=
	KeyPress, KeyRelease - for keyboard events=0A=
	ButtonPress, ButtonRelease, Motion, Enter, Leave, MouseWheel - for =
mouse events=0A=
	Visibility, Unmap, Map, Expose, FocusIn, FocusOut, Circulate,=0A=
	Colormap, Gravity, Reparent, Property, Destroy, Activate,=0A=
	Deactivate - for window events.=0A=
=0A=
	If a callback function for one of these events is registered=0A=
	using bind, bind_all, bind_class, or tag_bind, the callback is=0A=
	called with an Event as first argument. It will have the=0A=
	following attributes (in braces are the event types for which=0A=
	the attribute is valid):=0A=
		=0A=
        serial - serial number of event=0A=
	num - mouse button pressed (ButtonPress, ButtonRelease)=0A=
	focus - whether the window has the focus (Enter, Leave)=0A=
	height - height of the exposed window (Configure, Expose)=0A=
	width - width of the exposed window (Configure, Expose)=0A=
	keycode - keycode of the pressed key (KeyPress, KeyRelease)=0A=
	state - state of the event as a number (ButtonPress, ButtonRelease,=0A=
					        Enter, KeyPress, KeyRelease,=0A=
					        Leave, Motion)=0A=
	state - state as a string (Visibility)=0A=
	time - when the event occured=0A=
	x - x-position of the mouse=0A=
	y - y-position of the mouse=0A=
	x_root - x-position of the mouse on the screen=0A=
	         (ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion)=0A=
	y_root - y-position of the mouse on the screen=0A=
	         (ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion)=0A=
	char - pressed character (KeyPress, KeyRelease)=0A=
	send_event - see X/Windows documentation=0A=
	keysym - keysym of the the event as a string (KeyPress, KeyRelease)=0A=
	keysym_num - keysym of the event as a number (KeyPress, KeyRelease)=0A=
	type - type of the event as a number=0A=
	widget - widget in which the event occured=0A=
	delta - delta of wheel movement (MouseWheel)=0A=
	"""=0A=
	pass=0A=
=0A=
_support_default_root =3D 1=0A=
_default_root =3D None=0A=
=0A=
def NoDefaultRoot():=0A=
	"""Inhibit setting of default root window.=0A=
=0A=
	Call this function to inhibit that the first instance of=0A=
	Tk is used for windows without an explicit parent window.=0A=
	"""	=0A=
	global _support_default_root=0A=
	_support_default_root =3D 0=0A=
	global _default_root=0A=
	_default_root =3D None=0A=
	del _default_root=0A=
=0A=
def _tkerror(err):=0A=
	"""Internal function."""=0A=
	pass=0A=
=0A=
def _exit(code=3D'0'):=0A=
	"""Internal function. Calling it will throw the exception =
SystemExit."""=0A=
	raise SystemExit, code=0A=
=0A=
_varnum =3D 0=0A=
class Variable:=0A=
	"""Internal class. Base class to define value holders for e.g. =
buttons."""=0A=
	_default =3D ""=0A=
	def __init__(self, master=3DNone):=0A=
		"""Construct a variable with an optional MASTER as master widget.=0A=
		The variable is named PY_VAR_number in Tcl.=0A=
		"""=0A=
		global _varnum=0A=
		if not master:=0A=
			master =3D _default_root=0A=
		self._master =3D master=0A=
		self._tk =3D master.tk=0A=
		self._name =3D 'PY_VAR' + `_varnum`=0A=
		_varnum =3D _varnum + 1=0A=
		self.set(self._default)=0A=
	def __del__(self):=0A=
		"""Unset the variable in Tcl."""=0A=
		self._tk.globalunsetvar(self._name)=0A=
	def __str__(self):=0A=
		"""Return the name of the variable in Tcl."""=0A=
		return self._name=0A=
	def set(self, value):=0A=
		"""Set the variable to VALUE."""=0A=
		return self._tk.globalsetvar(self._name, value)=0A=
	def trace_variable(self, mode, callback):=0A=
		"""Define a trace callback for the variable.=0A=
=0A=
		MODE is one of "r", "w", "u" for read, write, undefine.=0A=
		CALLBACK must be a function which is called when=0A=
		the variable is read, written or undefined.=0A=
=0A=
		Return the name of the callback.=0A=
		"""=0A=
		cbname =3D self._master._register(callback)=0A=
		self._tk.call("trace", "variable", self._name, mode, cbname)=0A=
		return cbname=0A=
	trace =3D trace_variable=0A=
	def trace_vdelete(self, mode, cbname):=0A=
		"""Delete the trace callback for a variable.=0A=
=0A=
		MODE is one of "r", "w", "u" for read, write, undefine.=0A=
		CBNAME is the name of the callback returned from trace_variable or =
trace.=0A=
		"""=0A=
		self._tk.call("trace", "vdelete", self._name, mode, cbname)=0A=
		self._master.deletecommand(cbname)=0A=
	def trace_vinfo(self):=0A=
		"""Return all trace callback information."""=0A=
		return map(self._tk.split, self._tk.splitlist(=0A=
			self._tk.call("trace", "vinfo", self._name)))=0A=
=0A=
class StringVar(Variable):=0A=
	"""Value holder for strings variables."""=0A=
	_default =3D ""=0A=
	def __init__(self, master=3DNone):=0A=
		"""Construct a string variable.=0A=
=0A=
		MASTER can be given as master widget."""=0A=
		Variable.__init__(self, master)=0A=
=0A=
	def get(self):=0A=
		"""Return value of variable as string."""=0A=
		return self._tk.globalgetvar(self._name)=0A=
=0A=
class IntVar(Variable):=0A=
	"""Value holder for integer variables."""=0A=
	_default =3D 0=0A=
	def __init__(self, master=3DNone):=0A=
		"""Construct an integer variable.=0A=
=0A=
		MASTER can be given as master widget."""=0A=
		Variable.__init__(self, master)=0A=
=0A=
	def get(self):=0A=
		"""Return the value of the variable as an integer."""=0A=
		return getint(self._tk.globalgetvar(self._name))=0A=
=0A=
class DoubleVar(Variable):=0A=
	"""Value holder for float variables."""=0A=
	_default =3D 0.0=0A=
	def __init__(self, master=3DNone):=0A=
		"""Construct a float variable.=0A=
=0A=
		MASTER can be given as a master widget."""=0A=
		Variable.__init__(self, master)=0A=
		=0A=
	def get(self):=0A=
		"""Return the value of the variable as a float."""=0A=
		return getdouble(self._tk.globalgetvar(self._name))=0A=
=0A=
class BooleanVar(Variable):=0A=
	"""Value holder for boolean variables."""=0A=
	_default =3D "false"=0A=
	def __init__(self, master=3DNone):=0A=
		"""Construct a boolean variable.=0A=
=0A=
		MASTER can be given as a master widget."""=0A=
		Variable.__init__(self, master)=0A=
=0A=
	def get(self):=0A=
		"""Return the value of the variable as 0 or 1."""=0A=
		return self._tk.getboolean(self._tk.globalgetvar(self._name))=0A=
=0A=
def mainloop(n=3D0):=0A=
	"""Run the main loop of Tcl."""=0A=
	_default_root.tk.mainloop(n)=0A=
=0A=
getint =3D int=0A=
=0A=
getdouble =3D float=0A=
=0A=
def getboolean(s):=0A=
	"""Convert true and false to integer values 1 and 0."""=0A=
	return _default_root.tk.getboolean(s)=0A=
=0A=
# Methods defined on both toplevel and interior widgets=0A=
class Misc:=0A=
	"""Internal class.=0A=
=0A=
	Base class which defines methods common for interior widgets."""=0A=
	=0A=
	# XXX font command?=0A=
	_tclCommands =3D None=0A=
	def destroy(self):=0A=
		"""Internal function.=0A=
=0A=
		Delete all Tcl commands created for=0A=
		this widget in the Tcl interpreter."""=0A=
		if self._tclCommands is not None:=0A=
			for name in self._tclCommands:=0A=
				#print '- Tkinter: deleted command', name=0A=
				self.tk.deletecommand(name)=0A=
			self._tclCommands =3D None=0A=
	def deletecommand(self, name):=0A=
		"""Internal function.=0A=
=0A=
		Delete the Tcl command provided in NAME."""=0A=
		#print '- Tkinter: deleted command', name=0A=
		self.tk.deletecommand(name)=0A=
		try:=0A=
			self._tclCommands.remove(name)=0A=
		except ValueError:=0A=
			pass=0A=
	def tk_strictMotif(self, boolean=3DNone):=0A=
		"""Set Tcl internal variable, whether the look and feel=0A=
		should adhere to Motif.=0A=
=0A=
		A parameter of 1 means adhere to Motif (e.g. no color=0A=
		change if mouse passes over slider).=0A=
		Returns the set value."""=0A=
		return self.tk.getboolean(self.tk.call(=0A=
			'set', 'tk_strictMotif', boolean))=0A=
	def tk_bisque(self):=0A=
		"""Change the color scheme to light brown as used in Tk 3.6 and =
before.""" =0A=
		self.tk.call('tk_bisque')=0A=
	def tk_setPalette(self, *args, **kw):=0A=
		"""Set a new color scheme for all widget elements.=0A=
=0A=
		A single color as argument will cause that all colors of Tk=0A=
		widget elements are derived from this.=0A=
		Alternatively several keyword parameters and its associated=0A=
		colors can be given. The following keywords are valid:=0A=
		activeBackground, foreground, selectColor,=0A=
		activeForeground, highlightBackground, selectBackground,=0A=
		background, highlightColor, selectForeground,=0A=
		disabledForeground, insertBackground, troughColor."""=0A=
		self.tk.call(('tk_setPalette',)=0A=
		      + _flatten(args) + _flatten(kw.items()))=0A=
	def tk_menuBar(self, *args):=0A=
		"""Do not use. Needed in Tk 3.6 and earlier."""=0A=
		pass # obsolete since Tk 4.0=0A=
	def wait_variable(self, name=3D'PY_VAR'):=0A=
		"""Wait until the variable is modified.=0A=
=0A=
		A parameter of type IntVar, StringVar, DoubleVar or=0A=
		BooleanVar must be given."""=0A=
		self.tk.call('tkwait', 'variable', name)=0A=
	waitvar =3D wait_variable # XXX b/w compat=0A=
	def wait_window(self, window=3DNone):=0A=
		"""Wait until a WIDGET is destroyed.=0A=
=0A=
		If no parameter is given self is used."""=0A=
		if window =3D=3D None:=0A=
			window =3D self=0A=
		self.tk.call('tkwait', 'window', window._w)=0A=
	def wait_visibility(self, window=3DNone):=0A=
		"""Wait until the visibility of a WIDGET changes=0A=
		(e.g. it appears).=0A=
		=0A=
		If no parameter is given self is used."""=0A=
		if window =3D=3D None:=0A=
			window =3D self=0A=
		self.tk.call('tkwait', 'visibility', window._w)=0A=
	def setvar(self, name=3D'PY_VAR', value=3D'1'):=0A=
		"""Set Tcl variable NAME to VALUE."""=0A=
		self.tk.setvar(name, value)=0A=
	def getvar(self, name=3D'PY_VAR'):=0A=
		"""Return value of Tcl variable NAME."""=0A=
		return self.tk.getvar(name)=0A=
	getint =3D int=0A=
	getdouble =3D float=0A=
	def getboolean(self, s):=0A=
		"""Return 0 or 1 for Tcl boolean values true and false given as =
parameter."""=0A=
		return self.tk.getboolean(s)=0A=
	def focus_set(self):=0A=
		"""Direct input focus to this widget.=0A=
=0A=
		If the application currently does not have the focus=0A=
		this widget will get the focus if the application gets=0A=
		the focus through the window manager."""=0A=
		self.tk.call('focus', self._w)=0A=
	focus =3D focus_set # XXX b/w compat?=0A=
	def focus_force(self):=0A=
		"""Direct input focus to this widget even if the=0A=
		application does not have the focus. Use with=0A=
		caution!"""=0A=
		self.tk.call('focus', '-force', self._w)=0A=
	def focus_get(self):=0A=
		"""Return the widget which has currently the focus in the=0A=
		application.=0A=
=0A=
		Use focus_displayof to allow working with several=0A=
		displays. Return None if application does not have=0A=
		the focus."""=0A=
		name =3D self.tk.call('focus')=0A=
		if name =3D=3D 'none' or not name: return None=0A=
		return self._nametowidget(name)=0A=
	def focus_displayof(self):=0A=
		"""Return the widget which has currently the focus on the=0A=
		display where this widget is located.=0A=
=0A=
		Return None if the application does not have the focus."""=0A=
		name =3D self.tk.call('focus', '-displayof', self._w)=0A=
		if name =3D=3D 'none' or not name: return None=0A=
		return self._nametowidget(name)=0A=
	def focus_lastfor(self):=0A=
		"""Return the widget which would have the focus if top level=0A=
		for this widget gets the focus from the window manager."""=0A=
		name =3D self.tk.call('focus', '-lastfor', self._w)=0A=
		if name =3D=3D 'none' or not name: return None=0A=
		return self._nametowidget(name)=0A=
	def tk_focusFollowsMouse(self):=0A=
		"""The widget under mouse will get automatically focus. Can not=0A=
		be disabled easily."""=0A=
		self.tk.call('tk_focusFollowsMouse')=0A=
	def tk_focusNext(self):=0A=
		"""Return the next widget in the focus order which follows=0A=
		widget which has currently the focus.=0A=
=0A=
		The focus order first goes to the next child, then to=0A=
		the children of the child recursively and then to the=0A=
		next sibling which is higher in the stacking order.  A=0A=
		widget is ommited if it has the takefocus resource set=0A=
		to 0."""=0A=
		name =3D self.tk.call('tk_focusNext', self._w)=0A=
		if not name: return None=0A=
		return self._nametowidget(name)=0A=
	def tk_focusPrev(self):=0A=
		"""Return previous widget in the focus order. See tk_focusNext for =
details."""=0A=
		name =3D self.tk.call('tk_focusPrev', self._w)=0A=
		if not name: return None=0A=
		return self._nametowidget(name)=0A=
	def after(self, ms, func=3DNone, *args):=0A=
		"""Call function once after given time.=0A=
=0A=
		MS specifies the time in milliseconds. FUNC gives the=0A=
		function which shall be called. Additional parameters=0A=
		are given as parameters to the function call.  Return=0A=
		identifier to cancel scheduling with after_cancel."""=0A=
		if not func:=0A=
			# I'd rather use time.sleep(ms*0.001)=0A=
			self.tk.call('after', ms)=0A=
		else:=0A=
			# XXX Disgusting hack to clean up after calling func=0A=
			tmp =3D []=0A=
			def callit(func=3Dfunc, args=3Dargs, self=3Dself, tmp=3Dtmp):=0A=
				try:=0A=
					apply(func, args)=0A=
				finally:=0A=
					try:=0A=
						self.deletecommand(tmp[0])=0A=
					except TclError:=0A=
						pass=0A=
			name =3D self._register(callit)=0A=
			tmp.append(name)=0A=
			return self.tk.call('after', ms, name)=0A=
	def after_idle(self, func, *args):=0A=
		"""Call FUNC once if the Tcl main loop has no event to=0A=
		process.=0A=
=0A=
		Return an identifier to cancel the scheduling with=0A=
		after_cancel."""=0A=
		return apply(self.after, ('idle', func) + args)=0A=
	def after_cancel(self, id):=0A=
		"""Cancel scheduling of function identified with ID.=0A=
=0A=
		Identifier returned by after or after_idle must be=0A=
		given as first parameter."""=0A=
		self.tk.call('after', 'cancel', id)=0A=
	def bell(self, displayof=3D0):=0A=
		"""Ring a display's bell."""=0A=
		self.tk.call(('bell',) + self._displayof(displayof))=0A=
	# Clipboard handling:=0A=
	def clipboard_clear(self, **kw):=0A=
		"""Clear the data in the Tk clipboard.=0A=
=0A=
		A widget specified for the optional displayof keyword=0A=
		argument specifies the target display."""=0A=
		if not kw.has_key('displayof'): kw['displayof'] =3D self._w=0A=
		self.tk.call(('clipboard', 'clear') + self._options(kw))=0A=
	def clipboard_append(self, string, **kw):=0A=
		"""Append STRING to the Tk clipboard.=0A=
=0A=
		A widget specified at the optional displayof keyword=0A=
		argument specifies the target display. The clipboard=0A=
		can be retrieved with selection_get."""=0A=
		if not kw.has_key('displayof'): kw['displayof'] =3D self._w=0A=
		self.tk.call(('clipboard', 'append') + self._options(kw)=0A=
		      + ('--', string))=0A=
	# XXX grab current w/o window argument=0A=
	def grab_current(self):=0A=
		"""Return widget which has currently the grab in this application=0A=
		or None."""=0A=
		name =3D self.tk.call('grab', 'current', self._w)=0A=
		if not name: return None=0A=
		return self._nametowidget(name)=0A=
	def grab_release(self):=0A=
		"""Release grab for this widget if currently set."""=0A=
		self.tk.call('grab', 'release', self._w)=0A=
	def grab_set(self):=0A=
		"""Set grab for this widget.=0A=
=0A=
		A grab directs all events to this and descendant=0A=
		widgets in the application."""=0A=
		self.tk.call('grab', 'set', self._w)=0A=
	def grab_set_global(self):=0A=
		"""Set global grab for this widget.=0A=
=0A=
		A global grab directs all events to this and=0A=
		descendant widgets on the display. Use with caution -=0A=
		other applications do not get events anymore."""=0A=
		self.tk.call('grab', 'set', '-global', self._w)=0A=
	def grab_status(self):=0A=
		"""Return None, "local" or "global" if this widget has=0A=
		no, a local or a global grab."""=0A=
		status =3D self.tk.call('grab', 'status', self._w)=0A=
		if status =3D=3D 'none': status =3D None=0A=
		return status=0A=
	def lower(self, belowThis=3DNone):=0A=
		"""Lower this widget in the stacking order."""=0A=
		self.tk.call('lower', self._w, belowThis)=0A=
	def option_add(self, pattern, value, priority =3D None):=0A=
		"""Set a VALUE (second parameter) for an option=0A=
		PATTERN (first parameter).=0A=
=0A=
		An optional third parameter gives the numeric priority=0A=
		(defaults to 80)."""=0A=
		self.tk.call('option', 'add', pattern, value, priority)=0A=
	def option_clear(self):=0A=
		"""Clear the option database.=0A=
=0A=
		It will be reloaded if option_add is called."""=0A=
		self.tk.call('option', 'clear')=0A=
	def option_get(self, name, className):=0A=
		"""Return the value for an option NAME for this widget=0A=
		with CLASSNAME.=0A=
=0A=
		Values with higher priority override lower values."""=0A=
		return self.tk.call('option', 'get', self._w, name, className)=0A=
	def option_readfile(self, fileName, priority =3D None):=0A=
		"""Read file FILENAME into the option database.=0A=
=0A=
		An optional second paramter gives the numeric=0A=
		priority."""=0A=
		self.tk.call('option', 'readfile', fileName, priority)=0A=
	def selection_clear(self, **kw):=0A=
		"""Clear the current X selection."""=0A=
		if not kw.has_key('displayof'): kw['displayof'] =3D self._w=0A=
		self.tk.call(('selection', 'clear') + self._options(kw))=0A=
	def selection_get(self, **kw):=0A=
		"""Return the contents of the current X selection.=0A=
=0A=
		A keyword parameter selection specifies the name of=0A=
		the selection and defaults to PRIMARY.  A keyword=0A=
		parameter displayof specifies a widget on the display=0A=
		to use."""=0A=
		if not kw.has_key('displayof'): kw['displayof'] =3D self._w=0A=
		return self.tk.call(('selection', 'get') + self._options(kw))=0A=
	def selection_handle(self, command, **kw):=0A=
		"""Specify a function COMMAND to call if the X=0A=
		selection owned by this widget is queried by another=0A=
		application.=0A=
=0A=
		This function must return the contents of the=0A=
		selection. The function will be called with the=0A=
		arguments OFFSET and LENGTH which allows the chunking=0A=
		of very long selections. The following keyword=0A=
		parameters can be provided:=0A=
		selection - name of the selection (default PRIMARY),=0A=
		type - type of the selection (e.g. STRING, FILE_NAME)."""=0A=
		name =3D self._register(command)=0A=
		self.tk.call(('selection', 'handle') + self._options(kw)=0A=
		      + (self._w, name))=0A=
	def selection_own(self, **kw):=0A=
		"""Become owner of X selection.=0A=
=0A=
		A keyword parameter selection specifies the name of=0A=
		the selection (default PRIMARY)."""=0A=
		self.tk.call(('selection', 'own') +=0A=
			     self._options(kw) + (self._w,))=0A=
	def selection_own_get(self, **kw):=0A=
		"""Return owner of X selection.=0A=
=0A=
		The following keyword parameter can=0A=
		be provided:=0A=
		selection - name of the selection (default PRIMARY),=0A=
		type - type of the selection (e.g. STRING, FILE_NAME)."""=0A=
		if not kw.has_key('displayof'): kw['displayof'] =3D self._w=0A=
		name =3D self.tk.call(('selection', 'own') + self._options(kw))=0A=
		if not name: return None=0A=
		return self._nametowidget(name)=0A=
	def send(self, interp, cmd, *args):=0A=
		"""Send Tcl command CMD to different interpreter INTERP to be =
executed."""=0A=
		return self.tk.call(('send', interp, cmd) + args)=0A=
	def lower(self, belowThis=3DNone):=0A=
		"""Lower this widget in the stacking order."""=0A=
		self.tk.call('lower', self._w, belowThis)=0A=
	def tkraise(self, aboveThis=3DNone):=0A=
		"""Raise this widget in the stacking order."""=0A=
		self.tk.call('raise', self._w, aboveThis)=0A=
	lift =3D tkraise=0A=
	def colormodel(self, value=3DNone):=0A=
		"""Useless. Not implemented in Tk."""=0A=
		return self.tk.call('tk', 'colormodel', self._w, value)=0A=
	def winfo_atom(self, name, displayof=3D0):=0A=
		"""Return integer which represents atom NAME."""=0A=
		args =3D ('winfo', 'atom') + self._displayof(displayof) + (name,)=0A=
		return getint(self.tk.call(args))=0A=
	def winfo_atomname(self, id, displayof=3D0):=0A=
		"""Return name of atom with identifier ID."""=0A=
		args =3D ('winfo', 'atomname') \=0A=
		       + self._displayof(displayof) + (id,)=0A=
		return self.tk.call(args)=0A=
	def winfo_cells(self):=0A=
		"""Return number of cells in the colormap for this widget."""=0A=
		return getint(=0A=
			self.tk.call('winfo', 'cells', self._w))=0A=
	def winfo_children(self):=0A=
		"""Return a list of all widgets which are children of this =
widget."""=0A=
		return map(self._nametowidget,=0A=
			   self.tk.splitlist(self.tk.call(=0A=
				   'winfo', 'children', self._w)))=0A=
	def winfo_class(self):=0A=
		"""Return window class name of this widget."""=0A=
		return self.tk.call('winfo', 'class', self._w)=0A=
	def winfo_colormapfull(self):=0A=
		"""Return true if at the last color request the colormap was =
full."""=0A=
		return self.tk.getboolean(=0A=
			self.tk.call('winfo', 'colormapfull', self._w))=0A=
	def winfo_containing(self, rootX, rootY, displayof=3D0):=0A=
		"""Return the widget which is at the root coordinates ROOTX, =
ROOTY."""=0A=
		args =3D ('winfo', 'containing') \=0A=
		       + self._displayof(displayof) + (rootX, rootY)=0A=
		name =3D self.tk.call(args)=0A=
		if not name: return None=0A=
		return self._nametowidget(name)=0A=
	def winfo_depth(self):=0A=
		"""Return the number of bits per pixel."""=0A=
		return getint(self.tk.call('winfo', 'depth', self._w))=0A=
	def winfo_exists(self):=0A=
		"""Return true if this widget exists."""=0A=
		return getint(=0A=
			self.tk.call('winfo', 'exists', self._w))=0A=
	def winfo_fpixels(self, number):=0A=
		"""Return the number of pixels for the given distance NUMBER=0A=
		(e.g. "3c") as float."""=0A=
		return getdouble(self.tk.call(=0A=
			'winfo', 'fpixels', self._w, number))=0A=
	def winfo_geometry(self):=0A=
		"""Return geometry string for this widget in the form =
"widthxheight+X+Y"."""=0A=
		return self.tk.call('winfo', 'geometry', self._w)=0A=
	def winfo_height(self):=0A=
		"""Return heigth of this widget."""=0A=
		return getint(=0A=
			self.tk.call('winfo', 'height', self._w))=0A=
	def winfo_id(self):=0A=
		"""Return identifier ID for this widget."""=0A=
		return self.tk.getint(=0A=
			self.tk.call('winfo', 'id', self._w))=0A=
	def winfo_interps(self, displayof=3D0):=0A=
		"""Return the name of all Tcl interpreters for this display."""=0A=
		args =3D ('winfo', 'interps') + self._displayof(displayof)=0A=
		return self.tk.splitlist(self.tk.call(args))=0A=
	def winfo_ismapped(self):=0A=
		"""Return true if this widget is mapped."""=0A=
		return getint(=0A=
			self.tk.call('winfo', 'ismapped', self._w))=0A=
	def winfo_manager(self):=0A=
		"""Return the window mananger name for this widget."""=0A=
		return self.tk.call('winfo', 'manager', self._w)=0A=
	def winfo_name(self):=0A=
		"""Return the name of this widget."""=0A=
		return self.tk.call('winfo', 'name', self._w)=0A=
	def winfo_parent(self):=0A=
		"""Return the name of the parent of this widget."""=0A=
		return self.tk.call('winfo', 'parent', self._w)=0A=
	def winfo_pathname(self, id, displayof=3D0):=0A=
		"""Return the pathname of the widget given by ID."""=0A=
		args =3D ('winfo', 'pathname') \=0A=
		       + self._displayof(displayof) + (id,)=0A=
		return self.tk.call(args)=0A=
	def winfo_pixels(self, number):=0A=
		"""Rounded integer value of winfo_fpixels."""=0A=
		return getint(=0A=
			self.tk.call('winfo', 'pixels', self._w, number))=0A=
	def winfo_pointerx(self):=0A=
		"""Return the x coordinate of the pointer on the root window."""=0A=
		return getint(=0A=
			self.tk.call('winfo', 'pointerx', self._w))=0A=
	def winfo_pointerxy(self):=0A=
		"""Return a tupel of x and y coordinates of the pointer on the root =
window."""=0A=
		return self._getints(=0A=
			self.tk.call('winfo', 'pointerxy', self._w))=0A=
	def winfo_pointery(self):=0A=
		"""Return the y coordinate of the pointer on the root window."""=0A=
 		return getint(=0A=
			self.tk.call('winfo', 'pointery', self._w))=0A=
	def winfo_reqheight(self):=0A=
		"""Return requested height of this widget."""=0A=
		return getint(=0A=
			self.tk.call('winfo', 'reqheight', self._w))=0A=
	def winfo_reqwidth(self):=0A=
		"""Return requested width of this widget."""=0A=
		return getint(=0A=
			self.tk.call('winfo', 'reqwidth', self._w))=0A=
	def winfo_rgb(self, color):=0A=
		"""Return tupel of decimal values for red, green, blue for=0A=
		COLOR in this widget."""=0A=
		return self._getints(=0A=
			self.tk.call('winfo', 'rgb', self._w, color))=0A=
	def winfo_rootx(self):=0A=
		"""Return x coordinate of upper left corner of this widget on the=0A=
		root window."""=0A=
		return getint(=0A=
			self.tk.call('winfo', 'rootx', self._w))=0A=
	def winfo_rooty(self):=0A=
		"""Return y coordinate of upper left corner of this widget on the=0A=
		root window."""=0A=
		return getint(=0A=
			self.tk.call('winfo', 'rooty', self._w))=0A=
	def winfo_screen(self):=0A=
		"""Return the screen name of this widget."""=0A=
		return self.tk.call('winfo', 'screen', self._w)=0A=
	def winfo_screencells(self):=0A=
		"""Return the number of the cells in the colormap of the screen=0A=
		of this widget."""=0A=
		return getint(=0A=
			self.tk.call('winfo', 'screencells', self._w))=0A=
	def winfo_screendepth(self):=0A=
		"""Return the number of bits per pixel of the root window of the=0A=
		screen of this widget."""=0A=
		return getint(=0A=
			self.tk.call('winfo', 'screendepth', self._w))=0A=
	def winfo_screenheight(self):=0A=
		"""Return the number of pixels of the height of the screen of this =
widget=0A=
		in pixel."""=0A=
		return getint(=0A=
			self.tk.call('winfo', 'screenheight', self._w))=0A=
	def winfo_screenmmheight(self):=0A=
		"""Return the number of pixels of the height of the screen of=0A=
		this widget in mm."""=0A=
		return getint(=0A=
			self.tk.call('winfo', 'screenmmheight', self._w))=0A=
	def winfo_screenmmwidth(self):=0A=
		"""Return the number of pixels of the width of the screen of=0A=
		this widget in mm."""=0A=
		return getint(=0A=
			self.tk.call('winfo', 'screenmmwidth', self._w))=0A=
	def winfo_screenvisual(self):=0A=
		"""Return one of the strings directcolor, grayscale, pseudocolor,=0A=
		staticcolor, staticgray, or truecolor for the default=0A=
		colormodel of this screen."""=0A=
		return self.tk.call('winfo', 'screenvisual', self._w)=0A=
	def winfo_screenwidth(self):=0A=
		"""Return the number of pixels of the width of the screen of=0A=
		this widget in pixel."""=0A=
		return getint(=0A=
			self.tk.call('winfo', 'screenwidth', self._w))=0A=
	def winfo_server(self):=0A=
		"""Return information of the X-Server of the screen of this widget =
in=0A=
		the form "XmajorRminor vendor vendorVersion"."""=0A=
		return self.tk.call('winfo', 'server', self._w)=0A=
	def winfo_toplevel(self):=0A=
		"""Return the toplevel widget of this widget."""=0A=
		return self._nametowidget(self.tk.call(=0A=
			'winfo', 'toplevel', self._w))=0A=
	def winfo_viewable(self):=0A=
		"""Return true if the widget and all its higher anchestors are =
mapped."""=0A=
		return getint(=0A=
			self.tk.call('winfo', 'viewable', self._w))=0A=
	def winfo_visual(self):=0A=
		"""Return one of the strings directcolor, grayscale, pseudocolor,=0A=
		staticcolor, staticgray, or truecolor for the =0A=
		colormodel of this widget."""=0A=
		return self.tk.call('winfo', 'visual', self._w)=0A=
	def winfo_visualid(self):=0A=
		"""Return the X identifier for the visual for this widget."""=0A=
		return self.tk.call('winfo', 'visualid', self._w)=0A=
	def winfo_visualsavailable(self, includeids=3D0):=0A=
		"""Return a list of all visuals available for the screen=0A=
		of this widget.=0A=
=0A=
		Each item in the list consists of a visual name (see winfo_visual), =
a=0A=
		depth and if INCLUDEIDS=3D1 is given also the X identifier."""=0A=
		data =3D self.tk.split(=0A=
			self.tk.call('winfo', 'visualsavailable', self._w,=0A=
				     includeids and 'includeids' or None))=0A=
		return map(self.__winfo_parseitem, data)=0A=
	def __winfo_parseitem(self, t):=0A=
		"""Internal function."""=0A=
		return t[:1] + tuple(map(self.__winfo_getint, t[1:]))=0A=
	def __winfo_getint(self, x):=0A=
		"""Internal function."""=0A=
		return _string.atoi(x, 0)=0A=
	def winfo_vrootheight(self):=0A=
		"""Return the height of the virtual root window associated with =
this=0A=
		widget in pixels. If there is no virtual root window return the=0A=
		height of the screen."""=0A=
		return getint(=0A=
			self.tk.call('winfo', 'vrootheight', self._w))=0A=
	def winfo_vrootwidth(self):=0A=
		"""Return the width of the virtual root window associated with =
this=0A=
		widget in pixel. If there is no virtual root window return the=0A=
		width of the screen."""=0A=
		return getint(=0A=
			self.tk.call('winfo', 'vrootwidth', self._w))=0A=
	def winfo_vrootx(self):=0A=
		"""Return the x offset of the virtual root relative to the root=0A=
		window of the screen of this widget."""=0A=
		return getint(=0A=
			self.tk.call('winfo', 'vrootx', self._w))=0A=
	def winfo_vrooty(self):=0A=
		"""Return the y offset of the virtual root relative to the root=0A=
		window of the screen of this widget."""=0A=
		return getint(=0A=
			self.tk.call('winfo', 'vrooty', self._w))=0A=
	def winfo_width(self):=0A=
		"""Return the width of this widget."""=0A=
		return getint(=0A=
			self.tk.call('winfo', 'width', self._w))=0A=
	def winfo_x(self):=0A=
		"""Return the x coordinate of the upper left corner of this widget=0A=
		in the parent."""=0A=
		return getint(=0A=
			self.tk.call('winfo', 'x', self._w))=0A=
	def winfo_y(self):=0A=
		"""Return the y coordinate of the upper left corner of this widget=0A=
		in the parent."""=0A=
		return getint(=0A=
			self.tk.call('winfo', 'y', self._w))=0A=
	def update(self):=0A=
		"""Enter event loop until all pending events have been processed by =
Tcl."""=0A=
		self.tk.call('update')=0A=
	def update_idletasks(self):=0A=
		"""Enter event loop until all idle callbacks have been called. =
This=0A=
		will update the display of windows but not process events caused =
by=0A=
		the user."""=0A=
		self.tk.call('update', 'idletasks')=0A=
	def bindtags(self, tagList=3DNone):=0A=
		"""Set or get the list of bindtags for this widget.=0A=
=0A=
		With no argument return the list of all bindtags associated with=0A=
		this widget. With a list of strings as argument the bindtags are=0A=
		set to this list. The bindtags determine in which order events are=0A=
		processed (see bind)."""=0A=
		if tagList is None:=0A=
			return self.tk.splitlist(=0A=
				self.tk.call('bindtags', self._w))=0A=
		else:=0A=
			self.tk.call('bindtags', self._w, tagList)=0A=
	def _bind(self, what, sequence, func, add, needcleanup=3D1):=0A=
		"""Internal function."""=0A=
		if type(func) is StringType:=0A=
			self.tk.call(what + (sequence, func))=0A=
		elif func:=0A=
			funcid =3D self._register(func, self._substitute,=0A=
						needcleanup)=0A=
			cmd =3D ('%sif {"[%s %s]" =3D=3D "break"} break\n'=0A=
			       %=0A=
			       (add and '+' or '',=0A=
				funcid,=0A=
				_string.join(self._subst_format)))=0A=
			self.tk.call(what + (sequence, cmd))=0A=
			return funcid=0A=
		elif sequence:=0A=
			return self.tk.call(what + (sequence,))=0A=
		else:=0A=
			return self.tk.splitlist(self.tk.call(what))=0A=
	def bind(self, sequence=3DNone, func=3DNone, add=3DNone):=0A=
		"""Bind to this widget at event SEQUENCE a call to function FUNC.=0A=
=0A=
		SEQUENCE is a string of concatenated event=0A=
		patterns. An event pattern is of the form=0A=
		<MODIFIER-MODIFIER-TYPE-DETAIL> where MODIFIER is one=0A=
		of Control, Mod2, M2, Shift, Mod3, M3, Lock, Mod4, M4,=0A=
		Button1, B1, Mod5, M5 Button2, B2, Meta, M, Button3,=0A=
		B3, Alt, Button4, B4, Double, Button5, B5 Triple,=0A=
		Mod1, M1. TYPE is one of Activate, Enter, Map,=0A=
		ButtonPress, Button, Expose, Motion, ButtonRelease=0A=
		FocusIn, MouseWheel, Circulate, FocusOut, Property,=0A=
		Colormap, Gravity Reparent, Configure, KeyPress, Key,=0A=
		Unmap, Deactivate, KeyRelease Visibility, Destroy,=0A=
		Leave and DETAIL is the button number for ButtonPress,=0A=
		ButtonRelease and DETAIL is the Keysym for KeyPress and=0A=
		KeyRelease. Examples are=0A=
		<Control-Button-1> for pressing Control and mouse button 1 or=0A=
		<Alt-A> for pressing A and the Alt key (KeyPress can be omitted).=0A=
		An event pattern can also be a virtual event of the form=0A=
		<<AString>> where AString can be arbitrary. This=0A=
		event can be generated by event_generate.=0A=
		If events are concatenated they must appear shortly=0A=
		after each other.=0A=
=0A=
		FUNC will be called if the event sequence occurs with an=0A=
		instance of Event as argument. If the return value of FUNC is=0A=
		"break" no further bound function is invoked.=0A=
=0A=
		An additional boolean parameter ADD specifies whether FUNC will=0A=
		be called additionally to the other bound function or whether=0A=
		it will replace the previous function.=0A=
=0A=
		Bind will return an identifier to allow deletion of the bound =
function with=0A=
		unbind without memory leak.=0A=
=0A=
		If FUNC or SEQUENCE is omitted the bound function or list=0A=
		of bound events are returned."""=0A=
		=0A=
		return self._bind(('bind', self._w), sequence, func, add)=0A=
	def unbind(self, sequence, funcid=3DNone):=0A=
		"""Unbind for this widget for event SEQUENCE  the=0A=
		function identified with FUNCID."""=0A=
		self.tk.call('bind', self._w, sequence, '')=0A=
		if funcid:=0A=
			self.deletecommand(funcid)=0A=
	def bind_all(self, sequence=3DNone, func=3DNone, add=3DNone):=0A=
		"""Bind to all widgets at an event SEQUENCE a call to function =
FUNC.=0A=
		An additional boolean parameter ADD specifies whether FUNC will=0A=
		be called additionally to the other bound function or whether=0A=
		it will replace the previous function. See bind for the return =
value."""=0A=
		return self._bind(('bind', 'all'), sequence, func, add, 0)=0A=
	def unbind_all(self, sequence):=0A=
		"""Unbind for all widgets for event SEQUENCE all functions."""=0A=
		self.tk.call('bind', 'all' , sequence, '')=0A=
	def bind_class(self, className, sequence=3DNone, func=3DNone, =
add=3DNone):=0A=
=0A=
		"""Bind to widgets with bindtag CLASSNAME at event=0A=
		SEQUENCE a call of function FUNC. An additional=0A=
		boolean parameter ADD specifies whether FUNC will be=0A=
		called additionally to the other bound function or=0A=
		whether it will replace the previous function. See bind for=0A=
		the return value."""=0A=
		=0A=
		return self._bind(('bind', className), sequence, func, add, 0)=0A=
	def unbind_class(self, className, sequence):=0A=
		"""Unbind for a all widgets with bindtag CLASSNAME for event =
SEQUENCE=0A=
		all functions."""=0A=
		self.tk.call('bind', className , sequence, '')=0A=
	def mainloop(self, n=3D0):=0A=
		"""Call the mainloop of Tk."""=0A=
		self.tk.mainloop(n)=0A=
	def quit(self):=0A=
		"""Quit the Tcl interpreter. All widgets will be destroyed."""=0A=
		self.tk.quit()=0A=
	def _getints(self, string):=0A=
		"""Internal function."""=0A=
		if string:=0A=
			return tuple(map(getint, self.tk.splitlist(string)))=0A=
	def _getdoubles(self, string):=0A=
		"""Internal function."""=0A=
		if string:=0A=
			return tuple(map(getdouble, self.tk.splitlist(string)))=0A=
	def _getboolean(self, string):=0A=
		"""Internal function."""=0A=
		if string:=0A=
			return self.tk.getboolean(string)=0A=
	def _displayof(self, displayof):=0A=
		"""Internal function."""=0A=
		if displayof:=0A=
			return ('-displayof', displayof)=0A=
		if displayof is None:=0A=
			return ('-displayof', self._w)=0A=
		return ()=0A=
	def _options(self, cnf, kw =3D None):=0A=
		"""Internal function."""=0A=
		if kw:=0A=
			cnf =3D _cnfmerge((cnf, kw))=0A=
		else:=0A=
			cnf =3D _cnfmerge(cnf)=0A=
		res =3D ()=0A=
		for k, v in cnf.items():=0A=
			if v is not None:=0A=
				if k[-1] =3D=3D '_': k =3D k[:-1]=0A=
				if callable(v):=0A=
					v =3D self._register(v)=0A=
				res =3D res + ('-'+k, v)=0A=
		return res=0A=
	def nametowidget(self, name):=0A=
		"""Return the Tkinter instance of a widget identified by=0A=
		its Tcl name NAME."""=0A=
		w =3D self=0A=
		if name[0] =3D=3D '.':=0A=
			w =3D w._root()=0A=
			name =3D name[1:]=0A=
		find =3D _string.find=0A=
		while name:=0A=
			i =3D find(name, '.')=0A=
			if i >=3D 0:=0A=
				name, tail =3D name[:i], name[i+1:]=0A=
			else:=0A=
				tail =3D ''=0A=
			w =3D w.children[name]=0A=
			name =3D tail=0A=
		return w=0A=
	_nametowidget =3D nametowidget=0A=
	def _register(self, func, subst=3DNone, needcleanup=3D1):=0A=
		"""Return a newly created Tcl function. If this=0A=
		function is called, the Python function FUNC will=0A=
		be executed. An optional function SUBST can=0A=
		be given which will be executed before FUNC."""=0A=
		f =3D CallWrapper(func, subst, self).__call__=0A=
		name =3D `id(f)`=0A=
		try:=0A=
			func =3D func.im_func=0A=
		except AttributeError:=0A=
			pass=0A=
		try:=0A=
			name =3D name + func.__name__=0A=
		except AttributeError:=0A=
			pass=0A=
		self.tk.createcommand(name, f)=0A=
		if needcleanup:=0A=
			if self._tclCommands is None:=0A=
				self._tclCommands =3D []=0A=
			self._tclCommands.append(name)=0A=
		#print '+ Tkinter created command', name=0A=
		return name=0A=
	register =3D _register=0A=
	def _root(self):=0A=
		"""Internal function."""=0A=
		w =3D self=0A=
		while w.master: w =3D w.master=0A=
		return w=0A=
	_subst_format =3D ('%#', '%b', '%f', '%h', '%k', =0A=
			 '%s', '%t', '%w', '%x', '%y',=0A=
			 '%A', '%E', '%K', '%N', '%W', '%T', '%X', '%Y', '%D')=0A=
	def _substitute(self, *args):=0A=
		"""Internal function."""=0A=
		if len(args) !=3D len(self._subst_format): return args=0A=
		getboolean =3D self.tk.getboolean=0A=
		getint =3D int=0A=
		nsign, b, f, h, k, s, t, w, x, y, A, E, K, N, W, T, X, Y, D =3D =
args=0A=
		# Missing: (a, c, d, m, o, v, B, R)=0A=
		e =3D Event()=0A=
		e.serial =3D getint(nsign)=0A=
		e.num =3D getint(b)=0A=
		try: e.focus =3D getboolean(f)=0A=
		except TclError: pass=0A=
		e.height =3D getint(h)=0A=
		e.keycode =3D getint(k)=0A=
		# For Visibility events, event state is a string and=0A=
		# not an integer:=0A=
		try:=0A=
			e.state =3D getint(s)=0A=
		except ValueError:=0A=
			e.state =3D s=0A=
		e.time =3D getint(t)=0A=
		e.width =3D getint(w)=0A=
		e.x =3D getint(x)=0A=
		e.y =3D getint(y)=0A=
		e.char =3D A=0A=
		try: e.send_event =3D getboolean(E)=0A=
		except TclError: pass=0A=
		e.keysym =3D K=0A=
		e.keysym_num =3D getint(N)=0A=
		e.type =3D T=0A=
		try:=0A=
			e.widget =3D self._nametowidget(W)=0A=
		except KeyError:=0A=
			e.widget =3D W=0A=
		e.x_root =3D getint(X)=0A=
		e.y_root =3D getint(Y)=0A=
		e.delta =3D getint(D)=0A=
		return (e,)=0A=
	def _report_exception(self):=0A=
		"""Internal function."""=0A=
		import sys=0A=
		exc, val, tb =3D sys.exc_type, sys.exc_value, sys.exc_traceback=0A=
		root =3D self._root()=0A=
		root.report_callback_exception(exc, val, tb)=0A=
	# These used to be defined in Widget:=0A=
	def configure(self, cnf=3DNone, **kw):=0A=
		"""Configure resources of a widget.=0A=
=0A=
		The values for resources are specified as keyword=0A=
		arguments. To get an overview about=0A=
		the allowed keyword arguments call the method keys.=0A=
		"""=0A=
		# XXX ought to generalize this so tag_config etc. can use it=0A=
		if kw:=0A=
			cnf =3D _cnfmerge((cnf, kw))=0A=
		elif cnf:=0A=
			cnf =3D _cnfmerge(cnf)=0A=
		if cnf is None:=0A=
			cnf =3D {}=0A=
			for x in self.tk.split(=0A=
				self.tk.call(self._w, 'configure')):=0A=
				cnf[x[0][1:]] =3D (x[0][1:],) + x[1:]=0A=
			return cnf=0A=
		if type(cnf) is StringType:=0A=
			x =3D self.tk.split(self.tk.call(=0A=
				self._w, 'configure', '-'+cnf))=0A=
			return (x[0][1:],) + x[1:]=0A=
		self.tk.call((self._w, 'configure')=0A=
		      + self._options(cnf))=0A=
	config =3D configure=0A=
	def cget(self, key):=0A=
		"""Return the resource value for a KEY given as string."""=0A=
		return self.tk.call(self._w, 'cget', '-' + key)=0A=
	__getitem__ =3D cget=0A=
	def __setitem__(self, key, value):=0A=
		self.configure({key: value})=0A=
	def keys(self):=0A=
		"""Return a list of all resource names of this widget."""=0A=
		return map(lambda x: x[0][1:],=0A=
			   self.tk.split(self.tk.call(self._w, 'configure')))=0A=
	def __str__(self):=0A=
		"""Return the window path name of this widget."""=0A=
		return self._w=0A=
	# Pack methods that apply to the master=0A=
	_noarg_ =3D ['_noarg_']=0A=
	def pack_propagate(self, flag=3D_noarg_):=0A=
		"""Set or get the status for propagation of geometry information.=0A=
=0A=
		A boolean argument specifies whether the geometry information=0A=
		of the slaves will determine the size of this widget. If no =
argument=0A=
		is given the current setting will be returned.=0A=
		"""=0A=
		if flag is Misc._noarg_:=0A=
			return self._getboolean(self.tk.call(=0A=
				'pack', 'propagate', self._w))=0A=
		else:=0A=
			self.tk.call('pack', 'propagate', self._w, flag)=0A=
	propagate =3D pack_propagate=0A=
	def pack_slaves(self):=0A=
		"""Return a list of all slaves of this widget=0A=
		in its packing order."""=0A=
		return map(self._nametowidget,=0A=
			   self.tk.splitlist(=0A=
				   self.tk.call('pack', 'slaves', self._w)))=0A=
	slaves =3D pack_slaves=0A=
	# Place method that applies to the master=0A=
	def place_slaves(self):=0A=
		"""Return a list of all slaves of this widget=0A=
		in its packing order."""=0A=
		return map(self._nametowidget,=0A=
			   self.tk.splitlist(=0A=
				   self.tk.call(=0A=
					   'place', 'slaves', self._w)))=0A=
	# Grid methods that apply to the master=0A=
	def grid_bbox(self, column=3DNone, row=3DNone, col2=3DNone, =
row2=3DNone):=0A=
		"""Return a tuple of integer coordinates for the bounding=0A=
		box of this widget controlled by the geometry manager grid.=0A=
=0A=
		If COLUMN, ROW is given the bounding box applies from=0A=
		the cell with row and column 0 to the specified=0A=
		cell. If COL2 and ROW2 are given the bounding box=0A=
		starts at that cell.=0A=
=0A=
		The returned integers specify the offset of the uppler left=0A=
		corner in the master widget and the width and height.=0A=
		"""=0A=
		args =3D ('grid', 'bbox', self._w)=0A=
		if column is not None and row is not None:=0A=
			args =3D args + (column, row)=0A=
		if col2 is not None and row2 is not None:=0A=
			args =3D args + (col2, row2)=0A=
		return self._getints(apply(self.tk.call, args)) or None=0A=
=0A=
	bbox =3D grid_bbox=0A=
	def _grid_configure(self, command, index, cnf, kw):=0A=
		"""Internal function."""=0A=
		if type(cnf) is StringType and not kw:=0A=
			if cnf[-1:] =3D=3D '_':=0A=
				cnf =3D cnf[:-1]=0A=
			if cnf[:1] !=3D '-':=0A=
				cnf =3D '-'+cnf=0A=
			options =3D (cnf,)=0A=
		else:=0A=
			options =3D self._options(cnf, kw)=0A=
		if not options:=0A=
			res =3D self.tk.call('grid',=0A=
					   command, self._w, index)=0A=
			words =3D self.tk.splitlist(res)=0A=
			dict =3D {}=0A=
			for i in range(0, len(words), 2):=0A=
				key =3D words[i][1:]=0A=
				value =3D words[i+1]=0A=
				if not value:=0A=
					value =3D None=0A=
				elif '.' in value:=0A=
					value =3D getdouble(value)=0A=
				else:=0A=
					value =3D getint(value)=0A=
				dict[key] =3D value=0A=
			return dict=0A=
		res =3D self.tk.call(=0A=
			      ('grid', command, self._w, index) =0A=
			      + options)=0A=
		if len(options) =3D=3D 1:=0A=
			if not res: return None=0A=
			# In Tk 7.5, -width can be a float=0A=
			if '.' in res: return getdouble(res)=0A=
			return getint(res)=0A=
	def grid_columnconfigure(self, index, cnf=3D{}, **kw):=0A=
		"""Configure column INDEX of a grid.=0A=
=0A=
		Valid resources are minsize (minimum size of the column),=0A=
		weight (how much does additional space propagate to this column)=0A=
		and pad (how much space to let additionally)."""=0A=
		return self._grid_configure('columnconfigure', index, cnf, kw)=0A=
	columnconfigure =3D grid_columnconfigure=0A=
	def grid_propagate(self, flag=3D_noarg_):=0A=
		"""Set or get the status for propagation of geometry information.=0A=
=0A=
		A boolean argument specifies whether the geometry information=0A=
		of the slaves will determine the size of this widget. If no =
argument=0A=
		is given, the current setting will be returned.=0A=
		"""=0A=
		if flag is Misc._noarg_:=0A=
			return self._getboolean(self.tk.call(=0A=
				'grid', 'propagate', self._w))=0A=
		else:=0A=
			self.tk.call('grid', 'propagate', self._w, flag)=0A=
	def grid_rowconfigure(self, index, cnf=3D{}, **kw):=0A=
		"""Configure row INDEX of a grid.=0A=
=0A=
		Valid resources are minsize (minimum size of the row),=0A=
		weight (how much does additional space propagate to this row)=0A=
		and pad (how much space to let additionally)."""=0A=
		return self._grid_configure('rowconfigure', index, cnf, kw)=0A=
	rowconfigure =3D grid_rowconfigure=0A=
	def grid_size(self):=0A=
		"""Return a tuple of the number of column and rows in the grid."""=0A=
		return self._getints(=0A=
			self.tk.call('grid', 'size', self._w)) or None=0A=
	size =3D grid_size=0A=
	def grid_slaves(self, row=3DNone, column=3DNone):=0A=
		"""Return a list of all slaves of this widget=0A=
		in its packing order."""=0A=
		args =3D ()=0A=
		if row is not None:=0A=
			args =3D args + ('-row', row)=0A=
		if column is not None:=0A=
			args =3D args + ('-column', column)=0A=
		return map(self._nametowidget,=0A=
			   self.tk.splitlist(self.tk.call(=0A=
				   ('grid', 'slaves', self._w) + args)))=0A=
=0A=
	# Support for the "event" command, new in Tk 4.2.=0A=
	# By Case Roole.=0A=
=0A=
	def event_add(self, virtual, *sequences):=0A=
		"""Bind a virtual event VIRTUAL (of the form <<Name>>)=0A=
		to an event SEQUENCE such that the virtual event is triggered=0A=
		whenever SEQUENCE occurs."""=0A=
		args =3D ('event', 'add', virtual) + sequences=0A=
		self.tk.call(args)=0A=
=0A=
	def event_delete(self, virtual, *sequences):=0A=
		"""Unbind a virtual event VIRTUAL from SEQUENCE."""=0A=
		args =3D ('event', 'delete', virtual) + sequences=0A=
		self.tk.call(args)=0A=
=0A=
	def event_generate(self, sequence, **kw):=0A=
		"""Generate an event SEQUENCE. Additional=0A=
		keyword arguments specify parameter of the event=0A=
		(e.g. x, y, rootx, rooty)."""=0A=
		args =3D ('event', 'generate', self._w, sequence)=0A=
		for k, v in kw.items():=0A=
			args =3D args + ('-%s' % k, str(v))=0A=
		self.tk.call(args)=0A=
=0A=
	def event_info(self, virtual=3DNone):=0A=
		"""Return a list of all virtual events or the information=0A=
		about the SEQUENCE bound to the virtual event VIRTUAL."""=0A=
		return self.tk.splitlist(=0A=
		    self.tk.call('event', 'info', virtual))=0A=
=0A=
	# Image related commands=0A=
=0A=
	def image_names(self):=0A=
		"""Return a list of all existing image names."""=0A=
		return self.tk.call('image', 'names')=0A=
=0A=
	def image_types(self):=0A=
		"""Return a list of all available image types (e.g. phote =
bitmap)."""=0A=
		return self.tk.call('image', 'types')=0A=
=0A=
=0A=
class CallWrapper:=0A=
	"""Internal class. Stores function to call when some user=0A=
	defined Tcl function is called e.g. after an event occured."""=0A=
	def __init__(self, func, subst, widget):=0A=
		"""Store FUNC, SUBST and WIDGET as members."""=0A=
		self.func =3D func=0A=
		self.subst =3D subst=0A=
		self.widget =3D widget=0A=
	def __call__(self, *args):=0A=
		"""Apply first function SUBST to arguments, than FUNC."""=0A=
		try:=0A=
			if self.subst:=0A=
				args =3D apply(self.subst, args)=0A=
			return apply(self.func, args)=0A=
		except SystemExit, msg:=0A=
			raise SystemExit, msg=0A=
		except:=0A=
			self.widget._report_exception()=0A=
=0A=
=0A=
class Wm:=0A=
	"""Provides functions for the communication with the window =
manager."""=0A=
	def wm_aspect(self,=0A=
		      minNumer=3DNone, minDenom=3DNone, =0A=
		      maxNumer=3DNone, maxDenom=3DNone):=0A=
		"""Instruct the window manager to set the aspect ratio =
(width/height)=0A=
		of this widget to be between MINNUMER/MINDENOM and MAXNUMER/MAXDENOM. =
Return a tuple=0A=
		of the actual values if no argument is given."""=0A=
		return self._getints(=0A=
			self.tk.call('wm', 'aspect', self._w, =0A=
				     minNumer, minDenom, =0A=
				     maxNumer, maxDenom))=0A=
	aspect =3D wm_aspect=0A=
	def wm_client(self, name=3DNone):=0A=
		"""Store NAME in WM_CLIENT_MACHINE property of this widget. Return=0A=
		current value."""=0A=
		return self.tk.call('wm', 'client', self._w, name)=0A=
	client =3D wm_client=0A=
	def wm_colormapwindows(self, *wlist):=0A=
		"""Store list of window names (WLIST) into WM_COLORMAPWINDOWS =
property=0A=
		of this widget. This list contains windows whose colormaps differ =
from their=0A=
		parents. Return current list of widgets if WLIST is empty."""=0A=
		if len(wlist) > 1:=0A=
			wlist =3D (wlist,) # Tk needs a list of windows here=0A=
		args =3D ('wm', 'colormapwindows', self._w) + wlist=0A=
		return map(self._nametowidget, self.tk.call(args))=0A=
	colormapwindows =3D wm_colormapwindows=0A=
	def wm_command(self, value=3DNone):=0A=
		"""Store VALUE in WM_COMMAND property. It is the command=0A=
		which shall be used to invoke the application. Return current=0A=
		commmand if VALUE is None."""=0A=
		return self.tk.call('wm', 'command', self._w, value)=0A=
	command =3D wm_command=0A=
	def wm_deiconify(self):=0A=
		"""Deiconify this widget. If it was never mapped it will not be =
mapped.=0A=
		On Windows it will raise this widget and give it the focus."""=0A=
		return self.tk.call('wm', 'deiconify', self._w)=0A=
	deiconify =3D wm_deiconify=0A=
	def wm_focusmodel(self, model=3DNone):=0A=
		"""Set focus model to MODEL. "active" means that this widget will =
claim=0A=
		the focus itself, "passive" means that the window manager shall =
give=0A=
		the focus. Return current focus model if MODEL is None."""=0A=
		return self.tk.call('wm', 'focusmodel', self._w, model)=0A=
	focusmodel =3D wm_focusmodel=0A=
	def wm_frame(self):=0A=
		"""Return identifier for decorative frame of this widget if =
present."""=0A=
		return self.tk.call('wm', 'frame', self._w)=0A=
	frame =3D wm_frame=0A=
	def wm_geometry(self, newGeometry=3DNone):=0A=
		"""Set geometry to NEWGEOMETRY of the form =3Dwidthxheigth+x+y. =
Return=0A=
		current value if None is given."""=0A=
		return self.tk.call('wm', 'geometry', self._w, newGeometry)=0A=
	geometry =3D wm_geometry=0A=
	def wm_grid(self,=0A=
		 baseWidth=3DNone, baseHeight=3DNone, =0A=
		 widthInc=3DNone, heightInc=3DNone):=0A=
		"""Instruct the window manager that this widget shall only be=0A=
		resized on grid boundaries. WIDTHINC and HEIGHTINC are the width =
and=0A=
		height of a grid unit in pixels. BASEWIDTH and BASEHEIGHT are the=0A=
		number of grid units requested in Tk_GeometryRequest."""=0A=
		return self._getints(self.tk.call(=0A=
			'wm', 'grid', self._w,=0A=
			baseWidth, baseHeight, widthInc, heightInc))=0A=
	grid =3D wm_grid=0A=
	def wm_group(self, pathName=3DNone):=0A=
		"""Set the group leader widgets for related widgets to PATHNAME. =
Return=0A=
		the group leader of this widget if None is given."""=0A=
		return self.tk.call('wm', 'group', self._w, pathName)=0A=
	group =3D wm_group=0A=
	def wm_iconbitmap(self, bitmap=3DNone):=0A=
		"""Set bitmap for the iconified widget to BITMAP. Return=0A=
		the bitmap if None is given."""=0A=
		return self.tk.call('wm', 'iconbitmap', self._w, bitmap)=0A=
	iconbitmap =3D wm_iconbitmap=0A=
	def wm_iconify(self):=0A=
		"""Display widget as icon."""=0A=
		return self.tk.call('wm', 'iconify', self._w)=0A=
	iconify =3D wm_iconify=0A=
	def wm_iconmask(self, bitmap=3DNone):=0A=
		"""Set mask for the icon bitmap of this widget. Return the=0A=
		mask if None is given."""=0A=
		return self.tk.call('wm', 'iconmask', self._w, bitmap)=0A=
	iconmask =3D wm_iconmask=0A=
	def wm_iconname(self, newName=3DNone):=0A=
		"""Set the name of the icon for this widget. Return the name if=0A=
		None is given."""=0A=
		return self.tk.call('wm', 'iconname', self._w, newName)=0A=
	iconname =3D wm_iconname=0A=
	def wm_iconposition(self, x=3DNone, y=3DNone):=0A=
		"""Set the position of the icon of this widget to X and Y. Return=0A=
		a tuple of the current values of X and X if None is given."""=0A=
		return self._getints(self.tk.call(=0A=
			'wm', 'iconposition', self._w, x, y))=0A=
	iconposition =3D wm_iconposition=0A=
	def wm_iconwindow(self, pathName=3DNone):=0A=
		"""Set widget PATHNAME to be displayed instead of icon. Return the =
current=0A=
		value if None is given."""=0A=
		return self.tk.call('wm', 'iconwindow', self._w, pathName)=0A=
	iconwindow =3D wm_iconwindow=0A=
	def wm_maxsize(self, width=3DNone, height=3DNone):=0A=
		"""Set max WIDTH and HEIGHT for this widget. If the window is =
gridded=0A=
		the values are given in grid units. Return the current values if =
None=0A=
		is given."""=0A=
		return self._getints(self.tk.call(=0A=
			'wm', 'maxsize', self._w, width, height))=0A=
	maxsize =3D wm_maxsize=0A=
	def wm_minsize(self, width=3DNone, height=3DNone):=0A=
		"""Set min WIDTH and HEIGHT for this widget. If the window is =
gridded=0A=
		the values are given in grid units. Return the current values if =
None=0A=
		is given."""=0A=
		return self._getints(self.tk.call(=0A=
			'wm', 'minsize', self._w, width, height))=0A=
	minsize =3D wm_minsize=0A=
	def wm_overrideredirect(self, boolean=3DNone):=0A=
		"""Instruct the window manager to ignore this widget=0A=
		if BOOLEAN is given with 1. Return the current value if None=0A=
		is given."""=0A=
		return self._getboolean(self.tk.call(=0A=
			'wm', 'overrideredirect', self._w, boolean))=0A=
	overrideredirect =3D wm_overrideredirect=0A=
	def wm_positionfrom(self, who=3DNone):=0A=
		"""Instruct the window manager that the position of this widget =
shall=0A=
		be defined by the user if WHO is "user", and by its own policy if WHO =
is=0A=
		"program"."""=0A=
		return self.tk.call('wm', 'positionfrom', self._w, who)=0A=
	positionfrom =3D wm_positionfrom=0A=
	def wm_protocol(self, name=3DNone, func=3DNone):=0A=
		"""Bind function FUNC to command NAME for this widget.=0A=
		Return the function bound to NAME if None is given. NAME could be=0A=
		e.g. "WM_SAVE_YOURSELF" or "WM_DELETE_WINDOW"."""=0A=
		if callable(func):=0A=
			command =3D self._register(func)=0A=
		else:=0A=
			command =3D func=0A=
		return self.tk.call(=0A=
			'wm', 'protocol', self._w, name, command)=0A=
	protocol =3D wm_protocol=0A=
	def wm_resizable(self, width=3DNone, height=3DNone):=0A=
		"""Instruct the window manager whether this width can be resized=0A=
		in WIDTH or HEIGHT. Both values are boolean values."""=0A=
		return self.tk.call('wm', 'resizable', self._w, width, height)=0A=
	resizable =3D wm_resizable=0A=
	def wm_sizefrom(self, who=3DNone):=0A=
		"""Instruct the window manager that the size of this widget shall=0A=
		be defined by the user if WHO is "user", and by its own policy if WHO =
is=0A=
		"program"."""=0A=
		return self.tk.call('wm', 'sizefrom', self._w, who)=0A=
	sizefrom =3D wm_sizefrom=0A=
	def wm_state(self):=0A=
		"""Return the state of this widget as one of normal,=0A=
		icon, iconic (see wm_iconwindow) and withdrawn."""=0A=
		return self.tk.call('wm', 'state', self._w)=0A=
	state =3D wm_state=0A=
	def wm_title(self, string=3DNone):=0A=
		"""Set the title of this widget."""=0A=
		return self.tk.call('wm', 'title', self._w, string)=0A=
	title =3D wm_title=0A=
	def wm_transient(self, master=3DNone):=0A=
		"""Instruct the window manager that this widget is transient=0A=
		with regard to widget MASTER."""=0A=
		return self.tk.call('wm', 'transient', self._w, master)=0A=
	transient =3D wm_transient=0A=
	def wm_withdraw(self):=0A=
		"""Withdraw this widget from the screen such that it is unmapped=0A=
		and forgotten by the window manager. Re-draw it with =
wm_deiconify."""=0A=
		return self.tk.call('wm', 'withdraw', self._w)=0A=
	withdraw =3D wm_withdraw=0A=
=0A=
=0A=
class Tk(Misc, Wm):=0A=
	"""Toplevel widget of Tk which represents mostly the main window=0A=
	of an appliation. It has an associated Tcl interpreter."""=0A=
	_w =3D '.'=0A=
	def __init__(self, screenName=3DNone, baseName=3DNone, =
className=3D'Tk'):=0A=
		"""Return a new Toplevel widget on screen SCREENNAME. A new Tcl =
interpreter will=0A=
		be created. BASENAME will be used for the identification of the =
profile file (see=0A=
		readprofile).=0A=
		It is constructed from sys.argv[0] without extensions if None is =
given. CLASSNAME=0A=
		is the name of the widget class."""=0A=
		global _default_root=0A=
		self.master =3D None=0A=
		self.children =3D {}=0A=
		if baseName is None:=0A=
			import sys, os=0A=
			baseName =3D os.path.basename(sys.argv[0])=0A=
			baseName, ext =3D os.path.splitext(baseName)=0A=
			if ext not in ('.py', '.pyc', '.pyo'):=0A=
				baseName =3D baseName + ext=0A=
		self.tk =3D _tkinter.create(screenName, baseName, className)=0A=
		if _MacOS:=0A=
			# Disable event scanning except for Command-Period=0A=
			_MacOS.SchedParams(1, 0)=0A=
			# Work around nasty MacTk bug=0A=
			# XXX Is this one still needed?=0A=
			self.update()=0A=
		# Version sanity checks=0A=
		tk_version =3D self.tk.getvar('tk_version')=0A=
		if tk_version !=3D _tkinter.TK_VERSION:=0A=
		    raise RuntimeError, \=0A=
		    "tk.h version (%s) doesn't match libtk.a version (%s)" \=0A=
		    % (_tkinter.TK_VERSION, tk_version)=0A=
		tcl_version =3D self.tk.getvar('tcl_version')=0A=
		if tcl_version !=3D _tkinter.TCL_VERSION:=0A=
		    raise RuntimeError, \=0A=
		    "tcl.h version (%s) doesn't match libtcl.a version (%s)" \=0A=
		    % (_tkinter.TCL_VERSION, tcl_version)=0A=
		if TkVersion < 4.0:=0A=
			raise RuntimeError, \=0A=
			"Tk 4.0 or higher is required; found Tk %s" \=0A=
			% str(TkVersion)=0A=
		self.tk.createcommand('tkerror', _tkerror)=0A=
		self.tk.createcommand('exit', _exit)=0A=
		self.readprofile(baseName, className)=0A=
		if _support_default_root and not _default_root:=0A=
			_default_root =3D self=0A=
		self.protocol("WM_DELETE_WINDOW", self.destroy)=0A=
	def destroy(self):=0A=
		"""Destroy this and all descendants widgets. This will=0A=
		end the application of this Tcl interpreter."""=0A=
		for c in self.children.values(): c.destroy()=0A=
		self.tk.call('destroy', self._w)=0A=
		Misc.destroy(self)=0A=
		global _default_root=0A=
		if _support_default_root and _default_root is self:=0A=
			_default_root =3D None=0A=
	def readprofile(self, baseName, className):=0A=
		"""Internal function. It reads BASENAME.tcl and CLASSNAME.tcl into=0A=
		the Tcl Interpreter and calls execfile on BASENAME.py and =
CLASSNAME.py if=0A=
		such a file exists in the home directory."""=0A=
		import os=0A=
		if os.environ.has_key('HOME'): home =3D os.environ['HOME']=0A=
		else: home =3D os.curdir=0A=
		class_tcl =3D os.path.join(home, '.%s.tcl' % className)=0A=
		class_py =3D os.path.join(home, '.%s.py' % className)=0A=
		base_tcl =3D os.path.join(home, '.%s.tcl' % baseName)=0A=
		base_py =3D os.path.join(home, '.%s.py' % baseName)=0A=
		dir =3D {'self': self}=0A=
		exec 'from Tkinter import *' in dir=0A=
		if os.path.isfile(class_tcl):=0A=
			print 'source', `class_tcl`=0A=
			self.tk.call('source', class_tcl)=0A=
		if os.path.isfile(class_py):=0A=
			print 'execfile', `class_py`=0A=
			execfile(class_py, dir)=0A=
		if os.path.isfile(base_tcl):=0A=
			print 'source', `base_tcl`=0A=
			self.tk.call('source', base_tcl)=0A=
		if os.path.isfile(base_py):=0A=
			print 'execfile', `base_py`=0A=
			execfile(base_py, dir)=0A=
	def report_callback_exception(self, exc, val, tb):=0A=
		"""Internal function. It reports exception on sys.stderr."""=0A=
		import traceback, sys=0A=
		sys.stderr.write("Exception in Tkinter callback\n")=0A=
		sys.last_type =3D exc=0A=
		sys.last_value =3D val=0A=
		sys.last_traceback =3D tb=0A=
		traceback.print_exception(exc, val, tb)=0A=
=0A=
# Ideally, the classes Pack, Place and Grid disappear, the=0A=
# pack/place/grid methods are defined on the Widget class, and=0A=
# everybody uses w.pack_whatever(...) instead of Pack.whatever(w,=0A=
# ...), with pack(), place() and grid() being short for=0A=
# pack_configure(), place_configure() and grid_columnconfigure(), =
and=0A=
# forget() being short for pack_forget().  As a practical matter, =
I'm=0A=
# afraid that there is too much code out there that may be using the=0A=
# Pack, Place or Grid class, so I leave them intact -- but only as=0A=
# backwards compatibility features.  Also note that those methods =
that=0A=
# take a master as argument (e.g. pack_propagate) have been moved to=0A=
# the Misc class (which now incorporates all methods common between=0A=
# toplevel and interior widgets).  Again, for compatibility, these =
are=0A=
# copied into the Pack, Place or Grid class.=0A=
=0A=
class Pack:=0A=
	"""Geometry manager Pack.=0A=
=0A=
	Base class to use the methods pack_* in every widget."""=0A=
	def pack_configure(self, cnf=3D{}, **kw):=0A=
		"""Pack a widget in the parent widget. Use as options:=0A=
		after=3Dwidget - pack it after you have packed widget=0A=
		anchor=3DNSEW (or subset) - position widget according to=0A=
		                          given direction=0A=
                before=3Dwidget - pack it before you will pack =
widget=0A=
		expand=3D1 or 0 - expand widget if parent size grows=0A=
		fill=3DNONE or X or Y or BOTH - fill widget if widget grows=0A=
		in=3Dmaster - use master to contain this widget=0A=
		ipadx=3Damount - add internal padding in x direction=0A=
		ipady=3Damount - add internal padding in y direction=0A=
		padx=3Damount - add padding in x direction=0A=
		pady=3Damount - add padding in y direction=0A=
		side=3DTOP or BOTTOM or LEFT or RIGHT -  where to add this widget.=0A=
		"""=0A=
		self.tk.call(=0A=
		      ('pack', 'configure', self._w) =0A=
		      + self._options(cnf, kw))=0A=
	pack =3D configure =3D config =3D pack_configure=0A=
	def pack_forget(self):=0A=
		"""Unmap this widget and do not use it for the packing order."""=0A=
		self.tk.call('pack', 'forget', self._w)=0A=
	forget =3D pack_forget=0A=
	def pack_info(self):=0A=
		"""Return information about the packing options=0A=
		for this widget."""=0A=
		words =3D self.tk.splitlist(=0A=
			self.tk.call('pack', 'info', self._w))=0A=
		dict =3D {}=0A=
		for i in range(0, len(words), 2):=0A=
			key =3D words[i][1:]=0A=
			value =3D words[i+1]=0A=
			if value[:1] =3D=3D '.':=0A=
				value =3D self._nametowidget(value)=0A=
			dict[key] =3D value=0A=
		return dict=0A=
	info =3D pack_info=0A=
	propagate =3D pack_propagate =3D Misc.pack_propagate=0A=
	slaves =3D pack_slaves =3D Misc.pack_slaves=0A=
=0A=
class Place:=0A=
	"""Geometry manager Place.=0A=
=0A=
	Base class to use the methods place_* in every widget."""=0A=
	def place_configure(self, cnf=3D{}, **kw):=0A=
		"""Place a widget in the parent widget. Use as options:=0A=
		in=3Dmaster - master relative to which the widget is placed.=0A=
		x=3Damount - locate anchor of this widget at position x of master=0A=
		y=3Damount - locate anchor of this widget at position y of master=0A=
		relx=3Damount - locate anchor of this widget between 0.0 and 1.0=0A=
		              relative to width of master (1.0 is right edge)=0A=
	        rely=3Damount - locate anchor of this widget between 0.0 and =
1.0=0A=
		              relative to height of master (1.0 is bottom edge)=0A=
	        anchor=3DNSEW (or subset) - position anchor according to given =
direction=0A=
		width=3Damount - width of this widget in pixel=0A=
		height=3Damount - height of this widget in pixel=0A=
		relwidth=3Damount - width of this widget between 0.0 and 1.0=0A=
		                  relative to width of master (1.0 is the same =
width=0A=
				  as the master)=0A=
	        relheight=3Damount - height of this widget between 0.0 and =
1.0=0A=
		                   relative to heigth of master (1.0 is the same=0A=
				   height as the master)=0A=
	        bordermode=3D"inside" or "outside" - whether to take border =
width of master widget=0A=
	                                           into account=0A=
	        """=0A=
		for k in ['in_']:=0A=
			if kw.has_key(k):=0A=
				kw[k[:-1]] =3D kw[k]=0A=
				del kw[k]=0A=
		self.tk.call(=0A=
		      ('place', 'configure', self._w) =0A=
		      + self._options(cnf, kw))=0A=
	place =3D configure =3D config =3D place_configure=0A=
	def place_forget(self):=0A=
		"""Unmap this widget."""=0A=
		self.tk.call('place', 'forget', self._w)=0A=
	forget =3D place_forget=0A=
	def place_info(self):=0A=
		"""Return information about the placing options=0A=
		for this widget."""=0A=
		words =3D self.tk.splitlist(=0A=
			self.tk.call('place', 'info', self._w))=0A=
		dict =3D {}=0A=
		for i in range(0, len(words), 2):=0A=
			key =3D words[i][1:]=0A=
			value =3D words[i+1]=0A=
			if value[:1] =3D=3D '.':=0A=
				value =3D self._nametowidget(value)=0A=
			dict[key] =3D value=0A=
		return dict=0A=
	info =3D place_info=0A=
	slaves =3D place_slaves =3D Misc.place_slaves=0A=
=0A=
class Grid:=0A=
	"""Geometry manager Grid.=0A=
=0A=
	Base class to use the methods grid_* in every widget."""=0A=
	# Thanks to Masazumi Yoshikawa (yosikawa@isi.edu)=0A=
	def grid_configure(self, cnf=3D{}, **kw):=0A=
		"""Position a widget in the parent widget in a grid. Use as =
options:=0A=
		column=3Dnumber - use cell identified with given column (starting =
with 0)=0A=
		columnspan=3Dnumber - this widget will span several columns=0A=
		in=3Dmaster - use master to contain this widget=0A=
		ipadx=3Damount - add internal padding in x direction=0A=
		ipady=3Damount - add internal padding in y direction=0A=
		padx=3Damount - add padding in x direction=0A=
		pady=3Damount - add padding in y direction=0A=
		row=3Dnumber - use cell identified with given row (starting with =
0)=0A=
		rowspan=3Dnumber - this widget will span several rows=0A=
		sticky=3DNSEW - if cell is larger on which sides will this=0A=
		              widget stick to the cell boundary=0A=
		"""=0A=
		self.tk.call(=0A=
		      ('grid', 'configure', self._w) =0A=
		      + self._options(cnf, kw))=0A=
	grid =3D configure =3D config =3D grid_configure=0A=
	bbox =3D grid_bbox =3D Misc.grid_bbox=0A=
	columnconfigure =3D grid_columnconfigure =3D =
Misc.grid_columnconfigure=0A=
	def grid_forget(self):=0A=
		"""Unmap this widget."""=0A=
		self.tk.call('grid', 'forget', self._w)=0A=
	forget =3D grid_forget=0A=
	def grid_remove(self):=0A=
		"""Unmap this widget but remember the grid options."""=0A=
		self.tk.call('grid', 'remove', self._w)=0A=
	def grid_info(self):=0A=
		"""Return information about the options=0A=
		for positioning this widget in a grid."""=0A=
		words =3D self.tk.splitlist(=0A=
			self.tk.call('grid', 'info', self._w))=0A=
		dict =3D {}=0A=
		for i in range(0, len(words), 2):=0A=
			key =3D words[i][1:]=0A=
			value =3D words[i+1]=0A=
			if value[:1] =3D=3D '.':=0A=
				value =3D self._nametowidget(value)=0A=
			dict[key] =3D value=0A=
		return dict=0A=
	info =3D grid_info=0A=
	def grid_location(self, x, y):=0A=
		"""Return a tuple of column and row which identify the cell=0A=
		at which the pixel at position X and Y inside the master=0A=
		widget is located."""=0A=
		return self._getints(=0A=
			self.tk.call(=0A=
				'grid', 'location', self._w, x, y)) or None=0A=
	location =3D grid_location=0A=
	propagate =3D grid_propagate =3D Misc.grid_propagate=0A=
	rowconfigure =3D grid_rowconfigure =3D Misc.grid_rowconfigure=0A=
	size =3D grid_size =3D Misc.grid_size=0A=
	slaves =3D grid_slaves =3D Misc.grid_slaves=0A=
=0A=
class BaseWidget(Misc):=0A=
	"""Internal class."""=0A=
	def _setup(self, master, cnf):=0A=
		"""Internal function. Sets up information about children."""=0A=
		if _support_default_root:=0A=
			global _default_root=0A=
			if not master:=0A=
				if not _default_root:=0A=
					_default_root =3D Tk()=0A=
				master =3D _default_root=0A=
		self.master =3D master=0A=
		self.tk =3D master.tk=0A=
		name =3D None=0A=
		if cnf.has_key('name'):=0A=
			name =3D cnf['name']=0A=
			del cnf['name']=0A=
		if not name:=0A=
			name =3D `id(self)`=0A=
		self._name =3D name=0A=
		if master._w=3D=3D'.':=0A=
			self._w =3D '.' + name=0A=
		else:=0A=
			self._w =3D master._w + '.' + name=0A=
		self.children =3D {}=0A=
		if self.master.children.has_key(self._name):=0A=
			self.master.children[self._name].destroy()=0A=
		self.master.children[self._name] =3D self=0A=
	def __init__(self, master, widgetName, cnf=3D{}, kw=3D{}, =
extra=3D()):=0A=
		"""Construct a widget with the parent widget MASTER, a name =
WIDGETNAME=0A=
		and appropriate options."""=0A=
		if kw:=0A=
			cnf =3D _cnfmerge((cnf, kw))=0A=
		self.widgetName =3D widgetName=0A=
		BaseWidget._setup(self, master, cnf)=0A=
		classes =3D []=0A=
		for k in cnf.keys():=0A=
			if type(k) is ClassType:=0A=
				classes.append((k, cnf[k]))=0A=
				del cnf[k]=0A=
		self.tk.call(=0A=
			(widgetName, self._w) + extra + self._options(cnf))=0A=
		for k, v in classes:=0A=
			k.configure(self, v)=0A=
	def destroy(self):=0A=
		"""Destroy this and all descendants widgets."""=0A=
		for c in self.children.values(): c.destroy()=0A=
		if self.master.children.has_key(self._name):=0A=
			del self.master.children[self._name]=0A=
		self.tk.call('destroy', self._w)=0A=
		Misc.destroy(self)=0A=
	def _do(self, name, args=3D()):=0A=
		# XXX Obsolete -- better use self.tk.call directly!=0A=
		return self.tk.call((self._w, name) + args)=0A=
=0A=
class Widget(BaseWidget, Pack, Place, Grid):=0A=
	"""Internal class.=0A=
=0A=
	Base class for a widget which can be positioned with the geometry =
managers=0A=
	Pack, Place or Grid."""=0A=
	pass=0A=
=0A=
class Toplevel(BaseWidget, Wm):=0A=
	"""Toplevel widget, e.g. for dialogs."""=0A=
	def __init__(self, master=3DNone, cnf=3D{}, **kw):=0A=
		"""Construct a toplevel widget with the parent MASTER.=0A=
=0A=
		Valid resource names: background, bd, bg, borderwidth, class,=0A=
		colormap, container, cursor, height, highlightbackground,=0A=
		highlightcolor, highlightthickness, menu, relief, screen, =
takefocus,=0A=
		use, visual, width."""=0A=
		if kw:=0A=
			cnf =3D _cnfmerge((cnf, kw))=0A=
		extra =3D ()=0A=
		for wmkey in ['screen', 'class_', 'class', 'visual',=0A=
			      'colormap']:=0A=
			if cnf.has_key(wmkey):=0A=
				val =3D cnf[wmkey]=0A=
				# TBD: a hack needed because some keys=0A=
				# are not valid as keyword arguments=0A=
				if wmkey[-1] =3D=3D '_': opt =3D '-'+wmkey[:-1]=0A=
				else: opt =3D '-'+wmkey=0A=
				extra =3D extra + (opt, val)=0A=
				del cnf[wmkey]=0A=
		BaseWidget.__init__(self, master, 'toplevel', cnf, {}, extra)=0A=
		root =3D self._root()=0A=
		self.iconname(root.iconname())=0A=
		self.title(root.title())=0A=
		self.protocol("WM_DELETE_WINDOW", self.destroy)=0A=
=0A=
class Button(Widget):=0A=
	"""Button widget."""=0A=
	def __init__(self, master=3DNone, cnf=3D{}, **kw):=0A=
		"""Construct a button widget with the parent MASTER.=0A=
=0A=
		Valid resource names: activebackground, activeforeground, anchor,=0A=
		background, bd, bg, bitmap, borderwidth, command, cursor, default,=0A=
		disabledforeground, fg, font, foreground, height,=0A=
		highlightbackground, highlightcolor, highlightthickness, image,=0A=
		justify, padx, pady, relief, state, takefocus, text, textvariable,=0A=
		underline, width, wraplength."""=0A=
		Widget.__init__(self, master, 'button', cnf, kw)=0A=
	def tkButtonEnter(self, *dummy):=0A=
		self.tk.call('tkButtonEnter', self._w)=0A=
	def tkButtonLeave(self, *dummy):=0A=
		self.tk.call('tkButtonLeave', self._w)=0A=
	def tkButtonDown(self, *dummy):=0A=
		self.tk.call('tkButtonDown', self._w)=0A=
	def tkButtonUp(self, *dummy):=0A=
		self.tk.call('tkButtonUp', self._w)=0A=
	def tkButtonInvoke(self, *dummy):=0A=
		self.tk.call('tkButtonInvoke', self._w)=0A=
	def flash(self):=0A=
		self.tk.call(self._w, 'flash')=0A=
	def invoke(self):=0A=
		return self.tk.call(self._w, 'invoke')=0A=
=0A=
# Indices:=0A=
# XXX I don't like these -- take them away=0A=
def AtEnd():=0A=
	return 'end'=0A=
def AtInsert(*args):=0A=
	s =3D 'insert'=0A=
	for a in args:=0A=
		if a: s =3D s + (' ' + a)=0A=
	return s=0A=
def AtSelFirst():=0A=
	return 'sel.first'=0A=
def AtSelLast():=0A=
	return 'sel.last'=0A=
def At(x, y=3DNone):=0A=
	if y is None:=0A=
		return '@' + `x`		=0A=
	else:=0A=
		return '@' + `x` + ',' + `y`=0A=
=0A=
class Canvas(Widget):=0A=
	"""Canvas widget to display graphical elements like lines or =
text."""=0A=
	def __init__(self, master=3DNone, cnf=3D{}, **kw):=0A=
		"""Construct a canvas widget with the parent MASTER.=0A=
=0A=
		Valid resource names: background, bd, bg, borderwidth, =
closeenough,=0A=
		confine, cursor, height, highlightbackground, highlightcolor,=0A=
		highlightthickness, insertbackground, insertborderwidth,=0A=
		insertofftime, insertontime, insertwidth, offset, relief,=0A=
		scrollregion, selectbackground, selectborderwidth, =
selectforeground,=0A=
		state, takefocus, width, xscrollcommand, xscrollincrement,=0A=
		yscrollcommand, yscrollincrement."""=0A=
		Widget.__init__(self, master, 'canvas', cnf, kw)=0A=
	def addtag(self, *args):=0A=
		"""Internal function."""=0A=
		self.tk.call((self._w, 'addtag') + args)=0A=
	def addtag_above(self, newtag, tagOrId):=0A=
		"""Add tag NEWTAG to all items above TAGORID."""=0A=
		self.addtag(newtag, 'above', tagOrId)=0A=
	def addtag_all(self, newtag):=0A=
		"""Add tag NEWTAG to all items."""=0A=
		self.addtag(newtag, 'all')=0A=
	def addtag_below(self, newtag, tagOrId):=0A=
		"""Add tag NEWTAG to all items below TAGORID."""=0A=
		self.addtag(newtag, 'below', tagOrId)=0A=
	def addtag_closest(self, newtag, x, y, halo=3DNone, start=3DNone):=0A=
		"""Add tag NEWTAG to item which is closest to pixel at X, Y.=0A=
		If several match take the top-most.=0A=
		All items closer than HALO are considered overlapping (all are=0A=
		closests). If START is specified the next below this tag is =
taken."""=0A=
		self.addtag(newtag, 'closest', x, y, halo, start)=0A=
	def addtag_enclosed(self, newtag, x1, y1, x2, y2):=0A=
		"""Add tag NEWTAG to all items in the rectangle defined=0A=
		by X1,Y1,X2,Y2."""=0A=
		self.addtag(newtag, 'enclosed', x1, y1, x2, y2)=0A=
	def addtag_overlapping(self, newtag, x1, y1, x2, y2):=0A=
		"""Add tag NEWTAG to all items which overlap the rectangle=0A=
		defined by X1,Y1,X2,Y2."""=0A=
		self.addtag(newtag, 'overlapping', x1, y1, x2, y2)=0A=
	def addtag_withtag(self, newtag, tagOrId):=0A=
		"""Add tag NEWTAG to all items with TAGORID."""=0A=
		self.addtag(newtag, 'withtag', tagOrId)=0A=
	def bbox(self, *args):=0A=
		"""Return a tuple of X1,Y1,X2,Y2 coordinates for a rectangle=0A=
		which encloses all items with tags specified as arguments."""=0A=
		return self._getints(=0A=
			self.tk.call((self._w, 'bbox') + args)) or None=0A=
	def tag_unbind(self, tagOrId, sequence, funcid=3DNone):=0A=
		"""Unbind for all items with TAGORID for event SEQUENCE  the=0A=
		function identified with FUNCID."""=0A=
		self.tk.call(self._w, 'bind', tagOrId, sequence, '')=0A=
		if funcid:=0A=
			self.deletecommand(funcid)=0A=
	def tag_bind(self, tagOrId, sequence=3DNone, func=3DNone, =
add=3DNone):=0A=
		"""Bind to all items with TAGORID at event SEQUENCE a call to =
function FUNC.=0A=
=0A=
		An additional boolean parameter ADD specifies whether FUNC will be=0A=
		called additionally to the other bound function or whether it will=0A=
		replace the previous function. See bind for the return value."""=0A=
		return self._bind((self._w, 'bind', tagOrId),=0A=
				  sequence, func, add)=0A=
	def canvasx(self, screenx, gridspacing=3DNone):=0A=
		"""Return the canvas x coordinate of pixel position SCREENX =
rounded=0A=
		to nearest muliple of GRIDSPACING units."""=0A=
		return getdouble(self.tk.call(=0A=
			self._w, 'canvasx', screenx, gridspacing))=0A=
	def canvasy(self, screeny, gridspacing=3DNone):=0A=
		"""Return the canvas y coordinate of pixel position SCREENY =
rounded=0A=
		to nearest muliple of GRIDSPACING units."""=0A=
		return getdouble(self.tk.call(=0A=
			self._w, 'canvasy', screeny, gridspacing))=0A=
	def coords(self, *args):=0A=
		"""Return a list of coordinates for the item given in ARGS."""=0A=
		# XXX Should use _flatten on args=0A=
		return map(getdouble,=0A=
                           self.tk.splitlist(=0A=
				   self.tk.call((self._w, 'coords') + args)))=0A=
	def _create(self, itemType, args, kw): # Args: (val, val, ..., =
cnf=3D{})=0A=
		"""Internal function."""=0A=
		args =3D _flatten(args)=0A=
		cnf =3D args[-1]=0A=
		if type(cnf) in (DictionaryType, TupleType):=0A=
			args =3D args[:-1]=0A=
		else:=0A=
			cnf =3D {}=0A=
		return getint(apply(=0A=
			self.tk.call,=0A=
			(self._w, 'create', itemType) =0A=
			+ args + self._options(cnf, kw)))=0A=
	def create_arc(self, *args, **kw):=0A=
		"""Create arc shaped region with coordinates x1,y1,x2,y2."""=0A=
		return self._create('arc', args, kw)=0A=
	def create_bitmap(self, *args, **kw):=0A=
		"""Create bitmap with coordinates x1,y1."""=0A=
		return self._create('bitmap', args, kw)=0A=
	def create_image(self, *args, **kw):=0A=
		"""Create image item with coordinates x1,y1."""=0A=
		return self._create('image', args, kw)=0A=
	def create_line(self, *args, **kw):=0A=
		"""Create line with coordinates x1,y1,...,xn,yn."""=0A=
		return self._create('line', args, kw)=0A=
	def create_oval(self, *args, **kw):=0A=
		"""Create oval with coordinates x1,y1,x2,y2."""=0A=
		return self._create('oval', args, kw)=0A=
	def create_polygon(self, *args, **kw):=0A=
		"""Create polygon with coordinates x1,y1,...,xn,yn."""=0A=
		return self._create('polygon', args, kw)=0A=
	def create_rectangle(self, *args, **kw):=0A=
		"""Create rectangle with coordinates x1,y1,x2,y2."""=0A=
		return self._create('rectangle', args, kw)=0A=
	def create_text(self, *args, **kw):=0A=
		"""Create text with coordinates x1,y1."""=0A=
		return self._create('text', args, kw)=0A=
	def create_window(self, *args, **kw):=0A=
		"""Create window with coordinates x1,y1,x2,y2."""=0A=
		return self._create('window', args, kw)=0A=
	def dchars(self, *args):=0A=
		"""Delete characters of text items identified by tag or id in ARGS =
(possibly=0A=
		several times) from FIRST to LAST character (including)."""=0A=
		self.tk.call((self._w, 'dchars') + args)=0A=
	def delete(self, *args):=0A=
		"""Delete items identified by all tag or ids contained in ARGS."""=0A=
		self.tk.call((self._w, 'delete') + args)=0A=
	def dtag(self, *args):=0A=
		"""Delete tag or id given as last arguments in ARGS from items=0A=
		identified by first argument in ARGS."""=0A=
		self.tk.call((self._w, 'dtag') + args)=0A=
	def find(self, *args):=0A=
		"""Internal function."""=0A=
		return self._getints(=0A=
			self.tk.call((self._w, 'find') + args)) or ()=0A=
	def find_above(self, tagOrId):=0A=
		"""Return items above TAGORID."""=0A=
		return self.find('above', tagOrId)=0A=
	def find_all(self):=0A=
		"""Return all items."""=0A=
		return self.find('all')=0A=
	def find_below(self, tagOrId):=0A=
		"""Return all items below TAGORID."""=0A=
		return self.find('below', tagOrId)=0A=
	def find_closest(self, x, y, halo=3DNone, start=3DNone):=0A=
		"""Return item which is closest to pixel at X, Y.=0A=
		If several match take the top-most.=0A=
		All items closer than HALO are considered overlapping (all are=0A=
		closests). If START is specified the next below this tag is =
taken."""=0A=
		return self.find('closest', x, y, halo, start)=0A=
	def find_enclosed(self, x1, y1, x2, y2):=0A=
		"""Return all items in rectangle defined=0A=
		by X1,Y1,X2,Y2."""=0A=
		return self.find('enclosed', x1, y1, x2, y2)=0A=
	def find_overlapping(self, x1, y1, x2, y2):=0A=
		"""Return all items which overlap the rectangle=0A=
		defined by X1,Y1,X2,Y2."""=0A=
		return self.find('overlapping', x1, y1, x2, y2)=0A=
	def find_withtag(self, tagOrId):=0A=
		"""Return all items with TAGORID."""=0A=
		return self.find('withtag', tagOrId)=0A=
	def focus(self, *args):=0A=
		"""Set focus to the first item specified in ARGS."""=0A=
		return self.tk.call((self._w, 'focus') + args)=0A=
	def gettags(self, *args):=0A=
		"""Return tags associated with the first item specified in =
ARGS."""=0A=
		return self.tk.splitlist(=0A=
			self.tk.call((self._w, 'gettags') + args))=0A=
	def icursor(self, *args):=0A=
		"""Set cursor at position POS in the item identified by TAGORID.=0A=
		In ARGS TAGORID must be first."""=0A=
		self.tk.call((self._w, 'icursor') + args)=0A=
	def index(self, *args):=0A=
		"""Return position of cursor as integer in item specified in =
ARGS."""=0A=
		return getint(self.tk.call((self._w, 'index') + args))=0A=
	def insert(self, *args):=0A=
		"""Insert TEXT in item TAGORID at position POS. ARGS must=0A=
		be TAGORID POS TEXT."""=0A=
		self.tk.call((self._w, 'insert') + args)=0A=
	def itemcget(self, tagOrId, option):=0A=
		"""Return the resource value for an OPTION for item TAGORID."""=0A=
		return self.tk.call(=0A=
			(self._w, 'itemcget') + (tagOrId, '-'+option))=0A=
	def itemconfigure(self, tagOrId, cnf=3DNone, **kw):=0A=
		"""Configure resources of an item TAGORID.=0A=
=0A=
		The values for resources are specified as keyword=0A=
		arguments. To get an overview about=0A=
		the allowed keyword arguments call the method without arguments.=0A=
		"""=0A=
		if cnf is None and not kw:=0A=
			cnf =3D {}=0A=
			for x in self.tk.split(=0A=
				self.tk.call(self._w,=0A=
					     'itemconfigure', tagOrId)):=0A=
				cnf[x[0][1:]] =3D (x[0][1:],) + x[1:]=0A=
			return cnf=0A=
		if type(cnf) =3D=3D StringType and not kw:=0A=
			x =3D self.tk.split(self.tk.call(=0A=
				self._w, 'itemconfigure', tagOrId, '-'+cnf))=0A=
			return (x[0][1:],) + x[1:]=0A=
		self.tk.call((self._w, 'itemconfigure', tagOrId) +=0A=
			     self._options(cnf, kw))=0A=
	itemconfig =3D itemconfigure=0A=
	# lower, tkraise/lift hide Misc.lower, Misc.tkraise/lift,=0A=
	# so the preferred name for them is tag_lower, tag_raise=0A=
	# (similar to tag_bind, and similar to the Text widget);=0A=
	# unfortunately can't delete the old ones yet (maybe in 1.6)=0A=
	def tag_lower(self, *args):=0A=
		"""Lower an item TAGORID given in ARGS=0A=
		(optional below another item)."""=0A=
		self.tk.call((self._w, 'lower') + args)=0A=
	lower =3D tag_lower=0A=
	def move(self, *args):=0A=
		"""Move an item TAGORID given in ARGS."""=0A=
		self.tk.call((self._w, 'move') + args)=0A=
	def postscript(self, cnf=3D{}, **kw):=0A=
		"""Print the contents of the canvas to a postscript=0A=
		file. Valid options: colormap, colormode, file, fontmap,=0A=
		height, pageanchor, pageheight, pagewidth, pagex, pagey,=0A=
		rotate, witdh, x, y."""=0A=
		return self.tk.call((self._w, 'postscript') +=0A=
				    self._options(cnf, kw))=0A=
	def tag_raise(self, *args):=0A=
		"""Raise an item TAGORID given in ARGS=0A=
		(optional above another item)."""=0A=
		self.tk.call((self._w, 'raise') + args)=0A=
	lift =3D tkraise =3D tag_raise=0A=
	def scale(self, *args):=0A=
		"""Scale item TAGORID with XORIGIN, YORIGIN, XSCALE, YSCALE."""=0A=
		self.tk.call((self._w, 'scale') + args)=0A=
	def scan_mark(self, x, y):=0A=
		"""Remember the current X, Y coordinates."""=0A=
		self.tk.call(self._w, 'scan', 'mark', x, y)=0A=
	def scan_dragto(self, x, y):=0A=
		"""Adjust the view of the canvas to 10 times the=0A=
		difference between X and Y and the coordinates given in=0A=
		scan_mark."""=0A=
		self.tk.call(self._w, 'scan', 'dragto', x, y)=0A=
	def select_adjust(self, tagOrId, index):=0A=
		"""Adjust the end of the selection near the cursor of an item TAGORID =
to index."""=0A=
		self.tk.call(self._w, 'select', 'adjust', tagOrId, index)=0A=
	def select_clear(self):=0A=
		"""Clear the selection if it is in this widget."""=0A=
		self.tk.call(self._w, 'select', 'clear')=0A=
	def select_from(self, tagOrId, index):=0A=
		"""Set the fixed end of a selection in item TAGORID to INDEX."""=0A=
		self.tk.call(self._w, 'select', 'from', tagOrId, index)=0A=
	def select_item(self):=0A=
		"""Return the item which has the selection."""=0A=
		self.tk.call(self._w, 'select', 'item')=0A=
	def select_to(self, tagOrId, index):=0A=
		"""Set the variable end of a selection in item TAGORID to =
INDEX."""=0A=
		self.tk.call(self._w, 'select', 'to', tagOrId, index)=0A=
	def type(self, tagOrId):=0A=
		"""Return the type of the item TAGORID."""=0A=
		return self.tk.call(self._w, 'type', tagOrId) or None=0A=
	def xview(self, *args):=0A=
		"""Query and change horizontal position of the view."""=0A=
		if not args:=0A=
			return self._getdoubles(self.tk.call(self._w, 'xview'))=0A=
		self.tk.call((self._w, 'xview') + args)=0A=
	def xview_moveto(self, fraction):=0A=
		"""Adjusts the view in the window so that FRACTION of the=0A=
		total width of the canvas is off-screen to the left."""=0A=
		self.tk.call(self._w, 'xview', 'moveto', fraction)=0A=
	def xview_scroll(self, number, what):=0A=
		"""Shift the x-view according to NUMBER which is measured in "units" =
or "pages" (WHAT)."""=0A=
		self.tk.call(self._w, 'xview', 'scroll', number, what)=0A=
	def yview(self, *args):=0A=
		"""Query and change vertical position of the view."""=0A=
		if not args:=0A=
			return self._getdoubles(self.tk.call(self._w, 'yview'))=0A=
		self.tk.call((self._w, 'yview') + args)=0A=
	def yview_moveto(self, fraction):=0A=
		"""Adjusts the view in the window so that FRACTION of the=0A=
		total height of the canvas is off-screen to the top."""=0A=
		self.tk.call(self._w, 'yview', 'moveto', fraction)=0A=
	def yview_scroll(self, number, what):=0A=
		"""Shift the y-view according to NUMBER which is measured in "units" =
or "pages" (WHAT)."""=0A=
		self.tk.call(self._w, 'yview', 'scroll', number, what)=0A=
=0A=
class Checkbutton(Widget):=0A=
	"""Checkbutton widget which is either in on- or off-state."""=0A=
	def __init__(self, master=3DNone, cnf=3D{}, **kw):=0A=
		"""Construct a checkbutton widget with the parent MASTER.=0A=
=0A=
		Valid resource names: activebackground, activeforeground, anchor,=0A=
		background, bd, bg, bitmap, borderwidth, command, cursor,=0A=
		disabledforeground, fg, font, foreground, height,=0A=
		highlightbackground, highlightcolor, highlightthickness, image,=0A=
		indicatoron, justify, offvalue, onvalue, padx, pady, relief,=0A=
		selectcolor, selectimage, state, takefocus, text, textvariable,=0A=
		underline, variable, width, wraplength.""" =0A=
		Widget.__init__(self, master, 'checkbutton', cnf, kw)=0A=
	def deselect(self):=0A=
		"""Put the button in off-state."""=0A=
		self.tk.call(self._w, 'deselect')=0A=
	def flash(self):=0A=
		"""Flash the button."""=0A=
		self.tk.call(self._w, 'flash')=0A=
	def invoke(self):=0A=
		"""Toggle the button and invoke a command if given as resource."""=0A=
		return self.tk.call(self._w, 'invoke')=0A=
	def select(self):=0A=
		"""Put the button in on-state."""=0A=
		self.tk.call(self._w, 'select')=0A=
	def toggle(self):=0A=
		"""Toggle the button."""=0A=
		self.tk.call(self._w, 'toggle')=0A=
=0A=
class Entry(Widget):=0A=
	"""Entry widget which allows to display simple text."""=0A=
	def __init__(self, master=3DNone, cnf=3D{}, **kw):=0A=
		"""Construct an entry widget with the parent MASTER.=0A=
=0A=
		Valid resource names: background, bd, bg, borderwidth, cursor,=0A=
		exportselection, fg, font, foreground, highlightbackground,=0A=
		highlightcolor, highlightthickness, insertbackground,=0A=
		insertborderwidth, insertofftime, insertontime, insertwidth,=0A=
		invalidcommand, invcmd, justify, relief, selectbackground,=0A=
		selectborderwidth, selectforeground, show, state, takefocus,=0A=
		textvariable, validate, validatecommand, vcmd, width,=0A=
		xscrollcommand."""=0A=
		Widget.__init__(self, master, 'entry', cnf, kw)=0A=
	def delete(self, first, last=3DNone):=0A=
		"""Delete text from FIRST to LAST (not included)."""=0A=
		self.tk.call(self._w, 'delete', first, last)=0A=
	def get(self):=0A=
		"""Return the text."""=0A=
		return self.tk.call(self._w, 'get')=0A=
	def icursor(self, index):=0A=
		"""Insert cursor at INDEX."""=0A=
		self.tk.call(self._w, 'icursor', index)=0A=
	def index(self, index):=0A=
		"""Return position of cursor."""=0A=
		return getint(self.tk.call(=0A=
			self._w, 'index', index))=0A=
	def insert(self, index, string):=0A=
		"""Insert STRING at INDEX."""=0A=
		self.tk.call(self._w, 'insert', index, string)=0A=
	def scan_mark(self, x):=0A=
		"""Remember the current X, Y coordinates."""=0A=
		self.tk.call(self._w, 'scan', 'mark', x)=0A=
	def scan_dragto(self, x):=0A=
		"""Adjust the view of the canvas to 10 times the=0A=
		difference between X and Y and the coordinates given in=0A=
		scan_mark."""=0A=
		self.tk.call(self._w, 'scan', 'dragto', x)=0A=
	def selection_adjust(self, index):=0A=
		"""Adjust the end of the selection near the cursor to INDEX."""=0A=
		self.tk.call(self._w, 'selection', 'adjust', index)=0A=
	select_adjust =3D selection_adjust=0A=
	def selection_clear(self):=0A=
		"""Clear the selection if it is in this widget."""=0A=
		self.tk.call(self._w, 'selection', 'clear')=0A=
	select_clear =3D selection_clear=0A=
	def selection_from(self, index):=0A=
		"""Set the fixed end of a selection to INDEX."""=0A=
		self.tk.call(self._w, 'selection', 'from', index)=0A=
	select_from =3D selection_from=0A=
	def selection_present(self):=0A=
		"""Return whether the widget has the selection."""=0A=
		return self.tk.getboolean(=0A=
			self.tk.call(self._w, 'selection', 'present'))=0A=
	select_present =3D selection_present=0A=
	def selection_range(self, start, end):=0A=
		"""Set the selection from START to END (not included)."""=0A=
		self.tk.call(self._w, 'selection', 'range', start, end)=0A=
	select_range =3D selection_range=0A=
	def selection_to(self, index):=0A=
		"""Set the variable end of a selection to INDEX."""=0A=
		self.tk.call(self._w, 'selection', 'to', index)=0A=
	select_to =3D selection_to=0A=
	def xview(self, index):=0A=
		"""Query and change horizontal position of the view."""=0A=
		self.tk.call(self._w, 'xview', index)=0A=
	def xview_moveto(self, fraction):=0A=
		"""Adjust the view in the window so that FRACTION of the=0A=
		total width of the entry is off-screen to the left."""=0A=
		self.tk.call(self._w, 'xview', 'moveto', fraction)=0A=
	def xview_scroll(self, number, what):=0A=
		"""Shift the x-view according to NUMBER which is measured in "units" =
or "pages" (WHAT)."""=0A=
		self.tk.call(self._w, 'xview', 'scroll', number, what)=0A=
=0A=
class Frame(Widget):=0A=
	"""Frame widget which may contain other widgets and can have a 3D =
border."""=0A=
	def __init__(self, master=3DNone, cnf=3D{}, **kw):=0A=
		"""Construct a frame widget with the parent MASTER.=0A=
=0A=
		Valid resource names: background, bd, bg, borderwidth, class,=0A=
		colormap, container, cursor, height, highlightbackground,=0A=
		highlightcolor, highlightthickness, relief, takefocus, visual, =
width.""" =0A=
		cnf =3D _cnfmerge((cnf, kw))=0A=
		extra =3D ()=0A=
		if cnf.has_key('class_'):=0A=
			extra =3D ('-class', cnf['class_'])=0A=
			del cnf['class_']=0A=
		elif cnf.has_key('class'):=0A=
			extra =3D ('-class', cnf['class'])=0A=
			del cnf['class']=0A=
		Widget.__init__(self, master, 'frame', cnf, {}, extra)=0A=
=0A=
class Label(Widget):=0A=
	"""Label widget which can display text and bitmaps."""=0A=
	def __init__(self, master=3DNone, cnf=3D{}, **kw):=0A=
		"""Construct a label widget with the parent MASTER.=0A=
=0A=
		Valid resource names: anchor, background, bd, bg, bitmap,=0A=
		borderwidth, cursor, fg, font, foreground, height,=0A=
		highlightbackground, highlightcolor, highlightthickness, image,=0A=
		justify, padx, pady, relief, takefocus, text, textvariable,=0A=
		underline, width, wraplength.""" 		=0A=
		Widget.__init__(self, master, 'label', cnf, kw)=0A=
=0A=
class Listbox(Widget):=0A=
	"""Listbox widget which can display a list of strings."""=0A=
	def __init__(self, master=3DNone, cnf=3D{}, **kw):=0A=
		"""Construct a listbox widget with the parent MASTER.=0A=
=0A=
		Valid resource names: background, bd, bg, borderwidth, cursor,=0A=
		exportselection, fg, font, foreground, height, =
highlightbackground,=0A=
		highlightcolor, highlightthickness, relief, selectbackground,=0A=
		selectborderwidth, selectforeground, selectmode, setgrid, =
takefocus,=0A=
		width, xscrollcommand, yscrollcommand, listvariable."""=0A=
		Widget.__init__(self, master, 'listbox', cnf, kw)=0A=
	def activate(self, index):=0A=
		"""Activate item identified by INDEX."""=0A=
		self.tk.call(self._w, 'activate', index)=0A=
	def bbox(self, *args):=0A=
		"""Return a tuple of X1,Y1,X2,Y2 coordinates for a rectangle=0A=
		which encloses the item identified by index in ARGS."""=0A=
		return self._getints(=0A=
			self.tk.call((self._w, 'bbox') + args)) or None=0A=
	def curselection(self):=0A=
		"""Return list of indices of currently selected item."""=0A=
		# XXX Ought to apply self._getints()...=0A=
		return self.tk.splitlist(self.tk.call(=0A=
			self._w, 'curselection'))=0A=
	def delete(self, first, last=3DNone):=0A=
		"""Delete items from FIRST to LAST (not included)."""=0A=
		self.tk.call(self._w, 'delete', first, last)=0A=
	def get(self, first, last=3DNone):=0A=
		"""Get list of items from FIRST to LAST (not included)."""=0A=
		if last:=0A=
			return self.tk.splitlist(self.tk.call(=0A=
				self._w, 'get', first, last))=0A=
		else:=0A=
			return self.tk.call(self._w, 'get', first)=0A=
	def index(self, index):=0A=
		"""Return index of item identified with INDEX."""=0A=
		i =3D self.tk.call(self._w, 'index', index)=0A=
		if i =3D=3D 'none': return None=0A=
		return getint(i)=0A=
	def insert(self, index, *elements):=0A=
		"""Insert ELEMENTS at INDEX."""=0A=
		self.tk.call((self._w, 'insert', index) + elements)=0A=
	def nearest(self, y):=0A=
		"""Get index of item which is nearest to y coordinate Y."""=0A=
		return getint(self.tk.call(=0A=
			self._w, 'nearest', y))=0A=
	def scan_mark(self, x, y):=0A=
		"""Remember the current X, Y coordinates."""=0A=
		self.tk.call(self._w, 'scan', 'mark', x, y)=0A=
	def scan_dragto(self, x, y):=0A=
		"""Adjust the view of the listbox to 10 times the=0A=
		difference between X and Y and the coordinates given in=0A=
		scan_mark."""=0A=
		self.tk.call(self._w, 'scan', 'dragto', x, y)=0A=
	def see(self, index):=0A=
		"""Scroll such that INDEX is visible."""=0A=
		self.tk.call(self._w, 'see', index)=0A=
	def selection_anchor(self, index):=0A=
		"""Set the fixed end oft the selection to INDEX."""=0A=
		self.tk.call(self._w, 'selection', 'anchor', index)=0A=
	select_anchor =3D selection_anchor=0A=
	def selection_clear(self, first, last=3DNone):=0A=
		"""Clear the selection from FIRST to LAST (not included)."""=0A=
		self.tk.call(self._w,=0A=
			     'selection', 'clear', first, last)=0A=
	select_clear =3D selection_clear=0A=
	def selection_includes(self, index):=0A=
		"""Return 1 if INDEX is part of the selection."""=0A=
		return self.tk.getboolean(self.tk.call(=0A=
			self._w, 'selection', 'includes', index))=0A=
	select_includes =3D selection_includes=0A=
	def selection_set(self, first, last=3DNone):=0A=
		"""Set the selection from FIRST to LAST (not included) without=0A=
		changing the currently selected elements."""=0A=
		self.tk.call(self._w, 'selection', 'set', first, last)=0A=
	select_set =3D selection_set=0A=
	def size(self):=0A=
		"""Return the number of elements in the listbox."""=0A=
		return getint(self.tk.call(self._w, 'size'))=0A=
	def xview(self, *what):=0A=
		"""Query and change horizontal position of the view."""=0A=
		if not what:=0A=
			return self._getdoubles(self.tk.call(self._w, 'xview'))=0A=
		self.tk.call((self._w, 'xview') + what)=0A=
	def xview_moveto(self, fraction):=0A=
		"""Adjust the view in the window so that FRACTION of the=0A=
		total width of the entry is off-screen to the left."""=0A=
		self.tk.call(self._w, 'xview', 'moveto', fraction)=0A=
	def xview_scroll(self, number, what):=0A=
		"""Shift the x-view according to NUMBER which is measured in "units" =
or "pages" (WHAT)."""=0A=
		self.tk.call(self._w, 'xview', 'scroll', number, what)=0A=
	def yview(self, *what):=0A=
		"""Query and change vertical position of the view."""=0A=
		if not what:=0A=
			return self._getdoubles(self.tk.call(self._w, 'yview'))=0A=
		self.tk.call((self._w, 'yview') + what)=0A=
	def yview_moveto(self, fraction):=0A=
		"""Adjust the view in the window so that FRACTION of the=0A=
		total width of the entry is off-screen to the top."""=0A=
		self.tk.call(self._w, 'yview', 'moveto', fraction)=0A=
	def yview_scroll(self, number, what):=0A=
		"""Shift the y-view according to NUMBER which is measured in "units" =
or "pages" (WHAT)."""=0A=
		self.tk.call(self._w, 'yview', 'scroll', number, what)=0A=
=0A=
class Menu(Widget):=0A=
	"""Menu widget which allows to display menu bars, pull-down menus and =
pop-up menus."""=0A=
	def __init__(self, master=3DNone, cnf=3D{}, **kw):=0A=
		"""Construct menu widget with the parent MASTER.=0A=
=0A=
		Valid resource names: activebackground, activeborderwidth,=0A=
		activeforeground, background, bd, bg, borderwidth, cursor,=0A=
		disabledforeground, fg, font, foreground, postcommand, relief,=0A=
		selectcolor, takefocus, tearoff, tearoffcommand, title, type."""=0A=
		Widget.__init__(self, master, 'menu', cnf, kw)=0A=
	def tk_bindForTraversal(self):=0A=
		pass # obsolete since Tk 4.0=0A=
	def tk_mbPost(self):=0A=
		self.tk.call('tk_mbPost', self._w)=0A=
	def tk_mbUnpost(self):=0A=
		self.tk.call('tk_mbUnpost')=0A=
	def tk_traverseToMenu(self, char):=0A=
		self.tk.call('tk_traverseToMenu', self._w, char)=0A=
	def tk_traverseWithinMenu(self, char):=0A=
		self.tk.call('tk_traverseWithinMenu', self._w, char)=0A=
	def tk_getMenuButtons(self):=0A=
		return self.tk.call('tk_getMenuButtons', self._w)=0A=
	def tk_nextMenu(self, count):=0A=
		self.tk.call('tk_nextMenu', count)=0A=
	def tk_nextMenuEntry(self, count):=0A=
		self.tk.call('tk_nextMenuEntry', count)=0A=
	def tk_invokeMenu(self):=0A=
		self.tk.call('tk_invokeMenu', self._w)=0A=
	def tk_firstMenu(self):=0A=
		self.tk.call('tk_firstMenu', self._w)=0A=
	def tk_mbButtonDown(self):=0A=
		self.tk.call('tk_mbButtonDown', self._w)=0A=
	def tk_popup(self, x, y, entry=3D""):=0A=
		"""Post the menu at position X,Y with entry ENTRY."""=0A=
		self.tk.call('tk_popup', self._w, x, y, entry)=0A=
	def activate(self, index):=0A=
		"""Activate entry at INDEX."""=0A=
		self.tk.call(self._w, 'activate', index)=0A=
	def add(self, itemType, cnf=3D{}, **kw):=0A=
		"""Internal function."""=0A=
		self.tk.call((self._w, 'add', itemType) +=0A=
			     self._options(cnf, kw))=0A=
	def add_cascade(self, cnf=3D{}, **kw):=0A=
		"""Add hierarchical menu item."""=0A=
		self.add('cascade', cnf or kw)=0A=
	def add_checkbutton(self, cnf=3D{}, **kw):=0A=
		"""Add checkbutton menu item."""=0A=
		self.add('checkbutton', cnf or kw)=0A=
	def add_command(self, cnf=3D{}, **kw):=0A=
		"""Add command menu item."""=0A=
		self.add('command', cnf or kw)=0A=
	def add_radiobutton(self, cnf=3D{}, **kw):=0A=
		"""Addd radio menu item."""=0A=
		self.add('radiobutton', cnf or kw)=0A=
	def add_separator(self, cnf=3D{}, **kw):=0A=
		"""Add separator."""=0A=
		self.add('separator', cnf or kw)=0A=
	def insert(self, index, itemType, cnf=3D{}, **kw):=0A=
		"""Internal function."""=0A=
		self.tk.call((self._w, 'insert', index, itemType) +=0A=
			     self._options(cnf, kw))=0A=
	def insert_cascade(self, index, cnf=3D{}, **kw):=0A=
		"""Add hierarchical menu item at INDEX."""=0A=
		self.insert(index, 'cascade', cnf or kw)=0A=
	def insert_checkbutton(self, index, cnf=3D{}, **kw):=0A=
		"""Add checkbutton menu item at INDEX."""=0A=
		self.insert(index, 'checkbutton', cnf or kw)=0A=
	def insert_command(self, index, cnf=3D{}, **kw):=0A=
		"""Add command menu item at INDEX."""=0A=
		self.insert(index, 'command', cnf or kw)=0A=
	def insert_radiobutton(self, index, cnf=3D{}, **kw):=0A=
		"""Addd radio menu item at INDEX."""=0A=
		self.insert(index, 'radiobutton', cnf or kw)=0A=
	def insert_separator(self, index, cnf=3D{}, **kw):=0A=
		"""Add separator at INDEX."""=0A=
		self.insert(index, 'separator', cnf or kw)=0A=
	def delete(self, index1, index2=3DNone):=0A=
		"""Delete menu items between INDEX1 and INDEX2 (not included)."""=0A=
		self.tk.call(self._w, 'delete', index1, index2)=0A=
	def entrycget(self, index, option):=0A=
		"""Return the resource value of an menu item for OPTION at =
INDEX."""=0A=
		return self.tk.call(self._w, 'entrycget', index, '-' + option)=0A=
	def entryconfigure(self, index, cnf=3DNone, **kw):=0A=
		"""Configure a menu item at INDEX."""=0A=
		if cnf is None and not kw:=0A=
			cnf =3D {}=0A=
			for x in self.tk.split(self.tk.call(=0A=
				(self._w, 'entryconfigure', index))):=0A=
				cnf[x[0][1:]] =3D (x[0][1:],) + x[1:]=0A=
			return cnf=0A=
		if type(cnf) =3D=3D StringType and not kw:=0A=
			x =3D self.tk.split(self.tk.call(=0A=
				(self._w, 'entryconfigure', index, '-'+cnf)))=0A=
			return (x[0][1:],) + x[1:]=0A=
		self.tk.call((self._w, 'entryconfigure', index)=0A=
		      + self._options(cnf, kw))=0A=
	entryconfig =3D entryconfigure=0A=
	def index(self, index):=0A=
		"""Return the index of a menu item identified by INDEX."""=0A=
		i =3D self.tk.call(self._w, 'index', index)=0A=
		if i =3D=3D 'none': return None=0A=
		return getint(i)=0A=
	def invoke(self, index):=0A=
		"""Invoke a menu item identified by INDEX and execute=0A=
		the associated command."""=0A=
		return self.tk.call(self._w, 'invoke', index)=0A=
	def post(self, x, y):=0A=
		"""Display a menu at position X,Y."""=0A=
		self.tk.call(self._w, 'post', x, y)=0A=
	def type(self, index):=0A=
		"""Return the type of the menu item at INDEX."""=0A=
		return self.tk.call(self._w, 'type', index)=0A=
	def unpost(self):=0A=
		"""Unmap a menu."""=0A=
		self.tk.call(self._w, 'unpost')=0A=
	def yposition(self, index):=0A=
		"""Return the y-position of the topmost pixel of the menu item at =
INDEX."""=0A=
		return getint(self.tk.call(=0A=
			self._w, 'yposition', index))=0A=
=0A=
class Menubutton(Widget):=0A=
	"""Menubutton widget, obsolete since Tk8.0."""=0A=
	def __init__(self, master=3DNone, cnf=3D{}, **kw):=0A=
		Widget.__init__(self, master, 'menubutton', cnf, kw)=0A=
=0A=
class Message(Widget):=0A=
	"""Message widget to display multiline text. Obsolete since Label does =
it too."""=0A=
	def __init__(self, master=3DNone, cnf=3D{}, **kw):=0A=
		Widget.__init__(self, master, 'message', cnf, kw)=0A=
=0A=
class Radiobutton(Widget):=0A=
	"""Radiobutton widget which shows only one of several buttons in =
on-state."""=0A=
	def __init__(self, master=3DNone, cnf=3D{}, **kw):=0A=
		"""Construct a radiobutton widget with the parent MASTER.=0A=
=0A=
		Valid resource names: activebackground, activeforeground, anchor,=0A=
		background, bd, bg, bitmap, borderwidth, command, cursor,=0A=
		disabledforeground, fg, font, foreground, height,=0A=
		highlightbackground, highlightcolor, highlightthickness, image,=0A=
		indicatoron, justify, padx, pady, relief, selectcolor, =
selectimage,=0A=
		state, takefocus, text, textvariable, underline, value, variable,=0A=
		width, wraplength."""=0A=
		Widget.__init__(self, master, 'radiobutton', cnf, kw)=0A=
	def deselect(self):=0A=
		"""Put the button in off-state."""=0A=
=0A=
		self.tk.call(self._w, 'deselect')=0A=
	def flash(self):=0A=
		"""Flash the button."""=0A=
		self.tk.call(self._w, 'flash')=0A=
	def invoke(self):=0A=
		"""Toggle the button and invoke a command if given as resource."""=0A=
		return self.tk.call(self._w, 'invoke')=0A=
	def select(self):=0A=
		"""Put the button in on-state."""=0A=
		self.tk.call(self._w, 'select')=0A=
=0A=
class Scale(Widget):=0A=
	"""Scale widget which can display a numerical scale."""=0A=
	def __init__(self, master=3DNone, cnf=3D{}, **kw):=0A=
		"""Construct a scale widget with the parent MASTER.=0A=
=0A=
		Valid resource names: activebackground, background, bigincrement, =
bd,=0A=
		bg, borderwidth, command, cursor, digits, fg, font, foreground, =
from,=0A=
		highlightbackground, highlightcolor, highlightthickness, label,=0A=
		length, orient, relief, repeatdelay, repeatinterval, resolution,=0A=
		showvalue, sliderlength, sliderrelief, state, takefocus,=0A=
		tickinterval, to, troughcolor, variable, width.""" 		=0A=
		Widget.__init__(self, master, 'scale', cnf, kw)=0A=
	def get(self):=0A=
		"""Get the current value as integer or float."""=0A=
		value =3D self.tk.call(self._w, 'get')=0A=
		try:=0A=
			return getint(value)=0A=
		except ValueError:=0A=
			return getdouble(value)=0A=
	def set(self, value):=0A=
		"""Set the value to VALUE."""=0A=
		self.tk.call(self._w, 'set', value)=0A=
	def coords(self, value=3DNone):=0A=
		"""Return a tuple (X,Y) of the point along the centerline of the=0A=
		trough that corresponds to VALUE or the current value if None is=0A=
		given."""=0A=
		=0A=
		return self._getints(self.tk.call(self._w, 'coords', value))=0A=
	def identify(self, x, y):=0A=
		"""Return where the point X,Y lies. Valid return values are =
"slider",=0A=
		"though1" and "though2"."""=0A=
		return self.tk.call(self._w, 'identify', x, y)=0A=
=0A=
class Scrollbar(Widget):=0A=
	"""Scrollbar widget which displays a slider at a certain =
position."""=0A=
	def __init__(self, master=3DNone, cnf=3D{}, **kw):=0A=
		"""Construct a scrollbar widget with the parent MASTER.=0A=
=0A=
		Valid resource names: activebackground, activerelief,=0A=
		background, bd, bg, borderwidth, command, cursor,=0A=
		elementborderwidth, highlightbackground,=0A=
		highlightcolor, highlightthickness, jump, orient,=0A=
		relief, repeatdelay, repeatinterval, takefocus,=0A=
		troughcolor, width."""=0A=
		Widget.__init__(self, master, 'scrollbar', cnf, kw)=0A=
	def activate(self, index):=0A=
		"""Display the element at INDEX with activebackground and =
activerelief.=0A=
		INDEX can be "arrow1","slider" or "arrow2"."""=0A=
		self.tk.call(self._w, 'activate', index)=0A=
	def delta(self, deltax, deltay):=0A=
		"""Return the fractional change of the scrollbar setting if it=0A=
		would be moved by DELTAX or DELTAY pixels."""=0A=
		return getdouble(=0A=
			self.tk.call(self._w, 'delta', deltax, deltay))=0A=
	def fraction(self, x, y):=0A=
		"""Return the fractional value which corresponds to a slider=0A=
		position of X,Y."""=0A=
		return getdouble(self.tk.call(self._w, 'fraction', x, y))=0A=
	def identify(self, x, y):=0A=
		"""Return the element under position X,Y as one of=0A=
		"arrow1","slider","arrow2" or ""."""=0A=
		return self.tk.call(self._w, 'identify', x, y)=0A=
	def get(self):=0A=
		"""Return the current fractional values (upper and lower end)=0A=
		of the slider position."""=0A=
		return self._getdoubles(self.tk.call(self._w, 'get'))=0A=
	def set(self, *args):=0A=
		"""Set the fractional values of the slider position (upper and=0A=
		lower ends as value between 0 and 1)."""=0A=
		self.tk.call((self._w, 'set') + args)=0A=
=0A=
class Text(Widget):=0A=
	"""Text widget which can display text in various forms."""=0A=
	# XXX Add dump()=0A=
	def __init__(self, master=3DNone, cnf=3D{}, **kw):=0A=
		"""Construct a text widget with the parent MASTER.=0A=
=0A=
		Valid resource names: background, bd, bg, borderwidth, cursor,=0A=
		exportselection, fg, font, foreground, height,=0A=
		highlightbackground, highlightcolor, highlightthickness,=0A=
		insertbackground, insertborderwidth, insertofftime,=0A=
		insertontime, insertwidth, padx, pady, relief,=0A=
		selectbackground, selectborderwidth, selectforeground,=0A=
		setgrid, spacing1, spacing2, spacing3, state, tabs, takefocus,=0A=
		width, wrap, xscrollcommand, yscrollcommand."""=0A=
		Widget.__init__(self, master, 'text', cnf, kw)=0A=
	def bbox(self, *args):=0A=
		"""Return a tuple of (x,y,width,heigth) which gives the bounding=0A=
		box of the visible part of the character at the index in ARGS."""=0A=
		return self._getints(=0A=
			self.tk.call((self._w, 'bbox') + args)) or None=0A=
	def tk_textSelectTo(self, index):=0A=
		self.tk.call('tk_textSelectTo', self._w, index)=0A=
	def tk_textBackspace(self):=0A=
		self.tk.call('tk_textBackspace', self._w)=0A=
	def tk_textIndexCloser(self, a, b, c):=0A=
		self.tk.call('tk_textIndexCloser', self._w, a, b, c)=0A=
	def tk_textResetAnchor(self, index):=0A=
		self.tk.call('tk_textResetAnchor', self._w, index)=0A=
	def compare(self, index1, op, index2):=0A=
		"""Return whether between index INDEX1 and index INDEX2 the=0A=
		relation OP is satisfied. OP is one of <, <=3D, =3D=3D, >=3D, >, or =
!=3D."""=0A=
		return self.tk.getboolean(self.tk.call(=0A=
			self._w, 'compare', index1, op, index2))=0A=
	def debug(self, boolean=3DNone):=0A=
		"""Turn on the internal consistency checks of the B-Tree inside the =
text=0A=
		widget according to BOOLEAN."""=0A=
		return self.tk.getboolean(self.tk.call(=0A=
			self._w, 'debug', boolean))=0A=
	def delete(self, index1, index2=3DNone):=0A=
		"""Delete the characters between INDEX1 and INDEX2 (not =
included)."""=0A=
		self.tk.call(self._w, 'delete', index1, index2)=0A=
	def dlineinfo(self, index):=0A=
		"""Return tuple (x,y,width,height,baseline) giving the bounding =
box=0A=
		and baseline position of the visible part of the line containing=0A=
		the character at INDEX."""=0A=
		return self._getints(self.tk.call(self._w, 'dlineinfo', index))=0A=
	def get(self, index1, index2=3DNone):=0A=
		"""Return the text from INDEX1 to INDEX2 (not included)."""=0A=
		return self.tk.call(self._w, 'get', index1, index2)=0A=
	# (Image commands are new in 8.0)=0A=
	def image_cget(self, index, option):=0A=
		"""Return the value of OPTION of an embedded image at INDEX."""=0A=
		if option[:1] !=3D "-":=0A=
			option =3D "-" + option=0A=
		if option[-1:] =3D=3D "_":=0A=
			option =3D option[:-1]=0A=
		return self.tk.call(self._w, "image", "cget", index, option)=0A=
	def image_configure(self, index, cnf=3D{}, **kw):=0A=
		"""Configure an embedded image at INDEX."""=0A=
		if not cnf and not kw:=0A=
			cnf =3D {}=0A=
			for x in self.tk.split(=0A=
				    self.tk.call(=0A=
					self._w, "image", "configure", index)):=0A=
				cnf[x[0][1:]] =3D (x[0][1:],) + x[1:]=0A=
			return cnf=0A=
		apply(self.tk.call,=0A=
		      (self._w, "image", "configure", index)=0A=
		      + self._options(cnf, kw))=0A=
	def image_create(self, index, cnf=3D{}, **kw):=0A=
		"""Create an embedded image at INDEX."""=0A=
		return apply(self.tk.call,=0A=
			     (self._w, "image", "create", index)=0A=
			     + self._options(cnf, kw))=0A=
	def image_names(self):=0A=
		"""Return all names of embedded images in this widget."""=0A=
		return self.tk.call(self._w, "image", "names")=0A=
	def index(self, index):=0A=
		"""Return the index in the form line.char for INDEX."""=0A=
		return self.tk.call(self._w, 'index', index)=0A=
	def insert(self, index, chars, *args):=0A=
		"""Insert CHARS before the charaters at INDEX. An additional=0A=
		tag can be given in ARGS. Additional CHARS and tags can follow in =
ARGS."""=0A=
		self.tk.call((self._w, 'insert', index, chars) + args)=0A=
	def mark_gravity(self, markName, direction=3DNone):=0A=
		"""Change the gravity of a mark MARKNAME to DIRECTION (LEFT or =
RIGHT).=0A=
		Return the current value if None is given for DIRECTION."""=0A=
		return self.tk.call(=0A=
			(self._w, 'mark', 'gravity', markName, direction))=0A=
	def mark_names(self):=0A=
		"""Return all mark names."""=0A=
		return self.tk.splitlist(self.tk.call(=0A=
			self._w, 'mark', 'names'))=0A=
	def mark_set(self, markName, index):=0A=
		"""Set mark MARKNAME before the character at INDEX."""=0A=
		self.tk.call(self._w, 'mark', 'set', markName, index)=0A=
	def mark_unset(self, *markNames):=0A=
		"""Delete all marks in MARKNAMES."""=0A=
		self.tk.call((self._w, 'mark', 'unset') + markNames)=0A=
	def mark_next(self, index):=0A=
		"""Return the name of the next mark after INDEX."""=0A=
		return self.tk.call(self._w, 'mark', 'next', index) or None=0A=
	def mark_previous(self, index):=0A=
		"""Return the name of the previous mark before INDEX."""=0A=
		return self.tk.call(self._w, 'mark', 'previous', index) or None=0A=
	def scan_mark(self, x, y):=0A=
		"""Remember the current X, Y coordinates."""=0A=
		self.tk.call(self._w, 'scan', 'mark', x, y)=0A=
	def scan_dragto(self, x, y):=0A=
		"""Adjust the view of the text to 10 times the=0A=
		difference between X and Y and the coordinates given in=0A=
		scan_mark."""=0A=
		self.tk.call(self._w, 'scan', 'dragto', x, y)=0A=
	def search(self, pattern, index, stopindex=3DNone,=0A=
		   forwards=3DNone, backwards=3DNone, exact=3DNone,=0A=
		   regexp=3DNone, nocase=3DNone, count=3DNone):=0A=
		"""Search PATTERN beginning from INDEX until STOPINDEX.=0A=
		Return the index of the first character of a match or an empty =
string."""=0A=
		args =3D [self._w, 'search']=0A=
		if forwards: args.append('-forwards')=0A=
		if backwards: args.append('-backwards')=0A=
		if exact: args.append('-exact')=0A=
		if regexp: args.append('-regexp')=0A=
		if nocase: args.append('-nocase')=0A=
		if count: args.append('-count'); args.append(count)=0A=
		if pattern[0] =3D=3D '-': args.append('--')=0A=
		args.append(pattern)=0A=
		args.append(index)=0A=
		if stopindex: args.append(stopindex)=0A=
		return self.tk.call(tuple(args))=0A=
	def see(self, index):=0A=
		"""Scroll such that the character at INDEX is visible."""=0A=
		self.tk.call(self._w, 'see', index)=0A=
	def tag_add(self, tagName, index1, *args):=0A=
		"""Add tag TAGNAME to all characters between INDEX1 and index2 in =
ARGS.=0A=
		Addtional pairs of indices may follow in ARGS."""=0A=
		self.tk.call(=0A=
			(self._w, 'tag', 'add', tagName, index1) + args)=0A=
	def tag_unbind(self, tagName, sequence, funcid=3DNone):=0A=
		"""Unbind for all characters with TAGNAME for event SEQUENCE  the=0A=
		function identified with FUNCID."""=0A=
		self.tk.call(self._w, 'tag', 'bind', tagName, sequence, '')=0A=
		if funcid:=0A=
			self.deletecommand(funcid)=0A=
	def tag_bind(self, tagName, sequence, func, add=3DNone):=0A=
		"""Bind to all characters with TAGNAME at event SEQUENCE a call to =
function FUNC.=0A=
=0A=
		An additional boolean parameter ADD specifies whether FUNC will be=0A=
		called additionally to the other bound function or whether it will=0A=
		replace the previous function. See bind for the return value."""=0A=
		return self._bind((self._w, 'tag', 'bind', tagName),=0A=
				  sequence, func, add)=0A=
	def tag_cget(self, tagName, option):=0A=
		"""Return the value of OPTION for tag TAGNAME."""=0A=
		if option[:1] !=3D '-':=0A=
			option =3D '-' + option=0A=
		if option[-1:] =3D=3D '_':=0A=
			option =3D option[:-1]=0A=
		return self.tk.call(self._w, 'tag', 'cget', tagName, option)=0A=
	def tag_configure(self, tagName, cnf=3D{}, **kw):=0A=
		"""Configure a tag TAGNAME."""=0A=
		if type(cnf) =3D=3D StringType:=0A=
			x =3D self.tk.split(self.tk.call(=0A=
				self._w, 'tag', 'configure', tagName, '-'+cnf))=0A=
			return (x[0][1:],) + x[1:]=0A=
		self.tk.call(=0A=
		      (self._w, 'tag', 'configure', tagName)=0A=
		      + self._options(cnf, kw))=0A=
	tag_config =3D tag_configure=0A=
	def tag_delete(self, *tagNames):=0A=
		"""Delete all tags in TAGNAMES."""=0A=
		self.tk.call((self._w, 'tag', 'delete') + tagNames)=0A=
	def tag_lower(self, tagName, belowThis=3DNone):=0A=
		"""Change the priority of tag TAGNAME such that it is lower=0A=
		than the priority of BELOWTHIS."""=0A=
		self.tk.call(self._w, 'tag', 'lower', tagName, belowThis)=0A=
	def tag_names(self, index=3DNone):=0A=
		"""Return a list of all tag names."""=0A=
		return self.tk.splitlist(=0A=
			self.tk.call(self._w, 'tag', 'names', index))=0A=
	def tag_nextrange(self, tagName, index1, index2=3DNone):=0A=
		"""Return a list of start and end index for the first sequence of=0A=
		characters between INDEX1 and INDEX2 which all have tag TAGNAME.=0A=
		The text is searched forward from INDEX1."""=0A=
		return self.tk.splitlist(self.tk.call(=0A=
			self._w, 'tag', 'nextrange', tagName, index1, index2))=0A=
	def tag_prevrange(self, tagName, index1, index2=3DNone):=0A=
		"""Return a list of start and end index for the first sequence of=0A=
		characters between INDEX1 and INDEX2 which all have tag TAGNAME.=0A=
		The text is searched backwards from INDEX1."""=0A=
		return self.tk.splitlist(self.tk.call(=0A=
			self._w, 'tag', 'prevrange', tagName, index1, index2))=0A=
	def tag_raise(self, tagName, aboveThis=3DNone):=0A=
		"""Change the priority of tag TAGNAME such that it is higher=0A=
		than the priority of ABOVETHIS."""=0A=
		self.tk.call(=0A=
			self._w, 'tag', 'raise', tagName, aboveThis)=0A=
	def tag_ranges(self, tagName):=0A=
		"""Return a list of ranges of text which have tag TAGNAME."""=0A=
		return self.tk.splitlist(self.tk.call(=0A=
			self._w, 'tag', 'ranges', tagName))=0A=
	def tag_remove(self, tagName, index1, index2=3DNone):=0A=
		"""Remove tag TAGNAME from all characters between INDEX1 and =
INDEX2."""=0A=
		self.tk.call(=0A=
			self._w, 'tag', 'remove', tagName, index1, index2)=0A=
	def window_cget(self, index, option):=0A=
		"""Return the value of OPTION of an embedded window at INDEX."""=0A=
		if option[:1] !=3D '-':=0A=
			option =3D '-' + option=0A=
		if option[-1:] =3D=3D '_':=0A=
			option =3D option[:-1]=0A=
		return self.tk.call(self._w, 'window', 'cget', index, option)=0A=
	def window_configure(self, index, cnf=3D{}, **kw):=0A=
		"""Configure an embedded window at INDEX."""=0A=
		if type(cnf) =3D=3D StringType:=0A=
			x =3D self.tk.split(self.tk.call(=0A=
				self._w, 'window', 'configure',=0A=
				index, '-'+cnf))=0A=
			return (x[0][1:],) + x[1:]=0A=
		self.tk.call(=0A=
		      (self._w, 'window', 'configure', index)=0A=
		      + self._options(cnf, kw))=0A=
	window_config =3D window_configure=0A=
	def window_create(self, index, cnf=3D{}, **kw):=0A=
		"""Create a window at INDEX."""=0A=
		self.tk.call(=0A=
		      (self._w, 'window', 'create', index)=0A=
		      + self._options(cnf, kw))=0A=
	def window_names(self):=0A=
		"""Return all names of embedded windows in this widget."""=0A=
		return self.tk.splitlist(=0A=
			self.tk.call(self._w, 'window', 'names'))=0A=
	def xview(self, *what):=0A=
		"""Query and change horizontal position of the view."""=0A=
		if not what:=0A=
			return self._getdoubles(self.tk.call(self._w, 'xview'))=0A=
		self.tk.call((self._w, 'xview') + what)=0A=
	def yview(self, *what):=0A=
		"""Query and change vertical position of the view."""=0A=
		if not what:=0A=
			return self._getdoubles(self.tk.call(self._w, 'yview'))=0A=
		self.tk.call((self._w, 'yview') + what)=0A=
	def yview_pickplace(self, *what):=0A=
		"""Obsolete function, use see."""=0A=
		self.tk.call((self._w, 'yview', '-pickplace') + what)=0A=
=0A=
class _setit:=0A=
	"""Internal class. It wraps the command in the widget =
OptionMenu."""=0A=
	def __init__(self, var, value, callback=3DNone):=0A=
		self.__value =3D value=0A=
		self.__var =3D var=0A=
		self.__callback =3D callback=0A=
	def __call__(self, *args):=0A=
		self.__var.set(self.__value)=0A=
		if self.__callback:=0A=
			apply(self.__callback, (self.__value,)+args)=0A=
=0A=
class OptionMenu(Menubutton):=0A=
	"""OptionMenu which allows the user to select a value from a =
menu."""=0A=
	def __init__(self, master, variable, value, *values, **kwargs):=0A=
		"""Construct an optionmenu widget with the parent MASTER, with=0A=
		the resource textvariable set to VARIABLE, the initially selected=0A=
		value VALUE, the other menu values VALUES and an additional=0A=
		keyword argument command."""=0A=
		kw =3D {"borderwidth": 2, "textvariable": variable,=0A=
		      "indicatoron": 1, "relief": RAISED, "anchor": "c",=0A=
		      "highlightthickness": 2}=0A=
		Widget.__init__(self, master, "menubutton", kw)=0A=
		self.widgetName =3D 'tk_optionMenu'=0A=
		menu =3D self.__menu =3D Menu(self, name=3D"menu", tearoff=3D0)=0A=
		self.menuname =3D menu._w=0A=
		# 'command' is the only supported keyword=0A=
		callback =3D kwargs.get('command')=0A=
		if kwargs.has_key('command'):=0A=
			del kwargs['command']=0A=
		if kwargs:=0A=
			raise TclError, 'unknown option -'+kwargs.keys()[0]=0A=
		menu.add_command(label=3Dvalue,=0A=
				 command=3D_setit(variable, value, callback))=0A=
		for v in values:=0A=
			menu.add_command(label=3Dv,=0A=
					 command=3D_setit(variable, v, callback))=0A=
		self["menu"] =3D menu=0A=
=0A=
	def __getitem__(self, name):=0A=
		if name =3D=3D 'menu':=0A=
			return self.__menu=0A=
		return Widget.__getitem__(self, name)=0A=
=0A=
	def destroy(self):=0A=
		"""Destroy this widget and the associated menu."""=0A=
		Menubutton.destroy(self)=0A=
		self.__menu =3D None=0A=
=0A=
class Image:=0A=
	"""Base class for images."""=0A=
	def __init__(self, imgtype, name=3DNone, cnf=3D{}, master=3DNone, =
**kw):=0A=
		self.name =3D None=0A=
		if not master:=0A=
			master =3D _default_root=0A=
			if not master:=0A=
				raise RuntimeError, 'Too early to create image'=0A=
		self.tk =3D master.tk=0A=
		if not name:=0A=
			name =3D `id(self)`=0A=
			# The following is needed for systems where id(x)=0A=
			# can return a negative number, such as Linux/m68k:=0A=
			if name[0] =3D=3D '-': name =3D '_' + name[1:]=0A=
		if kw and cnf: cnf =3D _cnfmerge((cnf, kw))=0A=
		elif kw: cnf =3D kw=0A=
		options =3D ()=0A=
		for k, v in cnf.items():=0A=
			if callable(v):=0A=
				v =3D self._register(v)=0A=
			options =3D options + ('-'+k, v)=0A=
		self.tk.call(('image', 'create', imgtype, name,) + options)=0A=
		self.name =3D name=0A=
	def __str__(self): return self.name=0A=
	def __del__(self):=0A=
		if self.name:=0A=
			try:=0A=
				self.tk.call('image', 'delete', self.name)=0A=
			except TclError:=0A=
				# May happen if the root was destroyed=0A=
				pass=0A=
	def __setitem__(self, key, value):=0A=
		self.tk.call(self.name, 'configure', '-'+key, value)=0A=
	def __getitem__(self, key):=0A=
		return self.tk.call(self.name, 'configure', '-'+key)=0A=
	def configure(self, **kw):=0A=
		"""Configure the image."""=0A=
		res =3D ()=0A=
		for k, v in _cnfmerge(kw).items():=0A=
			if v is not None:=0A=
				if k[-1] =3D=3D '_': k =3D k[:-1]=0A=
				if callable(v):=0A=
					v =3D self._register(v)=0A=
				res =3D res + ('-'+k, v)=0A=
		self.tk.call((self.name, 'config') + res)=0A=
	config =3D configure=0A=
	def height(self):=0A=
		"""Return the height of the image."""=0A=
		return getint(=0A=
			self.tk.call('image', 'height', self.name))=0A=
	def type(self):=0A=
		"""Return the type of the imgage, e.g. "photo" or "bitmap"."""=0A=
		return self.tk.call('image', 'type', self.name)=0A=
	def width(self):=0A=
		"""Return the width of the image."""=0A=
		return getint(=0A=
			self.tk.call('image', 'width', self.name))=0A=
=0A=
class PhotoImage(Image):=0A=
	"""Widget which can display colored images in GIF, PPM/PGM =
format."""=0A=
	def __init__(self, name=3DNone, cnf=3D{}, master=3DNone, **kw):=0A=
		"""Create an image with NAME.=0A=
=0A=
		Valid resource names: data, format, file, gamma, height, palette,=0A=
		width."""=0A=
		apply(Image.__init__, (self, 'photo', name, cnf, master), kw)=0A=
	def blank(self):=0A=
		"""Display a transparent image."""=0A=
		self.tk.call(self.name, 'blank')=0A=
	def cget(self, option):=0A=
		"""Return the value of OPTION."""=0A=
		return self.tk.call(self.name, 'cget', '-' + option)=0A=
	# XXX config=0A=
	def __getitem__(self, key):=0A=
		return self.tk.call(self.name, 'cget', '-' + key)=0A=
	# XXX copy -from, -to, ...?=0A=
	def copy(self):=0A=
		"""Return a new PhotoImage with the same image as this widget."""=0A=
		destImage =3D PhotoImage()=0A=
		self.tk.call(destImage, 'copy', self.name)=0A=
		return destImage=0A=
	def zoom(self,x,y=3D''):=0A=
		"""Return a new PhotoImage with the same image as this widget=0A=
		but zoom it with X and Y."""=0A=
		destImage =3D PhotoImage()=0A=
		if y=3D=3D'': y=3Dx=0A=
		self.tk.call(destImage, 'copy', self.name, '-zoom',x,y)=0A=
		return destImage=0A=
	def subsample(self,x,y=3D''):=0A=
		"""Return a new PhotoImage based on the same image as this widget=0A=
		but use only every Xth or Yth pixel."""=0A=
		destImage =3D PhotoImage()=0A=
		if y=3D=3D'': y=3Dx=0A=
		self.tk.call(destImage, 'copy', self.name, '-subsample',x,y)=0A=
		return destImage=0A=
	def get(self, x, y):=0A=
		"""Return the color (red, green, blue) of the pixel at X,Y."""=0A=
		return self.tk.call(self.name, 'get', x, y)=0A=
	def put(self, data, to=3DNone):=0A=
		"""Put row formated colors to image starting from=0A=
		position TO, e.g. image.put("{red green} {blue yellow}", =
to=3D(4,6))"""=0A=
		args =3D (self.name, 'put', data)=0A=
		if to:=0A=
			if to[0] =3D=3D '-to':=0A=
				to =3D to[1:]=0A=
			args =3D args + ('-to',) + tuple(to)=0A=
		self.tk.call(args)=0A=
	# XXX read=0A=
	def write(self, filename, format=3DNone, from_coords=3DNone):=0A=
		"""Write image to file FILENAME in FORMAT starting from=0A=
		position FROM_COORDS."""=0A=
		args =3D (self.name, 'write', filename)=0A=
		if format:=0A=
			args =3D args + ('-format', format)=0A=
		if from_coords:=0A=
			args =3D args + ('-from',) + tuple(from_coords)=0A=
		self.tk.call(args)=0A=
=0A=
class BitmapImage(Image):=0A=
	"""Widget which can display a bitmap."""=0A=
	def __init__(self, name=3DNone, cnf=3D{}, master=3DNone, **kw):=0A=
		"""Create a bitmap with NAME.=0A=
=0A=
		Valid resource names: background, data, file, foreground, maskdata, =
maskfile."""=0A=
		apply(Image.__init__, (self, 'bitmap', name, cnf, master), kw)=0A=
=0A=
def image_names(): return _default_root.tk.call('image', 'names')=0A=
def image_types(): return _default_root.tk.call('image', 'types')=0A=
=0A=
######################################################################=0A=
# Extensions:=0A=
=0A=
class Studbutton(Button):=0A=
	def __init__(self, master=3DNone, cnf=3D{}, **kw):=0A=
		Widget.__init__(self, master, 'studbutton', cnf, kw)=0A=
		self.bind('<Any-Enter>',       self.tkButtonEnter)=0A=
		self.bind('<Any-Leave>',       self.tkButtonLeave)=0A=
		self.bind('<1>',               self.tkButtonDown)=0A=
		self.bind('<ButtonRelease-1>', self.tkButtonUp)=0A=
=0A=
class Tributton(Button):=0A=
	def __init__(self, master=3DNone, cnf=3D{}, **kw):=0A=
		Widget.__init__(self, master, 'tributton', cnf, kw)=0A=
		self.bind('<Any-Enter>',       self.tkButtonEnter)=0A=
		self.bind('<Any-Leave>',       self.tkButtonLeave)=0A=
		self.bind('<1>',               self.tkButtonDown)=0A=
		self.bind('<ButtonRelease-1>', self.tkButtonUp)=0A=
		self['fg']               =3D self['bg']=0A=
		self['activebackground'] =3D self['bg']=0A=
=0A=
######################################################################=0A=
# Test:=0A=
=0A=
def _test():=0A=
	root =3D Tk()=0A=
	text =3D "This is Tcl/Tk version %s" % TclVersion=0A=
	if TclVersion >=3D 8.1:=0A=
		text =3D text + u"\nThis should be a cedilla: \347"=0A=
	label =3D Label(root, text=3Dtext)=0A=
	label.pack()=0A=
	test =3D Button(root, text=3D"Click me!",=0A=
		      command=3Dlambda root=3Droot: root.test.configure(=0A=
			      text=3D"[%s]" % root.test['text']))=0A=
	test.pack()=0A=
	root.test =3D test=0A=
	quit =3D Button(root, text=3D"QUIT", command=3Droot.destroy)=0A=
	quit.pack()=0A=
	# The following three commands are needed so the window pops=0A=
	# up on top on Windows...=0A=
	root.iconify()=0A=
	root.update()=0A=
	root.deiconify()=0A=
	root.mainloop()=0A=
=0A=
if __name__ =3D=3D '__main__':=0A=
	_test()=0A=

------_=_NextPart_000_01BFDCDB.F3B3F44E--