From raycores at gmail.com Mon Oct 1 01:25:13 2012 From: raycores at gmail.com (Lynn Oliver) Date: Sun, 30 Sep 2012 16:25:13 -0700 Subject: [Tkinter-discuss] crash on tkFileDialog:asksaveasfilename() In-Reply-To: <7D3D3FC3-7401-4519-9128-D98305DD4395@mac.com> References: <302C0C86-AFE6-418A-8DB9-1001CFAAE4ED@gmail.com> <7A68FE1A-2584-4643-83B7-63370E0B38B1@gmail.com> <7D3D3FC3-7401-4519-9128-D98305DD4395@mac.com> Message-ID: <205B3635-0774-4A3C-8B4C-0FBDC2E2FFDB@gmail.com> On Sep 30, 2012, at 2:32 PM, wrw at mac.com wrote: > On Sep 30, 2012, at 3:46 PM, Lynn Oliver wrote: > >> It's packaged using pyinstaller, so it unpacks into a temp folder and runs from there. >> >> Sent from my iPad >> >> On Sep 30, 2012, at 12:22 PM, wrw at mac.com wrote: >> >>> On Sep 30, 2012, at 2:07 PM, Lynn Oliver wrote: >>> >>>> I'm puzzled by reports from a single person using my program, who states that he consistently crashes in the common file dialog invoked by asksaveasfilename() if, and only if, he attempts to change folders. He says this is happening on two different machines, an iMac (see below) and a 2011 MacBookPro, both running 10.8.2 (current version of Mountain Lion). >>>> >>>> The program is using Python 2.7.2, Tcl/Tk 8.5. I have never seen this error or been able to reproduce it on my machine, a 2011 iMac also running 10.8.2. >>>> >>>> My understanding is that Tkinter is handing control over to a system dialog, so the crash occurs before control returns to Tkinter. Is there anything I could be doing in my program that would affect this? I couldn't find any problem reports similar to this for Tkinter. >>>> >>>> The crash report he sent is below. >>>> >>>> Thanks... >>>> Lynn >>>> >>> >>> Lynn, I'm no help reading the dump, but I have a question, which is possibly relevant. >>> >>> How was your program distributed? That is, is it an OS-X 'bundle' produced by py2app, or is your user executing python source directly? >>> >>> -Bill >>> > > So, have you included _all_ the necessary libraries in the compressed package, and are the imports precise enough that it isn't maybe picking up one of the Apple system python libraries? > > -Bill That is certainly the idea, and I test it on a machine that has nothing installed other than the OS. It's not unlikely that the user in question has some dev tools on his machine, but he gets the same result on his wife's MBP, which is unlikely to have the same libraries installed. I'll check into it, though. -Lynn -------------- next part -------------- An HTML attachment was scrubbed... URL: From chigga101 at gmail.com Thu Oct 4 19:16:19 2012 From: chigga101 at gmail.com (Matthew Ngaha) Date: Thu, 4 Oct 2012 18:16:19 +0100 Subject: [Tkinter-discuss] displaying an image Message-ID: im trying to display an image. Ive tried different code from several tutorials but they seem outdated and nothing works. here's 1 line that makes me give up. my_image = Image.open("imagepath.jpg") this line returns an error of Image doesnt have attribute open, yet this is what my tutorial has shown me. can anyone please help? any new tkinter tutorials around? From michael.odonnell at uam.es Thu Oct 4 19:29:50 2012 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Thu, 4 Oct 2012 19:29:50 +0200 Subject: [Tkinter-discuss] displaying an image In-Reply-To: References: Message-ID: Hi Matthew, Your first line should in fact be: from PIL import Image ...then your line: my_image = Image.open("imagepath.jpg") Mick On Thu, Oct 4, 2012 at 7:16 PM, Matthew Ngaha wrote: > > im trying to display an image. Ive tried different code from several > tutorials but they seem outdated and nothing works. here's 1 line that > makes me give up. > > > > this line returns an error of Image doesnt have attribute open, yet > this is what my tutorial has shown me. can anyone please help? > > any new tkinter tutorials around? > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss -- Not sent from my iPhone From raycores at gmail.com Thu Oct 4 20:23:54 2012 From: raycores at gmail.com (Lynn Oliver) Date: Thu, 4 Oct 2012 11:23:54 -0700 Subject: [Tkinter-discuss] displaying an image In-Reply-To: References: Message-ID: <207F243D-25FF-44DF-AC64-AA6B9227325C@gmail.com> I know this isn't exactly what you asked, but I am displaying an image in a label in a --onefile distribution, and this code works both while debugging and while running the packaged application: if getattr(sys, 'frozen', None): basedir = sys._MEIPASS else: basedir = os.path.dirname(__file__) self.photo = tk.PhotoImage(file=os.path.join(basedir, 'myImage.gif')) self.myLabel = ttk.Label(self.myFrame, image=self.photo) self.myLabel.grid() Lynn On Oct 4, 2012, at 10:29 AM, Michael O'Donnell wrote: > Hi Matthew, > > Your first line should in fact be: > > from PIL import Image > > ...then your line: > > my_image = Image.open("imagepath.jpg") > > Mick > > On Thu, Oct 4, 2012 at 7:16 PM, Matthew Ngaha wrote: >> >> im trying to display an image. Ive tried different code from several >> tutorials but they seem outdated and nothing works. here's 1 line that >> makes me give up. >> >> >> >> this line returns an error of Image doesnt have attribute open, yet >> this is what my tutorial has shown me. can anyone please help? >> >> any new tkinter tutorials around? >> _______________________________________________ >> Tkinter-discuss mailing list >> Tkinter-discuss at python.org >> http://mail.python.org/mailman/listinfo/tkinter-discuss > > > > -- > > Not sent from my iPhone > _______________________________________________ > 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: From chigga101 at gmail.com Thu Oct 4 20:59:31 2012 From: chigga101 at gmail.com (Matthew Ngaha) Date: Thu, 4 Oct 2012 19:59:31 +0100 Subject: [Tkinter-discuss] displaying an image In-Reply-To: <207F243D-25FF-44DF-AC64-AA6B9227325C@gmail.com> References: <207F243D-25FF-44DF-AC64-AA6B9227325C@gmail.com> Message-ID: On Thu, Oct 4, 2012 at 7:23 PM, Lynn Oliver wrote: > I know this isn't exactly what you asked, but I am displaying an image in a > label in a --onefile distribution, and this code works both while debugging > and while running the packaged application: > > if getattr(sys, 'frozen', None): > basedir = sys._MEIPASS > else: > basedir = os.path.dirname(__file__) > self.photo = tk.PhotoImage(file=os.path.join(basedir, > 'myImage.gif')) > self.myLabel = ttk.Label(self.myFrame, image=self.photo) > self.myLabel.grid() > > Lynn i am very new to programming and all that code is confusing me:( sorry:) > Hi Matthew, > > Your first line should in fact be: > > from PIL import Image > > ...then your line: > > my_image = Image.open("imagepath.jpg") > > Mick it gave me an ImportError saying no module named PIL From michael.odonnell at uam.es Thu Oct 4 21:11:26 2012 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Thu, 4 Oct 2012 21:11:26 +0200 Subject: [Tkinter-discuss] displaying an image In-Reply-To: References: <207F243D-25FF-44DF-AC64-AA6B9227325C@gmail.com> Message-ID: You need to install PIL to use the tutorial you are doing. http://www.pythonware.com/products/pil/ PIL has some advantages to built in images within TKinter, especially if you are wanting to manipulate images rather than just display them Mick >> Hi Matthew, >> >> Your first line should in fact be: >> >> from PIL import Image >> >> ...then your line: >> >> my_image = Image.open("imagepath.jpg") >> >> Mick > > it gave me an ImportError saying no module named PIL From raycores at gmail.com Thu Oct 4 21:11:54 2012 From: raycores at gmail.com (Lynn Oliver) Date: Thu, 4 Oct 2012 12:11:54 -0700 Subject: [Tkinter-discuss] displaying an image In-Reply-To: References: <207F243D-25FF-44DF-AC64-AA6B9227325C@gmail.com> Message-ID: <6C62A460-BA0E-4E09-9EE5-F0642E884548@gmail.com> I should be the one to apologize; I included code that is required for packages created by pyinstaller, which is a tool that will take a Python script and turn it into a self-contained executable. Let me try again: import Tkinter as tk import ttk photo = tk.PhotoImage(file='myImageFile.gif')) myLabel = ttk.Label(self.myFrame, image=self.photo) myLabel.grid() This is just the Tkinter code. I have "tk.PhotoImage()" instead of just "PhotoImage()" because of the way I imported Tkinter. Most examples will probably show this: from Tkinter import * so you would not need the "tk." prefix. I prefer to keep the namespaces separate. I use "ttk.Label()" instead of "tk.Label()" because I like the newer ttk widgets better. On Oct 4, 2012, at 11:59 AM, Matthew Ngaha wrote: > On Thu, Oct 4, 2012 at 7:23 PM, Lynn Oliver wrote: >> I know this isn't exactly what you asked, but I am displaying an image in a >> label in a --onefile distribution, and this code works both while debugging >> and while running the packaged application: >> >> if getattr(sys, 'frozen', None): >> basedir = sys._MEIPASS >> else: >> basedir = os.path.dirname(__file__) >> self.photo = tk.PhotoImage(file=os.path.join(basedir, >> 'myImage.gif')) >> self.myLabel = ttk.Label(self.myFrame, image=self.photo) >> self.myLabel.grid() >> >> Lynn > > i am very new to programming and all that code is confusing me:( sorry:) > >> Hi Matthew, >> >> Your first line should in fact be: >> >> from PIL import Image >> >> ...then your line: >> >> my_image = Image.open("imagepath.jpg") >> >> Mick > > it gave me an ImportError saying no module named PIL > _______________________________________________ > 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: From chigga101 at gmail.com Thu Oct 4 21:29:31 2012 From: chigga101 at gmail.com (Matthew Ngaha) Date: Thu, 4 Oct 2012 20:29:31 +0100 Subject: [Tkinter-discuss] displaying an image In-Reply-To: <6C62A460-BA0E-4E09-9EE5-F0642E884548@gmail.com> References: <207F243D-25FF-44DF-AC64-AA6B9227325C@gmail.com> <6C62A460-BA0E-4E09-9EE5-F0642E884548@gmail.com> Message-ID: > import Tkinter as tk > import ttk i get an ImportError say no module named Tkinter:( From lionkimbro at gmail.com Thu Oct 4 21:51:08 2012 From: lionkimbro at gmail.com (Lion Kimbro) Date: Thu, 4 Oct 2012 12:51:08 -0700 Subject: [Tkinter-discuss] displaying an image In-Reply-To: References: <207F243D-25FF-44DF-AC64-AA6B9227325C@gmail.com> <6C62A460-BA0E-4E09-9EE5-F0642E884548@gmail.com> Message-ID: Are you running a tutorial for Python 2 from Python 3? On Thu, Oct 4, 2012 at 12:29 PM, Matthew Ngaha wrote: > > import Tkinter as tk > > import ttk > > > i get an ImportError say no module named Tkinter:( > _______________________________________________ > 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: From chigga101 at gmail.com Thu Oct 4 22:03:47 2012 From: chigga101 at gmail.com (Matthew Ngaha) Date: Thu, 4 Oct 2012 21:03:47 +0100 Subject: [Tkinter-discuss] displaying an image In-Reply-To: References: <207F243D-25FF-44DF-AC64-AA6B9227325C@gmail.com> <6C62A460-BA0E-4E09-9EE5-F0642E884548@gmail.com> Message-ID: > Are you running a tutorial for Python 2 from Python 3? sorry for the direct email. yes the tutorial uses Python 2, while i only have Python 3 From lionkimbro at gmail.com Thu Oct 4 22:08:38 2012 From: lionkimbro at gmail.com (Lion Kimbro) Date: Thu, 4 Oct 2012 13:08:38 -0700 Subject: [Tkinter-discuss] displaying an image In-Reply-To: References: <207F243D-25FF-44DF-AC64-AA6B9227325C@gmail.com> <6C62A460-BA0E-4E09-9EE5-F0642E884548@gmail.com> Message-ID: The tkinter modules were renamed from 2-3. I can't remember where the table is that shows the renames/reorganization, but you need to know that the modules were renamed. In Python 3, it's "import tkinter". In Python 2, it's "import Tkinter". Other modules within the tkinter hierarchy were renamed as well -- in most cases, uppercase became lowercase. If memory serves right, there was some reorganization of the hierarchy as well. On Thu, Oct 4, 2012 at 1:03 PM, Matthew Ngaha wrote: > > Are you running a tutorial for Python 2 from Python 3? > > sorry for the direct email. yes the tutorial uses Python 2, while i > only have Python 3 > _______________________________________________ > 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: From chigga101 at gmail.com Thu Oct 4 23:02:07 2012 From: chigga101 at gmail.com (Matthew Ngaha) Date: Thu, 4 Oct 2012 22:02:07 +0100 Subject: [Tkinter-discuss] [Tutor] displaying an image In-Reply-To: References: <207F243D-25FF-44DF-AC64-AA6B9227325C@gmail.com> Message-ID: > Well, you can download 2.7.3 (I think that's the current one) from > python.org so you aren't stuck on that front. I don't think PIL got > ported to Python 3.x -- it's more or less abandonware now. so i can have 2 diff versions of Python on my computer? they won't conflict with each other? From Cameron at phaseit.net Thu Oct 4 23:06:15 2012 From: Cameron at phaseit.net (Cameron Laird) Date: Thu, 4 Oct 2012 21:06:15 +0000 Subject: [Tkinter-discuss] [Tutor] displaying an image In-Reply-To: References: <207F243D-25FF-44DF-AC64-AA6B9227325C@gmail.com> Message-ID: <20121004210615.GA19717@lairds.us> On Thu, Oct 04, 2012 at 10:02:07PM +0100, Matthew Ngaha wrote: . . . > > Well, you can download 2.7.3 (I think that's the current one) from > > python.org so you aren't stuck on that front. I don't think PIL got > > ported to Python 3.x -- it's more or less abandonware now. > > > so i can have 2 diff versions of Python on my computer? they won't > conflict with each other? . . . It CERTAINLY is possible to have multiple Python releases nicely installed on a single host, with- out conflict. It's even common. It's also possible to confuse things and create considerable conflict. From chigga101 at gmail.com Thu Oct 4 23:44:19 2012 From: chigga101 at gmail.com (Matthew Ngaha) Date: Thu, 4 Oct 2012 22:44:19 +0100 Subject: [Tkinter-discuss] [Tutor] displaying an image In-Reply-To: <20121004210615.GA19717@lairds.us> References: <207F243D-25FF-44DF-AC64-AA6B9227325C@gmail.com> <20121004210615.GA19717@lairds.us> Message-ID: > It CERTAINLY is possible to have multiple Python > releases nicely installed on a single host, with- > out conflict. It's even common. > > It's also possible to confuse things and create > considerable conflict. thanks for all the help guys. ive been trying to learn tkinter all day with little luck so im too tired to continue. ill do everything you guys told me tomorrow and hopefully if all goes well, i won't be replying to this email, i'll be making a new one with brand new problems:) thanks again From chigga101 at gmail.com Fri Oct 5 03:06:41 2012 From: chigga101 at gmail.com (Matthew Ngaha) Date: Fri, 5 Oct 2012 02:06:41 +0100 Subject: [Tkinter-discuss] [Tutor] displaying an image In-Reply-To: References: <207F243D-25FF-44DF-AC64-AA6B9227325C@gmail.com> Message-ID: > Well actually, no. You can just install Python 2.7 and use PIL with > that. It might be better though to focus on things that do work in > Python 3 and find a tutorial that doesn't need PIL. oh thats a shame. ive look for many tkinter tutorials and all seem to only do it in Python 2. a book also would really help as they explain in more detail, but im yet to find a book for tkinter. the only 1 i saw was released in 2000:( From michael.odonnell at uam.es Fri Oct 5 08:30:37 2012 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Fri, 5 Oct 2012 08:30:37 +0200 Subject: [Tkinter-discuss] [Tutor] displaying an image In-Reply-To: References: <207F243D-25FF-44DF-AC64-AA6B9227325C@gmail.com> Message-ID: Reference guide at: http://infohost.nmt.edu/tcc/help/pubs/tkinter.pdf HTML vertsion of Fredrik Lundh's book on tkinter, from 1999, but still valid for explaining how things work (Tkinter has not changed much, although some things have been added, especially TTK): http://www.pythonware.com/library/tkinter/introduction/index.htm A lot of people are still working withpython 2.7. Some modules have not yet been ported to python3, and users are waiting for the port. I recently ported my program to 3, and support for some things is a bit buggy, although mostly there (e.g., issues in numpy, py2app). And yes, PIL is not yet ported to python3. Mick On Fri, Oct 5, 2012 at 3:06 AM, Matthew Ngaha wrote: > >> Well actually, no. You can just install Python 2.7 and use PIL with >> that. It might be better though to focus on things that do work in >> Python 3 and find a tutorial that doesn't need PIL. > > oh thats a shame. ive look for many tkinter tutorials and all seem to > only do it in Python 2. a book also would really help as they explain > in more detail, but im yet to find a book for tkinter. the only 1 i > saw was released in 2000:( > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss -- Not sent from my iPhone From john at nmt.edu Fri Oct 5 08:44:56 2012 From: john at nmt.edu (John W. Shipman) Date: Fri, 5 Oct 2012 00:44:56 -0600 (MDT) Subject: [Tkinter-discuss] [Tutor] displaying an image In-Reply-To: References: <207F243D-25FF-44DF-AC64-AA6B9227325C@gmail.com> Message-ID: On Fri, 5 Oct 2012, Michael O'Donnell wrote: > Reference guide at: > > http://infohost.nmt.edu/tcc/help/pubs/tkinter.pdf Thanks for the plug, Mr. O'Donnell. I'm the author of that work. A task on my agenda is to update it for the themed widgets, and also somehow document the differences in Python 3.x. However, it may be a few more months before I can dig down to it. Comments, suggestions, and corrections always welcome. Best regards, John Shipman (john at nmt.edu), Applications Specialist New Mexico Tech Computer Center, Speare 146, Socorro, NM 87801 (575) 835-5735, http://www.nmt.edu/~john ``Let's go outside and commiserate with nature.'' --Dave Farber From chigga101 at gmail.com Fri Oct 5 11:22:43 2012 From: chigga101 at gmail.com (Matthew Ngaha) Date: Fri, 5 Oct 2012 10:22:43 +0100 Subject: [Tkinter-discuss] [Tutor] displaying an image In-Reply-To: References: <207F243D-25FF-44DF-AC64-AA6B9227325C@gmail.com> Message-ID: > If you're using Windows, Christoph Gholke has an installer for an > unofficial port to 3.2/3.3 for 32-bit and 64-bit platforms: > > http://www.lfd.uci.edu/~gohlke/pythonlibs/#pil i have only Python 3.1. is 3.2/3.3 the only versions the installer will work on. > He also has the ported source code available to build PIL on a > non-Windows platform. But be forewarned this is rarely a simple > process. im on windows, but those steps are too complicated for me. i am only slightly past the hello world stage:( From chigga101 at gmail.com Fri Oct 5 20:10:35 2012 From: chigga101 at gmail.com (Matthew Ngaha) Date: Fri, 5 Oct 2012 19:10:35 +0100 Subject: [Tkinter-discuss] [Tutor] displaying an image In-Reply-To: References: <207F243D-25FF-44DF-AC64-AA6B9227325C@gmail.com> Message-ID: with no solution to my problem after 2 days of pulling my hair out:( i realize that some libraries are best for the Python version they support the most. Sadly most tkinter users use version 2 unlike me, so im pretty much on my own as the solutions don't apply to me. Can someone please recommend me a toolkit that is fully supported on Python 3 and has a similar or easier learning curve to tkinter? thanks for all the help and effort guys. From bryan.oakley at gmail.com Fri Oct 5 20:53:30 2012 From: bryan.oakley at gmail.com (Bryan Oakley) Date: Fri, 5 Oct 2012 13:53:30 -0500 Subject: [Tkinter-discuss] [Tutor] displaying an image In-Reply-To: References: <207F243D-25FF-44DF-AC64-AA6B9227325C@gmail.com> Message-ID: On Fri, Oct 5, 2012 at 1:10 PM, Matthew Ngaha wrote: > with no solution to my problem after 2 days of pulling my hair out:( i > realize that some libraries are best for the Python version they > support the most. Sadly most tkinter users use version 2 unlike me, so > im pretty much on my own as the solutions don't apply to me. Can > someone please recommend me a toolkit that is fully supported on > Python 3 and has a similar or easier learning curve to tkinter? thanks > for all the help and effort guys. Matthew: Sorry for your problems. Tkinter isn't usually so hard for people to get started with. Your original message showed you were trying to open a .jpg image. Do you have the option of converting it to the GIF format? If so, you don't need PIL at all since .GIF is directly supported by Tkinter. For example, to display a GIF image you can do this: class ExampleApp(tk.Tk): def __init__(self): tk.Tk.__init__(self) self.image = tk.PhotoImage(file=image_file) label = tk.Label(self, image=self.image) label.pack() app = ExampleApp() app.mainloop() The above code works for me just fine with Python 3.2. All you need to do is define 'image_file' to point to a .gif that you want to display. Unfortunately Tkinter only directly supports .gif and the older ppm/pgm formats. For any other format you'll need PIL, or some other way to convert the image to a supported format. Yeah, I know it's crazy that Tkinter only supports .GIF. For most people who use Tkinter there are workarounds. Unfortunately, as a newbie forced to use Python3, the workaround is not so evident. From klappnase at web.de Fri Oct 5 21:20:17 2012 From: klappnase at web.de (Michael Lange) Date: Fri, 5 Oct 2012 21:20:17 +0200 Subject: [Tkinter-discuss] [Tutor] displaying an image In-Reply-To: References: <207F243D-25FF-44DF-AC64-AA6B9227325C@gmail.com> Message-ID: <20121005212017.4e441980.klappnase@web.de> Hi Matthew, On Fri, 5 Oct 2012 19:10:35 +0100 Matthew Ngaha wrote: > with no solution to my problem after 2 days of pulling my hair out:( i > realize that some libraries are best for the Python version they > support the most. Sadly most tkinter users use version 2 unlike me, so > im pretty much on my own as the solutions don't apply to me. Can > someone please recommend me a toolkit that is fully supported on > Python 3 and has a similar or easier learning curve to tkinter? thanks > for all the help and effort guys. maybe what confused you were some of the more "advanced" suggestions about using the Python Imaging Library (PIL) or installing a second Python version or discussing the handling of namespaces. In fact, as far as I see, there is not too much difference in the Tkinter usage between Python2.7 and Python3, so for the most part the old Python2-based Tkinter tutorials should still serve you well. The most evident difference is that since Python3 the tkinter module spells in lower case. Coming back to the problem from your original post: > im trying to display an image. Ive tried different code from several > tutorials but they seem outdated and nothing works. here's 1 line that > makes me give up. > > my_image = Image.open("imagepath.jpg") > > this line returns an error of Image doesnt have attribute open, yet > this is what my tutorial has shown me. can anyone please help? This line seems in fact to be taken from some tutorial describing the usage of PIL. In plain Tkinter the simplest program displaying an image might look like (Python3 version): from tkinter import * root = Tk() img = PhotoImage(file='imagepath.gif') l = Label(root, image=img) l.pack() root.mainloop() The only difference to the "Python2-version" is the lower-case "Tkinter" in the first line. You see that in Tkinter you usually do not have to use the Image class at all (although it exists) but create the image directly with the PhotoImage class. One (more or less serious) restriction of Tkinter's standard PhotoImage class is however that you can only use GIF images, other formats like JPEG or PNG are not supported yet. So unfortunately you will either have to use an external tool to convert your jpegs into gif first or install a third-party extension like PIL or TkImg* (the latter is easier to use if you only need support for more file formats, because no commands are changed or added, but just support for a lot of image file formats is added silently in the background; I am not sure however if there is a precompiled binary for windows systems is easily available) if you really need these formats. Did this help any? Best regards Michael * http://sourceforge.net/projects/tkimg/ .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. [War] is instinctive. But the instinct can be fought. We're human beings with the blood of a million savage years on our hands! But we can stop it. We can admit that we're killers ... but we're not going to kill today. That's all it takes! Knowing that we're not going to kill today! -- Kirk, "A Taste of Armageddon", stardate 3193.0 From chigga101 at gmail.com Fri Oct 5 22:34:02 2012 From: chigga101 at gmail.com (Matthew Ngaha) Date: Fri, 5 Oct 2012 21:34:02 +0100 Subject: [Tkinter-discuss] [Tutor] displaying an image In-Reply-To: <20121005212017.4e441980.klappnase@web.de> References: <207F243D-25FF-44DF-AC64-AA6B9227325C@gmail.com> <20121005212017.4e441980.klappnase@web.de> Message-ID: >. So unfortunately you will either have > to use an external tool to convert your jpegs into gif first or install a > third-party extension like PIL or TkImg* (the latter is easier to use if > you only need support for more file formats, because no commands are > changed or added, but just support for a lot of image file formats is > added silently in the background; I am not sure however if there is a > precompiled binary for windows systems is easily available) if you really > need these formats. > Did this help any? > * http://sourceforge.net/projects/tkimg/ thanks. Yes this was very helpful. im not sure when you say precompiled binary for windows systems. i did download the Tkimg software from the link you provided. is the next step as easy as extracting the zip file into my Python folder or is it more involved? -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Sat Oct 6 11:57:18 2012 From: klappnase at web.de (Michael Lange) Date: Sat, 6 Oct 2012 11:57:18 +0200 Subject: [Tkinter-discuss] [Tutor] displaying an image In-Reply-To: References: <207F243D-25FF-44DF-AC64-AA6B9227325C@gmail.com> <20121005212017.4e441980.klappnase@web.de> Message-ID: <20121006115718.2ba86b60.klappnase@web.de> On Fri, 5 Oct 2012 21:34:02 +0100 Matthew Ngaha wrote: > >. So unfortunately you will either have > > to use an external tool to convert your jpegs into gif first or > > install a third-party extension like PIL or TkImg* (the latter is > > easier to use if you only need support for more file formats, because > > no commands are changed or added, but just support for a lot of image > > file formats is added silently in the background; I am not sure > > however if there is a precompiled binary for windows systems is > > easily available) if you really need these formats. > > > Did this help any? > > * http://sourceforge.net/projects/tkimg/ > > thanks. Yes this was very helpful. im not sure when you say precompiled > binary for windows systems. i did download the Tkimg software from the > link you provided. is the next step as easy as extracting the zip file > into my Python folder or is it more involved? Yes, im afraid ;) The first thing you should be aware is that TkImg does not have anything to do with Python, it is purely an extension to Tcl/Tk. So if you have the "binary" package the files must go into the Tcl folder of your Python install, usually something like C:\Python31\tcl . A binary tcl-extension Package usually contains one or more *.dll files and a pkgIndex.tcl file; the latter is important for the Tcl Interpreter, so it knows how to handle the dll(s). Now I looked at the tkimg14.zip file myself, and actually there don't seem to be any dlls, just the "source code" that must be "compiled" ("translated" into machine code) first, which unfortunately might not be too trivial for a beginner. If you want to try TkImg anyway without having to compile it yourself, you can look for example here: http://www.posoft.de/html/extTkImg.html They offer packages for "windows7" and for "windows" there, not sure if these also work with xp or vista in case you still have one of these. I think it might still be worth a try. Since Tk8.5 is there for years now, I don't think the Tk version actualy in use should matter. If you copy the contents of one of the .zip files offered there into your PythonXY\tcl folder there might be a good chance that it "just works", I never tested it myself. though. Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Our way is peace. -- Septimus, the Son Worshiper, "Bread and Circuses", stardate 4040.7. From chigga101 at gmail.com Sat Oct 6 16:36:31 2012 From: chigga101 at gmail.com (Matthew Ngaha) Date: Sat, 6 Oct 2012 15:36:31 +0100 Subject: [Tkinter-discuss] [Tutor] displaying an image In-Reply-To: <20121006115718.2ba86b60.klappnase@web.de> References: <207F243D-25FF-44DF-AC64-AA6B9227325C@gmail.com> <20121005212017.4e441980.klappnase@web.de> <20121006115718.2ba86b60.klappnase@web.de> Message-ID: > > If you want to try TkImg anyway without having to compile it yourself, > you can look for example here: > > http://www.posoft.de/html/extTkImg.html > > If you copy the contents of one of the .zip files offered there into your > PythonXY\tcl folder there might be a good chance that it "just works", I > never tested it myself. though. > nothing seems to work with TkImg but however the gif example you showed me is working fine so i guess im happy with that as gimp successfully converts my images into gifs. I will try sending an email to TkImg to see if they can direct me in steps to installling the program.. ive really really appreciated your help. Thanks for taking the time and effort to offer me help. Thanks to everyone else who commented also. -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Sat Oct 6 16:52:21 2012 From: klappnase at web.de (Michael Lange) Date: Sat, 6 Oct 2012 16:52:21 +0200 Subject: [Tkinter-discuss] [Tutor] displaying an image In-Reply-To: References: <207F243D-25FF-44DF-AC64-AA6B9227325C@gmail.com> <20121005212017.4e441980.klappnase@web.de> <20121006115718.2ba86b60.klappnase@web.de> Message-ID: <20121006165221.98dbd062.klappnase@web.de> Hi Matthew, On Sat, 6 Oct 2012 15:36:31 +0100 Matthew Ngaha wrote: > nothing seems to work with TkImg but however the gif example you > showed me is working fine so i guess im happy with that as gimp > successfully converts my images into gifs. I will try sending an email > to TkImg to see if they can direct me in steps to installling the > program. sorry, what I completely forgot to mention about TkImg is that of course after installing the dlls your program has to tell the Tcl/Tk Interpreter to use it. The magic line for that in Tcl is: package require Img In Python / Tkinter this can be accomplished with a single line, too, as in this snippet (note the third line): from tkinter import * root = Tk() root.tk.call('package', 'require', 'Img') img = PhotoImage(file='imagepath.jpg') l = Label(root, image=img) l.pack() root.mainloop() So in case you did not try this already, there may still be hope. Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Killing is stupid; useless! -- McCoy, "A Private Little War", stardate 4211.8 From chigga101 at gmail.com Sat Oct 6 17:14:39 2012 From: chigga101 at gmail.com (Matthew Ngaha) Date: Sat, 6 Oct 2012 16:14:39 +0100 Subject: [Tkinter-discuss] [Tutor] displaying an image In-Reply-To: <20121006165221.98dbd062.klappnase@web.de> References: <207F243D-25FF-44DF-AC64-AA6B9227325C@gmail.com> <20121005212017.4e441980.klappnase@web.de> <20121006115718.2ba86b60.klappnase@web.de> <20121006165221.98dbd062.klappnase@web.de> Message-ID: > > sorry, what I completely forgot to mention about TkImg is that of course > after installing the dlls your program has to tell the Tcl/Tk Interpreter > to use it. The magic line for that in Tcl is: > > package require Img > > In Python / Tkinter this can be accomplished with a single line, too, as > in this snippet (note the third line): > > from tkinter import * > root = Tk() > root.tk.call('package', 'require', 'Img') > img = PhotoImage(file='imagepath.jpg') > l = Label(root, image=img) > l.pack() > root.mainloop() > > So in case you did not try this already, there may still be hope. > sorry that last email was sent directly by mistake. The above code has fixed my issues and i am very happy right now:) -------------- next part -------------- An HTML attachment was scrubbed... URL: From chigga101 at gmail.com Sun Oct 7 16:59:52 2012 From: chigga101 at gmail.com (Matthew Ngaha) Date: Sun, 7 Oct 2012 15:59:52 +0100 Subject: [Tkinter-discuss] whats Style() Message-ID: hi guys. in my tutorial ive come across an undefined class called Style. using python 3 most import statements produce an error so i mainly stick to: from tkinter import * . here are some of the lines of code that produces errors in different examples making it hard to move on: Style().configure("TFrame", background="#333") and self.style = Style() self.style.theme_use("default") maybe the error is in my importing but the imports the examples use produce errors. here are one: from ttk import Frame, Button, Style my interpreter doesnt know what ttk is. -------------- next part -------------- An HTML attachment was scrubbed... URL: From chigga101 at gmail.com Sun Oct 7 17:42:44 2012 From: chigga101 at gmail.com (Matthew Ngaha) Date: Sun, 7 Oct 2012 16:42:44 +0100 Subject: [Tkinter-discuss] whats Style() In-Reply-To: References: Message-ID: hey guys please ignore this email, i figured out the problem by using this import: from tkinter import ttk then using style with ttk.Style() still unsure why from tkinter import ttk, Style didnt work. but that's ok -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Sun Oct 7 17:48:32 2012 From: klappnase at web.de (Michael Lange) Date: Sun, 7 Oct 2012 17:48:32 +0200 Subject: [Tkinter-discuss] whats Style() In-Reply-To: References: Message-ID: <20121007174832.bf0021f3.klappnase@web.de> Hi Matthew, On Sun, 7 Oct 2012 15:59:52 +0100 Matthew Ngaha wrote: > hi guys. in my tutorial ive come across an undefined class called Style. > using python 3 most import statements produce an error so i mainly stick > to: > from tkinter import * . > > here are some of the lines of code that produces errors in different > examples making it hard to move on: > > Style().configure("TFrame", background="#333") > and > > self.style = Style() > self.style.theme_use("default") > > maybe the error is in my importing but the imports the examples use > produce errors. here are one: > > from ttk import Frame, Button, Style > my interpreter doesnt know what ttk is. This is again due to the changes in the organization of tkinter in Python3. Your tutorial is probably Python2 based. You can see the difference in these brief python2- and -3 sessions: $ python2.6 Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from Tkinter import * >>> import ttk >>> style = ttk.Style() >>> style.theme_use('clam') >>> style.theme_use('default') >>> import sys >>> sys.path ['', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/local/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/python2.6', '/usr/lib/pymodules/python2.6/gtk-2.0', '/usr/lib/python2.6/dist-packages/wx-2.6-gtk2-unicode'] >>> $ python3.1 Python 3.1.3 (r313:86834, Nov 28 2010, 11:28:10) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from tkinter import * >>> from tkinter import ttk >>> style = ttk.Style() >>> style.theme_use('default') >>> import sys >>> sys.path ['', '/usr/lib/python3.1', '/usr/lib/python3.1/plat-linux2', '/usr/lib/python3.1/lib-dynload', '/usr/local/lib/python3.1/dist-packages', '/usr/lib/python3/dist-packages', '/usr/lib/python3.1/dist-packages'] >>> The reason of the different import mechanism is of course that in Python3 tkinter is not a single file "Tkinter.py" as in Python2 but now a "package" which consists of the whole tkinter folder in your Python install. Now when you call "from tkinter import *" everything in tkinter/__init__.py is added to the namespace but *not* anything from any other file in tkinter/... . If you want to use one of these you will have to import them separately, as with "from tkinter import ttk" or "from tkinter import messagebox" and so on. This is because in Python3 the folder containing the tkinter files is no longer in Python's standard module search path. If you compare the contents of "sys.path" of Python2 and Python3 above, you will see that the tkinter directory (here: '/usr/lib/python3.1/tkinter' is not included, whereas in Python 2 the tkinter directory (here: '/usr/lib/python2.6/lib-tk') is present. This all may be confusing at the first glance, but once you get the point I think it is quite straightforward. I hope this helps Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Genius doesn't work on an assembly line basis. You can't simply say, "Today I will be brilliant." -- Kirk, "The Ultimate Computer", stardate 4731.3 From chigga101 at gmail.com Sun Oct 7 19:15:36 2012 From: chigga101 at gmail.com (Matthew Ngaha) Date: Sun, 7 Oct 2012 18:15:36 +0100 Subject: [Tkinter-discuss] whats Style() In-Reply-To: References: <20121007174832.bf0021f3.klappnase@web.de> Message-ID: sorry i sent the email directly by mistake. Just like to say thanks once again for all the help -------------- next part -------------- An HTML attachment was scrubbed... URL: From mkieverpy at tlink.de Sun Oct 7 20:53:21 2012 From: mkieverpy at tlink.de (mkieverpy at tlink.de) Date: Sun, 07 Oct 2012 18:53:21 -0000 Subject: [Tkinter-discuss] =?utf-8?q?FocusOut_not_working_as_expected_-_ti?= =?utf-8?q?x_broken=3F?= Message-ID: <3XZYty66zszP7v@mail.python.org> Hello Michael, I'm back and tested a bit more. I updated to standard packages (debian wheezy) python 3.2 tcl/tk 8.5 tix 8.4.3 to avoid any problems with who is using who. I then expanded your test program to emulate my configuration and what I want to implement. There I noticed that it's not a tix problem at all, but standard tcl/tk focus behaves the same. Here's the program: ----------------------------------------------- import tkinter root = tkinter.Tk() f = tkinter.Frame(root) f.pack(fill='both', expand=1) tkinter.Button(f, text='foo').pack() f2 = tkinter.Frame(root) f2.pack(fill='both') tkinter.Button(f2, text='bar').pack() def on_key(event): print('key') def on_focus_out(event): print('focus out') f.focus_set() f.focus_set() f.bind('', on_key) f.bind('', on_focus_out) root.mainloop() ----------------------------------------------- The problem is when I use the 'Tab' key to move the focus. The first 'Tab' moves the focus to the 'foo' button. 'f' no longer gets key events but does not get the focus out event either. The next 'Tab' moves the focus to the 'bar' button, 'f' gets the focus out event and key events arrive again after I do 'focus_set'. So it looks like tk standard behaviour. Can I get what I want? In my program it's a mouse click that can move the focus away. So tweaking or disabling 'Tab' is not a solution. Regards, Matthias Kievernagel From mkieverpy at tlink.de Mon Oct 8 13:09:30 2012 From: mkieverpy at tlink.de (mkieverpy at tlink.de) Date: Mon, 08 Oct 2012 11:09:30 -0000 Subject: [Tkinter-discuss] =?utf-8?q?FocusOut_not_working_as_expected_-_ti?= =?utf-8?q?x_broken=3F?= Message-ID: <3XZzNd5Z6rzQmM@mail.python.org> Hello Michael, I found a workaround: ------------------------------------------------ import tkinter root = tkinter.Tk() f = tkinter.Frame(root) f.pack(fill='both', expand=1) tkinter.Button(f, text='foo').pack() f2 = tkinter.Frame(root) f2.pack(fill='both') tkinter.Button(f2, text='bar').pack() f3 = tkinter.Frame(root) f3.pack(fill='both') def on_key(event): print('key') def on_focus_out(event): print('focus out') f3.focus_set() f3.focus_set() f3.bind('', on_key) f3.bind('', on_focus_out) root.mainloop() ------------------------------------------------ The other program does not look wrong though. I think I'll ask at tcl/tk if they think it's a bug. Regards, Matthias Kievernagel From pedrovmarcal at gmail.com Tue Oct 9 11:32:32 2012 From: pedrovmarcal at gmail.com (Pedro Marcal) Date: Tue, 9 Oct 2012 02:32:32 -0700 Subject: [Tkinter-discuss] Error in import of Tkinter in python 2.7 Message-ID: I have python 2.6 and 2.7 installed on my Windows 7-prof. my IDLE runs OK with Tkinter. When I tried to use IDLE in 2.7 I got the above error. I suspect I need to set an environmental Variable. Thanks for any suggestions. Pedro -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: importer_error.jpg Type: image/jpeg Size: 85064 bytes Desc: not available URL: From lionkimbro at gmail.com Tue Oct 9 20:01:50 2012 From: lionkimbro at gmail.com (Lion Kimbro) Date: Tue, 9 Oct 2012 11:01:50 -0700 Subject: [Tkinter-discuss] Error in import of Tkinter in python 2.7 In-Reply-To: References: Message-ID: I'm curious -- do you have a file Python27/libs/_tkinter.lib ..? ( Maybe you have a Python build that excluded tk? ) On Tue, Oct 9, 2012 at 2:32 AM, Pedro Marcal wrote: > I have python 2.6 and 2.7 installed on my Windows 7-prof. > my IDLE runs OK with Tkinter. > When I tried to use IDLE in 2.7 I got the above error. I suspect I need to > set an environmental Variable. > Thanks for any suggestions. > Pedro > > _______________________________________________ > 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: From pedrovmarcal at gmail.com Tue Oct 9 20:50:44 2012 From: pedrovmarcal at gmail.com (Pedro Marcal) Date: Tue, 9 Oct 2012 11:50:44 -0700 Subject: [Tkinter-discuss] Error in import of Tkinter in python 2.7 In-Reply-To: References: Message-ID: I do have the file _tkinter.lib. In fact when I compare my Lib files, I have all the tkinter related files in 2.7 that I have in 2.6. Thanks, Pedro On Tue, Oct 9, 2012 at 11:01 AM, Lion Kimbro wrote: > > I'm curious -- do you have a file Python27/libs/_tkinter.lib ..? > > ( Maybe you have a Python build that excluded tk? ) > > > On Tue, Oct 9, 2012 at 2:32 AM, Pedro Marcal wrote: > >> I have python 2.6 and 2.7 installed on my Windows 7-prof. >> my IDLE runs OK with Tkinter. >> When I tried to use IDLE in 2.7 I got the above error. I suspect I need >> to set an environmental Variable. >> Thanks for any suggestions. >> Pedro >> >> _______________________________________________ >> 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: From lionkimbro at gmail.com Tue Oct 9 20:59:43 2012 From: lionkimbro at gmail.com (Lion Kimbro) Date: Tue, 9 Oct 2012 11:59:43 -0700 Subject: [Tkinter-discuss] Error in import of Tkinter in python 2.7 In-Reply-To: References: Message-ID: python -c "import sys; print sys.path" What do you get? On Tue, Oct 9, 2012 at 11:50 AM, Pedro Marcal wrote: > I do have the file _tkinter.lib. > In fact when I compare my Lib files, I have all the tkinter related files > in 2.7 that I have in 2.6. > Thanks, Pedro > > > On Tue, Oct 9, 2012 at 11:01 AM, Lion Kimbro wrote: > >> >> I'm curious -- do you have a file Python27/libs/_tkinter.lib ..? >> >> ( Maybe you have a Python build that excluded tk? ) >> >> >> On Tue, Oct 9, 2012 at 2:32 AM, Pedro Marcal wrote: >> >>> I have python 2.6 and 2.7 installed on my Windows 7-prof. >>> my IDLE runs OK with Tkinter. >>> When I tried to use IDLE in 2.7 I got the above error. I suspect I need >>> to set an environmental Variable. >>> Thanks for any suggestions. >>> Pedro >>> >>> _______________________________________________ >>> 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: From pedrovmarcal at gmail.com Tue Oct 9 21:41:25 2012 From: pedrovmarcal at gmail.com (Pedro Marcal) Date: Tue, 9 Oct 2012 12:41:25 -0700 Subject: [Tkinter-discuss] Error in import of Tkinter in python 2.7 In-Reply-To: References: Message-ID: the attached output. On Tue, Oct 9, 2012 at 11:59 AM, Lion Kimbro wrote: > > python -c "import sys; print sys.path" > > What do you get? > > > > On Tue, Oct 9, 2012 at 11:50 AM, Pedro Marcal wrote: > >> I do have the file _tkinter.lib. >> In fact when I compare my Lib files, I have all the tkinter related files >> in 2.7 that I have in 2.6. >> Thanks, Pedro >> >> >> On Tue, Oct 9, 2012 at 11:01 AM, Lion Kimbro wrote: >> >>> >>> I'm curious -- do you have a file Python27/libs/_tkinter.lib ..? >>> >>> ( Maybe you have a Python build that excluded tk? ) >>> >>> >>> On Tue, Oct 9, 2012 at 2:32 AM, Pedro Marcal wrote: >>> >>>> I have python 2.6 and 2.7 installed on my Windows 7-prof. >>>> my IDLE runs OK with Tkinter. >>>> When I tried to use IDLE in 2.7 I got the above error. I suspect I need >>>> to set an environmental Variable. >>>> Thanks for any suggestions. >>>> Pedro >>>> >>>> _______________________________________________ >>>> 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: -------------- next part -------------- A non-text attachment was scrubbed... Name: importer_2.jpg Type: image/jpeg Size: 100662 bytes Desc: not available URL: From klappnase at web.de Wed Oct 10 11:37:35 2012 From: klappnase at web.de (Michael Lange) Date: Wed, 10 Oct 2012 11:37:35 +0200 Subject: [Tkinter-discuss] FocusOut not working as expected - tix broken? In-Reply-To: <3XZzNd5Z6rzQmM@mail.python.org> References: <3XZzNd5Z6rzQmM@mail.python.org> Message-ID: <20121010113735.91baa50c.klappnase@web.de> Hi, On Mon, 08 Oct 2012 11:09:30 -0000 mkieverpy at tlink.de wrote: (...) > > The other program does not look wrong though. > I think I'll ask at tcl/tk if they think it's a bug. The problem in your first example is the following: def on_focus_out(event): print('focus out') f.focus_set() f.focus_set() f.bind('', on_key) f.bind('', on_focus_out) Now you force the focus when it leaves f immediately back to f - and this is exactly what Tk does : when you hit "Tab" while the "foo" button is focussed the event for f is triggered and so the focus is moved to f again (but *not* to the button and thus not visibly highlighted). Then you hit "tab" again and the focus moves to the "foo"-button again, but does not leave the parent-Frame f and so no event is created. I changed your example a little to help see what's going on: import tkinter root = tkinter.Tk() f = tkinter.Frame(root) f.pack(fill='both', expand=1) tkinter.Button(f, text='foo').pack() f2 = tkinter.Frame(root) f2.pack(fill='both') tkinter.Button(f2, text='bar').pack() def on_key(event): print('key') def on_focus_out(event): print('focus out') f.focus_set() f.focus_set() f.bind('', on_key) f.bind('', on_focus_out) def on_focus_in(event): print('focus in\n') f.bind('', on_focus_in) root.mainloop() On Sun, 07 Oct 2012 18:53:21 -0000 mkieverpy at tlink.de wrote: > The problem is when I use the 'Tab' key to move > the focus. The first 'Tab' moves the focus > to the 'foo' button. 'f' no longer gets key events > but does not get the focus out event either. > The next 'Tab' moves the focus to the 'bar' button, > 'f' gets the focus out event and key events arrive again > after I do 'focus_set'. > So it looks like tk standard behaviour. Can I get what I want? With your example from the previous post the focus will never reach the "bar" button, maybe it was a typo in on_focus_out() and should be f2.focus.set() ? Anyway, I am not sure what exactly you want to achieve (maybe I missed something from your previous posts?), is there a particular reason why not to do nothing about focus handling and just leave it to the WM? Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. We have found all life forms in the galaxy are capable of superior development. -- Kirk, "The Gamesters of Triskelion", stardate 3211.7 From mkieverpy at tlink.de Thu Oct 11 18:20:10 2012 From: mkieverpy at tlink.de (mkieverpy at tlink.de) Date: Thu, 11 Oct 2012 18:20:10 +0200 Subject: [Tkinter-discuss] =?utf-8?q?FocusOut_not_working_as_expected_-_ti?= =?utf-8?q?x_broken=3F?= In-Reply-To: <20121010113735.91baa50c.klappnase@web.de> References: <3XZzNd5Z6rzQmM@mail.python.org> <20121010113735.91baa50c.klappnase@web.de> Message-ID: Hi, On Wed, 10 Oct 2012 11:37:35 +0200, Michael Lange wrote: > (...) >> The problem is when I use the 'Tab' key to move >> the focus. The first 'Tab' moves the focus >> to the 'foo' button. 'f' no longer gets key events >> but does not get the focus out event either. >> The next 'Tab' moves the focus to the 'bar' button, >> 'f' gets the focus out event and key events arrive again >> after I do 'focus_set'. >> So it looks like tk standard behaviour. Can I get what I want? > > With your example from the previous post the focus will never reach > the > "bar" button, maybe it was a typo in on_focus_out() and should be > f2.focus.set() ? > Anyway, I am not sure what exactly you want to achieve (maybe I > missed > something from your previous posts?), is there a particular reason > why not > to do nothing about focus handling and just leave it to the WM? Sorry, to have been unclear here. My main interest is capturing all keyboard input with these lines: ------------------------------ def on_key(event): print('key') f.bind('', on_key) ------------------------------ I want to use this to implement keyboard control for some features. In the case where 'f' has children which can get focus I may loose keyboard input because 'f' won't get notified about FocusOut (lines 2-4 in my above description). In the workaround I use a frame without children. In this case I always get the FocusOut event and can reclaim focus with 'f.focus_set()'. Regards, Matthias Kievernagel From klappnase at web.de Thu Oct 11 19:19:52 2012 From: klappnase at web.de (Michael Lange) Date: Thu, 11 Oct 2012 19:19:52 +0200 Subject: [Tkinter-discuss] FocusOut not working as expected - tix broken? In-Reply-To: References: <3XZzNd5Z6rzQmM@mail.python.org> <20121010113735.91baa50c.klappnase@web.de> Message-ID: <20121011191952.3d80784d.klappnase@web.de> Hi, On Thu, 11 Oct 2012 18:20:10 +0200 mkieverpy at tlink.de wrote: > My main interest is capturing all keyboard input > with these lines: > ------------------------------ > def on_key(event): > print('key') > > f.bind('', on_key) > ------------------------------ > I want to use this to implement keyboard control for some features. > In the case where 'f' has children which can get focus > I may loose keyboard input because 'f' won't get notified > about FocusOut (lines 2-4 in my above description). > In the workaround I use a frame without children. > In this case I always get the FocusOut event and > can reclaim focus with 'f.focus_set()'. I am not sure if I understand correctly what you are trying to achieve; in one my programs there is a window with a couple of keyboard bindings for this and that, there I simply put all the bindings into one method like this: def apply_default_bindings(self, widget): for key in ('KP_Home', 'KP_End', 'KP_Insert', 'KP_Up', 'KP_Left', 'KP_Right', 'KP_Down', 'KP_Next', 'KP_Prior', 'KP_Begin', 'z'): widget.bind('' % key, self.zoom_in_by_key) for key in ('KP_0', 'KP_1', 'KP_2', 'KP_3', 'KP_4', 'KP_5', 'KP_6', 'KP_7', 'KP_8', 'KP_9', 'Z'): widget.bind('' %key, self.zoom_out_by_key) for key in ('Left', 'Right', 'Prior', 'Next', 'Home', 'End'): widget.bind('<%s>' % key, self.scroll_canvas) widget.bind('', self.openfile) widget.bind('', self.stop) widget.bind('', self.play) widget.bind('', self.pause) widget.bind('', self.set_volume) widget.bind('', self.set_volume) widget.bind('', self.setmark) widget.bind('', self.clearmarks) widget.bind('', self.see_next_mark) widget.bind('', self.see_prev_mark) widget.bind('', self.see_cursor) widget.bind('', self.center_cursor) widget.bind('', self.move_cursor) widget.bind('', self.move_cursor) widget.bind('', self.move_cursor) widget.bind('', self.move_cursor) and call this once every widget in the window, which costs a few extra lines, but otoh saves quite some headaches about which widget is focussed. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Leave bigotry in your quarters; there's no room for it on the bridge. -- Kirk, "Balance of Terror", stardate 1709.2 From bryan.oakley at gmail.com Thu Oct 11 19:35:23 2012 From: bryan.oakley at gmail.com (Bryan Oakley) Date: Thu, 11 Oct 2012 12:35:23 -0500 Subject: [Tkinter-discuss] FocusOut not working as expected - tix broken? In-Reply-To: References: <3XZzNd5Z6rzQmM@mail.python.org> <20121010113735.91baa50c.klappnase@web.de> Message-ID: On Thu, Oct 11, 2012 at 11:20 AM, wrote: > Sorry, to have been unclear here. > My main interest is capturing all keyboard input > with these lines: > ------------------------------ > > def on_key(event): > print('key') > > f.bind('', on_key) There are better ways to capture all keyboard input if that's your real goal. Are you aware of the "bind_all" method, which associates a binding with all widgets? Typically this is used for shortcuts, but it can be used any time you want to capture certain events no matter where they occur. Tkinter has the notion of "bind tags" (or bindtags). To this day, no other GUI toolkit has as powerful of a mechanism for managing events; this is truly one of Tkinter's hidden gems. The short version is, you can associate a custom tag to any (or every) widget, and then bind to that tag. Then, no matter what widget has focus, your binding will fire. The advantage this has over "bind_all" is that with the bindtag you can control when the event is processed -- before the actual event, after the actual event, etc. With "bind_all", the "all" bindings by default are processed after event and class level bindings. The practical implication of that is that the widget or class bindings have the option to prevent the event from propagating. With bind tags you can guarantee your bindings fire before any others. I From bryan.oakley at gmail.com Thu Oct 11 19:39:35 2012 From: bryan.oakley at gmail.com (Bryan Oakley) Date: Thu, 11 Oct 2012 12:39:35 -0500 Subject: [Tkinter-discuss] FocusOut not working as expected - tix broken? In-Reply-To: <20121011191952.3d80784d.klappnase@web.de> References: <3XZzNd5Z6rzQmM@mail.python.org> <20121010113735.91baa50c.klappnase@web.de> <20121011191952.3d80784d.klappnase@web.de> Message-ID: On Thu, Oct 11, 2012 at 12:19 PM, Michael Lange wrote: > I am not sure if I understand correctly what you are trying to achieve; > in one my programs there is a window with a couple of keyboard bindings > for this and that, there I simply put all the bindings into one method > like this: > > def apply_default_bindings(self, widget): > ... > and call this once every widget in the window, which > costs a few extra lines, but otoh saves quite some headaches about which > widget is focussed. That's more complicated than it needs to be. I'll give you the same advice as I just gave someone else: are you aware of "bind_all" and Tkinter's bindtags? That is a much cleaner way to implement global bindings IMO. The advantage to "bind_all" is that individual widgets can override the default bindings if they want (eg: if you want control-o to mean something totally different only in one widget, you can). From klappnase at web.de Thu Oct 11 20:23:24 2012 From: klappnase at web.de (Michael Lange) Date: Thu, 11 Oct 2012 20:23:24 +0200 Subject: [Tkinter-discuss] FocusOut not working as expected - tix broken? In-Reply-To: References: <3XZzNd5Z6rzQmM@mail.python.org> <20121010113735.91baa50c.klappnase@web.de> <20121011191952.3d80784d.klappnase@web.de> Message-ID: <20121011202324.f444711a.klappnase@web.de> On Thu, 11 Oct 2012 12:39:35 -0500 Bryan Oakley wrote: > That's more complicated than it needs to be. I'll give you the same > advice as I just gave someone else: are you aware of "bind_all" and > Tkinter's bindtags? That is a much cleaner way to implement global > bindings IMO. The advantage to "bind_all" is that individual widgets > can override the default bindings if they want (eg: if you want > control-o to mean something totally different only in one widget, you > can). It is not certain if we are talking about global bindings however, that depends on the the OP's application. In the case of my example the bindings just apply to the widgets inside one particular container, not globally to all widgets. Then it comes in handy to simply do: for widget in (button1, button2, button3, entry1, spinbox1, spinbox2): apply_default_bindings(widget) That's just three extra lines including the function definition to apply quite a bunch of bindings to all relevant widgets, I don't think this is so awfully complicated ;) There is of course bind_all, as well as bind_class and bindtags or the simple possibility of a custom widget class with extra default bindings. Which one is the best of course depends on what exactly you want to achieve and how the application window is designed. I think global bindings are usually fine for simple window layouts, but for more complex apps with several windows or several containers in one window (e.g. in Tab-like interfaces), custom dialogs etc. you may have to be careful to avoid unwanted effects. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. "Life and death are seldom logical." "But attaining a desired goal always is." -- McCoy and Spock, "The Galileo Seven", stardate 2821.7 From mkieverpy at tlink.de Tue Oct 16 14:42:25 2012 From: mkieverpy at tlink.de (mkieverpy at tlink.de) Date: Tue, 16 Oct 2012 12:42:25 -0000 Subject: [Tkinter-discuss] =?utf-8?q?FocusOut_not_working_as_expected_-_ti?= =?utf-8?q?x_broken=3F?= Message-ID: <3Xgz164djHzRDb@mail.python.org> Hello, thanks for the new hints/information Michael and Bryan. I don't know if your hints would work in my setup, though. Except bind_all, which should work, I guess. My program structure: I have a Frame, which is nearly the complete toplevel window (only a title label and quit button outside; this is the Frame I originally tried to let capture all the keys). The left half is taken by a tix Tree and the right half contains one of a few editor classes (subclassed from Frame) which get exchanged based on the selected Tree node. One type of nodes opens a Canvas in the right half where I want the key shortcuts to work. The problem I see with both your hints (bind keys to all widgets, tag widgets and bind keys to tag) is I doubt they will work with tix Tree. I don't think tix Tree hands down any bind or tag to its subwidgets (or does it?). Thanks again, Matthias Kievernagel From klappnase at web.de Tue Oct 16 20:03:40 2012 From: klappnase at web.de (Michael Lange) Date: Tue, 16 Oct 2012 20:03:40 +0200 Subject: [Tkinter-discuss] FocusOut not working as expected - tix broken? In-Reply-To: <3Xgz164djHzRDb@mail.python.org> References: <3Xgz164djHzRDb@mail.python.org> Message-ID: <20121016200340.2ccefc67.klappnase@web.de> Hi, On Tue, 16 Oct 2012 12:42:25 -0000 mkieverpy at tlink.de wrote: > The problem I see with both your hints (bind keys to all widgets, > tag widgets and bind keys to tag) is I doubt they will work with tix > Tree. I don't think tix Tree hands down any bind or tag to > its subwidgets (or does it?). Why not simply try it: import tkinter from tkinter import tix root = tix.Tk() t = tix.Tree(root) t.pack(side='left') l = tkinter.Listbox(root) l.pack(side='right') def on_key(event): print(str(event.widget) + ' received key event: ' + event.keysym) root.bind_all('', on_key, add=True) root.mainloop() Here this works as expected. You can even use a DirTree instead of a Tree and you will see that keyboard navigation through the tree still works fine. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Vulcans do not approve of violence. -- Spock, "Journey to Babel", stardate 3842.4 From psimon at sonic.net Mon Oct 22 00:31:06 2012 From: psimon at sonic.net (Paul Simon) Date: Sun, 21 Oct 2012 15:31:06 -0700 Subject: [Tkinter-discuss] loop delay Message-ID: I' m a novice python programmer and now starting to learn tkinter for a front and db back end to replace an application written MS Access/VBA. The following program doesn't work as I expected as data is not written to the text box until the def is exited. If I include a print statement with the increment it is printed. Any suggestions are welcome. from Tkinter import * from time import sleep def count (event): #while n < 2: for n in range(2): print str(n) text_button.insert(2.0, str(n)) sleep (2) root = Tk() root.geometry("300x300+10+10") frame = Frame(root,bg="red", width=100,height=100) text_button = Text(frame,fg ="green",bg="blue",height=1,width=7) text_button.bind("",count) text_button.pack(side=LEFT) quit_button = Button(frame, text="QUIT",fg="red", command=root.destroy) quit_button.pack(side=LEFT) frame.pack() root.mainloop() ------------------------------- Paul Simon From raycores at gmail.com Mon Oct 22 04:17:07 2012 From: raycores at gmail.com (Lynn Oliver) Date: Sun, 21 Oct 2012 19:17:07 -0700 Subject: [Tkinter-discuss] loop delay In-Reply-To: References: Message-ID: <7BF8A3B5-45A3-499C-89C8-34F1EC25103A@gmail.com> Maybe the idle loop needs to run so things get done. Try calling update_idletasks(). Be nice to have some indents... Lynn On Oct 21, 2012, at 3:31 PM, Paul Simon wrote: > I' m a novice python programmer and now starting to learn tkinter for a > front and db back end to replace an application written MS Access/VBA. The > following program doesn't work as I expected as data is not written to the > text box until the def is exited. If I include a print statement with the > increment it is printed. > > Any suggestions are welcome. > > from Tkinter import * > > from time import sleep > > def count (event): > > #while n < 2: > > for n in range(2): > > print str(n) > > text_button.insert(2.0, str(n)) > > sleep (2) > > > root = Tk() > > root.geometry("300x300+10+10") > > frame = Frame(root,bg="red", width=100,height=100) > > text_button = Text(frame,fg ="green",bg="blue",height=1,width=7) > > text_button.bind("",count) > > text_button.pack(side=LEFT) > > quit_button = Button(frame, text="QUIT",fg="red", command=root.destroy) > > quit_button.pack(side=LEFT) > > frame.pack() > > root.mainloop() > > ------------------------------- > > Paul Simon > > > > _______________________________________________ > 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: From psimon at sonic.net Mon Oct 22 05:39:59 2012 From: psimon at sonic.net (Paul Simon) Date: Sun, 21 Oct 2012 20:39:59 -0700 Subject: [Tkinter-discuss] loop delay References: <7BF8A3B5-45A3-499C-89C8-34F1EC25103A@gmail.com> Message-ID: Thank you! Just what I was looking for and will have to re-read the documentation. Sorry about the indents: Copying from linux to windows sometimes does some strange things and although I tried to fix it... Paul "Lynn Oliver" wrote in message news:7BF8A3B5-45A3-499C-89C8-34F1EC25103A at gmail.com... Maybe the idle loop needs to run so things get done. Try calling update_idletasks(). Be nice to have some indents... Lynn On Oct 21, 2012, at 3:31 PM, Paul Simon wrote: I' m a novice python programmer and now starting to learn tkinter for a front and db back end to replace an application written MS Access/VBA. The following program doesn't work as I expected as data is not written to the text box until the def is exited. If I include a print statement with the increment it is printed. Any suggestions are welcome. from Tkinter import * from time import sleep def count (event): #while n < 2: for n in range(2): print str(n) text_button.insert(2.0, str(n)) sleep (2) root = Tk() root.geometry("300x300+10+10") frame = Frame(root,bg="red", width=100,height=100) text_button = Text(frame,fg ="green",bg="blue",height=1,width=7) text_button.bind("",count) text_button.pack(side=LEFT) quit_button = Button(frame, text="QUIT",fg="red", command=root.destroy) quit_button.pack(side=LEFT) frame.pack() root.mainloop() ------------------------------- Paul Simon _______________________________________________ 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From raycores at gmail.com Mon Oct 22 06:02:41 2012 From: raycores at gmail.com (Lynn Oliver) Date: Sun, 21 Oct 2012 21:02:41 -0700 Subject: [Tkinter-discuss] loop delay In-Reply-To: References: <7BF8A3B5-45A3-499C-89C8-34F1EC25103A@gmail.com> Message-ID: <6275F90B-41E4-4E35-9BAA-AFA2B9BB71F3@gmail.com> My experience, which admittedly is limited, has been that a lot of the ins and outs are not well documented. For my current program I went through three iterations of the UI: the first when I found out about validators; the second when I learned how to use trace functions; and (hopefully) the last when I realized I could just bind the key_up events and do everything I needed right there. On Oct 21, 2012, at 8:39 PM, "Paul Simon" wrote: > Thank you! Just what I was looking for and will have to re-read the documentation. Sorry about the indents: Copying from linux to windows sometimes does some strange things and although I tried to fix it... > > Paul > "Lynn Oliver" wrote in message news:7BF8A3B5-45A3-499C-89C8-34F1EC25103A at gmail.com... > Maybe the idle loop needs to run so things get done. Try calling update_idletasks(). Be nice to have some indents... > > Lynn > > On Oct 21, 2012, at 3:31 PM, Paul Simon wrote: > >> I' m a novice python programmer and now starting to learn tkinter for a >> front and db back end to replace an application written MS Access/VBA. The >> following program doesn't work as I expected as data is not written to the >> text box until the def is exited. If I include a print statement with the >> increment it is printed. >> >> Any suggestions are welcome. >> >> from Tkinter import * >> >> from time import sleep >> >> def count (event): >> >> #while n < 2: >> >> for n in range(2): >> >> print str(n) >> >> text_button.insert(2.0, str(n)) >> >> sleep (2) >> >> >> root = Tk() >> >> root.geometry("300x300+10+10") >> >> frame = Frame(root,bg="red", width=100,height=100) >> >> text_button = Text(frame,fg ="green",bg="blue",height=1,width=7) >> >> text_button.bind("",count) >> >> text_button.pack(side=LEFT) >> >> quit_button = Button(frame, text="QUIT",fg="red", command=root.destroy) >> >> quit_button.pack(side=LEFT) >> >> frame.pack() >> >> root.mainloop() >> >> ------------------------------- >> >> Paul Simon >> >> >> >> _______________________________________________ >> 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 > _______________________________________________ > 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: From bryan.oakley at gmail.com Mon Oct 22 13:13:07 2012 From: bryan.oakley at gmail.com (Bryan Oakley) Date: Mon, 22 Oct 2012 06:13:07 -0500 Subject: [Tkinter-discuss] loop delay In-Reply-To: References: Message-ID: On Sun, Oct 21, 2012 at 5:31 PM, Paul Simon wrote: > I' m a novice python programmer and now starting to learn tkinter for a > front and db back end to replace an application written MS Access/VBA. The > following program doesn't work as I expected as data is not written to the > text box until the def is exited. If I include a print statement with the > increment it is printed. > > Any suggestions are welcome. The crux of the matter is this: the windows are (re)drawn in response to events which instruct them to redraw themselves. The only way that can happen is if the event loop is running. When you have a loop in your code, while that loop is running the event loop is _not_ running. This is especially bad if you put a sleep in your code, because that causes the entire GUI to freeze. As a rule of thumb you should never, ever use sleep in a GUI. The quick fix for your problem is to add a call to `update_idletasks` in your loop. Why `update_idletasks` instead of `update`? Because the redrawing of windows is considered an "idle" task -- it is a class of event that Tk will service when it is otherwise idle. That, and calling `update` is potentially dangerous since it effectively creates a new event loop nested inside the current event loop. However, that's just a hack. The better solution is to architect your code differently. If you have a long running process you should consider running it in a separate thread or separate process. Even better, if you can divide your work up into small chunks you can set it up so that each chunk can be run during one iteration of the event loop. You can request that Tkinter execute something during a future iteration of the event loop with the `after` method. Typically you do this with a function that does one chunk of work. It then checks to see if there are any more chunks (by checking a flag, or a list of data to be processed, etc) . If it finds there is more work to do it uses itself as an argument to `after`, with a delay of a few ms. That way, each time the event loop loops, it does one chunk of your processing. No threads, no processes, no sleeps. If you want to see an example of a countdown timer using this technique see http://stackoverflow.com/a/10599462/7432 From psimon at sonic.net Thu Oct 25 01:37:49 2012 From: psimon at sonic.net (Paul Simon) Date: Wed, 24 Oct 2012 16:37:49 -0700 Subject: [Tkinter-discuss] loop delay References: Message-ID: Thanks very much for your response. What I wrote is just a very simple script to familiarize myself with tkinter. I'm making a lot of mistakes and so learning a lot :-) The "sleep" command is in there so I can just see if the write loop is running, using the "sleep" for the delay. I'm still working on figuring out widget placement. The entire program is a replacement of a MS Access app written in VBA, and requires three parts. A gui (tkinter), data access using the serial port with RS-485, and a simple database using sqlite. The latter two pieces work, sort of, and am now working on the gui. The RS-485 interface needs the sleep command or a do-while loop to wait for hardware turn around due to the absence of hand shake in the serial interface. I would be happy to keep you guys informed of my slow process ("life interferes") if you wish. You can see the current implementation on my web site, www.gophergulch.net under "temperature." Paul "Bryan Oakley" wrote in message news:CAKypQny33xJ=w_Ti7CZyA4axopx+wxAh5ZO+qjFvLuGr_Ytsmw at mail.gmail.com... > On Sun, Oct 21, 2012 at 5:31 PM, Paul Simon wrote: >> I' m a novice python programmer and now starting to learn tkinter for a >> front and db back end to replace an application written MS Access/VBA. >> The >> following program doesn't work as I expected as data is not written to >> the >> text box until the def is exited. If I include a print statement with >> the >> increment it is printed. >> >> Any suggestions are welcome. > > The crux of the matter is this: the windows are (re)drawn in response > to events which instruct them to redraw themselves. The only way that > can happen is if the event loop is running. > > When you have a loop in your code, while that loop is running the > event loop is _not_ running. This is especially bad if you put a sleep > in your code, because that causes the entire GUI to freeze. As a rule > of thumb you should never, ever use sleep in a GUI. > > The quick fix for your problem is to add a call to `update_idletasks` > in your loop. Why `update_idletasks` instead of `update`? Because the > redrawing of windows is considered an "idle" task -- it is a class of > event that Tk will service when it is otherwise idle. That, and > calling `update` is potentially dangerous since it effectively creates > a new event loop nested inside the current event loop. > > However, that's just a hack. The better solution is to architect your > code differently. If you have a long running process you should > consider running it in a separate thread or separate process. Even > better, if you can divide your work up into small chunks you can set > it up so that each chunk can be run during one iteration of the event > loop. You can request that Tkinter execute something during a future > iteration of the event loop with the `after` method. > > Typically you do this with a function that does one chunk of work. It > then checks to see if there are any more chunks (by checking a flag, > or a list of data to be processed, etc) . If it finds there is more > work to do it uses itself as an argument to `after`, with a delay of a > few ms. That way, each time the event loop loops, it does one chunk of > your processing. No threads, no processes, no sleeps. > > If you want to see an example of a countdown timer using this > technique see http://stackoverflow.com/a/10599462/7432 From rowen at uw.edu Thu Oct 25 18:15:53 2012 From: rowen at uw.edu (Russell E. Owen) Date: Thu, 25 Oct 2012 09:15:53 -0700 Subject: [Tkinter-discuss] Checkbutton indicatoron ignored on Mac Message-ID: I just realized that the Checkbutton option "indicatoron" is being ignored on Mac OS X: the checkbox is always shown, even if indicatoron is false. I'm using ActiveState's Tcl/Tk 8.5.11, specifically: ActiveTcl8.5.11.1.295590-macosx10.5-i386-x86_64-threaded Has anyone else noticed this, and is there a workaround? It ruins the appearance of a lot of my application. I see that ActiveState now has version 8.5.12 available and I'll give that a try. Anyone know how reliable that is on Mac OS X? I've seen warnings of bugs, but I don't know if they were fixed in time for that release. -- Russell From nad at acm.org Thu Oct 25 23:40:16 2012 From: nad at acm.org (Ned Deily) Date: Thu, 25 Oct 2012 14:40:16 -0700 Subject: [Tkinter-discuss] Checkbutton indicatoron ignored on Mac References: Message-ID: In article , "Russell E. Owen" wrote: > I just realized that the Checkbutton option "indicatoron" is being > ignored on Mac OS X: the checkbox is always shown, even if indicatoron > is false. > > I'm using ActiveState's Tcl/Tk 8.5.11, specifically: > ActiveTcl8.5.11.1.295590-macosx10.5-i386-x86_64-threaded > > Has anyone else noticed this, and is there a workaround? It ruins the > appearance of a lot of my application. > > I see that ActiveState now has version 8.5.12 available and I'll give > that a try. Anyone know how reliable that is on Mac OS X? I've seen > warnings of bugs, but I don't know if they were fixed in time for that > release. Specifically with regard to using ActiveTcl 8.5.x with Python on OS X, there are some bugs fixed in 8.5.12.0 and 8.5.12.1; however there are at least two serious regressions that exist in 8.5.12.1. One is a Tk crash when attempting to open IDLE's Preferences menu: there is now a patch for all current versions of IDLE that works around the problem. Second is a Tk crash when using the clipboard copy command. That problem apparently has been fixed in the top-of-trunk of Cocoa Tk 8.5 (which was formerly a separate branch but has now been merged into the main Tk 8.5 support branch) subsequent to the release of ActiveTk 8.5.12.1. If either of these problems might affect your use, I would recommend staying with ActiveTcl 8.5.11.1 for the time being. http://www.python.org/download/mac/tcltk/ -- Ned Deily, nad at acm.org From kw at codebykevin.com Fri Oct 26 00:53:28 2012 From: kw at codebykevin.com (Kevin Walzer) Date: Thu, 25 Oct 2012 18:53:28 -0400 Subject: [Tkinter-discuss] Checkbutton indicatoron ignored on Mac In-Reply-To: References: Message-ID: <5089C2E8.6060307@codebykevin.com> On 10/25/12 12:15 PM, Russell E. Owen wrote: > I just realized that the Checkbutton option "indicatoron" is being > ignored on Mac OS X: the checkbox is always shown, even if indicatoron > is false. Can you post a script sample that illustrates the problem? -- Kevin Walzer Code by Kevin http://www.codebykevin.com From rowen at uw.edu Mon Oct 29 21:39:27 2012 From: rowen at uw.edu (Russell E. Owen) Date: Mon, 29 Oct 2012 13:39:27 -0700 Subject: [Tkinter-discuss] Checkbutton indicatoron ignored on Mac References: <5089C2E8.6060307@codebykevin.com> Message-ID: In article <5089C2E8.6060307 at codebykevin.com>, Kevin Walzer wrote: > On 10/25/12 12:15 PM, Russell E. Owen wrote: > > I just realized that the Checkbutton option "indicatoron" is being > > ignored on Mac OS X: the checkbox is always shown, even if indicatoron > > is false. > > Can you post a script sample that illustrates the problem? import Tkinter root = Tkinter.Tk() b = Tkinter.Checkbutton(root, text="Foo", indicatoron=False) b.pack() It also shows up in tcl (e.g. paste this into wish): checkbutton .b -text "Foo" -indicatoron 0 pack .b Note that I have been unable to avoid the bug. Any checkbutton I make with indicatoron false still shows the checkbox. Worse, "width" is applied as if it the checkbox was NOT there, so the width is far too short in that situation. My code had plenty of examples. It really messed up my app, though I've been able to work around the worst cases by changing the GUI to stop using indicatoron=False. I'm not sure when this first showed up. Until recently I only ever released 32-bit versions, which use ActiveState 8.4.19 and don't show the problem. -- Russell P.S. While we're on MacOS X bugs, here's another which I also reported to the Tcl/Tk project: the width of tk_menubutton is wrong on MacOS X (too narrow by several characters). Here's tcl code for that: tk_optionMenu .om omVar DC1 DC2 DC3 .om configure -width 3 # -indicatoron 0 pack .om I use wrapper classes for most Tcl/Tk widgets, including OptionMenu, so my workaround for this is to simply add 3 to width if a user specifies width on MacOS X. From rowen at uw.edu Mon Oct 29 21:40:20 2012 From: rowen at uw.edu (Russell E. Owen) Date: Mon, 29 Oct 2012 13:40:20 -0700 Subject: [Tkinter-discuss] Checkbutton indicatoron ignored on Mac References: Message-ID: In article , Ned Deily wrote: > In article , > "Russell E. Owen" wrote: > > > I just realized that the Checkbutton option "indicatoron" is being > > ignored on Mac OS X: the checkbox is always shown, even if indicatoron > > is false. > > > > I'm using ActiveState's Tcl/Tk 8.5.11, specifically: > > ActiveTcl8.5.11.1.295590-macosx10.5-i386-x86_64-threaded > > > > Has anyone else noticed this, and is there a workaround? It ruins the > > appearance of a lot of my application. > > > > I see that ActiveState now has version 8.5.12 available and I'll give > > that a try. Anyone know how reliable that is on Mac OS X? I've seen > > warnings of bugs, but I don't know if they were fixed in time for that > > release. > > Specifically with regard to using ActiveTcl 8.5.x with Python on OS X, > there are some bugs fixed in 8.5.12.0 and 8.5.12.1; however there are at > least two serious regressions that exist in 8.5.12.1. One is a Tk crash > when attempting to open IDLE's Preferences menu: there is now a patch > for all current versions of IDLE that works around the problem. Second > is a Tk crash when using the clipboard copy command. That problem > apparently has been fixed in the top-of-trunk of Cocoa Tk 8.5 (which was > formerly a separate branch but has now been merged into the main Tk 8.5 > support branch) subsequent to the release of ActiveTk 8.5.12.1. If > either of these problems might affect your use, I would recommend > staying with ActiveTcl 8.5.11.1 for the time being. > > http://www.python.org/download/mac/tcltk/ Thank you very much! Sounds safest to stick with 8.5.11.1 -- Russell From kw at codebykevin.com Tue Oct 30 16:23:15 2012 From: kw at codebykevin.com (Kevin Walzer) Date: Tue, 30 Oct 2012 11:23:15 -0400 Subject: [Tkinter-discuss] Checkbutton indicatoron ignored on Mac In-Reply-To: References: <5089C2E8.6060307@codebykevin.com> Message-ID: <508FF0E3.5080000@codebykevin.com> On 10/29/12 4:39 PM, Russell E. Owen wrote: > > It also shows up in tcl (e.g. paste this into wish): > checkbutton .b -text "Foo" -indicatoron 0 > pack .b I see the difference here between Tk-Cocoa and 8.4/Carbon. Cocoa does indeed ignore the -indicatoron flag. Not sure yet if this is a bug that can be fixed or not, but I'll take a closer look at the underlying code. > > P.S. While we're on MacOS X bugs, here's another which I also reported > to the Tcl/Tk project: the width of tk_menubutton is wrong on MacOS X > (too narrow by several characters). Here's tcl code for that: > > tk_optionMenu .om omVar DC1 DC2 DC3 > .om configure -width 3 # -indicatoron 0 > pack .om I see the clipping here, but that can be avoided by adding -fill both -expand yes to the config flags when the menu button is packed. This is probably a function of how Cocoa handles metrics and it may not be something that can be fixed, but I'll see what I can find. --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From rowen at uw.edu Tue Oct 30 21:16:31 2012 From: rowen at uw.edu (Russell E. Owen) Date: Tue, 30 Oct 2012 13:16:31 -0700 Subject: [Tkinter-discuss] Checkbutton indicatoron ignored on Mac References: <5089C2E8.6060307@codebykevin.com> <508FF0E3.5080000@codebykevin.com> Message-ID: In article <508FF0E3.5080000 at codebykevin.com>, Kevin Walzer wrote: > On 10/29/12 4:39 PM, Russell E. Owen wrote: > > > > > It also shows up in tcl (e.g. paste this into wish): > > checkbutton .b -text "Foo" -indicatoron 0 > > pack .b > > I see the difference here between Tk-Cocoa and 8.4/Carbon. Cocoa does > indeed ignore the -indicatoron flag. Not sure yet if this is a bug that > can be fixed or not, but I'll take a closer look at the underlying code. Thank you. As another, possibly irrelevant datapoint: the themed checkbutton widget does not have the indicatoron option. So I figure I'd better get used to not using that option, but it's a pity: I find bi-state buttons very useful. > > P.S. While we're on MacOS X bugs, here's another which I also reported > > to the Tcl/Tk project: the width of tk_menubutton is wrong on MacOS X > > (too narrow by several characters). Here's tcl code for that: > > > > tk_optionMenu .om omVar DC1 DC2 DC3 > > .om configure -width 3 # -indicatoron 0 > > pack .om > > I see the clipping here, but that can be avoided by adding -fill both > -expand yes to the config flags when the menu button is packed. This is > probably a function of how Cocoa handles metrics and it may not be > something that can be fixed, but I'll see what I can find. I'm not sure I understand; you are talking about the way the menubutton is packed inside the tk_optionMenu widget? Is this something I could control in Tkinter? -- Russell From klappnase at web.de Wed Oct 31 10:31:44 2012 From: klappnase at web.de (Michael Lange) Date: Wed, 31 Oct 2012 10:31:44 +0100 Subject: [Tkinter-discuss] Checkbutton indicatoron ignored on Mac In-Reply-To: References: <5089C2E8.6060307@codebykevin.com> <508FF0E3.5080000@codebykevin.com> Message-ID: <20121031103144.23e9374a.klappnase@web.de> Hi, On Tue, 30 Oct 2012 13:16:31 -0700 "Russell E. Owen" wrote: > In article <508FF0E3.5080000 at codebykevin.com>, > Kevin Walzer wrote: > > > On 10/29/12 4:39 PM, Russell E. Owen wrote: > > > > > > > > It also shows up in tcl (e.g. paste this into wish): > > > checkbutton .b -text "Foo" -indicatoron 0 > > > pack .b > > > > I see the difference here between Tk-Cocoa and 8.4/Carbon. Cocoa does > > indeed ignore the -indicatoron flag. Not sure yet if this is a bug > > that can be fixed or not, but I'll take a closer look at the > > underlying code. > > Thank you. > > As another, possibly irrelevant datapoint: the themed checkbutton > widget does not have the indicatoron option. So I figure I'd better get > used to not using that option, but it's a pity: I find bi-state buttons > very useful. in ttk you can use style='Toolbutton' instead, see http://wiki.tcl.tk/17899 Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. "Life and death are seldom logical." "But attaining a desired goal always is." -- McCoy and Spock, "The Galileo Seven", stardate 2821.7 From kw at codebykevin.com Wed Oct 31 16:15:25 2012 From: kw at codebykevin.com (Kevin Walzer) Date: Wed, 31 Oct 2012 11:15:25 -0400 Subject: [Tkinter-discuss] Checkbutton indicatoron ignored on Mac In-Reply-To: References: <5089C2E8.6060307@codebykevin.com> <508FF0E3.5080000@codebykevin.com> Message-ID: <5091408D.8010704@codebykevin.com> On 10/30/12 4:16 PM, Russell E. Owen wrote: > In article <508FF0E3.5080000 at codebykevin.com>, > Kevin Walzer wrote: > >> On 10/29/12 4:39 PM, Russell E. Owen wrote: >> >>> >>> It also shows up in tcl (e.g. paste this into wish): >>> checkbutton .b -text "Foo" -indicatoron 0 >>> pack .b >> >> I see the difference here between Tk-Cocoa and 8.4/Carbon. Cocoa does >> indeed ignore the -indicatoron flag. Not sure yet if this is a bug that >> can be fixed or not, but I'll take a closer look at the underlying code. > > Thank you. After looking at the code that implements the checkbutton, it appears that, internally, it is mapped to a specific Cocoa button style (NSSwitchButton) that does not allow us to turn off the checkmark. I suppose we'll have to add this to the list of Tk configuration flags that are ignored in certain contexts when Mac-native widgets are used (background, relief, etc.). >>> P.S. While we're on MacOS X bugs, here's another which I also reported >>> to the Tcl/Tk project: the width of tk_menubutton is wrong on MacOS X >>> (too narrow by several characters). Here's tcl code for that: >>> >>> tk_optionMenu .om omVar DC1 DC2 DC3 >>> .om configure -width 3 # -indicatoron 0 >>> pack .om >> >> I see the clipping here, but that can be avoided by adding -fill both >> -expand yes to the config flags when the menu button is packed. This is >> probably a function of how Cocoa handles metrics and it may not be >> something that can be fixed, but I'll see what I can find. > > I'm not sure I understand; you are talking about the way the menubutton > is packed inside the tk_optionMenu widget? Is this something I could > control in Tkinter? > om.pack(fill='both', expand='yes') --Kevin