[Tkinter-discuss] How to get DIB into Tkinter frame?

Reiner M. Stoss rstoss at online.de
Thu Aug 31 23:02:31 CEST 2006


Folks, I have a problem.

I have a scriptable software that works with
images in FITS format (astronomical images).
It can generate Windows device-independent bitmaps (DIB)
and paint them as picture into any device context including
Picture controls in Visual Basic, etc.

Here is VB sample code that works for me:

---
Private Sub Command1_Click() 

Set p = CreateObject("PinPoint.Plate") 
p.AttachFITS "M:\Images\LaSagra\20060828\012128+170000-sagra21-S001-R001.fts" 
Set m = p.NewPlateDIB() 
m.Create 1, 1, 1, 1 
m.Render 60000, 0 
m.PaintPicture Picture1.hDC 
p.DetachFITS 

End Sub 
---

The PaintPicture method sends the picture into
the PictureBox Picture1.

Now how to do the same in Python/Tkinter?
I have something as this:

---
p = win32com.client.dynamic.Dispatch('PinPoint.Plate') 
p.AttachFITS('M:/Images/LaSagra/20060828/012128+170000-sagra21-S001-R001.fts') 
m = p.NewPlateDIB() 
m.Create(1, 1, 1, 1) 
m.Render(60000, 0) 
m.PaintPicture(im) 
#Here some Tkinter lines like root = Tk() etc.
def expose(event): 
    dib = ImageWin.Dib(im) 
    dib.expose(ImageWin.HDC(left_frame.winfo_id())) 

left_frame.bind("", expose) 
p.DetachFITS() 
---

But it crashes with this message:

---
Traceback (most recent call last):
  File "L:\pin.py", line 91, in ?
    m.PaintPicture(im)
NameError: name 'im' is not defined
---

Clearly the problem is the argument I provide when
I call PaintPicture(). So how to get the picture painted
by PaintPicture() into a Tkinter frame?

Thanks,
Reiner




More information about the Tkinter-discuss mailing list