Metz, Bobby W, WWCS | 1 Sep 01:40 2006
Picon

Re: How to get DIB into Tkinter frame?

>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.

Bobby

-----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") 
p.AttachFITS
"M:\Images\LaSagra\20060828\012128+170000-sagra21-S001-R001.fts" 
(Continue reading)

Fredrik Lundh | 1 Sep 11:23 2006

Re: How to get DIB into Tkinter frame?

Reiner M. Stoss wrote:

> 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)

is PaintPicture rendering into a HDC?

can you get it to render to an ordinary bitmap?

</F> 
Reiner M. Stoss | 1 Sep 11:30 2006
Picon

Re: How to get DIB into Tkinter frame?

> 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.

Of course the error is valid, but how to avoid it? :-)
Yes, I have not defined "im". That's excatly the point.
I do not know how do define it.
Picture1 is a PictureBox in VB and the PaintPicture
method of PinPoint then sends the picture into this
PictureBox.
But I need to do it in Python/Tkinter so how to tell
the PaintPicture to send the picture into a Tkinter frame?

Again the code in VB:
---
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 
---

And the not working code in Python:
(Continue reading)

Reiner M. Stoss | 1 Sep 11:40 2006
Picon

Re: How to get DIB into Tkinter frame?

Fredrik,

> is PaintPicture rendering into a HDC?
> 
> can you get it to render to an ordinary bitmap?

Here is the description of this method from the reference:

---
PlateDIB.PaintPicture() Method

Copy the DIB bitmap to another using BitBlt.

Syntax
PlateDIB.PaintPicture(DeviceContext)

The method syntax has these parts:

Part Description 
DeviceContext (Long) Handle to a GDI device context
containing the destination bitmap (HDC, Long)
Return (Nothing) Does not return a value. 

Remarks
Paints the bitmap in the PlateDIB object onto a bitmap
in some other Windows Graphics Device Interface device.
>From Visual Basic, you can paint into a Picture control.
For example, suppose you have a form with a Picture
control on it named picImage, and a PlateDIB object
that has been Create()ed and Render()ed named pdM104: 
(Continue reading)

Metz, Bobby W, WWCS | 1 Sep 19:05 2006
Picon

Re: How to get DIB into Tkinter frame?

hDC is "handle to device context" in MS lingo.  I can't answer the use
of DCs in Tkinter, but I'm now very interested in Fredrik's response
having understood what you're doing after you second mail.  Wondering
too if the win32 GetDCex call might be used...just not sure how that'd
interface with tkinter.

Bobby

-----Original Message-----
From: tkinter-discuss-bounces <at> python.org
[mailto:tkinter-discuss-bounces <at> python.org]On Behalf Of Reiner M. Stoss
Sent: Friday, September 01, 2006 2:40 AM
To: tkinter-discuss <at> python.org
Subject: Re: [Tkinter-discuss] How to get DIB into Tkinter frame?

Fredrik,

> is PaintPicture rendering into a HDC?
> 
> can you get it to render to an ordinary bitmap?

Here is the description of this method from the reference:

---
PlateDIB.PaintPicture() Method

Copy the DIB bitmap to another using BitBlt.

Syntax
PlateDIB.PaintPicture(DeviceContext)
(Continue reading)

Reiner M. Stoss | 4 Sep 14:59 2006
Picon

Re: How to get DIB into Tkinter frame?

> hDC is "handle to device context" in MS lingo.  I can't answer the use
> of DCs in Tkinter, but I'm now very interested in Fredrik's response
> having understood what you're doing after you second mail.  Wondering
> too if the win32 GetDCex call might be used...just not sure how that'd
> interface with tkinter.

Thanks, Bobby. Someone mentioned that it might work like this:

class ImageShower(Tkinter.Frame):
	def __init__(self, dib):
		Tkinter.Frame.__init__(self)
		self.dib = dib
		self.bind("<Map>", self.redraw)
	
	def redraw(self, ev=None):
		self.dib.expose(ImageWin.HWND(self.winfo_id()))

But now how to make the connection between
PaintPicture(DeviceContext) and ImageShower()?
Something like this doesn't work:
m.PaintPicture(ImageShower(frame1))

It returns:
Traceback (most recent call last):
  File "L:\pin.py", line 100, in ?
    m.PaintPicture(ImageShower(frame1))
  File "<COMObject NewPlateDIB>", line 2, in PaintPicture
AttributeError: ImageShower instance has no attribute '__int__'

Reiner
(Continue reading)

Reiner M. Stoss | 4 Sep 15:53 2006
Picon

maybe like this? (was RE: How to get...)

dib = ImageWin.Dib(...)
hdc = ImageWin.HDC(left_frame.winfo_id())
m.PaintPicture(hdc)
dib.expose(hdc)

All seems okay, however I do not know what to insert
for the "..."

If I use just:
hdc = ImageWin.HDC(left_frame.winfo_id())
m.PaintPicture(hdc)

then I get no error but the image does not appear on the
screen. So do I have to use the expose method to
make it appear? If so, how to define dib?

Reiner
Ilknur Ozturk | 13 Sep 09:25 2006
Picon

bwidget progressbar

Hi,

 

I’m trying to use bwidget progressbar, but I could not find a page that explains its options and methods and gives some basic examples. If you know such a page, would you please send me its link?  If no, can you send us some info about it?

 

Thanks,

 

ilknur

 



**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Michael Lange | 13 Sep 11:32 2006
Picon

Re: bwidget progressbar

On Wed, 13 Sep 2006 10:25:42 +0300
"Ilknur Ozturk" <Ilknur.Ozturk <at> cabot.com.tr> wrote:

> Hi,
> 
>  
> 
> I'm trying to use bwidget progressbar, but I could not find a page that
> explains its options and methods and gives some basic examples. If you
> know such a page, would you please send me its link?  If no, can you
> send us some info about it?
> 
>  

Hi Ilknur,

have a look at the bwidget man pages that come with the pybwidget package.

I hope this helps

Michael
Michael Lange | 14 Sep 10:26 2006
Picon

Re: bwidget progressbar

On Wed, 13 Sep 2006 15:50:47 +0300
"Ilknur Ozturk" <Ilknur.Ozturk <at> cabot.com.tr> wrote:

> Thanks Michael,
> 
> I am new in Tk() and it will good for me if I can find samples for its
> usage. I found some on internet but they are very complex for me. In man
> pages, the options and methods are listed but there is no basic sample
> of them:(
> 

Hi Ilknur,

usually Tk man pages are quite straightforward to "translate" into Python.
The standard and widget-specific options in Tk begin with "-" (like -height),
in Python you can pass them to the widget constructor or to configure(), like
widget.configure(height=20). The WIDGET COMMAND section describes the
available commands for the widget, in case of the ProgressBar there is only
cget() and configure().

So an (untested) example according to the man page might look like:

from Tkinter import *
import bwidget

root = Tk()
var = IntVar()
var.set(0)
p = bwidget.ProgressBar(root, height=20, width=200, maximum=100, variable=var, type='normal')
p.pack()

def run_test():
    if var.get() < 100:
        var.set(var.get() + 1)
        root.after(50, run_test)
run_test()

root.mainloop()

I hope this helps

Michael

Gmane