Tkinter: button (beginner question)

Uwe Mayer merkosh at hadiko.de
Wed Oct 3 14:31:44 CEST 2001


hi,

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')
b.pack()
--

where 'test.bmp' is an image in the same folder python interactive shell 
was started.
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__
    self.tk.call(
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.
Yours
Uwe



More information about the Python-list mailing list