From dkgiesen at frontiernet.net Wed Feb 3 03:53:29 2010 From: dkgiesen at frontiernet.net (Dave and Kerrie Giesen) Date: Tue, 02 Feb 2010 21:53:29 -0500 Subject: [Tkinter-discuss] Swapping 2 widgets btween 2 cells in a grid-layout In-Reply-To: <27347924.post@talk.nabble.com> References: <27347924.post@talk.nabble.com> Message-ID: <4B68E529.5000506@frontiernet.net> You should be able to do something like the following: # initial grid label1.grid(row=0, column=0) label2.grid(row=1, column=0) # remove the labels from the grid so that they forget their original location label1.grid_forget() label2.grid_forget() # Put the labels back but switched label2.grid(row=0, column=0) label1.grid(row=1, column=0) Dave GKalman wrote: > I would like to swap the (grid cell) positions of 2 label-widgets (in an > array of widgets) in response to a mouse-event. (I have no trouble swapping > variables, but can't do it with widgets). Any suggestions or references > would be appreciated. > > > From teh_sh_meister at yahoo.com Tue Feb 9 02:38:18 2010 From: teh_sh_meister at yahoo.com (Nemes Andrei) Date: Mon, 8 Feb 2010 17:38:18 -0800 (PST) Subject: [Tkinter-discuss] menu bug Message-ID: <751343.96453.qm@web59914.mail.ac4.yahoo.com> Hi! I am trying to make a menu that uses small icons as well as text, but when I open the main menu, the icon in the pull down menu is not correctly displayed until I hoover over it. Could someone please be so kind to tell me what's wrong and how can I solve this. Image with error attached (or viewable at http://img11.imageshack.us/img11/9429/bugft.jpg) Thank you. menu code: #building icon set self.info=PhotoImage(file="gui/information.gif") #menu init self.myMenu=Menu(self) #help menu self.menu_help=Menu(self.myMenu, tearoff=0) self.menu_help.add_command(label="Credits ", command=mda) self.menu_help.add_command(label="About "+name, image=self.info, compound="left", command=mda) self.myMenu.add_cascade(label="Help", menu=self.menu_help) #show menu bar self.config(menu=self.myMenu) Kind regards, Andrei Nemes -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: bug.jpg Type: image/jpeg Size: 6171 bytes Desc: not available URL: From lionkimbro at gmail.com Tue Feb 9 21:44:44 2010 From: lionkimbro at gmail.com (Lion Kimbro) Date: Tue, 9 Feb 2010 12:44:44 -0800 Subject: [Tkinter-discuss] menu bug In-Reply-To: <751343.96453.qm@web59914.mail.ac4.yahoo.com> References: <751343.96453.qm@web59914.mail.ac4.yahoo.com> Message-ID: <497072fd1002091244k6423adebo1e7e06505d549699@mail.gmail.com> I have no idea, but would making the image slightly larger, (perhaps workable programmatically,) work as a work-around? On Mon, Feb 8, 2010 at 5:38 PM, Nemes Andrei wrote: > Hi! > I am trying to make a menu that uses small icons as well as text, but when > I open the main menu, the icon in the pull down menu is not correctly > displayed until I hoover over it. Could someone please be so kind to tell me > what's wrong and how can I solve this. Image with error attached (or > viewable at http://img11.imageshack.us/img11/9429/bugft.jpg) > Thank you. > > menu code: > #building icon set > self.info=PhotoImage(file="gui/information.gif") > > #menu init > self.myMenu=Menu(self) > > #help menu > self.menu_help=Menu(self.myMenu, tearoff=0) > self.menu_help.add_command(label="Credits ", command=mda) > self.menu_help.add_command(label="About "+name, image=self.info, > compound="left", command=mda) > self.myMenu.add_cascade(label="Help", menu=self.menu_help) > > #show menu bar > self.config(menu=self.myMenu) > > Kind regards, > Andrei Nemes > > > _______________________________________________ > 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 jmcmonagle at velseis.com Wed Feb 10 00:16:16 2010 From: jmcmonagle at velseis.com (John McMonagle) Date: Wed, 10 Feb 2010 09:16:16 +1000 Subject: [Tkinter-discuss] {Possible_Spam} menu bug In-Reply-To: <751343.96453.qm@web59914.mail.ac4.yahoo.com> References: <751343.96453.qm@web59914.mail.ac4.yahoo.com> Message-ID: <4B71ECC0.6080700@velseis.com.au> Nemes Andrei wrote: > Hi! > I am trying to make a menu that uses small icons as well as text, but > when I open the main menu, the icon in the pull down menu is not > correctly displayed until I hoover over it. Could someone please be so > kind to tell me what's wrong and how can I solve this. Image with error > attached (or viewable at http://img11.imageshack.us/img11/9429/bugft.jpg) > Thank you. It works correctly on my setup. tcl/tk 8.4.15 python 2.5.1 openSuse 10.3 kde 3.5.7 Regards, John From sierra_mtnview at sbcglobal.net Thu Feb 11 00:14:23 2010 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Wed, 10 Feb 2010 15:14:23 -0800 Subject: [Tkinter-discuss] Exiting a Tkinter Program-- An Anomaly or two Message-ID: <4B733DCF.4050605@sbcglobal.net> I'm looking a 1800+ line someone else wrote. It uses one large dialog for menus, and has a large area for images. A few menus open small dialogs, for example, to enter a file name. The File menu has an exit choice. The only other exit is the x in the upper right corner of the large dialog. I'm pretty sure that menu is coded to quit via a short def in the program. def Quit(self) self.running = False self.master.quit() I see no other code to quit. If I use Exit(menu item), the program does not quit. If I then use the x, it quits and the shell script is left open for a command. Any ideas why Quit doesn't work in the first case? It's accessible via a self.mainMenu.add_command(.. command=self.Quit) I had not turned the program loose by using a menu or touching any controls. If I cause the program to print to the shell, and then use x to exit that it hangs the shell. Why? When I x the shell, it tells me the prog is running." Do I want to kill it?" Yes, kills the shell window. The above seems abnormal to me. Comments? -- "Crime is way down. War is declining. And that's far from the good news." -- Steven Pinker (and other sources) Why is this true, but yet the media says otherwise? The media knows very well how to manipulate us (see limbic, emotion, $$). -- WTW From kw at codebykevin.com Thu Feb 11 03:07:01 2010 From: kw at codebykevin.com (Kevin Walzer) Date: Wed, 10 Feb 2010 21:07:01 -0500 Subject: [Tkinter-discuss] Exiting a Tkinter Program-- An Anomaly or two In-Reply-To: <4B733DCF.4050605@sbcglobal.net> References: <4B733DCF.4050605@sbcglobal.net> Message-ID: <4B736645.8090309@codebykevin.com> On 2/10/10 6:14 PM, Wayne Watson wrote: > > def Quit(self) > self.running = False > self.master.quit() > > If you change self.master.quit() to sys.exit(), what happens? (Also make sure that "import sys" is somewhere in the code.) -- Kevin Walzer Code by Kevin http://www.codebykevin.com From sierra_mtnview at sbcglobal.net Thu Feb 11 05:33:09 2010 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Wed, 10 Feb 2010 20:33:09 -0800 Subject: [Tkinter-discuss] Exiting a Tkinter Program-- An Anomaly or two In-Reply-To: <4B736645.8090309@codebykevin.com> References: <4B733DCF.4050605@sbcglobal.net> <4B736645.8090309@codebykevin.com> Message-ID: <4B738885.3060603@sbcglobal.net> I get the small dialog "Do you want to exit altogether?". I press yes. The shell and program windows close. If I say no, then I get error messages in the shell followed by a command prompt. The program continues to operate. Well, this isn't bad, but it probably changes how I want to print to the shell. If I exit this way, the shell closes and the user can't inspect the output any further. Probably, I need to print to a text window instead. I have no idea if it will close to with the exit. It seems likely. If yes,then I need to write the text fo a file. On 2/10/2010 6:07 PM, Kevin Walzer wrote: > On 2/10/10 6:14 PM, Wayne Watson wrote: >> >> def Quit(self) >> self.running = False >> self.master.quit() >> >> > > If you change self.master.quit() to sys.exit(), what happens? > > (Also make sure that "import sys" is somewhere in the code.) > -- "Crime is way down. War is declining. And that's far from the good news." -- Steven Pinker (and other sources) Why is this true, but yet the media says otherwise? The media knows very well how to manipulate us (see limbic, emotion, $$). -- WTW From sierra_mtnview at sbcglobal.net Thu Feb 11 22:18:15 2010 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Thu, 11 Feb 2010 13:18:15 -0800 Subject: [Tkinter-discuss] Exiting a Tkinter Program-- An Anomaly or two In-Reply-To: <791153ba1002111054m4187c028yb9394082d0a24b17@mail.gmail.com> References: <4B733DCF.4050605@sbcglobal.net> <791153ba1002111054m4187c028yb9394082d0a24b17@mail.gmail.com> Message-ID: <4B747417.9080207@sbcglobal.net> An HTML attachment was scrubbed... URL: From sierra_mtnview at sbcglobal.net Sat Feb 13 02:00:18 2010 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Fri, 12 Feb 2010 17:00:18 -0800 Subject: [Tkinter-discuss] Exiting a Tkinter Program-- An Anomaly or two In-Reply-To: <791153ba1002111427p4c83f16fo6ff2eed9161bfd0a@mail.gmail.com> References: <4B733DCF.4050605@sbcglobal.net> <791153ba1002111054m4187c028yb9394082d0a24b17@mail.gmail.com> <4B747417.9080207@sbcglobal.net> <791153ba1002111427p4c83f16fo6ff2eed9161bfd0a@mail.gmail.com> Message-ID: <4B75F9A2.7060004@sbcglobal.net> An HTML attachment was scrubbed... URL: From klappnase at web.de Sat Feb 13 12:25:31 2010 From: klappnase at web.de (Michael Lange) Date: Sat, 13 Feb 2010 12:25:31 +0100 Subject: [Tkinter-discuss] Exiting a Tkinter Program-- An Anomaly or two In-Reply-To: <4B75F9A2.7060004@sbcglobal.net> References: <4B733DCF.4050605@sbcglobal.net> <791153ba1002111054m4187c028yb9394082d0a24b17@mail.gmail.com> <4B747417.9080207@sbcglobal.net> <791153ba1002111427p4c83f16fo6ff2eed9161bfd0a@mail.gmail.com> <4B75F9A2.7060004@sbcglobal.net> Message-ID: <20100213122531.16020358.klappnase@web.de> Hi, On Fri, 12 Feb 2010 17:00:18 -0800 Wayne Watson wrote: > I have no qualms about sending you the code. The code by itself would > not be executable though unless I provide several files. The critical > ones are a jpg, which is used to fill the initial display area, and > two others that have to do with color and making a movie. A minimum > of two data files may be needed, but I suspect they could be skipped. > If they are necessary, then it's a simple matter of creating an > Events folder and putting them there. The py and extra files need to > in the same folder. It runs in Py 2.5. I guess the data files would > be useful in the case where one might test the exit when data is > viewed. I think I found the same results. Just a guess: you say the program "is making a movie", so maybe the program uses threads and a child thread is still running when you quit the program ? Regards Michael From noses at fatronik.com Wed Feb 17 16:41:47 2010 From: noses at fatronik.com (Noelia Oses) Date: Wed, 17 Feb 2010 16:41:47 +0100 Subject: [Tkinter-discuss] How to configure the non-default Python version to work with tk Message-ID: <712D9F513C825F46998CF3810BBA68E30155C2E0@ntexchange.fatronik.com> Hi all, I have a very newby question. I'm using a computer with Ubuntu Karmic Koala. The Ubuntu has python 2.6 installed by default, and this default installation includes tkinter. However, I'm using a platform (NuPIC) that needs Python 2.5. This I had to install manually in /usr/local. Unfortunately, the manually installed version that I need doesn't seem to be able to find the tkinter libraries. I have tried with "sudo apt-get install python2.5-tk" but it doesn't install it as it notices there is a newer version already. The error message that I get is: noses at PCF-191-0907l:~/NuPIC/current/share/projects/bitworm$ python DisplayReport.py Traceback (most recent call last): File "DisplayReport.py", line 18, in from pylab import * File "/home/noses/NuPIC/current/lib/python2.5/site-packages/pylab.py", line 1, in from matplotlib.pylab import * File "/home/noses/NuPIC/current/lib/python2.5/site-packages/matplotlib/pylab.py", line 253, in from matplotlib.pyplot import * File "/home/noses/NuPIC/current/lib/python2.5/site-packages/matplotlib/pyplot.py", line 75, in new_figure_manager, draw_if_interactive, show = pylab_setup() File "/home/noses/NuPIC/current/lib/python2.5/site-packages/matplotlib/backends/__init__.py", line 25, in pylab_setup globals(),locals(),[backend_name]) File "/home/noses/NuPIC/current/lib/python2.5/site-packages/matplotlib/backends/backend_tkagg.py", line 7, in import Tkinter as Tk, FileDialog File "/usr/local/lib/python2.5/lib-tk/Tkinter.py", line 38, in import _tkinter # If this fails your Python may not be configured for Tk ImportError: No module named _tkinter Any help figuring this out is very much appreciated!! Best regards, Noelia -------------- next part -------------- An HTML attachment was scrubbed... URL: From waynejwerner at gmail.com Wed Feb 17 17:10:21 2010 From: waynejwerner at gmail.com (Wayne Werner) Date: Wed, 17 Feb 2010 10:10:21 -0600 Subject: [Tkinter-discuss] How to configure the non-default Python version to work with tk In-Reply-To: <712D9F513C825F46998CF3810BBA68E30155C2E0@ntexchange.fatronik.com> References: <712D9F513C825F46998CF3810BBA68E30155C2E0@ntexchange.fatronik.com> Message-ID: <333efb451002170810w485aa380g632642252c6cf7b1@mail.gmail.com> On Wed, Feb 17, 2010 at 9:41 AM, Noelia Oses wrote: > > Hi all, > > I have a very newby question. > I'm using a computer with Ubuntu Karmic Koala. > The Ubuntu has python 2.6 installed by default, and this default > installation includes tkinter. > > However, I'm using a platform (NuPIC) that needs Python 2.5. This I had to > install manually in /usr/local. > Unfortunately, the manually installed version that I need doesn't seem to > be able to find the tkinter libraries. > > I have tried with "sudo apt-get install python2.5-tk" but it doesn't > install it as it notices there is a newer version already. > > try that with the --reinstall flag. it should at least go ahead and try to install it. HTH, wayne -------------- next part -------------- An HTML attachment was scrubbed... URL: From timj at tolisgroup.com Wed Feb 17 17:12:31 2010 From: timj at tolisgroup.com (Tim Jones) Date: Wed, 17 Feb 2010 09:12:31 -0700 Subject: [Tkinter-discuss] How to configure the non-default Python version to work with tk In-Reply-To: <712D9F513C825F46998CF3810BBA68E30155C2E0@ntexchange.fatronik.com> References: <712D9F513C825F46998CF3810BBA68E30155C2E0@ntexchange.fatronik.com> Message-ID: <5FB6BBA9-55B3-437C-8B3F-10C4DC23FF81@tolisgroup.com> On Feb 17, 2010, at 8:41 AM, Noelia Oses wrote: > Hi all, > > I have a very newby question. > I'm using a computer with Ubuntu Karmic Koala. > The Ubuntu has python 2.6 installed by default, and this default installation includes tkinter. > > However, I'm using a platform (NuPIC) that needs Python 2.5. This I had to install manually in /usr/local. > Unfortunately, the manually installed version that I need doesn't seem to be able to find the tkinter libraries. > > I have tried with "sudo apt-get install python2.5-tk" but it doesn't install it as it notices there is a newer version already. Unfortunately, I suspect that your only option will be to physically build your own Python / TKInter pair from sources, specifying the --prefix=/usr/local argument to config if you want to keep the default 2.6 version installed. The versions in the apt repositories all expect you to want the latest version or to be able to remove a newer version in deference to the older version. The odd thing is, you should be able to have multiple versions of Python installed without conflict, so it appears that the package makers didn't take that into account. HTH, Tim From noses at fatronik.com Wed Feb 17 17:22:18 2010 From: noses at fatronik.com (Noelia Oses) Date: Wed, 17 Feb 2010 17:22:18 +0100 Subject: [Tkinter-discuss] How to configure the non-default Pythonversion to work with tk References: <712D9F513C825F46998CF3810BBA68E30155C2E0@ntexchange.fatronik.com> <5FB6BBA9-55B3-437C-8B3F-10C4DC23FF81@tolisgroup.com> Message-ID: <712D9F513C825F46998CF3810BBA68E30155C2E2@ntexchange.fatronik.com> Thanks guys! Actually, I managed to fix it by installing tcl and tk dev versions and then reinstalling python2.5. I'm so relieved!!! Best regards, Noelia -----Original Message----- From: tkinter-discuss-bounces+noses=fatronik.com at python.org on behalf of Tim Jones Sent: Wed 2/17/2010 17:12 To: tkinter-discuss at python.org Subject: Re: [Tkinter-discuss] How to configure the non-default Pythonversion to work with tk On Feb 17, 2010, at 8:41 AM, Noelia Oses wrote: > Hi all, > > I have a very newby question. > I'm using a computer with Ubuntu Karmic Koala. > The Ubuntu has python 2.6 installed by default, and this default installation includes tkinter. > > However, I'm using a platform (NuPIC) that needs Python 2.5. This I had to install manually in /usr/local. > Unfortunately, the manually installed version that I need doesn't seem to be able to find the tkinter libraries. > > I have tried with "sudo apt-get install python2.5-tk" but it doesn't install it as it notices there is a newer version already. Unfortunately, I suspect that your only option will be to physically build your own Python / TKInter pair from sources, specifying the --prefix=/usr/local argument to config if you want to keep the default 2.6 version installed. The versions in the apt repositories all expect you to want the latest version or to be able to remove a newer version in deference to the older version. The odd thing is, you should be able to have multiple versions of Python installed without conflict, so it appears that the package makers didn't take that into account. HTH, Tim _______________________________________________ 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 sarah.nason at utoronto.ca Wed Feb 24 18:44:55 2010 From: sarah.nason at utoronto.ca (sarah.nason at utoronto.ca) Date: Wed, 24 Feb 2010 12:44:55 -0500 Subject: [Tkinter-discuss] TkAqua issue: are threaded Python applications still possible on OS X? Message-ID: <20100224124455.jtz3qfpfk04goggo@webmail.utoronto.ca> Hallo, For the last few weeks, I've been trying to fix a problem with the OS X port of a program I'm working on, PyGraphics; since I've had no luck, I'm here in search of your expertise. PyGraphics is a multithreaded module designed to be imported into and used in computer science students' programs. It works fine on Windows and Linux, and it used to function on OS X, too - but the release of Snow Leopard put an end to that. TkAqua does not permit mainloop() to be run on background threads, and since Wing (the IDE of choice for my university) is running the application, all threads related to PyGraphics are background threads by definition. Has anyone found any workarounds for this problem? I've looked into TkX11, and have recompiled Tcl/Tk with the --disable-aqua and --with-x configuration options, but that didn't help. There is a suggestion that the version of Python that ships with Snow Leopard doesn't play well with that version of Tk, but I've not found much documentation to confirm or deny that possibility. Right now, the most viable option appears to be rewriting the program to offer an unthreaded version to Mac students, but that's just sad. Any ideas? Thanks in advance! -- Sarah Nason From sarah.nason at utoronto.ca Wed Feb 24 18:44:34 2010 From: sarah.nason at utoronto.ca (sarah.nason at utoronto.ca) Date: Wed, 24 Feb 2010 12:44:34 -0500 Subject: [Tkinter-discuss] TkAqua issue: are threaded Python applications still possible on OS X? Message-ID: <20100224124434.xg2hdsp3sgssc8wg@webmail.utoronto.ca> Hallo, For the last few weeks, I've been trying to fix a problem with the OS X port of a program I'm working on, PyGraphics; since I've had no luck, I'm here in search of your expertise. PyGraphics is a multithreaded module designed to be imported into and used in computer science students' programs. It works fine on Windows and Linux, and it used to function on OS X, too - but the release of Snow Leopard put an end to that. TkAqua does not permit mainloop() to be run on background threads, and since Wing (the IDE of choice for my university) is running the application, all threads related to PyGraphics are background threads by definition. Has anyone found any workarounds for this problem? I've looked into TkX11, and have recompiled Tcl/Tk with the --disable-aqua and --with-x configuration options, but that didn't help. There is a suggestion that the version of Python that ships with Snow Leopard doesn't play well with that version of Tk, but I've not found much documentation to confirm or deny that possibility. Right now, the most viable option appears to be rewriting the program to offer an unthreaded version to Mac students, but that's just sad. Any ideas? Thanks in advance! -- Sarah Nason From bob at passcal.nmt.edu Thu Feb 25 01:15:34 2010 From: bob at passcal.nmt.edu (Bob Greschke) Date: Wed, 24 Feb 2010 17:15:34 -0700 Subject: [Tkinter-discuss] Kind of the old intercept the Entry() tab key question Message-ID: <1522940D-8582-42F8-8ACB-9735A44A7EE1@passcal.nmt.edu> I know this must have been handled before (but I can find no evidence of it), but what I want to do is have an entry field for filespecs (path+filename) that is on the same 'form' with other entry fields and I want the user to be able to use the Tab key to get to the field (so takefocus needs to be 1). When the field has the focus if what is in the field (i.e. the StringVar) does not match any filename (or path) when the Tab key is pressed I just want the program to beep and the cursor to stay in the field. If what is in there can be completed to match a filename (or path) then the contents gets completed when the Tab is pressed and the cursor stays in the field. If what is in the field already matches a filename (or path) then the Tab key press goes on to the next field as it usually would for other Entry fields. Is this possible? At this point I'm still not having much luck just getting the cursor to stay put after a Tab press, and using return "break" in the handler doesn't seem to be doing anything (I've only ever gotten the "break" thing to work once a long time ago, but then didn't use it, and I can't remember how I got it to work). Thanks! Bob From klappnase at web.de Thu Feb 25 11:52:20 2010 From: klappnase at web.de (Michael Lange) Date: Thu, 25 Feb 2010 11:52:20 +0100 Subject: [Tkinter-discuss] Kind of the old intercept the Entry() tab key question In-Reply-To: <1522940D-8582-42F8-8ACB-9735A44A7EE1@passcal.nmt.edu> References: <1522940D-8582-42F8-8ACB-9735A44A7EE1@passcal.nmt.edu> Message-ID: <20100225115220.e56e80e4.klappnase@web.de> Hi Bob, On Wed, 24 Feb 2010 17:15:34 -0700 Bob Greschke wrote: > I know this must have been handled before (but I can find no evidence > of it), but what I want to do is have an entry field for filespecs > (path+filename) that is on the same 'form' with other entry fields > and I want the user to be able to use the Tab key to get to the field > (so takefocus needs to be 1). > > When the field has the focus if what is in the field (i.e. the > StringVar) does not match any filename (or path) when the Tab key is > pressed I just want the program to beep and the cursor to stay in the > field. > > If what is in there can be completed to match a filename (or path) > then the contents gets completed when the Tab is pressed and the > cursor stays in the field. > > If what is in the field already matches a filename (or path) then the > Tab key press goes on to the next field as it usually would for other > Entry fields. > > Is this possible? At this point I'm still not having much luck just > getting the cursor to stay put after a Tab press, and using return > "break" in the handler doesn't seem to be doing anything (I've > only ever gotten the "break" thing to work once a long time ago, but > then didn't use it, and I can't remember how I got it to work). > Maybe you should rather use the Focus-Out event: import Tkinter root = Tkinter.Tk() e = Tkinter.Entry(root) e.pack(padx=100, pady=50) def focus_out(event): if e.get() != 'foo': e.bell() e.focus_set() e.bind('', focus_out) b = Tkinter.Button(root, text='quit', command=root.destroy) b.pack(padx=100, pady=50) b.focus_set() root.mainloop() Alternatively you can try the Entry's validatecommand, however this is a little tricky, because you need percent substitutions: import Tkinter root = Tkinter.Tk() e = Tkinter.Entry(root) e.pack(padx=100, pady=50) def validate(s): if s != 'foo': return 0 return 1 def invcmd(): e.bell() e.focus_set() vcmd = (e.register(validate), '%P') e.configure(vcmd=vcmd, validate='focusout', invcmd=invcmd) b = Tkinter.Button(root, text='quit', command=root.destroy) b.pack(padx=100, pady=50) b.focus_set() root.mainloop() I hope this helps! Michael From Cameron at phaseit.net Thu Feb 25 14:28:52 2010 From: Cameron at phaseit.net (Cameron Laird) Date: Thu, 25 Feb 2010 13:28:52 +0000 Subject: [Tkinter-discuss] TkAqua issue: are threaded Python applications still possible on OS X? In-Reply-To: <20100224124455.jtz3qfpfk04goggo@webmail.utoronto.ca> References: <20100224124455.jtz3qfpfk04goggo@webmail.utoronto.ca> Message-ID: <20100225132852.GA21547@lairds.us> On Wed, Feb 24, 2010 at 12:44:55PM -0500, sarah.nason at utoronto.ca wrote: . . . > For the last few weeks, I've been trying to fix a problem with the OS > X port of a program I'm working on, PyGraphics; since I've had no > luck, I'm here in search of your expertise. > > PyGraphics is a multithreaded module designed to be imported into and > used in computer science students' programs. It works fine on Windows > and Linux, and it used to function on OS X, too - but the release of > Snow Leopard put an end to that. TkAqua does not permit mainloop() to > be run on background threads, and since Wing (the IDE of choice for my > university) is running the application, all threads related to > PyGraphics are background threads by definition. > > Has anyone found any workarounds for this problem? I've looked into > TkX11, and have recompiled Tcl/Tk with the --disable-aqua and --with-x > configuration options, but that didn't help. There is a suggestion > that the version of Python that ships with Snow Leopard doesn't play > well with that version of Tk, but I've not found much documentation to > confirm or deny that possibility. Right now, the most viable option > appears to be rewriting the program to offer an unthreaded version to > Mac students, but that's just sad. . . . I chatted a bit with Jeff Hobbes about this. We all agree that Snow Leopard has symptoms. In rough terms, they have to do with interfaces; on its own, the Cocoa-based, fully-64-bit Tk is alleged to pass all pertinent tests. Summary advice: ".... try ActiveTcl with local python, or ActivePython ..." My impression: this is a solvable problem, but someone might do well to enlist explicitly the engagement of the ActivePython specialists at ActiveTcl. From Cameron at phaseit.net Thu Feb 25 14:44:56 2010 From: Cameron at phaseit.net (Cameron Laird) Date: Thu, 25 Feb 2010 13:44:56 +0000 Subject: [Tkinter-discuss] TkAqua issue: are threaded Python applications still possible on OS X? In-Reply-To: <20100225132852.GA21547@lairds.us> References: <20100224124455.jtz3qfpfk04goggo@webmail.utoronto.ca> <20100225132852.GA21547@lairds.us> Message-ID: <20100225134456.GA23807@lairds.us> On Thu, Feb 25, 2010 at 01:28:52PM +0000, Cameron Laird wrote: > . > . > . > I chatted a bit with Jeff Hobbes about this. We all agree that . . . Hobbs. Not "Hobbes". That's a particularly inexcusable and misleading typo, for which I apologize. From bob at passcal.nmt.edu Thu Feb 25 18:32:10 2010 From: bob at passcal.nmt.edu (Bob Greschke) Date: Thu, 25 Feb 2010 10:32:10 -0700 Subject: [Tkinter-discuss] Kind of the old intercept the Entry() tab key question In-Reply-To: <20100225115220.e56e80e4.klappnase@web.de> References: <1522940D-8582-42F8-8ACB-9735A44A7EE1@passcal.nmt.edu> <20100225115220.e56e80e4.klappnase@web.de> Message-ID: <43669B06-D441-4351-B444-2D46CD658A2A@passcal.nmt.edu> On Feb 25, 2010, at 03:52, Michael Lange wrote: > Hi Bob, > > On Wed, 24 Feb 2010 17:15:34 -0700 > Bob Greschke wrote: > >> I know this must have been handled before (but I can find no evidence >> of it), but what I want to do is have an entry field for filespecs >> (path+filename) that is on the same 'form' with other entry fields >> and I want the user to be able to use the Tab key to get to the field >> (so takefocus needs to be 1). >> >> When the field has the focus if what is in the field (i.e. the >> StringVar) does not match any filename (or path) when the Tab key is >> pressed I just want the program to beep and the cursor to stay in the >> field. >> >> If what is in there can be completed to match a filename (or path) >> then the contents gets completed when the Tab is pressed and the >> cursor stays in the field. >> >> If what is in the field already matches a filename (or path) then the >> Tab key press goes on to the next field as it usually would for other >> Entry fields. >> >> Is this possible? At this point I'm still not having much luck just >> getting the cursor to stay put after a Tab press, and using return >> "break" in the handler doesn't seem to be doing anything (I've >> only ever gotten the "break" thing to work once a long time ago, but >> then didn't use it, and I can't remember how I got it to work). >> > > Maybe you should rather use the Focus-Out event: > > import Tkinter > root = Tkinter.Tk() > e = Tkinter.Entry(root) > e.pack(padx=100, pady=50) > > def focus_out(event): > if e.get() != 'foo': > e.bell() > e.focus_set() > e.bind('', focus_out) > > b = Tkinter.Button(root, text='quit', command=root.destroy) > b.pack(padx=100, pady=50) > b.focus_set() > root.mainloop() > > Alternatively you can try the Entry's validatecommand, however this is > a little tricky, because you need percent substitutions: > > import Tkinter > root = Tkinter.Tk() > e = Tkinter.Entry(root) > e.pack(padx=100, pady=50) > > def validate(s): > if s != 'foo': > return 0 > return 1 > > def invcmd(): > e.bell() > e.focus_set() > > vcmd = (e.register(validate), '%P') > e.configure(vcmd=vcmd, validate='focusout', invcmd=invcmd) > > b = Tkinter.Button(root, text='quit', command=root.destroy) > b.pack(padx=100, pady=50) > b.focus_set() > root.mainloop() > > > I hope this helps! > > Michael Nice. They did help, thanks! After sleeping on it I think I'm going to go with a completely non-standard 'use the Return key' for doing this, instead of the Tab key. These are just in-house, only used by scientist-types programs, so not using the Tab key won't be a big problem. On top of that just tabbing through one of these field could potentially result in making the handler collect and look through literally 1000's (or 10's of 1000's) of file names, and that could cause a significant pause, so you'll really only want it to happen when the user really asks for it. I didn't know about the validation stuff for regular Entry fields. I only knew about that for PMW entry fields. Great! Thanks! Bob From geoff.bache at gmail.com Fri Feb 26 21:13:59 2010 From: geoff.bache at gmail.com (Geoff Bache) Date: Fri, 26 Feb 2010 21:13:59 +0100 Subject: [Tkinter-discuss] ANN: PyUseCase 3.2 - GUI testing for Tkinter (and PyGTK) Message-ID: <6e9920951002261213q25e25dc3he49234646a8706ef@mail.gmail.com> Hi all, Thought I'd announce that I've finally released my GUI testing effort for Tkinter. (If you don't want announcements here, please let me know and I'll desist.) As you'll gather if you read my previous postings I've been trying to get Tkinter support into PyUseCase (which has been a PyGTK-only tool up until now) and I've now made a release of my efforts, available from sourceforge (link below). At this point Tkinter support is fairly basic and doesn't come close to covering the widget set, but it's working on a couple of different "real-life" (but smallish) applications. The widgets it will currently handle interaction with are Button, Entry, Label, Menu, Tk, Toplevel and tkMessageBox. Adding support for further widgets shouldn't be too hard. If anyone's interested in trying to move this forward, I'd be interested to here from you - I'm very happy to help people get started. Regards, Geoff Bache A bit more detail: PyUseCase is an unconventional GUI testing tool for PyGTK and Tkinter, along with a framework for testing Python GUIs in general. Instead of recording GUI mechanics directly, it asks the user for descriptive names and hence builds up a "domain language" along with a "UI map file" that translates this language into actions on the current GUI widgets. The point is to reduce coupling, allow very expressive tests, and ensure that GUI changes mean changing the UI map file but not all the tests. Instead of an "assertion" mechanism, it auto-generates a log of the GUI appearance and changes to it. The point is then to use that as a baseline for text-based testing, using e.g. TextTest. It also includes support for instrumenting code so that "waits" can be recorded, making it far easier for a tester to record correctly synchronized tests without having to explicitly plan for this. Homepage: http://www.texttest.org/index.php?page=ui_testing Download: http://sourceforge.net/projects/pyusecase Mailing list: https://lists.sourceforge.net/lists/listinfo/pyusecase-users (new) Bugs: https://bugs.launchpad.net/pyusecase/ Source: https://code.launchpad.net/pyusecase/