From bwmetz at att.com Fri Sep 1 01:40:00 2006 From: bwmetz at att.com (Metz, Bobby W, WWCS) Date: Thu, 31 Aug 2006 18:40:00 -0500 Subject: [Tkinter-discuss] How to get DIB into Tkinter frame? In-Reply-To: <44F76A87.15751.277F60@localhost> Message-ID: <01D5341D04A2E64AB9B3457690473367026312FD@OCCLUST01EVS1.ugd.att.com> >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" 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 _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss at python.org http://mail.python.org/mailman/listinfo/tkinter-discuss From fredrik at pythonware.com Fri Sep 1 11:23:19 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 1 Sep 2006 11:23:19 +0200 Subject: [Tkinter-discuss] How to get DIB into Tkinter frame? References: <44F76A87.15751.277F60@localhost> Message-ID: 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? From rstoss at online.de Fri Sep 1 11:30:49 2006 From: rstoss at online.de (Reiner M. Stoss) Date: Fri, 01 Sep 2006 11:30:49 +0200 Subject: [Tkinter-discuss] How to get DIB into Tkinter frame? In-Reply-To: <01D5341D04A2E64AB9B3457690473367026312FD@OCCLUST01EVS1.ugd.att.com> References: <44F76A87.15751.277F60@localhost> Message-ID: <44F819E9.21860.3A9B36@localhost> > 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: --- 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() --- Traceback (most recent call last): File "L:\pin.py", line 91, in ? m.PaintPicture(im) NameError: name 'im' is not defined --- I know how to send an image from a file to a Tkinter frame. But in this case we talk about a DIB which is created/rendered/ painted by the methods of a software and this DIB should go directly into the Tkinter frame. Regards, Reiner From rstoss at online.de Fri Sep 1 11:40:11 2006 From: rstoss at online.de (Reiner M. Stoss) Date: Fri, 01 Sep 2006 11:40:11 +0200 Subject: [Tkinter-discuss] How to get DIB into Tkinter frame? In-Reply-To: Message-ID: <44F81C1B.18829.433097@localhost> 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: pdM104.PaintPicture picImage.handle --- I am new to Tkinter so this might be an easy problem for an expert but it is above my knowledge. I have lost already days with it :-( I was even wondering what HDC means. I see in VB that the PictureBox has a property called "HasDC" and it works with "m.PaintPicture Picture1.hDC" but I do not want to use VB at all and do all in Python/Tkinter. So the VB code snippet was just intended as a help to understanding the problem. Cheers, Reiner From bwmetz at att.com Fri Sep 1 19:05:24 2006 From: bwmetz at att.com (Metz, Bobby W, WWCS) Date: Fri, 1 Sep 2006 12:05:24 -0500 Subject: [Tkinter-discuss] How to get DIB into Tkinter frame? In-Reply-To: <44F81C1B.18829.433097@localhost> Message-ID: <01D5341D04A2E64AB9B34576904733670263177F@OCCLUST01EVS1.ugd.att.com> 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) 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: pdM104.PaintPicture picImage.handle --- I am new to Tkinter so this might be an easy problem for an expert but it is above my knowledge. I have lost already days with it :-( I was even wondering what HDC means. I see in VB that the PictureBox has a property called "HasDC" and it works with "m.PaintPicture Picture1.hDC" but I do not want to use VB at all and do all in Python/Tkinter. So the VB code snippet was just intended as a help to understanding the problem. Cheers, Reiner _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss at python.org http://mail.python.org/mailman/listinfo/tkinter-discuss From rstoss at online.de Mon Sep 4 14:59:41 2006 From: rstoss at online.de (Reiner M. Stoss) Date: Mon, 04 Sep 2006 14:59:41 +0200 Subject: [Tkinter-discuss] How to get DIB into Tkinter frame? In-Reply-To: <01D5341D04A2E64AB9B34576904733670263177F@OCCLUST01EVS1.ugd.att.com> References: <44F81C1B.18829.433097@localhost> Message-ID: <44FC3F5D.21108.FA7CE6@localhost> > 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("", 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 "", line 2, in PaintPicture AttributeError: ImageShower instance has no attribute '__int__' Reiner From rstoss at online.de Mon Sep 4 15:53:17 2006 From: rstoss at online.de (Reiner M. Stoss) Date: Mon, 04 Sep 2006 15:53:17 +0200 Subject: [Tkinter-discuss] maybe like this? (was RE: How to get...) In-Reply-To: <01D5341D04A2E64AB9B34576904733670263177F@OCCLUST01EVS1.ugd.att.com> References: <44F81C1B.18829.433097@localhost> Message-ID: <44FC4BED.29576.12B90BF@localhost> 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 From Ilknur.Ozturk at cabot.com.tr Wed Sep 13 09:25:42 2006 From: Ilknur.Ozturk at cabot.com.tr (Ilknur Ozturk) Date: Wed, 13 Sep 2006 10:25:42 +0300 Subject: [Tkinter-discuss] bwidget progressbar Message-ID: <79CD3DAD56583A4298D4941761CF687A657629@cabottrexch.cabot.local> 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 ______________________________________________________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20060913/0a688ca5/attachment.htm From klappnase at web.de Wed Sep 13 11:32:21 2006 From: klappnase at web.de (Michael Lange) Date: Wed, 13 Sep 2006 11:32:21 +0200 Subject: [Tkinter-discuss] bwidget progressbar In-Reply-To: <79CD3DAD56583A4298D4941761CF687A657629@cabottrexch.cabot.local> References: <79CD3DAD56583A4298D4941761CF687A657629@cabottrexch.cabot.local> Message-ID: <20060913113221.7be2c032.klappnase@web.de> On Wed, 13 Sep 2006 10:25:42 +0300 "Ilknur Ozturk" 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 From klappnase at web.de Thu Sep 14 10:26:07 2006 From: klappnase at web.de (Michael Lange) Date: Thu, 14 Sep 2006 10:26:07 +0200 Subject: [Tkinter-discuss] bwidget progressbar In-Reply-To: <79CD3DAD56583A4298D4941761CF687A6576F9@cabottrexch.cabot.local> References: <79CD3DAD56583A4298D4941761CF687A6576F9@cabottrexch.cabot.local> Message-ID: <20060914102607.6e8dac10.klappnase@web.de> On Wed, 13 Sep 2006 15:50:47 +0300 "Ilknur Ozturk" 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 From mj at maya3d.dk Thu Sep 14 10:05:24 2006 From: mj at maya3d.dk (Mikkel Jans) Date: Thu, 14 Sep 2006 01:05:24 -0700 (PDT) Subject: [Tkinter-discuss] Transparent Background Text Message-ID: <6301194.post@talk.nabble.com> Hello Is it possible to make a text widget's background transparent? -- View this message in context: http://www.nabble.com/Transparent-Background-Text-tf2270154.html#a6301194 Sent from the Python - tkinter-discuss forum at Nabble.com. From Sumanth.Thallam at wabco-auto.com Thu Sep 14 10:15:42 2006 From: Sumanth.Thallam at wabco-auto.com (sumanth_scl) Date: Thu, 14 Sep 2006 01:15:42 -0700 (PDT) Subject: [Tkinter-discuss] handling of item selected in the listbox Message-ID: <6301312.post@talk.nabble.com> hello friends.... i am new to forum, and i got a problem while using tkinter GUI with python.My script performs some initial operations and calls the result ot the operation to be displayed in listbox, and depending on selection of user input, the program should again proceede with some more operations. but the variable where i stored the input given by user to listbox is unable to hold that value if the processing is not in the GUI part.... can any one suggest solution for this. i am giving the part of python program for ur understanding the problem.. #__________________________________________________________________GUI_______________________________________________________________ from Tkinter import * def whichselected() : return int(select.curselection()[0]) def loadEntry () : temp_name=Total_variants[whichselected()] print temp_name def makeWindow () : global nameVar, select win = Tk() frame1 = Frame(win) frame1.pack() Label(frame1, text="List of Variants (please select the variant to be analysed)").grid(row=0, column=0, sticky=W) frame3 = Frame(win) # select of names frame3.pack() select = Listbox(frame3, height=22, width=85) select.pack(side=LEFT) frame2 = Frame(win) frame2.pack() b1=Button(frame2,text="Enter",command=loadEntry) b1.grid(row=2, column=0, sticky=W) return win def setSelect () : #Total_variants.sort() for name in Total_variants: select.insert (END, name) def user_variant (): win = makeWindow() setSelect () print temp_name win.mainloop() #_________________________________________________________________________________________________________________________________________ The script will run and collect some variants and store them in Total_variants , which is global variable and the script will calluser_variant(). now the problem is temp_name in function loadEntry () will give the exact thing selected by the user, the print temp_name in the function user_variant() will give error , not defined. If i define it as global then the value assaigned to it will print or some junk is printed and not the user selected thing. actually i want to use temp_name in later part of the program, but i m getting the error not defined. can any one give me the solution how to handle this. -- View this message in context: http://www.nabble.com/handling-of-item-selected-in-the-listbox-tf2270206.html#a6301312 Sent from the Python - tkinter-discuss forum at Nabble.com. From stewart.midwinter at gmail.com Fri Sep 15 01:29:31 2006 From: stewart.midwinter at gmail.com (Stewart Midwinter) Date: Thu, 14 Sep 2006 17:29:31 -0600 Subject: [Tkinter-discuss] handling of item selected in the listbox In-Reply-To: <6301312.post@talk.nabble.com> References: <6301312.post@talk.nabble.com> Message-ID: Sumanth, if you put your entry data into a StringVar or IntVar, it will be available for use elsewhere in the application. You can combine this with the textvariable parameter, as discussed in example 8-5 in Grayson's book Python and Tkinter Programming. all his examples are available here: http://www.manning.com/grayson/ and the book is recommended. here's his example 8-5: from Tkinter import * class Var(Frame): def __init__(self, master=None): Frame.__init__(self, master) self.pack() self.field = Entry() self.field.pack() self.value = StringVar() self.value.set("Jean-Paul Sartre") self.field["textvariable"] = self.value self.field.bind('', self.print_value) def print_value(self, event): print 'Value is "%s"' % self.value.get() test = Var() test.mainloop() -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20060914/0807bc71/attachment.htm From stewart.midwinter at gmail.com Fri Sep 15 01:33:08 2006 From: stewart.midwinter at gmail.com (Stewart Midwinter) Date: Thu, 14 Sep 2006 17:33:08 -0600 Subject: [Tkinter-discuss] Transparent Background Text In-Reply-To: <6301194.post@talk.nabble.com> References: <6301194.post@talk.nabble.com> Message-ID: well, with canvas widgets you can say fill="" and it will be transparent. Not sure that helps with text though. s On 9/14/06, Mikkel Jans wrote: > > > Hello > > Is it possible to make a text widget's background transparent? > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20060914/b408608f/attachment.html From Cameron at phaseit.net Fri Sep 15 01:48:59 2006 From: Cameron at phaseit.net (Cameron Laird) Date: Thu, 14 Sep 2006 23:48:59 +0000 Subject: [Tkinter-discuss] Transparent Background Text In-Reply-To: <6301194.post@talk.nabble.com> References: <6301194.post@talk.nabble.com> Message-ID: <20060914234859.GA15589@lairds.us> On Thu, Sep 14, 2006 at 01:05:24AM -0700, Mikkel Jans wrote: . . . > Is it possible to make a text widget's background transparent? . . . Effectively, no. Under Windows, with enough C-level coding, you might get results that are temporarily satisfying, but it turns out to be quite a hard problem. From bwmetz at att.com Fri Sep 15 02:37:28 2006 From: bwmetz at att.com (Metz, Bobby W, WWCS) Date: Thu, 14 Sep 2006 19:37:28 -0500 Subject: [Tkinter-discuss] Transparent Background Text In-Reply-To: <20060914234859.GA15589@lairds.us> Message-ID: <01D5341D04A2E64AB9B345769047336702767C60@OCCLUST01EVS1.ugd.att.com> I've heard transparency is available in newer versions of Tk but not sure it's trickled into a tkinter distribution yet. -----Original Message----- From: tkinter-discuss-bounces at python.org [mailto:tkinter-discuss-bounces at python.org]On Behalf Of Cameron Laird Sent: Thursday, September 14, 2006 4:49 PM To: Mikkel Jans Cc: tkinter-discuss at python.org Subject: Re: [Tkinter-discuss] Transparent Background Text On Thu, Sep 14, 2006 at 01:05:24AM -0700, Mikkel Jans wrote: . . . > Is it possible to make a text widget's background transparent? . . . Effectively, no. Under Windows, with enough C-level coding, you might get results that are temporarily satisfying, but it turns out to be quite a hard problem. _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss at python.org http://mail.python.org/mailman/listinfo/tkinter-discuss From chris at niekel.net Fri Sep 15 22:57:06 2006 From: chris at niekel.net (Chris Niekel) Date: Fri, 15 Sep 2006 22:57:06 +0200 Subject: [Tkinter-discuss] Transparent messages Message-ID: <20060915205706.GB13685@kira.niekel.net> Hi, I read this article http://www.humanized.com/weblog/2006/09/11/monolog_boxes_and_transparent_messages/ or http://tinyurl.com/k5jed and thought it'd be nice to play with this. Does anyone have an idea how this could be done with tkinter? For those who don't want to see the article, they suggest an alternative to a messagedialog, by showing a semi-transparent widget in the window, which disappears upon user-activity. I'm not so good at tkinter yet, but I'd love to use something like this. Regards, Chris Niekel From gerardo at computo-industrial.com.mx Sat Sep 16 00:24:29 2006 From: gerardo at computo-industrial.com.mx (Gerardo Juarez) Date: Fri, 15 Sep 2006 18:24:29 -0400 (EDT) Subject: [Tkinter-discuss] Minimizing a Python/Tk application Message-ID: Hi, I want a Python/Tk application to minimize itself as soon as it starts (it acts in the background). Is there a way to make this happen? An another question: how can I make this application appear on the tool bar, next to the volume control, anti-virus software and similar applications? I have searched and cannot find anything related. Thanks in advance, Gerardo From bwmetz at att.com Sat Sep 16 01:45:51 2006 From: bwmetz at att.com (Metz, Bobby W, WWCS) Date: Fri, 15 Sep 2006 18:45:51 -0500 Subject: [Tkinter-discuss] Minimizing a Python/Tk application In-Reply-To: Message-ID: <01D5341D04A2E64AB9B34576904733670276872F@OCCLUST01EVS1.ugd.att.com> use the withdraw() function, e.g. from Tkinter import * root = Tk() root.withdraw() # Hide the window root.deiconify() # Unhide the window Bobby -----Original Message----- From: tkinter-discuss-bounces at python.org [mailto:tkinter-discuss-bounces at python.org]On Behalf Of Gerardo Juarez Sent: Friday, September 15, 2006 3:24 PM To: tkinter-discuss at python.org Subject: [Tkinter-discuss] Minimizing a Python/Tk application Hi, I want a Python/Tk application to minimize itself as soon as it starts (it acts in the background). Is there a way to make this happen? An another question: how can I make this application appear on the tool bar, next to the volume control, anti-virus software and similar applications? I have searched and cannot find anything related. Thanks in advance, Gerardo _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss at python.org http://mail.python.org/mailman/listinfo/tkinter-discuss From francois.schnell at gmail.com Sat Sep 16 10:25:05 2006 From: francois.schnell at gmail.com (francois schnell) Date: Sat, 16 Sep 2006 10:25:05 +0200 Subject: [Tkinter-discuss] Minimizing a Python/Tk application In-Reply-To: References: Message-ID: <13a83ca10609160125s3e83ee65g2a93cbb966f3286@mail.gmail.com> On 16/09/06, Gerardo Juarez wrote: > > > > An another question: how can I make this application appear on the tool > bar, next to the volume control, anti-virus software and similar > applications? I have searched and cannot find anything related. I was searching for that also but I believe it's impossible with tkinter according to this : http://mail.python.org/pipermail/python-list/2002-September/123257.html > from Tkinter import * > root = Tk() > root.withdraw() # Hide the window > root.deiconify() # Unhide the window > I'm using also deiconify for a windows app. It worked fine as long as I was in the "main thread" but I had random problems when using it from another thread (which I couldn't avoid). I'm trying/learning wxpython now for a proper systray control and to see how the "deiconification from another thread" behave. francois > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20060916/3b598866/attachment.html From gerardo at computo-industrial.com.mx Wed Sep 20 18:51:39 2006 From: gerardo at computo-industrial.com.mx (Gerardo Juarez) Date: Wed, 20 Sep 2006 12:51:39 -0400 (EDT) Subject: [Tkinter-discuss] Minimizing a Python/Tk application In-Reply-To: <01D5341D04A2E64AB9B34576904733670276872F@OCCLUST01EVS1.ugd.att.com> Message-ID: Thanks, it works, but, once the application is minimized I don't have any way to access it -to tell it to deiconify itself for example. I doesn't use a console window. Is killing it the only option? Gerardo On Fri, 15 Sep 2006, Metz, Bobby W, WWCS wrote: > use the withdraw() function, e.g. > > from Tkinter import * > root = Tk() > root.withdraw() # Hide the window > root.deiconify() # Unhide the window > > Bobby > From gerardo at computo-industrial.com.mx Wed Sep 20 18:58:06 2006 From: gerardo at computo-industrial.com.mx (Gerardo Juarez) Date: Wed, 20 Sep 2006 12:58:06 -0400 (EDT) Subject: [Tkinter-discuss] Minimizing a Python/Tk application In-Reply-To: <13a83ca10609160125s3e83ee65g2a93cbb966f3286@mail.gmail.com> Message-ID: Thanks Francois, Multiple threads are always trickier. On the other hand, wxpython could be the solution, but I wish it could be done in Tk, because I already have the multiplatform program written and it would save me redoing it just for Windows. And also see my previous message. Gerardo On Sat, 16 Sep 2006, francois schnell wrote: > On 16/09/06, Gerardo Juarez wrote: > > > > > > > > An another question: how can I make this application appear on the tool > > bar, next to the volume control, anti-virus software and similar > > applications? I have searched and cannot find anything related. > > > I was searching for that also but I believe it's impossible with tkinter > according to this : > http://mail.python.org/pipermail/python-list/2002-September/123257.html > > > > from Tkinter import * > > root = Tk() > > root.withdraw() # Hide the window > > root.deiconify() # Unhide the window > > > > I'm using also deiconify for a windows app. It worked fine as long as I was > in the "main thread" but I had random problems when using it from another > thread (which I couldn't avoid). > > I'm trying/learning wxpython now for a proper systray control and to see how > the "deiconification from another thread" behave. > > francois > > > _______________________________________________ > > Tkinter-discuss mailing list > > Tkinter-discuss at python.org > > http://mail.python.org/mailman/listinfo/tkinter-discuss > > > From bwmetz at att.com Wed Sep 20 19:02:52 2006 From: bwmetz at att.com (Metz, Bobby W, WWCS) Date: Wed, 20 Sep 2006 12:02:52 -0500 Subject: [Tkinter-discuss] Minimizing a Python/Tk application In-Reply-To: Message-ID: <01D5341D04A2E64AB9B3457690473367027D32CE@OCCLUST01EVS1.ugd.att.com> What type of window are you displaying? It sounds like you're tying the withdraw code to a button or something for a user to click; otherwise, you would have some event or other sub-routine that fires the deiconify later based on conditions or program flow. In my example below, as long as you have a variable pointing to the window you can call the deiconify at any time. If there is a simple minimize instead of hide...I don't remember what that function is. B -----Original Message----- From: tkinter-discuss-bounces+bwmetz=att.com at python.org [mailto:tkinter-discuss-bounces+bwmetz=att.com at python.org] On Behalf Of Gerardo Juarez Sent: Wednesday, September 20, 2006 9:52 AM To: tkinter-discuss at python.org Subject: Re: [Tkinter-discuss] Minimizing a Python/Tk application Thanks, it works, but, once the application is minimized I don't have any way to access it -to tell it to deiconify itself for example. I doesn't use a console window. Is killing it the only option? Gerardo On Fri, 15 Sep 2006, Metz, Bobby W, WWCS wrote: > use the withdraw() function, e.g. > > from Tkinter import * > root = Tk() > root.withdraw() # Hide the window > root.deiconify() # Unhide the window > > Bobby > _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss at python.org http://mail.python.org/mailman/listinfo/tkinter-discuss From bwmetz at att.com Wed Sep 20 19:08:53 2006 From: bwmetz at att.com (Metz, Bobby W, WWCS) Date: Wed, 20 Sep 2006 12:08:53 -0500 Subject: [Tkinter-discuss] Minimizing a Python/Tk application In-Reply-To: Message-ID: <01D5341D04A2E64AB9B3457690473367027D32F2@OCCLUST01EVS1.ugd.att.com> Yes, manipulating Tk from a child thread is problematic and can't be done directly, e.g. try launching a Dialog box from a thread and see what happens. One trick I've done in the past is to pass a reference to the parent to the child thread, then when I want to update the GUI in the parent, say a status message line, I simple set the variable behind it using the parent reference. If you're going to have multiple threads updating that could get tricky I suppose considering the variable locking, but I'm sure someone out here has done it. Anyone? -----Original Message----- From: tkinter-discuss-bounces at python.org [mailto:tkinter-discuss-bounces at python.org] On Behalf Of Gerardo Juarez Sent: Wednesday, September 20, 2006 9:58 AM To: tkinter-discuss at python.org Subject: Re: [Tkinter-discuss] Minimizing a Python/Tk application Thanks Francois, Multiple threads are always trickier. On the other hand, wxpython could be the solution, but I wish it could be done in Tk, because I already have the multiplatform program written and it would save me redoing it just for Windows. And also see my previous message. Gerardo On Sat, 16 Sep 2006, francois schnell wrote: > On 16/09/06, Gerardo Juarez wrote: > > > > > > > > An another question: how can I make this application appear on the tool > > bar, next to the volume control, anti-virus software and similar > > applications? I have searched and cannot find anything related. > > > I was searching for that also but I believe it's impossible with tkinter > according to this : > http://mail.python.org/pipermail/python-list/2002-September/123257.html > > > > from Tkinter import * > > root = Tk() > > root.withdraw() # Hide the window > > root.deiconify() # Unhide the window > > > > I'm using also deiconify for a windows app. It worked fine as long as I was > in the "main thread" but I had random problems when using it from another > thread (which I couldn't avoid). > > I'm trying/learning wxpython now for a proper systray control and to see how > the "deiconification from another thread" behave. > > francois > > > _______________________________________________ > > Tkinter-discuss mailing list > > Tkinter-discuss at python.org > > http://mail.python.org/mailman/listinfo/tkinter-discuss > > > _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss at python.org http://mail.python.org/mailman/listinfo/tkinter-discuss From gerardo at computo-industrial.com.mx Wed Sep 20 19:36:20 2006 From: gerardo at computo-industrial.com.mx (Gerardo Juarez) Date: Wed, 20 Sep 2006 13:36:20 -0400 (EDT) Subject: [Tkinter-discuss] Minimizing a Python/Tk application In-Reply-To: <01D5341D04A2E64AB9B3457690473367027D32CE@OCCLUST01EVS1.ugd.att.com> Message-ID: I just found it! What I want is to run the application minimized and to see the controls only when I need to reconfigure its behaviour. I searched for the function that you mention and found that it must be iconify(). Like this: root = Tk() root.iconify() withdraw() removes the window from the screen altogether and probably is the right choice for a Toplevel window you don't need anymore, but which can be recalled with a button from the main window that's still displayed. Which is what you were talking about. Thanks for the tip. Gerardo On Wed, 20 Sep 2006, Metz, Bobby W, WWCS wrote: > What type of window are you displaying? It sounds like you're tying the > withdraw code to a button or something for a user to click; otherwise, > you would have some event or other sub-routine that fires the deiconify > later based on conditions or program flow. In my example below, as long > as you have a variable pointing to the window you can call the deiconify > at any time. If there is a simple minimize instead of hide...I don't > remember what that function is. > > B > > -----Original Message----- > From: tkinter-discuss-bounces+bwmetz=att.com at python.org > [mailto:tkinter-discuss-bounces+bwmetz=att.com at python.org] On Behalf Of > Gerardo Juarez > Sent: Wednesday, September 20, 2006 9:52 AM > To: tkinter-discuss at python.org > Subject: Re: [Tkinter-discuss] Minimizing a Python/Tk application > > > Thanks, it works, but, once the application is minimized I don't have > any > way to access it -to tell it to deiconify itself for example. I doesn't > use a console window. Is killing it the only option? > > Gerardo > > On Fri, 15 Sep 2006, Metz, Bobby W, WWCS wrote: > > > use the withdraw() function, e.g. > > > > from Tkinter import * > > root = Tk() > > root.withdraw() # Hide the window > > root.deiconify() # Unhide the window > > > > Bobby > > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From mhaimes at MIT.EDU Wed Sep 20 18:27:47 2006 From: mhaimes at MIT.EDU (Michael M Haimes) Date: Wed, 20 Sep 2006 12:27:47 -0400 Subject: [Tkinter-discuss] Tkinter, threads? memory? Message-ID: <20060920122747.vco8o18m4c48cswg@webmail.mit.edu> Hello Tkinter community, I'm a relatively experienced Python/Tk programmer having worked on multiple larger scale projects now, and I'm having two issues with Tkinter: ------------1---------- Linux implementations of Python/Tkinter (the most current) seem to exhibit the problem, but not Sun/Solaris or Windows. Essentially, I can't animate objects on a canvas without leaking memory at about 1Mb/s . I've tried 4 different methods, either deleting and redrawing objects, or just moving objects, and either using Tk tags to label and operate the objects, or storing their IDs in my program and operating with them that way. I can't think of any other way to do this, and I basically need to. I would try the WCK to make my own, but the idea is to have the software run on a base install of Python. The link to the four example test scripts I wrote up is here: http://web.mit.edu/mhaimes/Public/tktest.tar ------------2---------- The Mac OS X implementation of Python seems to exhibit this problem, and no other systems. This problem is related to the above, namely, on the Mac animation seems to be totally broken. Whenever Tk is running its event loop, it stops all other python threads from processing and sits and waits for input. So my example code below runs a counter in a background thread which increments the number Tk has displayed. On Windows/Linux, it just counts up until you press exit. On the Mac, it will sit there and freeze if you aren't inputting anything, but as soon as you wave the mouse around or start typing it'll continue to increment; whereas on Windows and Linux, the counter just counts up no matter what you are inputting. I know this could be done without two separate threads, but the real program that this is modelling an issue I'm having needs Tk to be in its event loop, so that is not an option. Test code as follows: ################# import Tkinter import thread import sys app = Tkinter.Tk() text = Tkinter.StringVar() Tkinter.Label(app, textvariable = text).pack() def looper(): count = 0 while 1: text.set(`count`) count+=1 thread.start_new_thread(looper, ()) Tkinter.Button(app, text="exit", command = sys.exit).pack() app.mainloop() ############## ----------------------- If anyone has any hints or suggestions for workarounds for either of the above problems, it would be much appreciated. Or if you just run any of the test programs on your systems and get different results than I predicted for you, tell me some things about your system and what happened. -Mike Haimes From klappnase at web.de Thu Sep 21 22:46:53 2006 From: klappnase at web.de (Michael Lange) Date: Thu, 21 Sep 2006 22:46:53 +0200 Subject: [Tkinter-discuss] Tkinter, threads? memory? In-Reply-To: <20060920122747.vco8o18m4c48cswg@webmail.mit.edu> References: <20060920122747.vco8o18m4c48cswg@webmail.mit.edu> Message-ID: <20060921224653.25e76f4d.klappnase@web.de> On Wed, 20 Sep 2006 12:27:47 -0400 Michael M Haimes wrote: > ------------1---------- > Linux implementations of Python/Tkinter (the most current) seem to exhibit the > problem, but not Sun/Solaris or Windows. > > Essentially, I can't animate objects on a canvas without leaking memory at about > 1Mb/s . I've tried 4 different methods, either deleting and redrawing objects, > or just moving objects, and either using Tk tags to label and operate the > objects, or storing their IDs in my program and operating with them that way. I > can't think of any other way to do this, and I basically need to. I would try > the WCK to make my own, but the idea is to have the software run on a base > install of Python. > > The link to the four example test scripts I wrote up is here: > http://web.mit.edu/mhaimes/Public/tktest.tar > > ------------2---------- > The Mac OS X implementation of Python seems to exhibit this problem, and no > other systems. > > This problem is related to the above, namely, on the Mac animation seems to be > totally broken. Whenever Tk is running its event loop, it stops all other > python threads from processing and sits and waits for input. So my example code > below runs a counter in a background thread which increments the number Tk has > displayed. On Windows/Linux, it just counts up until you press exit. On the > Mac, it will sit there and freeze if you aren't inputting anything, but as soon > as you wave the mouse around or start typing it'll continue to increment; > whereas on Windows and Linux, the counter just counts up no matter what you are > inputting. I know this could be done without two separate threads, but the real > program that this is modelling an issue I'm having needs Tk to be in its event > loop, so that is not an option. > > Test code as follows: > ################# > import Tkinter > import thread > import sys > > app = Tkinter.Tk() > text = Tkinter.StringVar() > Tkinter.Label(app, textvariable = text).pack() > def looper(): > count = 0 > while 1: > text.set(`count`) > count+=1 > thread.start_new_thread(looper, ()) > Tkinter.Button(app, text="exit", command = sys.exit).pack() > app.mainloop() > ############## > > ----------------------- > > If anyone has any hints or suggestions for workarounds for either of the above > problems, it would be much appreciated. Or if you just run any of the test > programs on your systems and get different results than I predicted for you, > tell me some things about your system and what happened. > Hi Michael, for me (on linux) #2 works, on all examples of #1 i get this error: Unhandled exception in thread started by Traceback (most recent call last): File "projekte/test2.py", line 18, in mover canvas.move(dot, -100*sin(t)*dt, 100*cos(t)*dt) File "/usr/lib/python2.4/lib-tk/Tkinter.py", line 2189, in move self.tk.call((self._w, 'move') + args) _tkinter.TclError: too many nested evaluations (infinite loop?) Generally I don't think it is a good idea to update Tk widgets directly from Python threads. I think you better create some variable to manage the communication between Tk and your child thread, as in this example which does practcally the same as #2: import Tkinter import thread import sys app = Tkinter.Tk() text = Tkinter.StringVar() Tkinter.Label(app, textvariable = text).pack() newtext = '0' def looper(): global newtext count = 0 while 1: #text.set(`count`) newtext = str(count) count+=1 thread.start_new_thread(looper, ()) Tkinter.Button(app, text="exit", command = sys.exit).pack() def update_label(): text.set(newtext) app.after(10, update_label) update_label() app.mainloop() And a working animation as in #1 with the same technique: import Tkinter from time import time, sleep from math import sin, cos from thread import start_new_thread import sys app = Tkinter.Tk() canvas = Tkinter.Canvas(app, width=300, height=300) canvas.pack() t = time() dot = canvas.create_oval(100*cos(t)+150, 100*sin(t)+150, 100*cos(t)+150, 100*sin(t)+150) x, y = 0, 0 def mover(): global x, y t = time() try: while 1: dt = time()-t;t=time() #canvas.move(dot, -100*sin(t)*dt, 100*cos(t)*dt) x, y = -100*sin(t)*dt, 100*cos(t)*dt sleep(0.1) except KeyboardInterrupt: sys.exit(-1) start_new_thread(mover, ()) def update_oval(): canvas.move(dot, x, y) canvas.after(100, update_oval) update_oval() app.mainloop() I hope this helps Michael