From: john.michelsen at gte.net (John Michelsen)
Date: Mon, 5 Apr 1999 10:04:34 -0700
Subject: Tkinter bug in Misc.tkraise, Canvas.tkraise
Message-ID: <7eaoop$leq$1@news-2.news.gte.net>
Content-Length: 1751
X-UID: 896                                                  

The following got posted in a reply tree by mistake:

I found a bug in using Tkinter to raise a canvas widget above later
packed (etc.) widgets.  It seems Tkinter gets confused between the
Misc.tkraise() method and the Canvas.tkraise(item) methods.
The following script shows the problem:

from Tkinter import *

def raiseCanvas():
    canvas1.lift()
    #canvas1.tkraise()
    #canvas1.widgetlift()

root = Tk()
canvas1 = Canvas(root, bg='blue')
canvas1.place(x=10, y=10, anchor=NW)
canvas2 = Canvas(root, bg='red')
canvas2.place(x=20, y=20, anchor=NW)
raiseButton = Button(root, text='raiseCanvas', command=raiseCanvas)
raiseButton.pack()
root.geometry("%dx%d" % (100,100))
root.mainloop()

which gives the following error:

Exception in Tkinter callback
Traceback (innermost last):
  File "C:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 764, in
__call__
    return apply(self.func, args)
  File "C:\PROGRA~1\PYTHON\RAISEC~1.PY", line 4, in raiseCanvas
    canvas1.lift()
  File "C:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 1287, in
tkraise
    self.tk.call((self._w, 'raise') + args)
TclError: wrong # args: should be ".8249616 raise tagOrId ?aboveThis?"

I made Tkinter do what I want by adding a method to the Misc
class and not the Canvas class:

class Misc...
    def tkraise(self, aboveThis=None):
        self.tk.call('raise', self._w, aboveThis)
    lift = widgetlift = tkraise

so that widgetlift will call the tkraise in Misc and not the tkraise in
Canvas.

I discovered the error in developing a multiple document interface for
Tkinter
which can be found on: http://www2.zyvex.com/OpenChem/index.htm
Dockable toolbars and a tree widget can also be found there.
They probably don't look very good on unix yet.

John









