Hi,
I want to display a button in my application that shows a bitmap (.xbm).
I'm going crazy. Why does this fragment work (adapted from imageview.py
in Guido's Tkinter demos):
[snip]
#!/usr/bin/env python
from Tkinter import *
import sys
def main():
filename = sys.argv[1]
root = Tk()
img = BitmapImage(file=filename)
label = Button(root, text=filename, image=img, command=sys.exit)
label.pack()
root.mainloop()
main()
[snip]
.... but this doesn't:
[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]
As far as I can see, the two are doing exactly the same. The first
example displays the bitmap, and the button is clickable, the second
displays a button the size of the bitmap, but which has nothing in it,
and which isn't clickable.
HELP!
TIA,
--Bjoern
PS Python 1.5.1 on Linux, if that is important.
--
+ thanks for your time, worship the antichrist, and have a nice day /\
+----------------------------------------------------------------- /()\
+ support privacy on the 'net: mail me for pgp public key /____\
I want to display a button in my application that shows a bitmap (.xbm).
I'm going crazy. Why does this fragment work (adapted from imageview.py
in Guido's Tkinter demos):
[snip]
#!/usr/bin/env python
from Tkinter import *
import sys
def main():
filename = sys.argv[1]
root = Tk()
img = BitmapImage(file=filename)
label = Button(root, text=filename, image=img, command=sys.exit)
label.pack()
root.mainloop()
main()
[snip]
.... but this doesn't:
[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]
As far as I can see, the two are doing exactly the same. The first
example displays the bitmap, and the button is clickable, the second
displays a button the size of the bitmap, but which has nothing in it,
and which isn't clickable.
HELP!
TIA,
--Bjoern
PS Python 1.5.1 on Linux, if that is important.
--
+ thanks for your time, worship the antichrist, and have a nice day /\
+----------------------------------------------------------------- /()\
+ support privacy on the 'net: mail me for pgp public key /____\