Tkinter: button (beginner question)
merkosh at hadiko.de
Wed Oct 3 14:31:44 CEST 2001
the following was supposed to display a Tkinter button with an image on
it (i.e for a toolbar):
from Tkinter import *
root = Tk()
b = Button(root,image='test.bmp')
where 'test.bmp' is an image in the same folder python interactive shell
however, pyhton aborts on the 3rd line with:
>>> b = Button(root,image='x1.xbm')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\Python21\lib\lib-tk\Tkinter.py", line 1817, in __init__
Widget.__init__(self, master, 'button', cnf, kw)
File "C:\Python21\lib\lib-tk\Tkinter.py", line 1756, in __init__
TclError: image "x1.xbm" doesn't exist
has anyone an idea what is going wrong here?
for the reference: i am running python 2.1.1 on windows 2k.
i read the Tkinter manual examples and i don't quite know why all
Button, Canvas, etc. are put into a Frame widget rather than letting
them stay in the "root = Tk()" widget, or Toplevel widget (-> Dialog
window example). Where's the difference?
Thanx in advance for comments.
More information about the Python-list