[Image-SIG] ImageTk
Deok Yong Park
Deokyong.Park@tribon.com
Wed, 4 Oct 2000 09:17:03 +0200
Hello,
I'm trying to use PIL to handle some image with Tk. But I have some trouble.
Could you give me some tips?
For your information, I'm using Windows NT.
Best regards,
Deok-Yong
from Tkinter import *
Import Image
Import ImageTk
self.CBframe = Frame(self.frame)
self.CBframe.pack()
myimage=Image.open("c:\\nor.jpg")
myimage1=myimage.convert("1")
#myimage1.show() # work well
myimageT= ImageTk.BitmapImage(myimage1) ### error
===============Error message================================
Exception exceptions.AttributeError: '_BitmapImage__photo' in <method
BitmapImage.__del__ of BitmapImage instance at 51b7b00> ignored
Traceback (innermost last):
File "C:\PROGRA~1\Python\Tools\idle\ScriptBinding.py", line 131, in
run_module_event
execfile(filename, mod.__dict__)
File "C:\menu.py", line 52, in ?
d=Mainmenu(root)
File "C:\menu.py", line 16, in __init__
self.MakeCheckButton()
File "C:\menu.py", line 37, in MakeCheckButton
myimageT= ImageTk.BitmapImage(myimage1)
File "C:\Program Files\Python\Lib\ImageTk.py", line 158, in __init__
self.__photo = apply(Tkinter.BitmapImage, (), kw)
File "C:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 1917, in
__init__
apply(Image.__init__, (self, 'bitmap', name, cnf, master), kw)
File "C:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 1839, in
__init__
self.tk.call(('image', 'create', imgtype, name,) + options)
TclError: can't invoke "image" command: application has been destroyed
==============================================================
#c = Checkbutton(self.frame, bitmap="@c:\\noriko8.xbm", fg="black",
command="BandCB")
c=Checkbutton(self.frame, bitmap=myimage1)
c.pack()