Tkinter bug in Misc.tkraise, Canvas.tkraise

Tamito Kajiyama kajiyama at grad.sccs.chukyo-u.ac.jp
Tue Apr 6 15:51:49 EDT 1999


"John Michelsen" <john.michelsen at gte.net> writes:
| 
| 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()

You can call Misc.lift (overriden by Canvas.lift) as follows:

    def raiseCanvas():
        Misc.lift(canvas1)

In general, you can call a base class method overriden by a subclass
method by BaseClassName.methodname(SubClassInstance, arguments).

You'll find that the same technique is used in the __init__ methods of
the Tkinter widget classes.

--
KAJIYAMA, Tamito <kajiyama at grad.sccs.chukyo-u.ac.jp>




More information about the Python-list mailing list