Stupid Tkinter question

Bjoern Giesler Bjoern.Giesler at stud.uni-karlsruhe.de
Mon Apr 12 16:17:52 EDT 1999


Hi,

On Mon, 12 Apr 1999 I wrote myself:
[snip]
>[snip]
>#!/usr/bin/env python
>
>from Tkinter import *
>from sys import *
>
>def makeToolbar(aFrame):
>    toolbar = Frame(aFrame)
>    markimage = BitmapImage(file = "Mark.xbm")
>    markbutton = Button(toolbar,
>                        image = markimage,
>                        command = exit)
>
>    markbutton.pack()
>    return toolbar
>
>def makeUI(anApp):
>    frame = Frame(anApp)
>    toolbar = makeToolbar(frame)
>
>    toolbar.pack()
>    frame.pack()
>
>app = Tk()
>makeUI(app)
>app.mainloop()     
>[snip]

I've just found out why the example above doesn't work: If I add a
"global markimage" to the function makeToolbar, it works. Now my
question: Why does markimage have to be global, since it's only used by
markbutton? And why, by analogy, doesn't markbutton have to be global?

		--Bjoern
--
+ thanks for your time, worship the antichrist, and have a nice day /\
+----------------------------------------------------------------- /()\
+     support privacy on the 'net: mail me for pgp public key     /____\




More information about the Python-list mailing list