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

Metz, Bobby W, WWCS bwmetz at att.com
Fri Sep 1 01:40:00 CEST 2006

>From your code snippet I fail to see where you're defining "im".  I'm
assuming the value of im is the same as your VB value "Picture1.hDC".
Is that a constant from the PinPoint.Plate object?  If so, perhaps it's
not defined.  From first glance the error looks valid.


-----Original Message-----
From: tkinter-discuss-bounces at python.org
[mailto:tkinter-discuss-bounces at python.org]On Behalf Of Reiner M. Stoss
Sent: Thursday, August 31, 2006 2:03 PM
To: tkinter-discuss at python.org
Subject: [Tkinter-discuss] How to get DIB into Tkinter frame?

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") 
Set m = p.NewPlateDIB() 
m.Create 1, 1, 1, 1 
m.Render 60000, 0 
m.PaintPicture Picture1.hDC 

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') 
m = p.NewPlateDIB() 
m.Create(1, 1, 1, 1) 
m.Render(60000, 0) 
#Here some Tkinter lines like root = Tk() etc.
def expose(event): 
    dib = ImageWin.Dib(im) 

left_frame.bind("", expose) 

But it crashes with this message:

Traceback (most recent call last):
  File "L:\pin.py", line 91, in ?
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?


Tkinter-discuss mailing list
Tkinter-discuss at python.org

More information about the Tkinter-discuss mailing list