[Tkinter] Placing a ScrolledText on a Canvas?

Def P def-p at usa.net
Sun Jun 20 15:29:57 CEST 1999


The subject says it all, really... I would like to have a window with some
fancy background, yet full functionality. So I thought, I use a Canvas, put an
image on it, then put additional components on it. So far it works
reasonably... I put an Entry on it (== the Canvas with PhotoImage on it), with
no problems at all.

However, I cannot seem to manage to put a ScrolledText on the same Canvas. The
following code demonstrates this:

from Tkinter import *
from ScrolledText import ScrolledText

root = Tk()
root.canvas = Canvas(root, width=400, height=580,
background='gray',relief=SUNKEN)
root.canvas.pack()

photo = PhotoImage(file="c:/multimedia/pix/SmallerDragonBanner.gif")
item = root.canvas.create_image(1, 1, anchor=NW, image=photo)

entry = Entry(root, width=38)
entry1 = root.canvas.create_window(60, 490, anchor=NW, window=entry)

textBox = ScrolledText(root, width=15, height=30)
textBox1 = root.canvas.create_window(50, 100, anchor=NW, window=textBox)

root.mainloop()

I cannot copy the exact error message but it says that it "can't use
.8201376.text in a window item of this canvas"...

Am I doing something wrong, or is a ScrolledText "just" an item that cannot be
put on a canvas?

Thanks,
Def P


____________________________________________________________________
Get free e-mail and a permanent address at http://www.netaddress.com/?N=1




More information about the Python-list mailing list