From o.lenstra at gmail.com Sun Nov 2 13:34:53 2008 From: o.lenstra at gmail.com (Olrik Lenstra) Date: Sun, 2 Nov 2008 13:34:53 +0100 Subject: [Tkinter-discuss] Fwd: WxPython -> Tkinter In-Reply-To: <3c8f6fd70810290723u561ed191s31dec5b9ad9f7213@mail.gmail.com> References: <3c8f6fd70810282252o166d438fhbf8460233be21a89@mail.gmail.com> <3c8f6fd70810290649madf53e2q1fcc1acd21f6bfff@mail.gmail.com> <3c8f6fd70810290723u561ed191s31dec5b9ad9f7213@mail.gmail.com> Message-ID: <3c8f6fd70811020434o7749cd80we7d7d980ac9c039e@mail.gmail.com> Hmm, I'm a bit stumped. I installed the ttk module and tried applying the code. However when I ran my code it gave me an error. I thought I might have left a small typo in or something and removed the code to check my own. After I removed the ttk import and code it wouldn't even run my own code again. Below is the Traceback: C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik>python TSO.pyw Traceback (most recent call last): File "TSO.pyw", line 24, in import TSOmain File "C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik\TSOmain.pyw", line 79, in TSO() File "C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik\TSOmain.pyw", line 37, in TSO root = Tk.Tk() File "D:\Python25\lib\lib-tk\Tkinter.py", line 1638, in __init__ self._loadtk() File "D:\Python25\lib\site-packages\ttk.py", line 50, in _wrapper self.tk.eval('package require tile') # TclError may be raised here _tkinter.TclError: can't find package tile C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik> Regards, Olrik 2008/10/29 Olrik Lenstra : > So that means that you will use a ttk frame instead of the Tkinter.Frame? > I'll see if I can get this working once I get home. (my program is on my > Desktop and I just do some testing on my laptop) > > Thanks a lot so far! > Regards, > Olrik > > 2008/10/29 Guilherme Polo >> >> On 10/29/08, Olrik Lenstra wrote: >> > I see, Thanks a lot, I really don't wish to bother you any further, but >> > here's my current situation. >> > I am still a beginning programmer and I am not entirely sure where to >> > put >> > this code exactly. >> > >> > How would I go about using this code? >> > >> >> It should be very similar to what you are already doing in wx. >> >> But, you would need to layout your toplevel (the one that is created >> when you call Tkinter.Tk()) as this: >> >> There would be a ttk.Frame that would hold all the other widgets, >> which should be all ttk widgets according to this sample. Then you >> would call safe_yield(frame, True) in the same situations you would in >> wx. Now it remains to check if there is the same need for this in tk >> as there is in wx. >> >> Finally, a sample way to layout the widgets: >> >> root = Tkinter.Tk() >> frame = ttk.Frame(root) >> btn1 = ttk.Button(frame, text="Button 1") >> ... >> ... some time later: >> safe_yield(frame, True) >> ... >> >> > Thank you so much in advance. >> > Regards, >> > Olrik >> > >> > 2008/10/29 Guilherme Polo >> > >> > > >> > > >> > > >> > > ---------- Forwarded message ---------- >> > > From: Guilherme Polo >> > > Date: Oct 29, 2008 9:16 AM >> > > Subject: Re: [Tkinter-discuss] WxPython -> Tkinter >> > > To: Olrik Lenstra >> > > Cc: python-list at python.org >> > > >> > > >> > > On 10/29/08, Olrik Lenstra wrote: >> > > > Hello everyone, >> > > > >> > > > A while ago I joined the Tutor mailing list, and they helped me out >> > with a >> > > > question regarding wxPython. >> > > > Now however, I have tried a program in Tkinter and I would like to >> > > see >> > if >> > > > there is a similar command to "wx.SafeYield(self, True)". >> > > >> > > >> > > It will be a combination of commands, not a single one. Initially I >> > > considered this as "probably without solution", since tcl acquired a >> > > yield command just in the 8.6a3 release, but then I looked at >> > > wx.SafeYield code and apparently it is possible to replicate it. >> > > >> > > Here is an initial cut, it is very possible to contain something not >> > > equivalent to wx.SafeYield (besides it could be improved): >> > > >> > > >> > > import ttk >> > > >> > > inside_tkyield = False >> > > disabled_wins = {} >> > > >> > > def safe_yield(window, only_if_needed=False): >> > > window_disabler(window) >> > > >> > > try: >> > > return tk_yield(window, only_if_needed) >> > > finally: >> > > for widget, flags in disabled_wins.iteritems(): >> > > ttk.Widget.state(widget, flags) >> > > disabled_wins.clear() >> > > >> > > >> > > def window_disabler(window): >> > > widgets = window.children.values() >> > > widgets.append(window) >> > > >> > > for widget in widgets: >> > > if widget.instate(['!disabled']): >> > > prev_flags = widget.state(['disabled']) >> > > disabled_wins[widget] = prev_flags >> > > >> > > >> > > def tk_yield(window, only_if_needed=False): >> > > # wx implements this differently based on the backend it is using >> > > global inside_tkyield >> > > if inside_tkyield: >> > > if not only_if_needed: >> > > raise RuntimeError("safe_yield called recursively") >> > > >> > > return False >> > > >> > > inside_tkyield = True; >> > > >> > > window.update() >> > > window.update_idletasks() >> > > >> > > inside_tkyield = False; >> > > >> > > return True >> > > >> > > >> > > Note that this depends on ttk widgets >> > > (http://pypi.python.org/pypi/pyttk) since it uses >> > widget.state to >> > > disable and reenable the widgets. On windows the "wm" command >> > > supports >> > > disabling the entire window, so it is easier if you can use it. >> > > >> > > [Forwarded because I sent to the wrong list first time] >> > > >> > > >> > > > Below is a copy of the message to the tutor list. >> > > > >> > > > > Dear Mailing list, >> > > > > >> > > > > a while ago a few of you helped me solve an issue I had with a >> > > GUI / >> > scan >> > > > > program that I made. >> > > > > The problem was that when I tried to move the frame it would hang >> > until >> > > > the >> > > > > scan was finished. >> > > > > To solve this I had to add "wx.SafeYield(self, True)" to the scan >> > > and >> > the >> > > > > GUI wouldn't hang any more. >> > > > > Now I have redone the program and have written it with Tkinter >> > instead of >> > > > > WxPython. >> > > > > >> > > > > So is there a similar command for Tkinter as there is for >> > > WxPython? >> > > > > >> > > > > Thanks in advance. >> > > > > Regards, >> > > > > Olrik >> > > > > >> > > > >> > > >> > > > _______________________________________________ >> > > > Tkinter-discuss mailing list >> > > > Tkinter-discuss at python.org >> > > > >> > http://mail.python.org/mailman/listinfo/tkinter-discuss >> > > > >> > > > >> > > >> > > >> > > >> > > -- >> > > -- Guilherme H. Polo Goncalves >> > > >> > > >> > > -- >> > > -- Guilherme H. Polo Goncalves >> > > >> > > >> > > >> > > _______________________________________________ >> > > Tkinter-discuss mailing list >> > > Tkinter-discuss at python.org >> > > >> > http://mail.python.org/mailman/listinfo/tkinter-discuss >> > > >> > >> > >> >> >> -- >> -- Guilherme H. Polo Goncalves > > From ggpolo at gmail.com Sun Nov 2 14:06:41 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Sun, 2 Nov 2008 11:06:41 -0200 Subject: [Tkinter-discuss] Fwd: WxPython -> Tkinter In-Reply-To: <3c8f6fd70811020434o7749cd80we7d7d980ac9c039e@mail.gmail.com> References: <3c8f6fd70810282252o166d438fhbf8460233be21a89@mail.gmail.com> <3c8f6fd70810290649madf53e2q1fcc1acd21f6bfff@mail.gmail.com> <3c8f6fd70810290723u561ed191s31dec5b9ad9f7213@mail.gmail.com> <3c8f6fd70811020434o7749cd80we7d7d980ac9c039e@mail.gmail.com> Message-ID: On Sun, Nov 2, 2008 at 10:34 AM, Olrik Lenstra wrote: > Hmm, I'm a bit stumped. > I installed the ttk module and tried applying the code. > However when I ran my code it gave me an error. > I thought I might have left a small typo in or something and removed > the code to check my own. > > After I removed the ttk import and code it wouldn't even run my own code again. > Below is the Traceback: > > C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik>python TSO.pyw > Traceback (most recent call last): > File "TSO.pyw", line 24, in > import TSOmain > File "C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik\TSOmain.pyw", line > 79, in > TSO() > File "C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik\TSOmain.pyw", line > 37, in TSO > root = Tk.Tk() > File "D:\Python25\lib\lib-tk\Tkinter.py", line 1638, in __init__ > self._loadtk() > File "D:\Python25\lib\site-packages\ttk.py", line 50, in _wrapper > self.tk.eval('package require tile') # TclError may be raised here > _tkinter.TclError: can't find package tile > You don't have tile installed neither was your tkinter compiled against tcl/tk 8.5. Python 2.6 already brings tcl/tk 8.5 and tkinter compiled against them. Another option is to download tile from: http://sourceforge.net/project/showfiles.php?group_id=11464&package_id=107795 (get the tile082.zip so you have to do nothing at all). Then unpack that somewhere. Then you have to set the environment variable TILE_LIBRARY to the directory where this was unpacked, then you should be able to run the program with ttk. You could set this environment var inside your app too: import os os.environ['TILE_LIBRARY'] = 'x:/unpacked/tile/here' import ttk .... > C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik> > > > Regards, > Olrik > > 2008/10/29 Olrik Lenstra : >> So that means that you will use a ttk frame instead of the Tkinter.Frame? >> I'll see if I can get this working once I get home. (my program is on my >> Desktop and I just do some testing on my laptop) >> >> Thanks a lot so far! >> Regards, >> Olrik >> >> 2008/10/29 Guilherme Polo >>> >>> On 10/29/08, Olrik Lenstra wrote: >>> > I see, Thanks a lot, I really don't wish to bother you any further, but >>> > here's my current situation. >>> > I am still a beginning programmer and I am not entirely sure where to >>> > put >>> > this code exactly. >>> > >>> > How would I go about using this code? >>> > >>> >>> It should be very similar to what you are already doing in wx. >>> >>> But, you would need to layout your toplevel (the one that is created >>> when you call Tkinter.Tk()) as this: >>> >>> There would be a ttk.Frame that would hold all the other widgets, >>> which should be all ttk widgets according to this sample. Then you >>> would call safe_yield(frame, True) in the same situations you would in >>> wx. Now it remains to check if there is the same need for this in tk >>> as there is in wx. >>> >>> Finally, a sample way to layout the widgets: >>> >>> root = Tkinter.Tk() >>> frame = ttk.Frame(root) >>> btn1 = ttk.Button(frame, text="Button 1") >>> ... >>> ... some time later: >>> safe_yield(frame, True) >>> ... >>> >>> > Thank you so much in advance. >>> > Regards, >>> > Olrik >>> > >>> > 2008/10/29 Guilherme Polo >>> > >>> > > >>> > > >>> > > >>> > > ---------- Forwarded message ---------- >>> > > From: Guilherme Polo >>> > > Date: Oct 29, 2008 9:16 AM >>> > > Subject: Re: [Tkinter-discuss] WxPython -> Tkinter >>> > > To: Olrik Lenstra >>> > > Cc: python-list at python.org >>> > > >>> > > >>> > > On 10/29/08, Olrik Lenstra wrote: >>> > > > Hello everyone, >>> > > > >>> > > > A while ago I joined the Tutor mailing list, and they helped me out >>> > with a >>> > > > question regarding wxPython. >>> > > > Now however, I have tried a program in Tkinter and I would like to >>> > > see >>> > if >>> > > > there is a similar command to "wx.SafeYield(self, True)". >>> > > >>> > > >>> > > It will be a combination of commands, not a single one. Initially I >>> > > considered this as "probably without solution", since tcl acquired a >>> > > yield command just in the 8.6a3 release, but then I looked at >>> > > wx.SafeYield code and apparently it is possible to replicate it. >>> > > >>> > > Here is an initial cut, it is very possible to contain something not >>> > > equivalent to wx.SafeYield (besides it could be improved): >>> > > >>> > > >>> > > import ttk >>> > > >>> > > inside_tkyield = False >>> > > disabled_wins = {} >>> > > >>> > > def safe_yield(window, only_if_needed=False): >>> > > window_disabler(window) >>> > > >>> > > try: >>> > > return tk_yield(window, only_if_needed) >>> > > finally: >>> > > for widget, flags in disabled_wins.iteritems(): >>> > > ttk.Widget.state(widget, flags) >>> > > disabled_wins.clear() >>> > > >>> > > >>> > > def window_disabler(window): >>> > > widgets = window.children.values() >>> > > widgets.append(window) >>> > > >>> > > for widget in widgets: >>> > > if widget.instate(['!disabled']): >>> > > prev_flags = widget.state(['disabled']) >>> > > disabled_wins[widget] = prev_flags >>> > > >>> > > >>> > > def tk_yield(window, only_if_needed=False): >>> > > # wx implements this differently based on the backend it is using >>> > > global inside_tkyield >>> > > if inside_tkyield: >>> > > if not only_if_needed: >>> > > raise RuntimeError("safe_yield called recursively") >>> > > >>> > > return False >>> > > >>> > > inside_tkyield = True; >>> > > >>> > > window.update() >>> > > window.update_idletasks() >>> > > >>> > > inside_tkyield = False; >>> > > >>> > > return True >>> > > >>> > > >>> > > Note that this depends on ttk widgets >>> > > (http://pypi.python.org/pypi/pyttk) since it uses >>> > widget.state to >>> > > disable and reenable the widgets. On windows the "wm" command >>> > > supports >>> > > disabling the entire window, so it is easier if you can use it. >>> > > >>> > > [Forwarded because I sent to the wrong list first time] >>> > > >>> > > >>> > > > Below is a copy of the message to the tutor list. >>> > > > >>> > > > > Dear Mailing list, >>> > > > > >>> > > > > a while ago a few of you helped me solve an issue I had with a >>> > > GUI / >>> > scan >>> > > > > program that I made. >>> > > > > The problem was that when I tried to move the frame it would hang >>> > until >>> > > > the >>> > > > > scan was finished. >>> > > > > To solve this I had to add "wx.SafeYield(self, True)" to the scan >>> > > and >>> > the >>> > > > > GUI wouldn't hang any more. >>> > > > > Now I have redone the program and have written it with Tkinter >>> > instead of >>> > > > > WxPython. >>> > > > > >>> > > > > So is there a similar command for Tkinter as there is for >>> > > WxPython? >>> > > > > >>> > > > > Thanks in advance. >>> > > > > Regards, >>> > > > > Olrik >>> > > > > >>> > > > >>> > > >>> > > > _______________________________________________ >>> > > > Tkinter-discuss mailing list >>> > > > Tkinter-discuss at python.org >>> > > > >>> > http://mail.python.org/mailman/listinfo/tkinter-discuss >>> > > > >>> > > > >>> > > >>> > > >>> > > >>> > > -- >>> > > -- Guilherme H. Polo Goncalves >>> > > >>> > > >>> > > -- >>> > > -- Guilherme H. Polo Goncalves >>> > > >>> > > >>> > > >>> > > _______________________________________________ >>> > > Tkinter-discuss mailing list >>> > > Tkinter-discuss at python.org >>> > > >>> > http://mail.python.org/mailman/listinfo/tkinter-discuss >>> > > >>> > >>> > >>> >>> >>> -- >>> -- Guilherme H. Polo Goncalves >> >> > -- -- Guilherme H. Polo Goncalves From o.lenstra at gmail.com Sun Nov 2 15:34:16 2008 From: o.lenstra at gmail.com (Olrik Lenstra) Date: Sun, 2 Nov 2008 15:34:16 +0100 Subject: [Tkinter-discuss] Fwd: WxPython -> Tkinter In-Reply-To: References: <3c8f6fd70810282252o166d438fhbf8460233be21a89@mail.gmail.com> <3c8f6fd70810290649madf53e2q1fcc1acd21f6bfff@mail.gmail.com> <3c8f6fd70810290723u561ed191s31dec5b9ad9f7213@mail.gmail.com> <3c8f6fd70811020434o7749cd80we7d7d980ac9c039e@mail.gmail.com> Message-ID: <3c8f6fd70811020634t42dd1161waa5e201ed6a1b53f@mail.gmail.com> I would like to thank you already for all the help you've given me, it is really appreciated :) I decided to update to Python2.6 instead of using the tile pack. My application now shows the GUI again. So I added the code you gave me to prevent the window from hanging once I execute my scan. I get the following Traceback: D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)>python TSO. pyw Exception in Tkinter callback Traceback (most recent call last): File "D:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__ return self.func(*args) File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO main.pyw", line 29, in OnScan TSOscn.Scan(root, status) File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO scn.pyw", line 23, in Scan TSOex.safe_yield(Frame, True) File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO ex.pyw", line 75, in safe_yield window_disabler(window) File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO ex.pyw", line 90, in window_disabler if widget.instate(['!disabled']): AttributeError: Button instance has no attribute 'instate' D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)> I don't know if it makes a difference, But I think you should know that I use different files that import other applications (made by me) Example: TSO.pyw is the main script, this looks if the very first argument is "TSO.pyw", if it is, run "TSOmain.TSO()" TSOmain.pyw is the GUI and the GUI only, from there it calls other files etc. I hope that wasn't too confusing. Thanks again, I really appreciate it. Regards, Olrik 2008/11/2 Guilherme Polo : > On Sun, Nov 2, 2008 at 10:34 AM, Olrik Lenstra wrote: >> Hmm, I'm a bit stumped. >> I installed the ttk module and tried applying the code. >> However when I ran my code it gave me an error. >> I thought I might have left a small typo in or something and removed >> the code to check my own. >> >> After I removed the ttk import and code it wouldn't even run my own code again. >> Below is the Traceback: >> >> C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik>python TSO.pyw >> Traceback (most recent call last): >> File "TSO.pyw", line 24, in >> import TSOmain >> File "C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik\TSOmain.pyw", line >> 79, in >> TSO() >> File "C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik\TSOmain.pyw", line >> 37, in TSO >> root = Tk.Tk() >> File "D:\Python25\lib\lib-tk\Tkinter.py", line 1638, in __init__ >> self._loadtk() >> File "D:\Python25\lib\site-packages\ttk.py", line 50, in _wrapper >> self.tk.eval('package require tile') # TclError may be raised here >> _tkinter.TclError: can't find package tile >> > > You don't have tile installed neither was your tkinter compiled > against tcl/tk 8.5. > Python 2.6 already brings tcl/tk 8.5 and tkinter compiled against them. > Another option is to download tile from: > http://sourceforge.net/project/showfiles.php?group_id=11464&package_id=107795 > (get the tile082.zip so you have to do nothing at all). Then unpack > that somewhere. Then you have to set the environment variable > TILE_LIBRARY to the directory where this was unpacked, then you should > be able to run the program with ttk. > You could set this environment var inside your app too: > > import os > os.environ['TILE_LIBRARY'] = 'x:/unpacked/tile/here' > > import ttk > > .... > >> C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik> >> >> >> Regards, >> Olrik >> >> 2008/10/29 Olrik Lenstra : >>> So that means that you will use a ttk frame instead of the Tkinter.Frame? >>> I'll see if I can get this working once I get home. (my program is on my >>> Desktop and I just do some testing on my laptop) >>> >>> Thanks a lot so far! >>> Regards, >>> Olrik >>> >>> 2008/10/29 Guilherme Polo >>>> >>>> On 10/29/08, Olrik Lenstra wrote: >>>> > I see, Thanks a lot, I really don't wish to bother you any further, but >>>> > here's my current situation. >>>> > I am still a beginning programmer and I am not entirely sure where to >>>> > put >>>> > this code exactly. >>>> > >>>> > How would I go about using this code? >>>> > >>>> >>>> It should be very similar to what you are already doing in wx. >>>> >>>> But, you would need to layout your toplevel (the one that is created >>>> when you call Tkinter.Tk()) as this: >>>> >>>> There would be a ttk.Frame that would hold all the other widgets, >>>> which should be all ttk widgets according to this sample. Then you >>>> would call safe_yield(frame, True) in the same situations you would in >>>> wx. Now it remains to check if there is the same need for this in tk >>>> as there is in wx. >>>> >>>> Finally, a sample way to layout the widgets: >>>> >>>> root = Tkinter.Tk() >>>> frame = ttk.Frame(root) >>>> btn1 = ttk.Button(frame, text="Button 1") >>>> ... >>>> ... some time later: >>>> safe_yield(frame, True) >>>> ... >>>> >>>> > Thank you so much in advance. >>>> > Regards, >>>> > Olrik >>>> > >>>> > 2008/10/29 Guilherme Polo >>>> > >>>> > > >>>> > > >>>> > > >>>> > > ---------- Forwarded message ---------- >>>> > > From: Guilherme Polo >>>> > > Date: Oct 29, 2008 9:16 AM >>>> > > Subject: Re: [Tkinter-discuss] WxPython -> Tkinter >>>> > > To: Olrik Lenstra >>>> > > Cc: python-list at python.org >>>> > > >>>> > > >>>> > > On 10/29/08, Olrik Lenstra wrote: >>>> > > > Hello everyone, >>>> > > > >>>> > > > A while ago I joined the Tutor mailing list, and they helped me out >>>> > with a >>>> > > > question regarding wxPython. >>>> > > > Now however, I have tried a program in Tkinter and I would like to >>>> > > see >>>> > if >>>> > > > there is a similar command to "wx.SafeYield(self, True)". >>>> > > >>>> > > >>>> > > It will be a combination of commands, not a single one. Initially I >>>> > > considered this as "probably without solution", since tcl acquired a >>>> > > yield command just in the 8.6a3 release, but then I looked at >>>> > > wx.SafeYield code and apparently it is possible to replicate it. >>>> > > >>>> > > Here is an initial cut, it is very possible to contain something not >>>> > > equivalent to wx.SafeYield (besides it could be improved): >>>> > > >>>> > > >>>> > > import ttk >>>> > > >>>> > > inside_tkyield = False >>>> > > disabled_wins = {} >>>> > > >>>> > > def safe_yield(window, only_if_needed=False): >>>> > > window_disabler(window) >>>> > > >>>> > > try: >>>> > > return tk_yield(window, only_if_needed) >>>> > > finally: >>>> > > for widget, flags in disabled_wins.iteritems(): >>>> > > ttk.Widget.state(widget, flags) >>>> > > disabled_wins.clear() >>>> > > >>>> > > >>>> > > def window_disabler(window): >>>> > > widgets = window.children.values() >>>> > > widgets.append(window) >>>> > > >>>> > > for widget in widgets: >>>> > > if widget.instate(['!disabled']): >>>> > > prev_flags = widget.state(['disabled']) >>>> > > disabled_wins[widget] = prev_flags >>>> > > >>>> > > >>>> > > def tk_yield(window, only_if_needed=False): >>>> > > # wx implements this differently based on the backend it is using >>>> > > global inside_tkyield >>>> > > if inside_tkyield: >>>> > > if not only_if_needed: >>>> > > raise RuntimeError("safe_yield called recursively") >>>> > > >>>> > > return False >>>> > > >>>> > > inside_tkyield = True; >>>> > > >>>> > > window.update() >>>> > > window.update_idletasks() >>>> > > >>>> > > inside_tkyield = False; >>>> > > >>>> > > return True >>>> > > >>>> > > >>>> > > Note that this depends on ttk widgets >>>> > > (http://pypi.python.org/pypi/pyttk) since it uses >>>> > widget.state to >>>> > > disable and reenable the widgets. On windows the "wm" command >>>> > > supports >>>> > > disabling the entire window, so it is easier if you can use it. >>>> > > >>>> > > [Forwarded because I sent to the wrong list first time] >>>> > > >>>> > > >>>> > > > Below is a copy of the message to the tutor list. >>>> > > > >>>> > > > > Dear Mailing list, >>>> > > > > >>>> > > > > a while ago a few of you helped me solve an issue I had with a >>>> > > GUI / >>>> > scan >>>> > > > > program that I made. >>>> > > > > The problem was that when I tried to move the frame it would hang >>>> > until >>>> > > > the >>>> > > > > scan was finished. >>>> > > > > To solve this I had to add "wx.SafeYield(self, True)" to the scan >>>> > > and >>>> > the >>>> > > > > GUI wouldn't hang any more. >>>> > > > > Now I have redone the program and have written it with Tkinter >>>> > instead of >>>> > > > > WxPython. >>>> > > > > >>>> > > > > So is there a similar command for Tkinter as there is for >>>> > > WxPython? >>>> > > > > >>>> > > > > Thanks in advance. >>>> > > > > Regards, >>>> > > > > Olrik >>>> > > > > >>>> > > > >>>> > > >>>> > > > _______________________________________________ >>>> > > > Tkinter-discuss mailing list >>>> > > > Tkinter-discuss at python.org >>>> > > > >>>> > http://mail.python.org/mailman/listinfo/tkinter-discuss >>>> > > > >>>> > > > >>>> > > >>>> > > >>>> > > >>>> > > -- >>>> > > -- Guilherme H. Polo Goncalves >>>> > > >>>> > > >>>> > > -- >>>> > > -- Guilherme H. Polo Goncalves >>>> > > >>>> > > >>>> > > >>>> > > _______________________________________________ >>>> > > Tkinter-discuss mailing list >>>> > > Tkinter-discuss at python.org >>>> > > >>>> > http://mail.python.org/mailman/listinfo/tkinter-discuss >>>> > > >>>> > >>>> > >>>> >>>> >>>> -- >>>> -- Guilherme H. Polo Goncalves >>> >>> >> > > > > -- > -- Guilherme H. Polo Goncalves > From ggpolo at gmail.com Sun Nov 2 17:40:13 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Sun, 2 Nov 2008 14:40:13 -0200 Subject: [Tkinter-discuss] Fwd: WxPython -> Tkinter In-Reply-To: <3c8f6fd70811020634t42dd1161waa5e201ed6a1b53f@mail.gmail.com> References: <3c8f6fd70810282252o166d438fhbf8460233be21a89@mail.gmail.com> <3c8f6fd70810290649madf53e2q1fcc1acd21f6bfff@mail.gmail.com> <3c8f6fd70810290723u561ed191s31dec5b9ad9f7213@mail.gmail.com> <3c8f6fd70811020434o7749cd80we7d7d980ac9c039e@mail.gmail.com> <3c8f6fd70811020634t42dd1161waa5e201ed6a1b53f@mail.gmail.com> Message-ID: On Sun, Nov 2, 2008 at 12:34 PM, Olrik Lenstra wrote: > I would like to thank you already for all the help you've given me, it > is really appreciated :) You are welcome. > I decided to update to Python2.6 instead of using the tile pack. My > application now shows the GUI again. > So I added the code you gave me to prevent the window from hanging > once I execute my scan. > I get the following Traceback: > > D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)>python TSO. > pyw > Exception in Tkinter callback > Traceback (most recent call last): > File "D:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__ > return self.func(*args) > File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO > main.pyw", line 29, in OnScan > TSOscn.Scan(root, status) > File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO > scn.pyw", line 23, in Scan > TSOex.safe_yield(Frame, True) > File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO > ex.pyw", line 75, in safe_yield > window_disabler(window) > File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO > ex.pyw", line 90, in window_disabler > if widget.instate(['!disabled']): > AttributeError: Button instance has no attribute 'instate' > That is because Button is not a ttk.Button, but a "normal" Tkinter.Button. I didn't know before you would be using windows, but since this is the case, you may try substituting the use of instate and state calls (that are available only for ttk widgets) by the use of widget.wm_attributes('-disabled', 1), widget.wm_attributes('-disabled', 0) and widget.wm_attributes('-disabled'). I will be able to test it here later since my new pc arrived with a windows vista. > D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)> > > I don't know if it makes a difference, But I think you should know > that I use different files that import other applications (made by me) > Example: > > TSO.pyw is the main script, this looks if the very first argument is > "TSO.pyw", if it is, run "TSOmain.TSO()" > TSOmain.pyw is the GUI and the GUI only, from there it calls other files etc. > I hope that wasn't too confusing. > > Thanks again, I really appreciate it. > > Regards, > Olrik > > 2008/11/2 Guilherme Polo : >> On Sun, Nov 2, 2008 at 10:34 AM, Olrik Lenstra wrote: >>> Hmm, I'm a bit stumped. >>> I installed the ttk module and tried applying the code. >>> However when I ran my code it gave me an error. >>> I thought I might have left a small typo in or something and removed >>> the code to check my own. >>> >>> After I removed the ttk import and code it wouldn't even run my own code again. >>> Below is the Traceback: >>> >>> C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik>python TSO.pyw >>> Traceback (most recent call last): >>> File "TSO.pyw", line 24, in >>> import TSOmain >>> File "C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik\TSOmain.pyw", line >>> 79, in >>> TSO() >>> File "C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik\TSOmain.pyw", line >>> 37, in TSO >>> root = Tk.Tk() >>> File "D:\Python25\lib\lib-tk\Tkinter.py", line 1638, in __init__ >>> self._loadtk() >>> File "D:\Python25\lib\site-packages\ttk.py", line 50, in _wrapper >>> self.tk.eval('package require tile') # TclError may be raised here >>> _tkinter.TclError: can't find package tile >>> >> >> You don't have tile installed neither was your tkinter compiled >> against tcl/tk 8.5. >> Python 2.6 already brings tcl/tk 8.5 and tkinter compiled against them. >> Another option is to download tile from: >> http://sourceforge.net/project/showfiles.php?group_id=11464&package_id=107795 >> (get the tile082.zip so you have to do nothing at all). Then unpack >> that somewhere. Then you have to set the environment variable >> TILE_LIBRARY to the directory where this was unpacked, then you should >> be able to run the program with ttk. >> You could set this environment var inside your app too: >> >> import os >> os.environ['TILE_LIBRARY'] = 'x:/unpacked/tile/here' >> >> import ttk >> >> .... >> >>> C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik> >>> >>> >>> Regards, >>> Olrik >>> >>> 2008/10/29 Olrik Lenstra : >>>> So that means that you will use a ttk frame instead of the Tkinter.Frame? >>>> I'll see if I can get this working once I get home. (my program is on my >>>> Desktop and I just do some testing on my laptop) >>>> >>>> Thanks a lot so far! >>>> Regards, >>>> Olrik >>>> >>>> 2008/10/29 Guilherme Polo >>>>> >>>>> On 10/29/08, Olrik Lenstra wrote: >>>>> > I see, Thanks a lot, I really don't wish to bother you any further, but >>>>> > here's my current situation. >>>>> > I am still a beginning programmer and I am not entirely sure where to >>>>> > put >>>>> > this code exactly. >>>>> > >>>>> > How would I go about using this code? >>>>> > >>>>> >>>>> It should be very similar to what you are already doing in wx. >>>>> >>>>> But, you would need to layout your toplevel (the one that is created >>>>> when you call Tkinter.Tk()) as this: >>>>> >>>>> There would be a ttk.Frame that would hold all the other widgets, >>>>> which should be all ttk widgets according to this sample. Then you >>>>> would call safe_yield(frame, True) in the same situations you would in >>>>> wx. Now it remains to check if there is the same need for this in tk >>>>> as there is in wx. >>>>> >>>>> Finally, a sample way to layout the widgets: >>>>> >>>>> root = Tkinter.Tk() >>>>> frame = ttk.Frame(root) >>>>> btn1 = ttk.Button(frame, text="Button 1") >>>>> ... >>>>> ... some time later: >>>>> safe_yield(frame, True) >>>>> ... >>>>> >>>>> > Thank you so much in advance. >>>>> > Regards, >>>>> > Olrik >>>>> > >>>>> > 2008/10/29 Guilherme Polo >>>>> > >>>>> > > >>>>> > > >>>>> > > >>>>> > > ---------- Forwarded message ---------- >>>>> > > From: Guilherme Polo >>>>> > > Date: Oct 29, 2008 9:16 AM >>>>> > > Subject: Re: [Tkinter-discuss] WxPython -> Tkinter >>>>> > > To: Olrik Lenstra >>>>> > > Cc: python-list at python.org >>>>> > > >>>>> > > >>>>> > > On 10/29/08, Olrik Lenstra wrote: >>>>> > > > Hello everyone, >>>>> > > > >>>>> > > > A while ago I joined the Tutor mailing list, and they helped me out >>>>> > with a >>>>> > > > question regarding wxPython. >>>>> > > > Now however, I have tried a program in Tkinter and I would like to >>>>> > > see >>>>> > if >>>>> > > > there is a similar command to "wx.SafeYield(self, True)". >>>>> > > >>>>> > > >>>>> > > It will be a combination of commands, not a single one. Initially I >>>>> > > considered this as "probably without solution", since tcl acquired a >>>>> > > yield command just in the 8.6a3 release, but then I looked at >>>>> > > wx.SafeYield code and apparently it is possible to replicate it. >>>>> > > >>>>> > > Here is an initial cut, it is very possible to contain something not >>>>> > > equivalent to wx.SafeYield (besides it could be improved): >>>>> > > >>>>> > > >>>>> > > import ttk >>>>> > > >>>>> > > inside_tkyield = False >>>>> > > disabled_wins = {} >>>>> > > >>>>> > > def safe_yield(window, only_if_needed=False): >>>>> > > window_disabler(window) >>>>> > > >>>>> > > try: >>>>> > > return tk_yield(window, only_if_needed) >>>>> > > finally: >>>>> > > for widget, flags in disabled_wins.iteritems(): >>>>> > > ttk.Widget.state(widget, flags) >>>>> > > disabled_wins.clear() >>>>> > > >>>>> > > >>>>> > > def window_disabler(window): >>>>> > > widgets = window.children.values() >>>>> > > widgets.append(window) >>>>> > > >>>>> > > for widget in widgets: >>>>> > > if widget.instate(['!disabled']): >>>>> > > prev_flags = widget.state(['disabled']) >>>>> > > disabled_wins[widget] = prev_flags >>>>> > > >>>>> > > >>>>> > > def tk_yield(window, only_if_needed=False): >>>>> > > # wx implements this differently based on the backend it is using >>>>> > > global inside_tkyield >>>>> > > if inside_tkyield: >>>>> > > if not only_if_needed: >>>>> > > raise RuntimeError("safe_yield called recursively") >>>>> > > >>>>> > > return False >>>>> > > >>>>> > > inside_tkyield = True; >>>>> > > >>>>> > > window.update() >>>>> > > window.update_idletasks() >>>>> > > >>>>> > > inside_tkyield = False; >>>>> > > >>>>> > > return True >>>>> > > >>>>> > > >>>>> > > Note that this depends on ttk widgets >>>>> > > (http://pypi.python.org/pypi/pyttk) since it uses >>>>> > widget.state to >>>>> > > disable and reenable the widgets. On windows the "wm" command >>>>> > > supports >>>>> > > disabling the entire window, so it is easier if you can use it. >>>>> > > >>>>> > > [Forwarded because I sent to the wrong list first time] >>>>> > > >>>>> > > >>>>> > > > Below is a copy of the message to the tutor list. >>>>> > > > >>>>> > > > > Dear Mailing list, >>>>> > > > > >>>>> > > > > a while ago a few of you helped me solve an issue I had with a >>>>> > > GUI / >>>>> > scan >>>>> > > > > program that I made. >>>>> > > > > The problem was that when I tried to move the frame it would hang >>>>> > until >>>>> > > > the >>>>> > > > > scan was finished. >>>>> > > > > To solve this I had to add "wx.SafeYield(self, True)" to the scan >>>>> > > and >>>>> > the >>>>> > > > > GUI wouldn't hang any more. >>>>> > > > > Now I have redone the program and have written it with Tkinter >>>>> > instead of >>>>> > > > > WxPython. >>>>> > > > > >>>>> > > > > So is there a similar command for Tkinter as there is for >>>>> > > WxPython? >>>>> > > > > >>>>> > > > > Thanks in advance. >>>>> > > > > Regards, >>>>> > > > > Olrik >>>>> > > > > >>>>> > > > >>>>> > > >>>>> > > > _______________________________________________ >>>>> > > > Tkinter-discuss mailing list >>>>> > > > Tkinter-discuss at python.org >>>>> > > > >>>>> > http://mail.python.org/mailman/listinfo/tkinter-discuss >>>>> > > > >>>>> > > > >>>>> > > >>>>> > > >>>>> > > >>>>> > > -- >>>>> > > -- Guilherme H. Polo Goncalves >>>>> > > >>>>> > > >>>>> > > -- >>>>> > > -- Guilherme H. Polo Goncalves >>>>> > > >>>>> > > >>>>> > > >>>>> > > _______________________________________________ >>>>> > > Tkinter-discuss mailing list >>>>> > > Tkinter-discuss at python.org >>>>> > > >>>>> > http://mail.python.org/mailman/listinfo/tkinter-discuss >>>>> > > >>>>> > >>>>> > >>>>> >>>>> >>>>> -- >>>>> -- Guilherme H. Polo Goncalves >>>> >>>> >>> >> >> >> >> -- >> -- Guilherme H. Polo Goncalves >> > -- -- Guilherme H. Polo Goncalves From o.lenstra at gmail.com Sun Nov 2 18:26:26 2008 From: o.lenstra at gmail.com (Olrik Lenstra) Date: Sun, 2 Nov 2008 18:26:26 +0100 Subject: [Tkinter-discuss] Fwd: WxPython -> Tkinter In-Reply-To: References: <3c8f6fd70810282252o166d438fhbf8460233be21a89@mail.gmail.com> <3c8f6fd70810290649madf53e2q1fcc1acd21f6bfff@mail.gmail.com> <3c8f6fd70810290723u561ed191s31dec5b9ad9f7213@mail.gmail.com> <3c8f6fd70811020434o7749cd80we7d7d980ac9c039e@mail.gmail.com> <3c8f6fd70811020634t42dd1161waa5e201ed6a1b53f@mail.gmail.com> Message-ID: <3c8f6fd70811020926i879f70bl56ce58379a7fd5f4@mail.gmail.com> I see. So I will have to go about and change all the Tk.Button() to ttk.Button()? The program I am making will be for the windows OS only. Is the syntax for ttk the same as for Tkinter? Regards, Olrik 2008/11/2 Guilherme Polo : > On Sun, Nov 2, 2008 at 12:34 PM, Olrik Lenstra wrote: >> I would like to thank you already for all the help you've given me, it >> is really appreciated :) > > You are welcome. > >> I decided to update to Python2.6 instead of using the tile pack. My >> application now shows the GUI again. >> So I added the code you gave me to prevent the window from hanging >> once I execute my scan. >> I get the following Traceback: >> >> D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)>python TSO. >> pyw >> Exception in Tkinter callback >> Traceback (most recent call last): >> File "D:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__ >> return self.func(*args) >> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >> main.pyw", line 29, in OnScan >> TSOscn.Scan(root, status) >> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >> scn.pyw", line 23, in Scan >> TSOex.safe_yield(Frame, True) >> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >> ex.pyw", line 75, in safe_yield >> window_disabler(window) >> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >> ex.pyw", line 90, in window_disabler >> if widget.instate(['!disabled']): >> AttributeError: Button instance has no attribute 'instate' >> > > That is because Button is not a ttk.Button, but a "normal" > Tkinter.Button. I didn't know before you would be using windows, but > since this is the case, you may try substituting the use of instate > and state calls (that are available only for ttk widgets) by the use > of widget.wm_attributes('-disabled', 1), > widget.wm_attributes('-disabled', 0) and > widget.wm_attributes('-disabled'). I will be able to test it here > later since my new pc arrived with a windows vista. > >> D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)> >> >> I don't know if it makes a difference, But I think you should know >> that I use different files that import other applications (made by me) >> Example: >> >> TSO.pyw is the main script, this looks if the very first argument is >> "TSO.pyw", if it is, run "TSOmain.TSO()" >> TSOmain.pyw is the GUI and the GUI only, from there it calls other files etc. >> I hope that wasn't too confusing. >> >> Thanks again, I really appreciate it. >> >> Regards, >> Olrik >> >> 2008/11/2 Guilherme Polo : >>> On Sun, Nov 2, 2008 at 10:34 AM, Olrik Lenstra wrote: >>>> Hmm, I'm a bit stumped. >>>> I installed the ttk module and tried applying the code. >>>> However when I ran my code it gave me an error. >>>> I thought I might have left a small typo in or something and removed >>>> the code to check my own. >>>> >>>> After I removed the ttk import and code it wouldn't even run my own code again. >>>> Below is the Traceback: >>>> >>>> C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik>python TSO.pyw >>>> Traceback (most recent call last): >>>> File "TSO.pyw", line 24, in >>>> import TSOmain >>>> File "C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik\TSOmain.pyw", line >>>> 79, in >>>> TSO() >>>> File "C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik\TSOmain.pyw", line >>>> 37, in TSO >>>> root = Tk.Tk() >>>> File "D:\Python25\lib\lib-tk\Tkinter.py", line 1638, in __init__ >>>> self._loadtk() >>>> File "D:\Python25\lib\site-packages\ttk.py", line 50, in _wrapper >>>> self.tk.eval('package require tile') # TclError may be raised here >>>> _tkinter.TclError: can't find package tile >>>> >>> >>> You don't have tile installed neither was your tkinter compiled >>> against tcl/tk 8.5. >>> Python 2.6 already brings tcl/tk 8.5 and tkinter compiled against them. >>> Another option is to download tile from: >>> http://sourceforge.net/project/showfiles.php?group_id=11464&package_id=107795 >>> (get the tile082.zip so you have to do nothing at all). Then unpack >>> that somewhere. Then you have to set the environment variable >>> TILE_LIBRARY to the directory where this was unpacked, then you should >>> be able to run the program with ttk. >>> You could set this environment var inside your app too: >>> >>> import os >>> os.environ['TILE_LIBRARY'] = 'x:/unpacked/tile/here' >>> >>> import ttk >>> >>> .... >>> >>>> C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik> >>>> >>>> >>>> Regards, >>>> Olrik >>>> >>>> 2008/10/29 Olrik Lenstra : >>>>> So that means that you will use a ttk frame instead of the Tkinter.Frame? >>>>> I'll see if I can get this working once I get home. (my program is on my >>>>> Desktop and I just do some testing on my laptop) >>>>> >>>>> Thanks a lot so far! >>>>> Regards, >>>>> Olrik >>>>> >>>>> 2008/10/29 Guilherme Polo >>>>>> >>>>>> On 10/29/08, Olrik Lenstra wrote: >>>>>> > I see, Thanks a lot, I really don't wish to bother you any further, but >>>>>> > here's my current situation. >>>>>> > I am still a beginning programmer and I am not entirely sure where to >>>>>> > put >>>>>> > this code exactly. >>>>>> > >>>>>> > How would I go about using this code? >>>>>> > >>>>>> >>>>>> It should be very similar to what you are already doing in wx. >>>>>> >>>>>> But, you would need to layout your toplevel (the one that is created >>>>>> when you call Tkinter.Tk()) as this: >>>>>> >>>>>> There would be a ttk.Frame that would hold all the other widgets, >>>>>> which should be all ttk widgets according to this sample. Then you >>>>>> would call safe_yield(frame, True) in the same situations you would in >>>>>> wx. Now it remains to check if there is the same need for this in tk >>>>>> as there is in wx. >>>>>> >>>>>> Finally, a sample way to layout the widgets: >>>>>> >>>>>> root = Tkinter.Tk() >>>>>> frame = ttk.Frame(root) >>>>>> btn1 = ttk.Button(frame, text="Button 1") >>>>>> ... >>>>>> ... some time later: >>>>>> safe_yield(frame, True) >>>>>> ... >>>>>> >>>>>> > Thank you so much in advance. >>>>>> > Regards, >>>>>> > Olrik >>>>>> > >>>>>> > 2008/10/29 Guilherme Polo >>>>>> > >>>>>> > > >>>>>> > > >>>>>> > > >>>>>> > > ---------- Forwarded message ---------- >>>>>> > > From: Guilherme Polo >>>>>> > > Date: Oct 29, 2008 9:16 AM >>>>>> > > Subject: Re: [Tkinter-discuss] WxPython -> Tkinter >>>>>> > > To: Olrik Lenstra >>>>>> > > Cc: python-list at python.org >>>>>> > > >>>>>> > > >>>>>> > > On 10/29/08, Olrik Lenstra wrote: >>>>>> > > > Hello everyone, >>>>>> > > > >>>>>> > > > A while ago I joined the Tutor mailing list, and they helped me out >>>>>> > with a >>>>>> > > > question regarding wxPython. >>>>>> > > > Now however, I have tried a program in Tkinter and I would like to >>>>>> > > see >>>>>> > if >>>>>> > > > there is a similar command to "wx.SafeYield(self, True)". >>>>>> > > >>>>>> > > >>>>>> > > It will be a combination of commands, not a single one. Initially I >>>>>> > > considered this as "probably without solution", since tcl acquired a >>>>>> > > yield command just in the 8.6a3 release, but then I looked at >>>>>> > > wx.SafeYield code and apparently it is possible to replicate it. >>>>>> > > >>>>>> > > Here is an initial cut, it is very possible to contain something not >>>>>> > > equivalent to wx.SafeYield (besides it could be improved): >>>>>> > > >>>>>> > > >>>>>> > > import ttk >>>>>> > > >>>>>> > > inside_tkyield = False >>>>>> > > disabled_wins = {} >>>>>> > > >>>>>> > > def safe_yield(window, only_if_needed=False): >>>>>> > > window_disabler(window) >>>>>> > > >>>>>> > > try: >>>>>> > > return tk_yield(window, only_if_needed) >>>>>> > > finally: >>>>>> > > for widget, flags in disabled_wins.iteritems(): >>>>>> > > ttk.Widget.state(widget, flags) >>>>>> > > disabled_wins.clear() >>>>>> > > >>>>>> > > >>>>>> > > def window_disabler(window): >>>>>> > > widgets = window.children.values() >>>>>> > > widgets.append(window) >>>>>> > > >>>>>> > > for widget in widgets: >>>>>> > > if widget.instate(['!disabled']): >>>>>> > > prev_flags = widget.state(['disabled']) >>>>>> > > disabled_wins[widget] = prev_flags >>>>>> > > >>>>>> > > >>>>>> > > def tk_yield(window, only_if_needed=False): >>>>>> > > # wx implements this differently based on the backend it is using >>>>>> > > global inside_tkyield >>>>>> > > if inside_tkyield: >>>>>> > > if not only_if_needed: >>>>>> > > raise RuntimeError("safe_yield called recursively") >>>>>> > > >>>>>> > > return False >>>>>> > > >>>>>> > > inside_tkyield = True; >>>>>> > > >>>>>> > > window.update() >>>>>> > > window.update_idletasks() >>>>>> > > >>>>>> > > inside_tkyield = False; >>>>>> > > >>>>>> > > return True >>>>>> > > >>>>>> > > >>>>>> > > Note that this depends on ttk widgets >>>>>> > > (http://pypi.python.org/pypi/pyttk) since it uses >>>>>> > widget.state to >>>>>> > > disable and reenable the widgets. On windows the "wm" command >>>>>> > > supports >>>>>> > > disabling the entire window, so it is easier if you can use it. >>>>>> > > >>>>>> > > [Forwarded because I sent to the wrong list first time] >>>>>> > > >>>>>> > > >>>>>> > > > Below is a copy of the message to the tutor list. >>>>>> > > > >>>>>> > > > > Dear Mailing list, >>>>>> > > > > >>>>>> > > > > a while ago a few of you helped me solve an issue I had with a >>>>>> > > GUI / >>>>>> > scan >>>>>> > > > > program that I made. >>>>>> > > > > The problem was that when I tried to move the frame it would hang >>>>>> > until >>>>>> > > > the >>>>>> > > > > scan was finished. >>>>>> > > > > To solve this I had to add "wx.SafeYield(self, True)" to the scan >>>>>> > > and >>>>>> > the >>>>>> > > > > GUI wouldn't hang any more. >>>>>> > > > > Now I have redone the program and have written it with Tkinter >>>>>> > instead of >>>>>> > > > > WxPython. >>>>>> > > > > >>>>>> > > > > So is there a similar command for Tkinter as there is for >>>>>> > > WxPython? >>>>>> > > > > >>>>>> > > > > Thanks in advance. >>>>>> > > > > Regards, >>>>>> > > > > Olrik >>>>>> > > > > >>>>>> > > > >>>>>> > > >>>>>> > > > _______________________________________________ >>>>>> > > > Tkinter-discuss mailing list >>>>>> > > > Tkinter-discuss at python.org >>>>>> > > > >>>>>> > http://mail.python.org/mailman/listinfo/tkinter-discuss >>>>>> > > > >>>>>> > > > >>>>>> > > >>>>>> > > >>>>>> > > >>>>>> > > -- >>>>>> > > -- Guilherme H. Polo Goncalves >>>>>> > > >>>>>> > > >>>>>> > > -- >>>>>> > > -- Guilherme H. Polo Goncalves >>>>>> > > >>>>>> > > >>>>>> > > >>>>>> > > _______________________________________________ >>>>>> > > Tkinter-discuss mailing list >>>>>> > > Tkinter-discuss at python.org >>>>>> > > >>>>>> > http://mail.python.org/mailman/listinfo/tkinter-discuss >>>>>> > > >>>>>> > >>>>>> > >>>>>> >>>>>> >>>>>> -- >>>>>> -- Guilherme H. Polo Goncalves >>>>> >>>>> >>>> >>> >>> >>> >>> -- >>> -- Guilherme H. Polo Goncalves >>> >> > > > > -- > -- Guilherme H. Polo Goncalves > From ggpolo at gmail.com Sun Nov 2 18:56:13 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Sun, 2 Nov 2008 15:56:13 -0200 Subject: [Tkinter-discuss] Fwd: WxPython -> Tkinter In-Reply-To: <3c8f6fd70811020926i879f70bl56ce58379a7fd5f4@mail.gmail.com> References: <3c8f6fd70810282252o166d438fhbf8460233be21a89@mail.gmail.com> <3c8f6fd70810290649madf53e2q1fcc1acd21f6bfff@mail.gmail.com> <3c8f6fd70810290723u561ed191s31dec5b9ad9f7213@mail.gmail.com> <3c8f6fd70811020434o7749cd80we7d7d980ac9c039e@mail.gmail.com> <3c8f6fd70811020634t42dd1161waa5e201ed6a1b53f@mail.gmail.com> <3c8f6fd70811020926i879f70bl56ce58379a7fd5f4@mail.gmail.com> Message-ID: On Sun, Nov 2, 2008 at 3:26 PM, Olrik Lenstra wrote: > I see. So I will have to go about and change all the Tk.Button() to > ttk.Button()? > The program I am making will be for the windows OS only. What I'm saying is that you won't even need ttk widgets for this, if you stick to windows only. > > Is the syntax for ttk the same as for Tkinter? ttk is still tcl/tk, it is just new widges and theming engine. If by same syntax you mean the widgets support the same options and methods, then no. > > Regards, > Olrik > > 2008/11/2 Guilherme Polo : >> On Sun, Nov 2, 2008 at 12:34 PM, Olrik Lenstra wrote: >>> I would like to thank you already for all the help you've given me, it >>> is really appreciated :) >> >> You are welcome. >> >>> I decided to update to Python2.6 instead of using the tile pack. My >>> application now shows the GUI again. >>> So I added the code you gave me to prevent the window from hanging >>> once I execute my scan. >>> I get the following Traceback: >>> >>> D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)>python TSO. >>> pyw >>> Exception in Tkinter callback >>> Traceback (most recent call last): >>> File "D:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__ >>> return self.func(*args) >>> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >>> main.pyw", line 29, in OnScan >>> TSOscn.Scan(root, status) >>> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >>> scn.pyw", line 23, in Scan >>> TSOex.safe_yield(Frame, True) >>> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >>> ex.pyw", line 75, in safe_yield >>> window_disabler(window) >>> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >>> ex.pyw", line 90, in window_disabler >>> if widget.instate(['!disabled']): >>> AttributeError: Button instance has no attribute 'instate' >>> >> >> That is because Button is not a ttk.Button, but a "normal" >> Tkinter.Button. I didn't know before you would be using windows, but >> since this is the case, you may try substituting the use of instate >> and state calls (that are available only for ttk widgets) by the use >> of widget.wm_attributes('-disabled', 1), >> widget.wm_attributes('-disabled', 0) and >> widget.wm_attributes('-disabled'). I will be able to test it here >> later since my new pc arrived with a windows vista. >> >>> D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)> >>> >>> I don't know if it makes a difference, But I think you should know >>> that I use different files that import other applications (made by me) >>> Example: >>> >>> TSO.pyw is the main script, this looks if the very first argument is >>> "TSO.pyw", if it is, run "TSOmain.TSO()" >>> TSOmain.pyw is the GUI and the GUI only, from there it calls other files etc. >>> I hope that wasn't too confusing. >>> >>> Thanks again, I really appreciate it. >>> >>> Regards, >>> Olrik >>> >>> 2008/11/2 Guilherme Polo : >>>> On Sun, Nov 2, 2008 at 10:34 AM, Olrik Lenstra wrote: >>>>> Hmm, I'm a bit stumped. >>>>> I installed the ttk module and tried applying the code. >>>>> However when I ran my code it gave me an error. >>>>> I thought I might have left a small typo in or something and removed >>>>> the code to check my own. >>>>> >>>>> After I removed the ttk import and code it wouldn't even run my own code again. >>>>> Below is the Traceback: >>>>> >>>>> C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik>python TSO.pyw >>>>> Traceback (most recent call last): >>>>> File "TSO.pyw", line 24, in >>>>> import TSOmain >>>>> File "C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik\TSOmain.pyw", line >>>>> 79, in >>>>> TSO() >>>>> File "C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik\TSOmain.pyw", line >>>>> 37, in TSO >>>>> root = Tk.Tk() >>>>> File "D:\Python25\lib\lib-tk\Tkinter.py", line 1638, in __init__ >>>>> self._loadtk() >>>>> File "D:\Python25\lib\site-packages\ttk.py", line 50, in _wrapper >>>>> self.tk.eval('package require tile') # TclError may be raised here >>>>> _tkinter.TclError: can't find package tile >>>>> >>>> >>>> You don't have tile installed neither was your tkinter compiled >>>> against tcl/tk 8.5. >>>> Python 2.6 already brings tcl/tk 8.5 and tkinter compiled against them. >>>> Another option is to download tile from: >>>> http://sourceforge.net/project/showfiles.php?group_id=11464&package_id=107795 >>>> (get the tile082.zip so you have to do nothing at all). Then unpack >>>> that somewhere. Then you have to set the environment variable >>>> TILE_LIBRARY to the directory where this was unpacked, then you should >>>> be able to run the program with ttk. >>>> You could set this environment var inside your app too: >>>> >>>> import os >>>> os.environ['TILE_LIBRARY'] = 'x:/unpacked/tile/here' >>>> >>>> import ttk >>>> >>>> .... >>>> >>>>> C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik> >>>>> >>>>> >>>>> Regards, >>>>> Olrik >>>>> >>>>> 2008/10/29 Olrik Lenstra : >>>>>> So that means that you will use a ttk frame instead of the Tkinter.Frame? >>>>>> I'll see if I can get this working once I get home. (my program is on my >>>>>> Desktop and I just do some testing on my laptop) >>>>>> >>>>>> Thanks a lot so far! >>>>>> Regards, >>>>>> Olrik >>>>>> >>>>>> 2008/10/29 Guilherme Polo >>>>>>> >>>>>>> On 10/29/08, Olrik Lenstra wrote: >>>>>>> > I see, Thanks a lot, I really don't wish to bother you any further, but >>>>>>> > here's my current situation. >>>>>>> > I am still a beginning programmer and I am not entirely sure where to >>>>>>> > put >>>>>>> > this code exactly. >>>>>>> > >>>>>>> > How would I go about using this code? >>>>>>> > >>>>>>> >>>>>>> It should be very similar to what you are already doing in wx. >>>>>>> >>>>>>> But, you would need to layout your toplevel (the one that is created >>>>>>> when you call Tkinter.Tk()) as this: >>>>>>> >>>>>>> There would be a ttk.Frame that would hold all the other widgets, >>>>>>> which should be all ttk widgets according to this sample. Then you >>>>>>> would call safe_yield(frame, True) in the same situations you would in >>>>>>> wx. Now it remains to check if there is the same need for this in tk >>>>>>> as there is in wx. >>>>>>> >>>>>>> Finally, a sample way to layout the widgets: >>>>>>> >>>>>>> root = Tkinter.Tk() >>>>>>> frame = ttk.Frame(root) >>>>>>> btn1 = ttk.Button(frame, text="Button 1") >>>>>>> ... >>>>>>> ... some time later: >>>>>>> safe_yield(frame, True) >>>>>>> ... >>>>>>> >>>>>>> > Thank you so much in advance. >>>>>>> > Regards, >>>>>>> > Olrik >>>>>>> > >>>>>>> > 2008/10/29 Guilherme Polo >>>>>>> > >>>>>>> > > >>>>>>> > > >>>>>>> > > >>>>>>> > > ---------- Forwarded message ---------- >>>>>>> > > From: Guilherme Polo >>>>>>> > > Date: Oct 29, 2008 9:16 AM >>>>>>> > > Subject: Re: [Tkinter-discuss] WxPython -> Tkinter >>>>>>> > > To: Olrik Lenstra >>>>>>> > > Cc: python-list at python.org >>>>>>> > > >>>>>>> > > >>>>>>> > > On 10/29/08, Olrik Lenstra wrote: >>>>>>> > > > Hello everyone, >>>>>>> > > > >>>>>>> > > > A while ago I joined the Tutor mailing list, and they helped me out >>>>>>> > with a >>>>>>> > > > question regarding wxPython. >>>>>>> > > > Now however, I have tried a program in Tkinter and I would like to >>>>>>> > > see >>>>>>> > if >>>>>>> > > > there is a similar command to "wx.SafeYield(self, True)". >>>>>>> > > >>>>>>> > > >>>>>>> > > It will be a combination of commands, not a single one. Initially I >>>>>>> > > considered this as "probably without solution", since tcl acquired a >>>>>>> > > yield command just in the 8.6a3 release, but then I looked at >>>>>>> > > wx.SafeYield code and apparently it is possible to replicate it. >>>>>>> > > >>>>>>> > > Here is an initial cut, it is very possible to contain something not >>>>>>> > > equivalent to wx.SafeYield (besides it could be improved): >>>>>>> > > >>>>>>> > > >>>>>>> > > import ttk >>>>>>> > > >>>>>>> > > inside_tkyield = False >>>>>>> > > disabled_wins = {} >>>>>>> > > >>>>>>> > > def safe_yield(window, only_if_needed=False): >>>>>>> > > window_disabler(window) >>>>>>> > > >>>>>>> > > try: >>>>>>> > > return tk_yield(window, only_if_needed) >>>>>>> > > finally: >>>>>>> > > for widget, flags in disabled_wins.iteritems(): >>>>>>> > > ttk.Widget.state(widget, flags) >>>>>>> > > disabled_wins.clear() >>>>>>> > > >>>>>>> > > >>>>>>> > > def window_disabler(window): >>>>>>> > > widgets = window.children.values() >>>>>>> > > widgets.append(window) >>>>>>> > > >>>>>>> > > for widget in widgets: >>>>>>> > > if widget.instate(['!disabled']): >>>>>>> > > prev_flags = widget.state(['disabled']) >>>>>>> > > disabled_wins[widget] = prev_flags >>>>>>> > > >>>>>>> > > >>>>>>> > > def tk_yield(window, only_if_needed=False): >>>>>>> > > # wx implements this differently based on the backend it is using >>>>>>> > > global inside_tkyield >>>>>>> > > if inside_tkyield: >>>>>>> > > if not only_if_needed: >>>>>>> > > raise RuntimeError("safe_yield called recursively") >>>>>>> > > >>>>>>> > > return False >>>>>>> > > >>>>>>> > > inside_tkyield = True; >>>>>>> > > >>>>>>> > > window.update() >>>>>>> > > window.update_idletasks() >>>>>>> > > >>>>>>> > > inside_tkyield = False; >>>>>>> > > >>>>>>> > > return True >>>>>>> > > >>>>>>> > > >>>>>>> > > Note that this depends on ttk widgets >>>>>>> > > (http://pypi.python.org/pypi/pyttk) since it uses >>>>>>> > widget.state to >>>>>>> > > disable and reenable the widgets. On windows the "wm" command >>>>>>> > > supports >>>>>>> > > disabling the entire window, so it is easier if you can use it. >>>>>>> > > >>>>>>> > > [Forwarded because I sent to the wrong list first time] >>>>>>> > > >>>>>>> > > >>>>>>> > > > Below is a copy of the message to the tutor list. >>>>>>> > > > >>>>>>> > > > > Dear Mailing list, >>>>>>> > > > > >>>>>>> > > > > a while ago a few of you helped me solve an issue I had with a >>>>>>> > > GUI / >>>>>>> > scan >>>>>>> > > > > program that I made. >>>>>>> > > > > The problem was that when I tried to move the frame it would hang >>>>>>> > until >>>>>>> > > > the >>>>>>> > > > > scan was finished. >>>>>>> > > > > To solve this I had to add "wx.SafeYield(self, True)" to the scan >>>>>>> > > and >>>>>>> > the >>>>>>> > > > > GUI wouldn't hang any more. >>>>>>> > > > > Now I have redone the program and have written it with Tkinter >>>>>>> > instead of >>>>>>> > > > > WxPython. >>>>>>> > > > > >>>>>>> > > > > So is there a similar command for Tkinter as there is for >>>>>>> > > WxPython? >>>>>>> > > > > >>>>>>> > > > > Thanks in advance. >>>>>>> > > > > Regards, >>>>>>> > > > > Olrik >>>>>>> > > > > >>>>>>> > > > >>>>>>> > > >>>>>>> > > > _______________________________________________ >>>>>>> > > > Tkinter-discuss mailing list >>>>>>> > > > Tkinter-discuss at python.org >>>>>>> > > > >>>>>>> > http://mail.python.org/mailman/listinfo/tkinter-discuss >>>>>>> > > > >>>>>>> > > > >>>>>>> > > >>>>>>> > > >>>>>>> > > >>>>>>> > > -- >>>>>>> > > -- Guilherme H. Polo Goncalves >>>>>>> > > >>>>>>> > > >>>>>>> > > -- >>>>>>> > > -- Guilherme H. Polo Goncalves >>>>>>> > > >>>>>>> > > >>>>>>> > > >>>>>>> > > _______________________________________________ >>>>>>> > > Tkinter-discuss mailing list >>>>>>> > > Tkinter-discuss at python.org >>>>>>> > > >>>>>>> > http://mail.python.org/mailman/listinfo/tkinter-discuss >>>>>>> > > >>>>>>> > >>>>>>> > >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> -- Guilherme H. Polo Goncalves >>>>>> >>>>>> >>>>> >>>> >>>> >>>> >>>> -- >>>> -- Guilherme H. Polo Goncalves >>>> >>> >> >> >> >> -- >> -- Guilherme H. Polo Goncalves >> > -- -- Guilherme H. Polo Goncalves From o.lenstra at gmail.com Sun Nov 2 20:21:38 2008 From: o.lenstra at gmail.com (Olrik Lenstra) Date: Sun, 2 Nov 2008 20:21:38 +0100 Subject: [Tkinter-discuss] Fwd: WxPython -> Tkinter In-Reply-To: References: <3c8f6fd70810282252o166d438fhbf8460233be21a89@mail.gmail.com> <3c8f6fd70810290649madf53e2q1fcc1acd21f6bfff@mail.gmail.com> <3c8f6fd70810290723u561ed191s31dec5b9ad9f7213@mail.gmail.com> <3c8f6fd70811020434o7749cd80we7d7d980ac9c039e@mail.gmail.com> <3c8f6fd70811020634t42dd1161waa5e201ed6a1b53f@mail.gmail.com> <3c8f6fd70811020926i879f70bl56ce58379a7fd5f4@mail.gmail.com> Message-ID: <3c8f6fd70811021121q4fabbec2of1e49292af157ae@mail.gmail.com> << What I'm saying is that you won't even need ttk widgets for this, if you stick to windows only. >> Would that mean that the GUI in windows has other widgets that could prevent it from hanging once I start executing some code? Without the ttk widgets that is. Regards, Olrik 2008/11/2 Guilherme Polo : > On Sun, Nov 2, 2008 at 3:26 PM, Olrik Lenstra wrote: >> I see. So I will have to go about and change all the Tk.Button() to >> ttk.Button()? >> The program I am making will be for the windows OS only. > > What I'm saying is that you won't even need ttk widgets for this, if > you stick to windows only. > >> >> Is the syntax for ttk the same as for Tkinter? > > ttk is still tcl/tk, it is just new widges and theming engine. If by > same syntax you mean the widgets support the same options and methods, > then no. > >> >> Regards, >> Olrik >> >> 2008/11/2 Guilherme Polo : >>> On Sun, Nov 2, 2008 at 12:34 PM, Olrik Lenstra wrote: >>>> I would like to thank you already for all the help you've given me, it >>>> is really appreciated :) >>> >>> You are welcome. >>> >>>> I decided to update to Python2.6 instead of using the tile pack. My >>>> application now shows the GUI again. >>>> So I added the code you gave me to prevent the window from hanging >>>> once I execute my scan. >>>> I get the following Traceback: >>>> >>>> D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)>python TSO. >>>> pyw >>>> Exception in Tkinter callback >>>> Traceback (most recent call last): >>>> File "D:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__ >>>> return self.func(*args) >>>> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >>>> main.pyw", line 29, in OnScan >>>> TSOscn.Scan(root, status) >>>> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >>>> scn.pyw", line 23, in Scan >>>> TSOex.safe_yield(Frame, True) >>>> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >>>> ex.pyw", line 75, in safe_yield >>>> window_disabler(window) >>>> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >>>> ex.pyw", line 90, in window_disabler >>>> if widget.instate(['!disabled']): >>>> AttributeError: Button instance has no attribute 'instate' >>>> >>> >>> That is because Button is not a ttk.Button, but a "normal" >>> Tkinter.Button. I didn't know before you would be using windows, but >>> since this is the case, you may try substituting the use of instate >>> and state calls (that are available only for ttk widgets) by the use >>> of widget.wm_attributes('-disabled', 1), >>> widget.wm_attributes('-disabled', 0) and >>> widget.wm_attributes('-disabled'). I will be able to test it here >>> later since my new pc arrived with a windows vista. >>> >>>> D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)> >>>> >>>> I don't know if it makes a difference, But I think you should know >>>> that I use different files that import other applications (made by me) >>>> Example: >>>> >>>> TSO.pyw is the main script, this looks if the very first argument is >>>> "TSO.pyw", if it is, run "TSOmain.TSO()" >>>> TSOmain.pyw is the GUI and the GUI only, from there it calls other files etc. >>>> I hope that wasn't too confusing. >>>> >>>> Thanks again, I really appreciate it. >>>> >>>> Regards, >>>> Olrik >>>> >>>> 2008/11/2 Guilherme Polo : >>>>> On Sun, Nov 2, 2008 at 10:34 AM, Olrik Lenstra wrote: >>>>>> Hmm, I'm a bit stumped. >>>>>> I installed the ttk module and tried applying the code. >>>>>> However when I ran my code it gave me an error. >>>>>> I thought I might have left a small typo in or something and removed >>>>>> the code to check my own. >>>>>> >>>>>> After I removed the ttk import and code it wouldn't even run my own code again. >>>>>> Below is the Traceback: >>>>>> >>>>>> C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik>python TSO.pyw >>>>>> Traceback (most recent call last): >>>>>> File "TSO.pyw", line 24, in >>>>>> import TSOmain >>>>>> File "C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik\TSOmain.pyw", line >>>>>> 79, in >>>>>> TSO() >>>>>> File "C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik\TSOmain.pyw", line >>>>>> 37, in TSO >>>>>> root = Tk.Tk() >>>>>> File "D:\Python25\lib\lib-tk\Tkinter.py", line 1638, in __init__ >>>>>> self._loadtk() >>>>>> File "D:\Python25\lib\site-packages\ttk.py", line 50, in _wrapper >>>>>> self.tk.eval('package require tile') # TclError may be raised here >>>>>> _tkinter.TclError: can't find package tile >>>>>> >>>>> >>>>> You don't have tile installed neither was your tkinter compiled >>>>> against tcl/tk 8.5. >>>>> Python 2.6 already brings tcl/tk 8.5 and tkinter compiled against them. >>>>> Another option is to download tile from: >>>>> http://sourceforge.net/project/showfiles.php?group_id=11464&package_id=107795 >>>>> (get the tile082.zip so you have to do nothing at all). Then unpack >>>>> that somewhere. Then you have to set the environment variable >>>>> TILE_LIBRARY to the directory where this was unpacked, then you should >>>>> be able to run the program with ttk. >>>>> You could set this environment var inside your app too: >>>>> >>>>> import os >>>>> os.environ['TILE_LIBRARY'] = 'x:/unpacked/tile/here' >>>>> >>>>> import ttk >>>>> >>>>> .... >>>>> >>>>>> C:\Users\Olrik Lenstra\Desktop\TroubleShooting Olrik> >>>>>> >>>>>> >>>>>> Regards, >>>>>> Olrik >>>>>> >>>>>> 2008/10/29 Olrik Lenstra : >>>>>>> So that means that you will use a ttk frame instead of the Tkinter.Frame? >>>>>>> I'll see if I can get this working once I get home. (my program is on my >>>>>>> Desktop and I just do some testing on my laptop) >>>>>>> >>>>>>> Thanks a lot so far! >>>>>>> Regards, >>>>>>> Olrik >>>>>>> >>>>>>> 2008/10/29 Guilherme Polo >>>>>>>> >>>>>>>> On 10/29/08, Olrik Lenstra wrote: >>>>>>>> > I see, Thanks a lot, I really don't wish to bother you any further, but >>>>>>>> > here's my current situation. >>>>>>>> > I am still a beginning programmer and I am not entirely sure where to >>>>>>>> > put >>>>>>>> > this code exactly. >>>>>>>> > >>>>>>>> > How would I go about using this code? >>>>>>>> > >>>>>>>> >>>>>>>> It should be very similar to what you are already doing in wx. >>>>>>>> >>>>>>>> But, you would need to layout your toplevel (the one that is created >>>>>>>> when you call Tkinter.Tk()) as this: >>>>>>>> >>>>>>>> There would be a ttk.Frame that would hold all the other widgets, >>>>>>>> which should be all ttk widgets according to this sample. Then you >>>>>>>> would call safe_yield(frame, True) in the same situations you would in >>>>>>>> wx. Now it remains to check if there is the same need for this in tk >>>>>>>> as there is in wx. >>>>>>>> >>>>>>>> Finally, a sample way to layout the widgets: >>>>>>>> >>>>>>>> root = Tkinter.Tk() >>>>>>>> frame = ttk.Frame(root) >>>>>>>> btn1 = ttk.Button(frame, text="Button 1") >>>>>>>> ... >>>>>>>> ... some time later: >>>>>>>> safe_yield(frame, True) >>>>>>>> ... >>>>>>>> >>>>>>>> > Thank you so much in advance. >>>>>>>> > Regards, >>>>>>>> > Olrik >>>>>>>> > >>>>>>>> > 2008/10/29 Guilherme Polo >>>>>>>> > >>>>>>>> > > >>>>>>>> > > >>>>>>>> > > >>>>>>>> > > ---------- Forwarded message ---------- >>>>>>>> > > From: Guilherme Polo >>>>>>>> > > Date: Oct 29, 2008 9:16 AM >>>>>>>> > > Subject: Re: [Tkinter-discuss] WxPython -> Tkinter >>>>>>>> > > To: Olrik Lenstra >>>>>>>> > > Cc: python-list at python.org >>>>>>>> > > >>>>>>>> > > >>>>>>>> > > On 10/29/08, Olrik Lenstra wrote: >>>>>>>> > > > Hello everyone, >>>>>>>> > > > >>>>>>>> > > > A while ago I joined the Tutor mailing list, and they helped me out >>>>>>>> > with a >>>>>>>> > > > question regarding wxPython. >>>>>>>> > > > Now however, I have tried a program in Tkinter and I would like to >>>>>>>> > > see >>>>>>>> > if >>>>>>>> > > > there is a similar command to "wx.SafeYield(self, True)". >>>>>>>> > > >>>>>>>> > > >>>>>>>> > > It will be a combination of commands, not a single one. Initially I >>>>>>>> > > considered this as "probably without solution", since tcl acquired a >>>>>>>> > > yield command just in the 8.6a3 release, but then I looked at >>>>>>>> > > wx.SafeYield code and apparently it is possible to replicate it. >>>>>>>> > > >>>>>>>> > > Here is an initial cut, it is very possible to contain something not >>>>>>>> > > equivalent to wx.SafeYield (besides it could be improved): >>>>>>>> > > >>>>>>>> > > >>>>>>>> > > import ttk >>>>>>>> > > >>>>>>>> > > inside_tkyield = False >>>>>>>> > > disabled_wins = {} >>>>>>>> > > >>>>>>>> > > def safe_yield(window, only_if_needed=False): >>>>>>>> > > window_disabler(window) >>>>>>>> > > >>>>>>>> > > try: >>>>>>>> > > return tk_yield(window, only_if_needed) >>>>>>>> > > finally: >>>>>>>> > > for widget, flags in disabled_wins.iteritems(): >>>>>>>> > > ttk.Widget.state(widget, flags) >>>>>>>> > > disabled_wins.clear() >>>>>>>> > > >>>>>>>> > > >>>>>>>> > > def window_disabler(window): >>>>>>>> > > widgets = window.children.values() >>>>>>>> > > widgets.append(window) >>>>>>>> > > >>>>>>>> > > for widget in widgets: >>>>>>>> > > if widget.instate(['!disabled']): >>>>>>>> > > prev_flags = widget.state(['disabled']) >>>>>>>> > > disabled_wins[widget] = prev_flags >>>>>>>> > > >>>>>>>> > > >>>>>>>> > > def tk_yield(window, only_if_needed=False): >>>>>>>> > > # wx implements this differently based on the backend it is using >>>>>>>> > > global inside_tkyield >>>>>>>> > > if inside_tkyield: >>>>>>>> > > if not only_if_needed: >>>>>>>> > > raise RuntimeError("safe_yield called recursively") >>>>>>>> > > >>>>>>>> > > return False >>>>>>>> > > >>>>>>>> > > inside_tkyield = True; >>>>>>>> > > >>>>>>>> > > window.update() >>>>>>>> > > window.update_idletasks() >>>>>>>> > > >>>>>>>> > > inside_tkyield = False; >>>>>>>> > > >>>>>>>> > > return True >>>>>>>> > > >>>>>>>> > > >>>>>>>> > > Note that this depends on ttk widgets >>>>>>>> > > (http://pypi.python.org/pypi/pyttk) since it uses >>>>>>>> > widget.state to >>>>>>>> > > disable and reenable the widgets. On windows the "wm" command >>>>>>>> > > supports >>>>>>>> > > disabling the entire window, so it is easier if you can use it. >>>>>>>> > > >>>>>>>> > > [Forwarded because I sent to the wrong list first time] >>>>>>>> > > >>>>>>>> > > >>>>>>>> > > > Below is a copy of the message to the tutor list. >>>>>>>> > > > >>>>>>>> > > > > Dear Mailing list, >>>>>>>> > > > > >>>>>>>> > > > > a while ago a few of you helped me solve an issue I had with a >>>>>>>> > > GUI / >>>>>>>> > scan >>>>>>>> > > > > program that I made. >>>>>>>> > > > > The problem was that when I tried to move the frame it would hang >>>>>>>> > until >>>>>>>> > > > the >>>>>>>> > > > > scan was finished. >>>>>>>> > > > > To solve this I had to add "wx.SafeYield(self, True)" to the scan >>>>>>>> > > and >>>>>>>> > the >>>>>>>> > > > > GUI wouldn't hang any more. >>>>>>>> > > > > Now I have redone the program and have written it with Tkinter >>>>>>>> > instead of >>>>>>>> > > > > WxPython. >>>>>>>> > > > > >>>>>>>> > > > > So is there a similar command for Tkinter as there is for >>>>>>>> > > WxPython? >>>>>>>> > > > > >>>>>>>> > > > > Thanks in advance. >>>>>>>> > > > > Regards, >>>>>>>> > > > > Olrik >>>>>>>> > > > > >>>>>>>> > > > >>>>>>>> > > >>>>>>>> > > > _______________________________________________ >>>>>>>> > > > Tkinter-discuss mailing list >>>>>>>> > > > Tkinter-discuss at python.org >>>>>>>> > > > >>>>>>>> > http://mail.python.org/mailman/listinfo/tkinter-discuss >>>>>>>> > > > >>>>>>>> > > > >>>>>>>> > > >>>>>>>> > > >>>>>>>> > > >>>>>>>> > > -- >>>>>>>> > > -- Guilherme H. Polo Goncalves >>>>>>>> > > >>>>>>>> > > >>>>>>>> > > -- >>>>>>>> > > -- Guilherme H. Polo Goncalves >>>>>>>> > > >>>>>>>> > > >>>>>>>> > > >>>>>>>> > > _______________________________________________ >>>>>>>> > > Tkinter-discuss mailing list >>>>>>>> > > Tkinter-discuss at python.org >>>>>>>> > > >>>>>>>> > http://mail.python.org/mailman/listinfo/tkinter-discuss >>>>>>>> > > >>>>>>>> > >>>>>>>> > >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> -- Guilherme H. Polo Goncalves >>>>>>> >>>>>>> >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> -- Guilherme H. Polo Goncalves >>>>> >>>> >>> >>> >>> >>> -- >>> -- Guilherme H. Polo Goncalves >>> >> > > > > -- > -- Guilherme H. Polo Goncalves > From ggpolo at gmail.com Sun Nov 2 20:23:11 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Sun, 2 Nov 2008 17:23:11 -0200 Subject: [Tkinter-discuss] Fwd: WxPython -> Tkinter In-Reply-To: References: <3c8f6fd70810282252o166d438fhbf8460233be21a89@mail.gmail.com> <3c8f6fd70810290649madf53e2q1fcc1acd21f6bfff@mail.gmail.com> <3c8f6fd70810290723u561ed191s31dec5b9ad9f7213@mail.gmail.com> <3c8f6fd70811020434o7749cd80we7d7d980ac9c039e@mail.gmail.com> <3c8f6fd70811020634t42dd1161waa5e201ed6a1b53f@mail.gmail.com> Message-ID: On Sun, Nov 2, 2008 at 2:40 PM, Guilherme Polo wrote: > On Sun, Nov 2, 2008 at 12:34 PM, Olrik Lenstra wrote: >> I would like to thank you already for all the help you've given me, it >> is really appreciated :) > > You are welcome. > >> I decided to update to Python2.6 instead of using the tile pack. My >> application now shows the GUI again. >> So I added the code you gave me to prevent the window from hanging >> once I execute my scan. >> I get the following Traceback: >> >> D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)>python TSO. >> pyw >> Exception in Tkinter callback >> Traceback (most recent call last): >> File "D:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__ >> return self.func(*args) >> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >> main.pyw", line 29, in OnScan >> TSOscn.Scan(root, status) >> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >> scn.pyw", line 23, in Scan >> TSOex.safe_yield(Frame, True) >> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >> ex.pyw", line 75, in safe_yield >> window_disabler(window) >> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >> ex.pyw", line 90, in window_disabler >> if widget.instate(['!disabled']): >> AttributeError: Button instance has no attribute 'instate' >> > > That is because Button is not a ttk.Button, but a "normal" > Tkinter.Button. I didn't know before you would be using windows, but > since this is the case, you may try substituting the use of instate > and state calls (that are available only for ttk widgets) by the use > of widget.wm_attributes('-disabled', 1), > widget.wm_attributes('-disabled', 0) and > widget.wm_attributes('-disabled'). I will be able to test it here > later since my new pc arrived with a windows vista. > I have changed it a bit now, please retry with this one: import sys inside_tkyield = False disabled_wins = {} platform_win = 'win' in sys.platform if not platform_win: import ttk def safe_yield(window, only_if_needed=False): window_disabler(window) try: return tk_yield(window, only_if_needed) finally: window_enabler(window) def window_enabler(window): for widget, flags in disabled_wins.iteritems(): if platform_win: window.wm_attributes('-disabled', 0) else: ttk.Widget.state(widget, flags) disabled_wins.clear() def window_disabler(window): if platform_win and not int(window.wm_attributes('-disabled')): window.wm_attributes('-disabled', 1) disabled_wins[window] = 1 return widgets = window.children.values() widgets.append(window) for widget in widgets: if widget.instate(['!disabled']): prev_flags = widget.state(['disabled']) disabled_wins[widget] = prev_flags def tk_yield(window, only_if_needed=False): # wx implements this differently based on the backend it is using global inside_tkyield if inside_tkyield: if not only_if_needed: raise RuntimeError("safe_yield called recursively") return False inside_tkyield = True; window.update() window.update_idletasks() inside_tkyield = False; return True It should work under windows, but it is not very nice elsewhere right now unfortunately. >> D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)> >> >> I don't know if it makes a difference, But I think you should know >> that I use different files that import other applications (made by me) >> Example: >> >> TSO.pyw is the main script, this looks if the very first argument is >> "TSO.pyw", if it is, run "TSOmain.TSO()" >> TSOmain.pyw is the GUI and the GUI only, from there it calls other files etc. >> I hope that wasn't too confusing. >> >> Thanks again, I really appreciate it. >> >> Regards, >> Olrik >> -- -- Guilherme H. Polo Goncalves From o.lenstra at gmail.com Sun Nov 2 22:17:04 2008 From: o.lenstra at gmail.com (Olrik Lenstra) Date: Sun, 2 Nov 2008 22:17:04 +0100 Subject: [Tkinter-discuss] Fwd: WxPython -> Tkinter In-Reply-To: References: <3c8f6fd70810282252o166d438fhbf8460233be21a89@mail.gmail.com> <3c8f6fd70810290649madf53e2q1fcc1acd21f6bfff@mail.gmail.com> <3c8f6fd70810290723u561ed191s31dec5b9ad9f7213@mail.gmail.com> <3c8f6fd70811020434o7749cd80we7d7d980ac9c039e@mail.gmail.com> <3c8f6fd70811020634t42dd1161waa5e201ed6a1b53f@mail.gmail.com> Message-ID: <3c8f6fd70811021317l1ff27c37le74edad428287864@mail.gmail.com> Hmm, The program worked and no error messages popped up but the GUI still hung when I tried running the scan. Maybe this is a help: The program is a program that does a couple of scans like ipconfig / dxdiag etc. While the scan is running the GUI has a status bar in which the text changes when the scan is running a new part of the scan. like: "TSO is now making an ipconfig log" Thanks again! :) Regards, Olrik 2008/11/2 Guilherme Polo : > On Sun, Nov 2, 2008 at 2:40 PM, Guilherme Polo wrote: >> On Sun, Nov 2, 2008 at 12:34 PM, Olrik Lenstra wrote: >>> I would like to thank you already for all the help you've given me, it >>> is really appreciated :) >> >> You are welcome. >> >>> I decided to update to Python2.6 instead of using the tile pack. My >>> application now shows the GUI again. >>> So I added the code you gave me to prevent the window from hanging >>> once I execute my scan. >>> I get the following Traceback: >>> >>> D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)>python TSO. >>> pyw >>> Exception in Tkinter callback >>> Traceback (most recent call last): >>> File "D:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__ >>> return self.func(*args) >>> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >>> main.pyw", line 29, in OnScan >>> TSOscn.Scan(root, status) >>> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >>> scn.pyw", line 23, in Scan >>> TSOex.safe_yield(Frame, True) >>> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >>> ex.pyw", line 75, in safe_yield >>> window_disabler(window) >>> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >>> ex.pyw", line 90, in window_disabler >>> if widget.instate(['!disabled']): >>> AttributeError: Button instance has no attribute 'instate' >>> >> >> That is because Button is not a ttk.Button, but a "normal" >> Tkinter.Button. I didn't know before you would be using windows, but >> since this is the case, you may try substituting the use of instate >> and state calls (that are available only for ttk widgets) by the use >> of widget.wm_attributes('-disabled', 1), >> widget.wm_attributes('-disabled', 0) and >> widget.wm_attributes('-disabled'). I will be able to test it here >> later since my new pc arrived with a windows vista. >> > > I have changed it a bit now, please retry with this one: > > import sys > > inside_tkyield = False > disabled_wins = {} > platform_win = 'win' in sys.platform > if not platform_win: > import ttk > > def safe_yield(window, only_if_needed=False): > window_disabler(window) > try: > return tk_yield(window, only_if_needed) > finally: > window_enabler(window) > > > def window_enabler(window): > for widget, flags in disabled_wins.iteritems(): > if platform_win: > window.wm_attributes('-disabled', 0) > else: > ttk.Widget.state(widget, flags) > disabled_wins.clear() > > > def window_disabler(window): > if platform_win and not int(window.wm_attributes('-disabled')): > window.wm_attributes('-disabled', 1) > disabled_wins[window] = 1 > return > > widgets = window.children.values() > widgets.append(window) > > for widget in widgets: > if widget.instate(['!disabled']): > prev_flags = widget.state(['disabled']) > disabled_wins[widget] = prev_flags > > > def tk_yield(window, only_if_needed=False): > # wx implements this differently based on the backend it is using > global inside_tkyield > if inside_tkyield: > if not only_if_needed: > raise RuntimeError("safe_yield called recursively") > > return False > > inside_tkyield = True; > > window.update() > window.update_idletasks() > > inside_tkyield = False; > > return True > > It should work under windows, but it is not very nice elsewhere right > now unfortunately. > >>> D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)> >>> >>> I don't know if it makes a difference, But I think you should know >>> that I use different files that import other applications (made by me) >>> Example: >>> >>> TSO.pyw is the main script, this looks if the very first argument is >>> "TSO.pyw", if it is, run "TSOmain.TSO()" >>> TSOmain.pyw is the GUI and the GUI only, from there it calls other files etc. >>> I hope that wasn't too confusing. >>> >>> Thanks again, I really appreciate it. >>> >>> Regards, >>> Olrik >>> > > > -- > -- Guilherme H. Polo Goncalves > From ggpolo at gmail.com Sun Nov 2 22:23:12 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Sun, 2 Nov 2008 19:23:12 -0200 Subject: [Tkinter-discuss] Fwd: WxPython -> Tkinter In-Reply-To: <3c8f6fd70811021317l1ff27c37le74edad428287864@mail.gmail.com> References: <3c8f6fd70810282252o166d438fhbf8460233be21a89@mail.gmail.com> <3c8f6fd70810290649madf53e2q1fcc1acd21f6bfff@mail.gmail.com> <3c8f6fd70810290723u561ed191s31dec5b9ad9f7213@mail.gmail.com> <3c8f6fd70811020434o7749cd80we7d7d980ac9c039e@mail.gmail.com> <3c8f6fd70811020634t42dd1161waa5e201ed6a1b53f@mail.gmail.com> <3c8f6fd70811021317l1ff27c37le74edad428287864@mail.gmail.com> Message-ID: On Sun, Nov 2, 2008 at 7:17 PM, Olrik Lenstra wrote: > Hmm, The program worked and no error messages popped up but the GUI > still hung when I tried running the scan. If the scan blocks the application then that safe_yield is not supposed to work, it wouldn't work in wxpython either (using only that). Do use polling to determine when the scan finishes for example ? That would be the place to run safe_yield. If this is not the case, and the scanner doesn't let you work it in an asynchronous way, then you will have to run that scan in another thread/process and the gui will not block. > Maybe this is a help: > > The program is a program that does a couple of scans like ipconfig / dxdiag etc. > While the scan is running the GUI has a status bar in which the text > changes when the scan is running a new part of the scan. > like: "TSO is now making an ipconfig log" > > Thanks again! :) > Regards, > Olrik > > 2008/11/2 Guilherme Polo : >> On Sun, Nov 2, 2008 at 2:40 PM, Guilherme Polo wrote: >>> On Sun, Nov 2, 2008 at 12:34 PM, Olrik Lenstra wrote: >>>> I would like to thank you already for all the help you've given me, it >>>> is really appreciated :) >>> >>> You are welcome. >>> >>>> I decided to update to Python2.6 instead of using the tile pack. My >>>> application now shows the GUI again. >>>> So I added the code you gave me to prevent the window from hanging >>>> once I execute my scan. >>>> I get the following Traceback: >>>> >>>> D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)>python TSO. >>>> pyw >>>> Exception in Tkinter callback >>>> Traceback (most recent call last): >>>> File "D:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__ >>>> return self.func(*args) >>>> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >>>> main.pyw", line 29, in OnScan >>>> TSOscn.Scan(root, status) >>>> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >>>> scn.pyw", line 23, in Scan >>>> TSOex.safe_yield(Frame, True) >>>> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >>>> ex.pyw", line 75, in safe_yield >>>> window_disabler(window) >>>> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >>>> ex.pyw", line 90, in window_disabler >>>> if widget.instate(['!disabled']): >>>> AttributeError: Button instance has no attribute 'instate' >>>> >>> >>> That is because Button is not a ttk.Button, but a "normal" >>> Tkinter.Button. I didn't know before you would be using windows, but >>> since this is the case, you may try substituting the use of instate >>> and state calls (that are available only for ttk widgets) by the use >>> of widget.wm_attributes('-disabled', 1), >>> widget.wm_attributes('-disabled', 0) and >>> widget.wm_attributes('-disabled'). I will be able to test it here >>> later since my new pc arrived with a windows vista. >>> >> >> I have changed it a bit now, please retry with this one: >> >> import sys >> >> inside_tkyield = False >> disabled_wins = {} >> platform_win = 'win' in sys.platform >> if not platform_win: >> import ttk >> >> def safe_yield(window, only_if_needed=False): >> window_disabler(window) >> try: >> return tk_yield(window, only_if_needed) >> finally: >> window_enabler(window) >> >> >> def window_enabler(window): >> for widget, flags in disabled_wins.iteritems(): >> if platform_win: >> window.wm_attributes('-disabled', 0) >> else: >> ttk.Widget.state(widget, flags) >> disabled_wins.clear() >> >> >> def window_disabler(window): >> if platform_win and not int(window.wm_attributes('-disabled')): >> window.wm_attributes('-disabled', 1) >> disabled_wins[window] = 1 >> return >> >> widgets = window.children.values() >> widgets.append(window) >> >> for widget in widgets: >> if widget.instate(['!disabled']): >> prev_flags = widget.state(['disabled']) >> disabled_wins[widget] = prev_flags >> >> >> def tk_yield(window, only_if_needed=False): >> # wx implements this differently based on the backend it is using >> global inside_tkyield >> if inside_tkyield: >> if not only_if_needed: >> raise RuntimeError("safe_yield called recursively") >> >> return False >> >> inside_tkyield = True; >> >> window.update() >> window.update_idletasks() >> >> inside_tkyield = False; >> >> return True >> >> It should work under windows, but it is not very nice elsewhere right >> now unfortunately. >> >>>> D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)> >>>> >>>> I don't know if it makes a difference, But I think you should know >>>> that I use different files that import other applications (made by me) >>>> Example: >>>> >>>> TSO.pyw is the main script, this looks if the very first argument is >>>> "TSO.pyw", if it is, run "TSOmain.TSO()" >>>> TSOmain.pyw is the GUI and the GUI only, from there it calls other files etc. >>>> I hope that wasn't too confusing. >>>> >>>> Thanks again, I really appreciate it. >>>> >>>> Regards, >>>> Olrik >>>> >> >> >> -- >> -- Guilherme H. Polo Goncalves >> > -- -- Guilherme H. Polo Goncalves From o.lenstra at gmail.com Sun Nov 2 22:41:03 2008 From: o.lenstra at gmail.com (Olrik Lenstra) Date: Sun, 2 Nov 2008 22:41:03 +0100 Subject: [Tkinter-discuss] Fwd: WxPython -> Tkinter In-Reply-To: References: <3c8f6fd70810282252o166d438fhbf8460233be21a89@mail.gmail.com> <3c8f6fd70810290723u561ed191s31dec5b9ad9f7213@mail.gmail.com> <3c8f6fd70811020434o7749cd80we7d7d980ac9c039e@mail.gmail.com> <3c8f6fd70811020634t42dd1161waa5e201ed6a1b53f@mail.gmail.com> <3c8f6fd70811021317l1ff27c37le74edad428287864@mail.gmail.com> Message-ID: <3c8f6fd70811021341h72fe7730g127889ef5f8408bb@mail.gmail.com> I see, now if I recall correctly I can run the scan by using the following command: thread.start_new_thread(myfunction,("Thread No:1",2)) So I'd replace myfunction with the scan function and it would run at the same time? Regards, Olrik 2008/11/2 Guilherme Polo : > On Sun, Nov 2, 2008 at 7:17 PM, Olrik Lenstra wrote: >> Hmm, The program worked and no error messages popped up but the GUI >> still hung when I tried running the scan. > > If the scan blocks the application then that safe_yield is not > supposed to work, it wouldn't work in wxpython either (using only > that). Do use polling to determine when the scan finishes for example > ? That would be the place to run safe_yield. If this is not the case, > and the scanner doesn't let you work it in an asynchronous way, then > you will have to run that scan in another thread/process and the gui > will not block. > >> Maybe this is a help: >> >> The program is a program that does a couple of scans like ipconfig / dxdiag etc. >> While the scan is running the GUI has a status bar in which the text >> changes when the scan is running a new part of the scan. >> like: "TSO is now making an ipconfig log" >> >> Thanks again! :) >> Regards, >> Olrik >> >> 2008/11/2 Guilherme Polo : >>> On Sun, Nov 2, 2008 at 2:40 PM, Guilherme Polo wrote: >>>> On Sun, Nov 2, 2008 at 12:34 PM, Olrik Lenstra wrote: >>>>> I would like to thank you already for all the help you've given me, it >>>>> is really appreciated :) >>>> >>>> You are welcome. >>>> >>>>> I decided to update to Python2.6 instead of using the tile pack. My >>>>> application now shows the GUI again. >>>>> So I added the code you gave me to prevent the window from hanging >>>>> once I execute my scan. >>>>> I get the following Traceback: >>>>> >>>>> D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)>python TSO. >>>>> pyw >>>>> Exception in Tkinter callback >>>>> Traceback (most recent call last): >>>>> File "D:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__ >>>>> return self.func(*args) >>>>> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >>>>> main.pyw", line 29, in OnScan >>>>> TSOscn.Scan(root, status) >>>>> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >>>>> scn.pyw", line 23, in Scan >>>>> TSOex.safe_yield(Frame, True) >>>>> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >>>>> ex.pyw", line 75, in safe_yield >>>>> window_disabler(window) >>>>> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >>>>> ex.pyw", line 90, in window_disabler >>>>> if widget.instate(['!disabled']): >>>>> AttributeError: Button instance has no attribute 'instate' >>>>> >>>> >>>> That is because Button is not a ttk.Button, but a "normal" >>>> Tkinter.Button. I didn't know before you would be using windows, but >>>> since this is the case, you may try substituting the use of instate >>>> and state calls (that are available only for ttk widgets) by the use >>>> of widget.wm_attributes('-disabled', 1), >>>> widget.wm_attributes('-disabled', 0) and >>>> widget.wm_attributes('-disabled'). I will be able to test it here >>>> later since my new pc arrived with a windows vista. >>>> >>> >>> I have changed it a bit now, please retry with this one: >>> >>> import sys >>> >>> inside_tkyield = False >>> disabled_wins = {} >>> platform_win = 'win' in sys.platform >>> if not platform_win: >>> import ttk >>> >>> def safe_yield(window, only_if_needed=False): >>> window_disabler(window) >>> try: >>> return tk_yield(window, only_if_needed) >>> finally: >>> window_enabler(window) >>> >>> >>> def window_enabler(window): >>> for widget, flags in disabled_wins.iteritems(): >>> if platform_win: >>> window.wm_attributes('-disabled', 0) >>> else: >>> ttk.Widget.state(widget, flags) >>> disabled_wins.clear() >>> >>> >>> def window_disabler(window): >>> if platform_win and not int(window.wm_attributes('-disabled')): >>> window.wm_attributes('-disabled', 1) >>> disabled_wins[window] = 1 >>> return >>> >>> widgets = window.children.values() >>> widgets.append(window) >>> >>> for widget in widgets: >>> if widget.instate(['!disabled']): >>> prev_flags = widget.state(['disabled']) >>> disabled_wins[widget] = prev_flags >>> >>> >>> def tk_yield(window, only_if_needed=False): >>> # wx implements this differently based on the backend it is using >>> global inside_tkyield >>> if inside_tkyield: >>> if not only_if_needed: >>> raise RuntimeError("safe_yield called recursively") >>> >>> return False >>> >>> inside_tkyield = True; >>> >>> window.update() >>> window.update_idletasks() >>> >>> inside_tkyield = False; >>> >>> return True >>> >>> It should work under windows, but it is not very nice elsewhere right >>> now unfortunately. >>> >>>>> D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)> >>>>> >>>>> I don't know if it makes a difference, But I think you should know >>>>> that I use different files that import other applications (made by me) >>>>> Example: >>>>> >>>>> TSO.pyw is the main script, this looks if the very first argument is >>>>> "TSO.pyw", if it is, run "TSOmain.TSO()" >>>>> TSOmain.pyw is the GUI and the GUI only, from there it calls other files etc. >>>>> I hope that wasn't too confusing. >>>>> >>>>> Thanks again, I really appreciate it. >>>>> >>>>> Regards, >>>>> Olrik >>>>> >>> >>> >>> -- >>> -- Guilherme H. Polo Goncalves >>> >> > > > > -- > -- Guilherme H. Polo Goncalves > From ggpolo at gmail.com Sun Nov 2 23:04:46 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Sun, 2 Nov 2008 20:04:46 -0200 Subject: [Tkinter-discuss] Fwd: WxPython -> Tkinter In-Reply-To: <3c8f6fd70811021341h72fe7730g127889ef5f8408bb@mail.gmail.com> References: <3c8f6fd70810282252o166d438fhbf8460233be21a89@mail.gmail.com> <3c8f6fd70810290723u561ed191s31dec5b9ad9f7213@mail.gmail.com> <3c8f6fd70811020434o7749cd80we7d7d980ac9c039e@mail.gmail.com> <3c8f6fd70811020634t42dd1161waa5e201ed6a1b53f@mail.gmail.com> <3c8f6fd70811021317l1ff27c37le74edad428287864@mail.gmail.com> <3c8f6fd70811021341h72fe7730g127889ef5f8408bb@mail.gmail.com> Message-ID: On Sun, Nov 2, 2008 at 7:41 PM, Olrik Lenstra wrote: > I see, now if I recall correctly I can run the scan by using the > following command: > thread.start_new_thread(myfunction,("Thread No:1",2)) It's more likely that you will want to use the threading module instead. That would then be: mythread = threading.Thread(target=myfunction, args=("Thread No: 1", 2)) and at some point you would call mythread.start() and then at some other point you could check if it is alive by doing mythread.is_alive (in python 2.6 or mythread.isAlive() in older versions), and possible other things you may want to do of course. > > So I'd replace myfunction with the scan function and it would run at > the same time? > Not really at same time, GIL doesn't allow for that, but you don't need this "feature" for this task. It wouldn't block the GUI tho. > Regards, > Olrik > > 2008/11/2 Guilherme Polo : >> On Sun, Nov 2, 2008 at 7:17 PM, Olrik Lenstra wrote: >>> Hmm, The program worked and no error messages popped up but the GUI >>> still hung when I tried running the scan. >> >> If the scan blocks the application then that safe_yield is not >> supposed to work, it wouldn't work in wxpython either (using only >> that). Do use polling to determine when the scan finishes for example >> ? That would be the place to run safe_yield. If this is not the case, >> and the scanner doesn't let you work it in an asynchronous way, then >> you will have to run that scan in another thread/process and the gui >> will not block. >> >>> Maybe this is a help: >>> >>> The program is a program that does a couple of scans like ipconfig / dxdiag etc. >>> While the scan is running the GUI has a status bar in which the text >>> changes when the scan is running a new part of the scan. >>> like: "TSO is now making an ipconfig log" >>> >>> Thanks again! :) >>> Regards, >>> Olrik >>> >>> 2008/11/2 Guilherme Polo : >>>> On Sun, Nov 2, 2008 at 2:40 PM, Guilherme Polo wrote: >>>>> On Sun, Nov 2, 2008 at 12:34 PM, Olrik Lenstra wrote: >>>>>> I would like to thank you already for all the help you've given me, it >>>>>> is really appreciated :) >>>>> >>>>> You are welcome. >>>>> >>>>>> I decided to update to Python2.6 instead of using the tile pack. My >>>>>> application now shows the GUI again. >>>>>> So I added the code you gave me to prevent the window from hanging >>>>>> once I execute my scan. >>>>>> I get the following Traceback: >>>>>> >>>>>> D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)>python TSO. >>>>>> pyw >>>>>> Exception in Tkinter callback >>>>>> Traceback (most recent call last): >>>>>> File "D:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__ >>>>>> return self.func(*args) >>>>>> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >>>>>> main.pyw", line 29, in OnScan >>>>>> TSOscn.Scan(root, status) >>>>>> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >>>>>> scn.pyw", line 23, in Scan >>>>>> TSOex.safe_yield(Frame, True) >>>>>> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >>>>>> ex.pyw", line 75, in safe_yield >>>>>> window_disabler(window) >>>>>> File "D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)\TSO >>>>>> ex.pyw", line 90, in window_disabler >>>>>> if widget.instate(['!disabled']): >>>>>> AttributeError: Button instance has no attribute 'instate' >>>>>> >>>>> >>>>> That is because Button is not a ttk.Button, but a "normal" >>>>> Tkinter.Button. I didn't know before you would be using windows, but >>>>> since this is the case, you may try substituting the use of instate >>>>> and state calls (that are available only for ttk widgets) by the use >>>>> of widget.wm_attributes('-disabled', 1), >>>>> widget.wm_attributes('-disabled', 0) and >>>>> widget.wm_attributes('-disabled'). I will be able to test it here >>>>> later since my new pc arrived with a windows vista. >>>>> >>>> >>>> I have changed it a bit now, please retry with this one: >>>> >>>> import sys >>>> >>>> inside_tkyield = False >>>> disabled_wins = {} >>>> platform_win = 'win' in sys.platform >>>> if not platform_win: >>>> import ttk >>>> >>>> def safe_yield(window, only_if_needed=False): >>>> window_disabler(window) >>>> try: >>>> return tk_yield(window, only_if_needed) >>>> finally: >>>> window_enabler(window) >>>> >>>> >>>> def window_enabler(window): >>>> for widget, flags in disabled_wins.iteritems(): >>>> if platform_win: >>>> window.wm_attributes('-disabled', 0) >>>> else: >>>> ttk.Widget.state(widget, flags) >>>> disabled_wins.clear() >>>> >>>> >>>> def window_disabler(window): >>>> if platform_win and not int(window.wm_attributes('-disabled')): >>>> window.wm_attributes('-disabled', 1) >>>> disabled_wins[window] = 1 >>>> return >>>> >>>> widgets = window.children.values() >>>> widgets.append(window) >>>> >>>> for widget in widgets: >>>> if widget.instate(['!disabled']): >>>> prev_flags = widget.state(['disabled']) >>>> disabled_wins[widget] = prev_flags >>>> >>>> >>>> def tk_yield(window, only_if_needed=False): >>>> # wx implements this differently based on the backend it is using >>>> global inside_tkyield >>>> if inside_tkyield: >>>> if not only_if_needed: >>>> raise RuntimeError("safe_yield called recursively") >>>> >>>> return False >>>> >>>> inside_tkyield = True; >>>> >>>> window.update() >>>> window.update_idletasks() >>>> >>>> inside_tkyield = False; >>>> >>>> return True >>>> >>>> It should work under windows, but it is not very nice elsewhere right >>>> now unfortunately. >>>> >>>>>> D:\Documents\OLPrograms\TroubleShooting Olrik\sourcecode\TSO(source)> >>>>>> >>>>>> I don't know if it makes a difference, But I think you should know >>>>>> that I use different files that import other applications (made by me) >>>>>> Example: >>>>>> >>>>>> TSO.pyw is the main script, this looks if the very first argument is >>>>>> "TSO.pyw", if it is, run "TSOmain.TSO()" >>>>>> TSOmain.pyw is the GUI and the GUI only, from there it calls other files etc. >>>>>> I hope that wasn't too confusing. >>>>>> >>>>>> Thanks again, I really appreciate it. >>>>>> >>>>>> Regards, >>>>>> Olrik >>>>>> >>>> >>>> >>>> -- >>>> -- Guilherme H. Polo Goncalves >>>> >>> >> >> >> >> -- >> -- Guilherme H. Polo Goncalves >> > -- -- Guilherme H. Polo Goncalves From btkuhn at email.unc.edu Tue Nov 4 20:45:54 2008 From: btkuhn at email.unc.edu (btkuhn at email.unc.edu) Date: Tue, 04 Nov 2008 14:45:54 -0500 Subject: [Tkinter-discuss] Tkinter page layout Message-ID: <20081104144554.n0zia4p6gwk0sksw@webmail4.isis.unc.edu> Hi guys, I'm new to the list; actually just found out it existed. I'm fairly new to python and programming, and I'm just beginning with Tkinter. I'm trying to layout my page, and I'm having problems understanding the action of some of the frames. I actually posted about this on a general python help message board and someone suggested that I repost it to this list. My question is somewhat complex, so in attempt to simplify things a bit I am posting part of a response I posted in a thread on the previous message board. Hopefully this fully describes my problem: When I specify dimensions of the text boxes, no matter how high or low, the enclosing frame seems to adjust to fit the new boxes. So, for instance, if I try inserting a text widget in leftframe with dimensions 1x1, leftframe shrinks down to 1x1. If I make the text widget 100x100, leftframe takes that size. What I want, and what seems like should be happening, is if I have leftframe which is 500X500 pixels, and I create a text box wit effective dimensions of 200X200 (I understand that text widgets use lines as dimensions), the text box should take up a little less than half of leftframe, with leftframe remaining 500X500 pixels. Instead, leftframe is shrinking down to become 200X200, and I can't figure out why. After a while I tried removing the text boxes and I got the same problem. I think maybe this code will better illustrate the problem. This first set of code is the totally stripped down version, and you can see leftframe in white on the left, and rightframe in blue on the right. from Tkinter import * import tkFileDialog,tkSimpleDialog,tkMessageBox WINDOWWIDTH=500 WINDOWHEIGHT=500 TITLEFONT = ("Courier",12,"normal") HEADINGFONT = ("Helvetica",9,"bold") class App: def __init__ (self,master): self.window = Frame(master,width=WINDOWWIDTH,height=WINDOWHEIGHT) self.window.pack(expand=YES, fill=BOTH) self.master= master self.currentfeeds = [] #Create frame to contain all others self.display=Frame(self.window,width=WINDOWWIDTH,height=WINDOWHEIGHT, bg='black') self.display.pack() #Create widgets self.createwidgets() def createwidgets(self): # create a top menu self.addMenu(self.master) self.addToolbar() self.leftframe=Frame(self.display, width=WINDOWWIDTH/3,height=WINDOWHEIGHT, bg='white') self.rightframe=Frame(self.display, width=2*WINDOWWIDTH/3,height=WINDOWHEIGHT, bg='blue') self.leftframe.pack(side="left", expand="yes", fill="x") self.rightframe.pack(side="left", expand="yes", fill="x") def addMenu(self,master): self.menu = Menu(self.window) master.config(menu=self.menu) self.filemenu = Menu(self.menu) def addToolbar(self): self.toolbar = Frame(self.display) self.toolbar.pack(side='top',expand="yes", fill="x") root=Tk() app=App(root) root.mainloop() Next, if I try to pack ANYTHING inside rightframe, it shrinks down to size and totally distorts my screen dimensions. Here is the exact same code, adding a label widget in self.rightframe. It completely shrinks rightframe and distorts the screen dimensions. Does my question make sense now? from Tkinter import * import tkFileDialog,tkSimpleDialog,tkMessageBox WINDOWWIDTH=500 WINDOWHEIGHT=500 TITLEFONT = ("Courier",12,"normal") HEADINGFONT = ("Helvetica",9,"bold") class App: def __init__ (self,master): self.window = Frame(master,width=WINDOWWIDTH,height=WINDOWHEIGHT) self.window.pack(expand=YES, fill=BOTH) self.master= master self.currentfeeds = [] #Create frame to contain all others self.display=Frame(self.window,width=WINDOWWIDTH,height=WINDOWHEIGHT, bg='black') self.display.pack() #Create widgets self.createwidgets() def createwidgets(self): # create a top menu self.addMenu(self.master) self.addToolbar() self.leftframe=Frame(self.display, width=WINDOWWIDTH/3,height=WINDOWHEIGHT, bg='white') self.rightframe=Frame(self.display, width=2*WINDOWWIDTH/3,height=WINDOWHEIGHT, bg='blue') self.leftframe.pack(side="left", expand="yes", fill="x") self.rightframe.pack(side="left", expand="yes", fill="x") self.label=Label(self.rightframe,text='Current story',font=HEADINGFONT).pack(side='top') def addMenu(self,master): self.menu = Menu(self.window) master.config(menu=self.menu) self.filemenu = Menu(self.menu) def addToolbar(self): self.toolbar = Frame(self.display) self.toolbar.pack(side='top',expand="yes", fill="x") root=Tk() app=App(root) root.mainloop() From ggpolo at gmail.com Tue Nov 4 22:15:43 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Tue, 4 Nov 2008 19:15:43 -0200 Subject: [Tkinter-discuss] Tkinter page layout In-Reply-To: <20081104144554.n0zia4p6gwk0sksw@webmail4.isis.unc.edu> References: <20081104144554.n0zia4p6gwk0sksw@webmail4.isis.unc.edu> Message-ID: On Tue, Nov 4, 2008 at 5:45 PM, wrote: > Hi guys, > > I'm new to the list; actually just found out it existed. I'm fairly new to > python and programming, and I'm just beginning with Tkinter. I'm trying to > layout my page, and I'm having problems understanding the action of some of > the frames. I actually posted about this on a general python help message > board and someone suggested that I repost it to this list. My question is > somewhat complex, so in attempt to simplify things a bit I am posting part > of a response I posted in a thread on the previous message board. Hopefully > this fully describes my problem: > > > When I specify dimensions of the text boxes, no matter how high or low, the > enclosing frame seems to adjust to fit the new boxes. So, for instance, if I > try inserting a text widget in leftframe with dimensions 1x1, leftframe > shrinks down to 1x1. If I make the text widget 100x100, leftframe takes that > size. What I want, and what seems like should be happening, is if I have > leftframe which is 500X500 pixels, and I create a text box wit effective > dimensions of 200X200 (I understand that text widgets use lines as > dimensions), the text box should take up a little less than half of > leftframe, with leftframe remaining 500X500 pixels. Instead, leftframe is > shrinking down to become 200X200, and I can't figure out why. After a while > I tried removing the text boxes and I got the same problem. I think maybe > this code will better illustrate the problem. This first set of code is the > totally stripped down version, and you can see leftframe in white on the > left, and rightframe in blue on the right. > > from Tkinter import * > import tkFileDialog,tkSimpleDialog,tkMessageBox > > > WINDOWWIDTH=500 > WINDOWHEIGHT=500 > TITLEFONT = ("Courier",12,"normal") > HEADINGFONT = ("Helvetica",9,"bold") > > > > class App: > def __init__ (self,master): > self.window = Frame(master,width=WINDOWWIDTH,height=WINDOWHEIGHT) > self.window.pack(expand=YES, fill=BOTH) > self.master= master > self.currentfeeds = [] > #Create frame to contain all others > self.display=Frame(self.window,width=WINDOWWIDTH,height=WINDOWHEIGHT, > bg='black') > self.display.pack() > > > > #Create widgets > self.createwidgets() > def createwidgets(self): > # create a top menu > self.addMenu(self.master) > self.addToolbar() > self.leftframe=Frame(self.display, > width=WINDOWWIDTH/3,height=WINDOWHEIGHT, bg='white') > self.rightframe=Frame(self.display, > width=2*WINDOWWIDTH/3,height=WINDOWHEIGHT, bg='blue') > self.leftframe.pack(side="left", expand="yes", fill="x") > self.rightframe.pack(side="left", expand="yes", fill="x") > > > > def addMenu(self,master): > self.menu = Menu(self.window) > master.config(menu=self.menu) > self.filemenu = Menu(self.menu) > > def addToolbar(self): > self.toolbar = Frame(self.display) > > self.toolbar.pack(side='top',expand="yes", fill="x") > > > root=Tk() > app=App(root) > > root.mainloop() > You could have simplified a lot more actually. (*) > > > > Next, if I try to pack ANYTHING inside rightframe, it shrinks down to size > and totally distorts my screen dimensions. Here is the exact same code, > adding a label widget in self.rightframe. It completely shrinks rightframe > and distorts the screen dimensions. Does my question make sense now? > > > > > from Tkinter import * > import tkFileDialog,tkSimpleDialog,tkMessageBox > > > WINDOWWIDTH=500 > WINDOWHEIGHT=500 > TITLEFONT = ("Courier",12,"normal") > HEADINGFONT = ("Helvetica",9,"bold") > > > > class App: > def __init__ (self,master): > self.window = Frame(master,width=WINDOWWIDTH,height=WINDOWHEIGHT) > self.window.pack(expand=YES, fill=BOTH) > self.master= master > self.currentfeeds = [] > #Create frame to contain all others > self.display=Frame(self.window,width=WINDOWWIDTH,height=WINDOWHEIGHT, > bg='black') > self.display.pack() > > > > #Create widgets > self.createwidgets() > def createwidgets(self): > # create a top menu > self.addMenu(self.master) > self.addToolbar() > self.leftframe=Frame(self.display, > width=WINDOWWIDTH/3,height=WINDOWHEIGHT, bg='white') > self.rightframe=Frame(self.display, > width=2*WINDOWWIDTH/3,height=WINDOWHEIGHT, bg='blue') > self.leftframe.pack(side="left", expand="yes", fill="x") > self.rightframe.pack(side="left", expand="yes", fill="x") > > > > self.label=Label(self.rightframe,text='Current > story',font=HEADINGFONT).pack(side='top') > def addMenu(self,master): > self.menu = Menu(self.window) > master.config(menu=self.menu) > self.filemenu = Menu(self.menu) > > def addToolbar(self): > self.toolbar = Frame(self.display) > > self.toolbar.pack(side='top',expand="yes", fill="x") > > > root=Tk() > app=App(root) > > root.mainloop() > See (*). Thinking about your problem for a moment, it is not really a problem. You are not supposed to develop GUI applications with a completely fixed layout, because people that will use the GUI app will adjust it according to their preferences. It is very very bad to layout widgets like that, and harder too. You should rethink about the problem you are trying to solve. Said that, it is possibly to manually position things without using pack or grid, that is, use place for that. But.. reconsider what you are doing. Nevertheless, follows a sample that demonstrate what you seems to want right now: from Tkinter import Tk, Frame, Label WINDOWWIDTH = 500 WINDOWHEIGHT = 500 class App: def __init__ (self): #Create frame to contain all others self.display = Frame(width=WINDOWWIDTH, height=WINDOWHEIGHT) self.display.pack() #Create widgets self.createwidgets() def createwidgets(self): self.leftframe=Frame(self.display, width=WINDOWWIDTH / 3, height=WINDOWHEIGHT, bg='red') self.rightframe=Frame(self.display, width=2 * WINDOWWIDTH / 3, height=WINDOWHEIGHT, bg='blue') self.leftframe.pack(side="left", expand=True, fill="x") self.rightframe.pack(side="left", expand=True, fill="x") label = Label(self.rightframe, text='test') label.place(x=200, y=200) root = Tk() app = App() root.mainloop() It is possible that you are after paned windows, that is perfectly understandable then. For that, take a look at Tkinter.PanedWindow -- -- Guilherme H. Polo Goncalves From btkuhn at email.unc.edu Tue Nov 4 22:25:11 2008 From: btkuhn at email.unc.edu (btkuhn at email.unc.edu) Date: Tue, 04 Nov 2008 16:25:11 -0500 Subject: [Tkinter-discuss] Tkinter page layout In-Reply-To: <27FBC833-4C65-415B-A0CF-7EDA30771DE8@tolisgroup.com> References: <20081104144554.n0zia4p6gwk0sksw@webmail4.isis.unc.edu> <27FBC833-4C65-415B-A0CF-7EDA30771DE8@tolisgroup.com> Message-ID: <20081104162511.dxxjwamkg4sow8gw@webmail4.isis.unc.edu> Thanks Tim. I actually started out using the grid geometry manager, though, and I switched to pack specifically because I thought maybe the problem was being caused by the grid manager, and thought maybe the pack manager would correct things. I'm getting the same problem with both the pack and grid managers; specifically, that my enclosing frames seem to move to adjust to the size of widgets placed inside of them, which distorts the dimensions of all my windows. Thanks, Ben Quoting Tim Jones : > On Nov 4, 2008, at 12:45 PM, btkuhn at email.unc.edu wrote: > >> When I specify dimensions of the text boxes, no matter how high or >> low, the enclosing frame seems to adjust to fit the new boxes. So, >> for instance, if I try inserting a text widget in leftframe with >> dimensions 1x1, leftframe shrinks down to 1x1. If I make the text >> widget 100x100, leftframe takes that size. What I want, and what >> seems like should be happening, is if I have leftframe which is >> 500X500 pixels, and I create a text box wit effective dimensions of >> 200X200 (I understand that text widgets use lines as dimensions), >> the text box should take up a little less than half of leftframe, >> with leftframe remaining 500X500 pixels. Instead, leftframe is >> shrinking down to become 200X200, and I can't figure out why. After >> a while I tried removing the text boxes and I got the same problem. >> I think maybe this code will better illustrate the problem. This >> first set of code is the totally stripped down version, and you can >> see leftframe in white on the left, and rightframe in blue on the >> right. > > Check out the tkinter docs (or tk docs, for that matter) for the Grid > geometry manager and how to use it over the pack geometry manager. > > HTH, > Tim > From Cameron at phaseit.net Tue Nov 4 22:31:26 2008 From: Cameron at phaseit.net (Cameron Laird) Date: Tue, 4 Nov 2008 21:31:26 +0000 Subject: [Tkinter-discuss] Tkinter page layout In-Reply-To: <20081104162511.dxxjwamkg4sow8gw@webmail4.isis.unc.edu> References: <20081104144554.n0zia4p6gwk0sksw@webmail4.isis.unc.edu> <27FBC833-4C65-415B-A0CF-7EDA30771DE8@tolisgroup.com> <20081104162511.dxxjwamkg4sow8gw@webmail4.isis.unc.edu> Message-ID: <20081104213126.GB30503@lairds.us> On Tue, Nov 04, 2008 at 04:25:11PM -0500, btkuhn at email.unc.edu wrote: . . . > Thanks Tim. I actually started out using the grid geometry manager, > though, and I switched to pack specifically because I thought maybe the > problem was being caused by the grid manager, and thought maybe the > pack manager would correct things. I'm getting the same problem with > both the pack and grid managers; specifically, that my enclosing frames > seem to move to adjust to the size of widgets placed inside of them, > which distorts the dimensions of all my windows. . . . Right; for many who work with GUIs, that adjustment is regarded as a feature, more than a problem. You should have received by now, though, a message from Guilherme which explains how to circumvent the behavior. From btkuhn at email.unc.edu Tue Nov 4 22:59:20 2008 From: btkuhn at email.unc.edu (btkuhn at email.unc.edu) Date: Tue, 04 Nov 2008 16:59:20 -0500 Subject: [Tkinter-discuss] Tkinter page layout In-Reply-To: References: <20081104144554.n0zia4p6gwk0sksw@webmail4.isis.unc.edu> Message-ID: <20081104165920.9oea9fnts08c4448@webmail4.isis.unc.edu> Thanks Guilherme. I think you're right that I must be approaching my layout incorrectly. Your sample code does work, but I anticipate that this would get fairly difficult to manage with complex windows. I thought that I was approaching the layout problem logically. Basically, I want two frames, one on the left and one on the right, so I created these frames within the larger (entire window) frame. Then, I want to fill each frame with various objects; for instance, a text box, label, button, and listbox in the left frame and a label and text box in the right. Is there a better way to approach this than what I am doing? My thinking is that the frames will look very awkward if the widgets take up the entire frames and the frames "shrink to fit" the widgets. Thanks again. Quoting Guilherme Polo : > On Tue, Nov 4, 2008 at 5:45 PM, wrote: >> Hi guys, >> >> I'm new to the list; actually just found out it existed. I'm fairly new to >> python and programming, and I'm just beginning with Tkinter. I'm trying to >> layout my page, and I'm having problems understanding the action of some of >> the frames. I actually posted about this on a general python help message >> board and someone suggested that I repost it to this list. My question is >> somewhat complex, so in attempt to simplify things a bit I am posting part >> of a response I posted in a thread on the previous message board. Hopefully >> this fully describes my problem: >> >> >> When I specify dimensions of the text boxes, no matter how high or low, the >> enclosing frame seems to adjust to fit the new boxes. So, for instance, if I >> try inserting a text widget in leftframe with dimensions 1x1, leftframe >> shrinks down to 1x1. If I make the text widget 100x100, leftframe takes that >> size. What I want, and what seems like should be happening, is if I have >> leftframe which is 500X500 pixels, and I create a text box wit effective >> dimensions of 200X200 (I understand that text widgets use lines as >> dimensions), the text box should take up a little less than half of >> leftframe, with leftframe remaining 500X500 pixels. Instead, leftframe is >> shrinking down to become 200X200, and I can't figure out why. After a while >> I tried removing the text boxes and I got the same problem. I think maybe >> this code will better illustrate the problem. This first set of code is the >> totally stripped down version, and you can see leftframe in white on the >> left, and rightframe in blue on the right. >> >> from Tkinter import * >> import tkFileDialog,tkSimpleDialog,tkMessageBox >> >> >> WINDOWWIDTH=500 >> WINDOWHEIGHT=500 >> TITLEFONT = ("Courier",12,"normal") >> HEADINGFONT = ("Helvetica",9,"bold") >> >> >> >> class App: >> def __init__ (self,master): >> self.window = Frame(master,width=WINDOWWIDTH,height=WINDOWHEIGHT) >> self.window.pack(expand=YES, fill=BOTH) >> self.master= master >> self.currentfeeds = [] >> #Create frame to contain all others >> self.display=Frame(self.window,width=WINDOWWIDTH,height=WINDOWHEIGHT, >> bg='black') >> self.display.pack() >> >> >> >> #Create widgets >> self.createwidgets() >> def createwidgets(self): >> # create a top menu >> self.addMenu(self.master) >> self.addToolbar() >> self.leftframe=Frame(self.display, >> width=WINDOWWIDTH/3,height=WINDOWHEIGHT, bg='white') >> self.rightframe=Frame(self.display, >> width=2*WINDOWWIDTH/3,height=WINDOWHEIGHT, bg='blue') >> self.leftframe.pack(side="left", expand="yes", fill="x") >> self.rightframe.pack(side="left", expand="yes", fill="x") >> >> >> >> def addMenu(self,master): >> self.menu = Menu(self.window) >> master.config(menu=self.menu) >> self.filemenu = Menu(self.menu) >> >> def addToolbar(self): >> self.toolbar = Frame(self.display) >> >> self.toolbar.pack(side='top',expand="yes", fill="x") >> >> >> root=Tk() >> app=App(root) >> >> root.mainloop() >> > > You could have simplified a lot more actually. (*) > >> >> >> >> Next, if I try to pack ANYTHING inside rightframe, it shrinks down to size >> and totally distorts my screen dimensions. Here is the exact same code, >> adding a label widget in self.rightframe. It completely shrinks rightframe >> and distorts the screen dimensions. Does my question make sense now? >> >> >> >> >> from Tkinter import * >> import tkFileDialog,tkSimpleDialog,tkMessageBox >> >> >> WINDOWWIDTH=500 >> WINDOWHEIGHT=500 >> TITLEFONT = ("Courier",12,"normal") >> HEADINGFONT = ("Helvetica",9,"bold") >> >> >> >> class App: >> def __init__ (self,master): >> self.window = Frame(master,width=WINDOWWIDTH,height=WINDOWHEIGHT) >> self.window.pack(expand=YES, fill=BOTH) >> self.master= master >> self.currentfeeds = [] >> #Create frame to contain all others >> self.display=Frame(self.window,width=WINDOWWIDTH,height=WINDOWHEIGHT, >> bg='black') >> self.display.pack() >> >> >> >> #Create widgets >> self.createwidgets() >> def createwidgets(self): >> # create a top menu >> self.addMenu(self.master) >> self.addToolbar() >> self.leftframe=Frame(self.display, >> width=WINDOWWIDTH/3,height=WINDOWHEIGHT, bg='white') >> self.rightframe=Frame(self.display, >> width=2*WINDOWWIDTH/3,height=WINDOWHEIGHT, bg='blue') >> self.leftframe.pack(side="left", expand="yes", fill="x") >> self.rightframe.pack(side="left", expand="yes", fill="x") >> >> >> >> self.label=Label(self.rightframe,text='Current >> story',font=HEADINGFONT).pack(side='top') >> def addMenu(self,master): >> self.menu = Menu(self.window) >> master.config(menu=self.menu) >> self.filemenu = Menu(self.menu) >> >> def addToolbar(self): >> self.toolbar = Frame(self.display) >> >> self.toolbar.pack(side='top',expand="yes", fill="x") >> >> >> root=Tk() >> app=App(root) >> >> root.mainloop() >> > > See (*). > > > Thinking about your problem for a moment, it is not really a problem. > You are not supposed to develop GUI applications with a completely > fixed layout, because people that will use the GUI app will adjust it > according to their preferences. It is very very bad to layout widgets > like that, and harder too. You should rethink about the problem you > are trying to solve. > > Said that, it is possibly to manually position things without using > pack or grid, that is, use place for that. But.. reconsider what you > are doing. Nevertheless, follows a sample that demonstrate what you > seems to want right now: > > > from Tkinter import Tk, Frame, Label > > WINDOWWIDTH = 500 > WINDOWHEIGHT = 500 > > class App: > def __init__ (self): > #Create frame to contain all others > self.display = Frame(width=WINDOWWIDTH, height=WINDOWHEIGHT) > self.display.pack() > > #Create widgets > self.createwidgets() > > def createwidgets(self): > self.leftframe=Frame(self.display, width=WINDOWWIDTH / 3, > height=WINDOWHEIGHT, bg='red') > self.rightframe=Frame(self.display, width=2 * WINDOWWIDTH / 3, > height=WINDOWHEIGHT, bg='blue') > self.leftframe.pack(side="left", expand=True, fill="x") > self.rightframe.pack(side="left", expand=True, fill="x") > > label = Label(self.rightframe, text='test') > label.place(x=200, y=200) > > > root = Tk() > app = App() > root.mainloop() > > > It is possible that you are after paned windows, that is perfectly > understandable then. For that, take a look at Tkinter.PanedWindow > > -- > -- Guilherme H. Polo Goncalves > From ggpolo at gmail.com Tue Nov 4 23:10:03 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Tue, 4 Nov 2008 20:10:03 -0200 Subject: [Tkinter-discuss] Tkinter page layout In-Reply-To: <20081104165920.9oea9fnts08c4448@webmail4.isis.unc.edu> References: <20081104144554.n0zia4p6gwk0sksw@webmail4.isis.unc.edu> <20081104165920.9oea9fnts08c4448@webmail4.isis.unc.edu> Message-ID: On Tue, Nov 4, 2008 at 7:59 PM, wrote: > Thanks Guilherme. I think you're right that I must be approaching my layout > incorrectly. Your sample code does work, but I anticipate that this would > get fairly difficult to manage with complex windows. I thought that I was > approaching the layout problem logically. Basically, I want two frames, one > on the left and one on the right, so I created these frames within the > larger (entire window) frame. Then, I want to fill each frame with various > objects; for instance, a text box, label, button, and listbox in the left > frame and a label and text box in the right. Is there a better way to > approach this than what I am doing? Did you check the last line I wrote in the previous email ? Maybe you just want to use a Tkinter.PanedWindow > My thinking is that the frames will look > very awkward if the widgets take up the entire frames and the frames "shrink > to fit" the widgets. > Uhm.. I don't think so. All the time you see GUI applications using this form of widget layout and I doubt you consider they all awkward. > Thanks again. -- -- Guilherme H. Polo Goncalves From Ferg.Stephen at bls.gov Wed Nov 5 17:37:14 2008 From: Ferg.Stephen at bls.gov (Ferg, Stephen - BLS) Date: Wed, 5 Nov 2008 11:37:14 -0500 Subject: [Tkinter-discuss] Tkinter page layout In-Reply-To: <11C64B18E4E93049BD58E8532CA9FE7F1C5FA5AC@psbexmb1.psb.bls.gov> References: <20081104144554.n0zia4p6gwk0sksw@webmail4.isis.unc.edu> <11C64B18E4E93049BD58E8532CA9FE7F1C5FA5AC@psbexmb1.psb.bls.gov> Message-ID: <11C64B18E4E93049BD58E8532CA9FE7F1C5FA5AD@psbexmb1.psb.bls.gov> Re: ================================================================ Next, if I try to pack ANYTHING inside rightframe, it shrinks down to size and totally distorts my screen dimensions. Here is the exact same code, adding a label widget in self.rightframe. It completely shrinks rightframe and distorts the screen dimensions. Does my question make sense now? ================================================================ Maybe "Thinking in Tkinter" can shed some light on your situation... ================================================================ tt095.py Sizing windows can be a frustrating experience when working with Tkinter. Imagine this situation. You believe in iterative development, so first you carefully lay out a frame with the height and width specification that you want. You test it and you see that it works. Then you move on to the next step, and add some buttons to the frame. You test it again, but now to your surprise Tkinter is acting as if there were no "height" and "width" specifications for the frame, and the frame has snapped down to tightly encase the buttons. What's going on ???!!! Well, the packer's behavior is inconsistent. Or, shall we say: the packer's behavior depends on a lot of situational factors. The bottom line is that the packer will honor the size request of a container if the container is empty, but if the container contains any other widgets, then the elastic nature of the container comes to the fore -- the "height" and "width" settings for the container are ignored, and the size of the container is adjusted to enclose the widgets as closely as possible. The bottom line is that you really cannot control the size of a container that contains widgets. What you CAN control is the the initial size of the entire root window, and you do this with the Window Manager "geometry" option. ================================================================ see... http://www.ferg.org/thinking_in_tkinter/all_programs.html and more generally... http://www.ferg.org/thinking_in_tkinter/index.html -- Steve Ferg _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss at python.org http://mail.python.org/mailman/listinfo/tkinter-discuss From Ferg.Stephen at bls.gov Wed Nov 5 17:21:36 2008 From: Ferg.Stephen at bls.gov (Ferg, Stephen - BLS) Date: Wed, 5 Nov 2008 11:21:36 -0500 Subject: [Tkinter-discuss] Tkinter page layout In-Reply-To: <20081104144554.n0zia4p6gwk0sksw@webmail4.isis.unc.edu> References: <20081104144554.n0zia4p6gwk0sksw@webmail4.isis.unc.edu> Message-ID: <11C64B18E4E93049BD58E8532CA9FE7F1C5FA5AC@psbexmb1.psb.bls.gov> Re: Next, if I try to pack ANYTHING inside rightframe, it shrinks down to size and totally distorts my screen dimensions. Here is the exact same code, adding a label widget in self.rightframe. It completely shrinks rightframe and distorts the screen dimensions. Does my question make sense now? Maybe "Thinking in Tkinter" can shed some light on your situation... ================================================================ tt095.py Sizing windows can be a frustrating experience when working with Tkinter. Imagine this situation. You believe in iterative development, so first you carefully lay out a frame with the height and width specification that you want. You test it and you see that it works. Then you move on to the next step, and add some buttons to the frame. You test it again, but now to your surprise Tkinter is acting as if there were no "height" and "width" specifications for the frame, and the frame has snapped down to tightly encase the buttons. What's going on ???!!! Well, the packer's behavior is inconsistent. Or, shall we say: the packer's behavior depends on a lot of situational factors. The bottom line is that the packer will honor the size request of a container if the container is empty, but if the container contains any other widgets, then the elastic nature of the container comes to the fore -- the "height" and "width" settings for the container are ignored, and the size of the container is adjusted to enclose the widgets as closely as possible. The bottom line is that you really cannot control the size of a container that contains widgets. What you CAN control is the the initial size of the entire root window, and you do this with the Window Manager "geometry" option. ================================================================ see... http://www.ferg.org/thinking_in_tkinter/all_programs.html and more generally... http://www.ferg.org/thinking_in_tkinter/index.html -- Steve Ferg _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss at python.org http://mail.python.org/mailman/listinfo/tkinter-discuss From david.giesen at kodak.com Fri Nov 7 14:18:18 2008 From: david.giesen at kodak.com (david.giesen at kodak.com) Date: Fri, 7 Nov 2008 08:18:18 -0500 Subject: [Tkinter-discuss] Scale widget fires command on entering mainloop? Message-ID: Hi - I'm trying to figure out why the Tkinter Scale widget seems to fire its command callback when the root.mainloop() is executed. This seems in contrast with other widgets like the Button that only fire the command callback in response to user interaction. I'm using Windows XP, the Python 2.5 and, based on the folder names in the Python\tcl folder, tk8.4 and tcl8.4. Below is an example script. It sets up two sliders who get values initialized in two different ways. The print statements show that the sliders are initialized and packed, and THEN the command callbacks occur once the root.mainloop() statement executes. Can suggest a way to prevent this from happening? I could have each callback do no action the first time it is called, I suppose. But I wonder if I'm simply doing something wrong, or if I'm assuming a behavior from Tkinter that I should not, or if I've encountered something "strange". Thanks in advance! Dave Giesen # Start of demo script import Tkinter as Tk import gwidgets as gw root = Tk.Tk() def printme1(value): print 'Scale # 1 just called back with value:', value scalevar = gw.iVar(7) scale1 = Tk.Scale(root, command=printme1, variable=scalevar) print 'Scale #1 initialized with value:', scale1.get() def printme2(value): print 'Scale # 2 just called back with value:', value scale2 = Tk.Scale(root) print 'Scale #2 initialized with value: ', scale2.get() scale2.set(4) print 'Scale #2 just set to value: ', scale2.get() scale2.configure(command=printme2) print 'Now packing scales' scale1.pack() scale2.pack() print 'Done packing scales' root.mainloop() # End of demo script From ggpolo at gmail.com Fri Nov 7 15:23:48 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Fri, 7 Nov 2008 12:23:48 -0200 Subject: [Tkinter-discuss] Scale widget fires command on entering mainloop? In-Reply-To: References: Message-ID: On Fri, Nov 7, 2008 at 11:18 AM, wrote: > Hi - > > I'm trying to figure out why the Tkinter Scale widget seems to fire its > command callback when the root.mainloop() is executed. This seems in > contrast with other widgets like the Button that only fire the command > callback in response to user interaction. I'm using Windows XP, the > Python 2.5 and, based on the folder names in the Python\tcl folder, tk8.4 > and tcl8.4. > > Below is an example script. It sets up two sliders who get values > initialized in two different ways. The print statements show that the > sliders are initialized and packed, and THEN the command callbacks occur > once the root.mainloop() statement executes. > > Can suggest a way to prevent this from happening? I could have each > callback do no action the first time it is called, I suppose. But I > wonder if I'm simply doing something wrong, or if I'm assuming a behavior > from Tkinter that I should not, or if I've encountered something > "strange". > > Thanks in advance! > > Dave Giesen > > # Start of demo script > import Tkinter as Tk > import gwidgets as gw > > root = Tk.Tk() > def printme1(value): > print 'Scale # 1 just called back with value:', value > scalevar = gw.iVar(7) > scale1 = Tk.Scale(root, command=printme1, variable=scalevar) > print 'Scale #1 initialized with value:', scale1.get() > > def printme2(value): > print 'Scale # 2 just called back with value:', value > scale2 = Tk.Scale(root) > print 'Scale #2 initialized with value: ', scale2.get() > scale2.set(4) > print 'Scale #2 just set to value: ', scale2.get() > scale2.configure(command=printme2) > > print 'Now packing scales' > scale1.pack() > scale2.pack() > print 'Done packing scales' > > root.mainloop() > # End of demo script Comparing this Scale example with a command set and a Button with a command set is unfair. When you change Scale's value, the scale eventually has to be redraw. So, you create a Scale with the "command" option set, then you change its value by calling scale.set, then you run mainloop. When mainloop runs the scheduled events start firing, and there is one around there saying your scale changed its value so the slider has to be redrawn. But you also set a command, so, since the scale changed now it must be invoked, and the callback is called. Can you explain why is it a problem to invoke the callback if the scale has changed ? And why don't you want it to be called the first time. -- -- Guilherme H. Polo Goncalves From ggpolo at gmail.com Fri Nov 7 16:32:06 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Fri, 7 Nov 2008 13:32:06 -0200 Subject: [Tkinter-discuss] Scale widget fires command on entering mainloop? In-Reply-To: References: Message-ID: On Fri, Nov 7, 2008 at 12:53 PM, wrote: > "Guilherme Polo" wrote on 11/07/2008 09:23:48 AM: >> >> Comparing this Scale example with a command set and a Button with a >> command set is unfair. When you change Scale's value, the scale >> eventually has to be redraw. >> >> So, you create a Scale with the "command" option set, then you change >> its value by calling scale.set, then you run mainloop. When mainloop >> runs the scheduled events start firing, and there is one around there >> saying your scale changed its value so the slider has to be redrawn. >> But you also set a command, so, since the scale changed now it must be >> invoked, and the callback is called. >> >> Can you explain why is it a problem to invoke the callback if the >> scale has changed ? And why don't you want it to be called the first >> time. >> >> -- >> -- Guilherme H. Polo Goncalves > > Thanks for the quick response and the explanation about there being a > scheduled events queue that waiting for the mainloop to start, Guilherme. > That's something I hadn't thought about and it explains why there is a > delayed command firing. However, it doesn't change my thinking that the > command shouldn't be firing at all in these two cases. > > First off, I have no problem if the callback is invoked when the scale is > changed, that is why I'm using it. > > However, in the first case, I don't think of the scale being 'changed'. > I'm giving it the initial value via the Tkinter variable scalevar and I'm > not changing it, so I don't understand why the command gets called. The > scale doesn't have to be redrawn, only drawn the first time. Maybe my > original button argument wasn't the best, but I do see this as the same as > a Checkbutton. I can pass in an initial value to the Checkbutton via a > Tkinter variable, and the Checkbutton command does not fire when the > mainloop starts (see the example below, which I've also fixed so it no > longer imports a custom module of my own - it should run for anyone now). > > And in the second case, there is no command callback registered at the > time that I change the scale value - the callback is added later via a > configure statement. So again, I don't see why a callback is registered > for the change. This behavior is again different from a checkbutton - if > I create a checkbutton with no callback, then change the value, then add a > callback function, the callback command is not called. I've added both > the checkbutton examples to the code below for comparison. > > As for why I don't want the callback to be called when the widget is first > created, well I might have something in my callback routine that I only > want to occur in response to the user changing the initial scale value. > Regardless, it seems like quite non-standard and unexpected (to me) > behavior since other widgets don't do this. > > Dave > > > import Tkinter as Tk > > root = Tk.Tk() > def printme1(value): > print 'Scale # 1 just fired with value:', value > scalevar = Tk.IntVar() > scalevar.set(7) > scale1 = Tk.Scale(root, command=printme1, variable=scalevar) > print 'Scale #1 initialized with value:', scale1.get() > Ok, it is understandable that you want the callback to not be invoked in this case, but unfortunately that is how scale works for now. It may not make a difference to the problem, but the behaviour of ttk.Scale is the one you are expecting. > def printme2(value): > print 'Scale # 2 just fired with value:', value > scale2 = Tk.Scale(root) > print 'Scale #2 initialized with value: ', scale2.get() > scale2.set(4) > print 'Scale #2 just set to value: ', scale2.get() > scale2.configure(command=printme2) > Now this is basically the same as the example in the other email. It is differently internally in tkScale.c, but will result in the same actions. Calling scale2.configure includes setting the scale value to itself to ensure that the scale's value is within the new acceptable range for the scale (note that you didn't change its range, but unfortunately it does this anyway). When it goes to set the scale's value, the scale command is already set (you just gave it one), so it is scheduled for redrawn and the callback will eventually be called. To achieve what you want you will have to drop the "command" option usage and stick to tcl variables. In the first example in this email you already used an IntVar, now all you have to do is trace that variable for changes on it, specially when you write to it. This means: scalevar.trace_variable('w', callback) callback is a function that takes 3 arguments, the first is the variable name, the second is just used if you are using an tcl array (Tkinter.py doesn't wrap it), and the third argument will be the flags given to trace_variable ('w' here). To access the variable value in the callback you would do something like: root.globalgetvar(varname) where root could be Tkinter.Tk() for example, and varname would be the first parameter in the callback function. > def printme3(): > print 'Checkbutton # 1 just fired with value:', cbvar.get() > cbvar = Tk.IntVar() > cbvar.set(1) > cb1 = Tk.Checkbutton(root, variable=cbvar, command=printme3) > print 'Checkbutton #1 initialized with value: ', cbvar.get() > > def printme4(): > print 'Checkbutton # 2 just fired with value:', cbvar2.get() > cbvar2 = Tk.IntVar() > cbvar2.set(1) > cb2 = Tk.Checkbutton(root, variable=cbvar) > cb2.invoke() > print 'Just invoked cb2 with no callback' > cb2.configure(command=printme4) > > print 'Now packing scales' > scale1.pack() > scale2.pack() > cb1.pack() > print 'Done packing scales' > > root.mainloop() > -- -- Guilherme H. Polo Goncalves From ggpolo at gmail.com Fri Nov 7 16:35:46 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Fri, 7 Nov 2008 13:35:46 -0200 Subject: [Tkinter-discuss] Scale widget fires command on entering mainloop? In-Reply-To: References: Message-ID: On Fri, Nov 7, 2008 at 1:32 PM, Guilherme Polo wrote: > On Fri, Nov 7, 2008 at 12:53 PM, wrote: >> "Guilherme Polo" wrote on 11/07/2008 09:23:48 AM: >>> >>> Comparing this Scale example with a command set and a Button with a >>> command set is unfair. When you change Scale's value, the scale >>> eventually has to be redraw. >>> >>> So, you create a Scale with the "command" option set, then you change >>> its value by calling scale.set, then you run mainloop. When mainloop >>> runs the scheduled events start firing, and there is one around there >>> saying your scale changed its value so the slider has to be redrawn. >>> But you also set a command, so, since the scale changed now it must be >>> invoked, and the callback is called. >>> >>> Can you explain why is it a problem to invoke the callback if the >>> scale has changed ? And why don't you want it to be called the first >>> time. >>> >>> -- >>> -- Guilherme H. Polo Goncalves >> >> Thanks for the quick response and the explanation about there being a >> scheduled events queue that waiting for the mainloop to start, Guilherme. >> That's something I hadn't thought about and it explains why there is a >> delayed command firing. However, it doesn't change my thinking that the >> command shouldn't be firing at all in these two cases. >> >> First off, I have no problem if the callback is invoked when the scale is >> changed, that is why I'm using it. >> >> However, in the first case, I don't think of the scale being 'changed'. >> I'm giving it the initial value via the Tkinter variable scalevar and I'm >> not changing it, so I don't understand why the command gets called. The >> scale doesn't have to be redrawn, only drawn the first time. Maybe my >> original button argument wasn't the best, but I do see this as the same as >> a Checkbutton. I can pass in an initial value to the Checkbutton via a >> Tkinter variable, and the Checkbutton command does not fire when the >> mainloop starts (see the example below, which I've also fixed so it no >> longer imports a custom module of my own - it should run for anyone now). >> >> And in the second case, there is no command callback registered at the >> time that I change the scale value - the callback is added later via a >> configure statement. So again, I don't see why a callback is registered >> for the change. This behavior is again different from a checkbutton - if >> I create a checkbutton with no callback, then change the value, then add a >> callback function, the callback command is not called. I've added both >> the checkbutton examples to the code below for comparison. >> >> As for why I don't want the callback to be called when the widget is first >> created, well I might have something in my callback routine that I only >> want to occur in response to the user changing the initial scale value. >> Regardless, it seems like quite non-standard and unexpected (to me) >> behavior since other widgets don't do this. >> >> Dave >> >> >> import Tkinter as Tk >> >> root = Tk.Tk() >> def printme1(value): >> print 'Scale # 1 just fired with value:', value >> scalevar = Tk.IntVar() >> scalevar.set(7) >> scale1 = Tk.Scale(root, command=printme1, variable=scalevar) >> print 'Scale #1 initialized with value:', scale1.get() >> > > Ok, it is understandable that you want the callback to not be invoked > in this case, but unfortunately that is how scale works for now. It > may not make a difference to the problem, but the behaviour of > ttk.Scale is the one you are expecting. > >> def printme2(value): >> print 'Scale # 2 just fired with value:', value >> scale2 = Tk.Scale(root) >> print 'Scale #2 initialized with value: ', scale2.get() >> scale2.set(4) >> print 'Scale #2 just set to value: ', scale2.get() >> scale2.configure(command=printme2) >> > > Now this is basically the same as the example in the other email. It > is differently internally in tkScale.c, but will result in the same > actions. Calling scale2.configure includes setting the scale value to > itself to ensure that the scale's value is within the new acceptable > range for the scale (note that you didn't change its range, but > unfortunately it does this anyway). When it goes to set the scale's > value, the scale command is already set (you just gave it one), so it > is scheduled for redrawn and the callback will eventually be called. > > To achieve what you want you will have to drop the "command" option > usage and stick to tcl variables. In the first example in this email > you already used an IntVar, now all you have to do is trace that > variable for changes on it, specially when you write to it. This > means: > > scalevar.trace_variable('w', callback) > > callback is a function that takes 3 arguments, the first is the > variable name, the second is just used if you are using an tcl array > (Tkinter.py doesn't wrap it), and the third argument will be the flags > given to trace_variable ('w' here). > To access the variable value in the callback you would do something > like: root.globalgetvar(varname) where root could be Tkinter.Tk() for > example, and varname would be the first parameter in the callback > function. root.tk.globalgetvar actually > >> def printme3(): >> print 'Checkbutton # 1 just fired with value:', cbvar.get() >> cbvar = Tk.IntVar() >> cbvar.set(1) >> cb1 = Tk.Checkbutton(root, variable=cbvar, command=printme3) >> print 'Checkbutton #1 initialized with value: ', cbvar.get() >> >> def printme4(): >> print 'Checkbutton # 2 just fired with value:', cbvar2.get() >> cbvar2 = Tk.IntVar() >> cbvar2.set(1) >> cb2 = Tk.Checkbutton(root, variable=cbvar) >> cb2.invoke() >> print 'Just invoked cb2 with no callback' >> cb2.configure(command=printme4) >> Just quickly commenting on these examples. Well, they are different widgets after all. A checkbutton doesn't draw a slider, it is much easier to control its values. >> print 'Now packing scales' >> scale1.pack() >> scale2.pack() >> cb1.pack() >> print 'Done packing scales' >> >> root.mainloop() >> > > > > -- > -- Guilherme H. Polo Goncalves > -- -- Guilherme H. Polo Goncalves From david.giesen at kodak.com Fri Nov 7 16:50:20 2008 From: david.giesen at kodak.com (david.giesen at kodak.com) Date: Fri, 7 Nov 2008 10:50:20 -0500 Subject: [Tkinter-discuss] Scale widget fires command on entering mainloop? In-Reply-To: Message-ID: Ahh - thanks for the clear explanations and the workaround! Do you see these behaviors as "unexpected" enough that I should submit them to someone as something to possibly change in the future, or do you feel that they are appropriate - or at least appropriate enough not to make a change that might break old code? And if they should be submitted, to whom? Thanks again! Dave "Guilherme Polo" wrote on 11/07/2008 10:32:06 AM: > On Fri, Nov 7, 2008 at 12:53 PM, wrote: > > "Guilherme Polo" wrote on 11/07/2008 09:23:48 AM: > >> > >> Comparing this Scale example with a command set and a Button with a > >> command set is unfair. When you change Scale's value, the scale > >> eventually has to be redraw. > >> > >> So, you create a Scale with the "command" option set, then you change > >> its value by calling scale.set, then you run mainloop. When mainloop > >> runs the scheduled events start firing, and there is one around there > >> saying your scale changed its value so the slider has to be redrawn. > >> But you also set a command, so, since the scale changed now it must be > >> invoked, and the callback is called. > >> > >> Can you explain why is it a problem to invoke the callback if the > >> scale has changed ? And why don't you want it to be called the first > >> time. > >> > >> -- > >> -- Guilherme H. Polo Goncalves > > > > Thanks for the quick response and the explanation about there being a > > scheduled events queue that waiting for the mainloop to start, Guilherme. > > That's something I hadn't thought about and it explains why there is a > > delayed command firing. However, it doesn't change my thinking that the > > command shouldn't be firing at all in these two cases. > > > > First off, I have no problem if the callback is invoked when the scale is > > changed, that is why I'm using it. > > > > However, in the first case, I don't think of the scale being 'changed'. > > I'm giving it the initial value via the Tkinter variable scalevar and I'm > > not changing it, so I don't understand why the command gets called. The > > scale doesn't have to be redrawn, only drawn the first time. Maybe my > > original button argument wasn't the best, but I do see this as the same as > > a Checkbutton. I can pass in an initial value to the Checkbutton via a > > Tkinter variable, and the Checkbutton command does not fire when the > > mainloop starts (see the example below, which I've also fixed so it no > > longer imports a custom module of my own - it should run for anyone now). > > > > And in the second case, there is no command callback registered at the > > time that I change the scale value - the callback is added later via a > > configure statement. So again, I don't see why a callback is registered > > for the change. This behavior is again different from a checkbutton - if > > I create a checkbutton with no callback, then change the value, then add a > > callback function, the callback command is not called. I've added both > > the checkbutton examples to the code below for comparison. > > > > As for why I don't want the callback to be called when the widget is first > > created, well I might have something in my callback routine that I only > > want to occur in response to the user changing the initial scale value. > > Regardless, it seems like quite non-standard and unexpected (to me) > > behavior since other widgets don't do this. > > > > Dave > > > > > > import Tkinter as Tk > > > > root = Tk.Tk() > > def printme1(value): > > print 'Scale # 1 just fired with value:', value > > scalevar = Tk.IntVar() > > scalevar.set(7) > > scale1 = Tk.Scale(root, command=printme1, variable=scalevar) > > print 'Scale #1 initialized with value:', scale1.get() > > > > Ok, it is understandable that you want the callback to not be invoked > in this case, but unfortunately that is how scale works for now. It > may not make a difference to the problem, but the behaviour of > ttk.Scale is the one you are expecting. > > > def printme2(value): > > print 'Scale # 2 just fired with value:', value > > scale2 = Tk.Scale(root) > > print 'Scale #2 initialized with value: ', scale2.get() > > scale2.set(4) > > print 'Scale #2 just set to value: ', scale2.get() > > scale2.configure(command=printme2) > > > > Now this is basically the same as the example in the other email. It > is differently internally in tkScale.c, but will result in the same > actions. Calling scale2.configure includes setting the scale value to > itself to ensure that the scale's value is within the new acceptable > range for the scale (note that you didn't change its range, but > unfortunately it does this anyway). When it goes to set the scale's > value, the scale command is already set (you just gave it one), so it > is scheduled for redrawn and the callback will eventually be called. > > To achieve what you want you will have to drop the "command" option > usage and stick to tcl variables. In the first example in this email > you already used an IntVar, now all you have to do is trace that > variable for changes on it, specially when you write to it. This > means: > > scalevar.trace_variable('w', callback) > > callback is a function that takes 3 arguments, the first is the > variable name, the second is just used if you are using an tcl array > (Tkinter.py doesn't wrap it), and the third argument will be the flags > given to trace_variable ('w' here). > To access the variable value in the callback you would do something > like: root.globalgetvar(varname) where root could be Tkinter.Tk() for > example, and varname would be the first parameter in the callback > function. > > > def printme3(): > > print 'Checkbutton # 1 just fired with value:', cbvar.get() > > cbvar = Tk.IntVar() > > cbvar.set(1) > > cb1 = Tk.Checkbutton(root, variable=cbvar, command=printme3) > > print 'Checkbutton #1 initialized with value: ', cbvar.get() > > > > def printme4(): > > print 'Checkbutton # 2 just fired with value:', cbvar2.get() > > cbvar2 = Tk.IntVar() > > cbvar2.set(1) > > cb2 = Tk.Checkbutton(root, variable=cbvar) > > cb2.invoke() > > print 'Just invoked cb2 with no callback' > > cb2.configure(command=printme4) > > > > print 'Now packing scales' > > scale1.pack() > > scale2.pack() > > cb1.pack() > > print 'Done packing scales' > > > > root.mainloop() > > > > > > -- > -- Guilherme H. Polo Goncalves From ggpolo at gmail.com Fri Nov 7 17:02:46 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Fri, 7 Nov 2008 14:02:46 -0200 Subject: [Tkinter-discuss] Scale widget fires command on entering mainloop? In-Reply-To: References: Message-ID: On Fri, Nov 7, 2008 at 1:50 PM, wrote: > Ahh - thanks for the clear explanations and the workaround! > > Do you see these behaviors as "unexpected" enough that I should submit > them to someone as something to possibly change in the future, or do you > feel that they are appropriate - or at least appropriate enough not to > make a change that might break old code? > I will let that to someone else judge > And if they should be submitted, to whom? Given the unexpected behaviour is in tk itself, you should report it in the tk bug tracker: http://sourceforge.net/tracker/?atid=112997&group_id=12997&func=browse If it was a problem with Tkinter then you would report it at bugs.python.org instead (not the case here). > > Thanks again! > > Dave -- -- Guilherme H. Polo Goncalves From ggpolo at gmail.com Fri Nov 7 17:24:59 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Fri, 7 Nov 2008 14:24:59 -0200 Subject: [Tkinter-discuss] Scale widget fires command on entering mainloop? In-Reply-To: References: Message-ID: On Fri, Nov 7, 2008 at 2:02 PM, Guilherme Polo wrote: > On Fri, Nov 7, 2008 at 1:50 PM, wrote: >> Ahh - thanks for the clear explanations and the workaround! >> >> Do you see these behaviors as "unexpected" enough that I should submit >> them to someone as something to possibly change in the future, or do you >> feel that they are appropriate - or at least appropriate enough not to >> make a change that might break old code? >> > > I will let that to someone else judge > >> And if they should be submitted, to whom? > > Given the unexpected behaviour is in tk itself, you should report it > in the tk bug tracker: > http://sourceforge.net/tracker/?atid=112997&group_id=12997&func=browse > It would be good to include a minimal tcl sample too: scale .s -command {puts} pack .s > If it was a problem with Tkinter then you would report it at > bugs.python.org instead (not the case here). > >> >> Thanks again! >> >> Dave > > -- > -- Guilherme H. Polo Goncalves > -- -- Guilherme H. Polo Goncalves From ggpolo at gmail.com Sat Nov 8 22:47:33 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Sat, 8 Nov 2008 19:47:33 -0200 Subject: [Tkinter-discuss] New tktable python wrapper Message-ID: Hi there, I've fixed some problems with the current tktable python wrapper (found in tktable's cvs) while using the current Tkinter, added some other methods that weren't there and some other things. I though it would be of interest of someone around here to know that, so I'm writing this email. It can be found at http://tkinter.unpy.net/wiki/TkTableWrapper right now. There are tests for it but they are not there. Regards, -- -- Guilherme H. Polo Goncalves From david.giesen at kodak.com Tue Nov 11 15:11:06 2008 From: david.giesen at kodak.com (david.giesen at kodak.com) Date: Tue, 11 Nov 2008 09:11:06 -0500 Subject: [Tkinter-discuss] Custom Colors in tkColorChooser dialog Message-ID: Hi - When invoking the tkColorChooser.askcolor() dialog on Windows, a window pops up that shows on the lefthand side a grid of basic color patches and two rows of custom color patches. The custom color patches by default seem to simply be a set of reds and purples. The user can modify these, but the modifications only last for the duration of the program - the next time it starts, the colors are back to the defaults. Is there any way to modify this set of custom colors via code? I'd like to present the users with a custom template for a program I'm writing. Thanks! Dave David J. Giesen | Research Scientist | FPEG US Display OLED Materials R+D | Eastman Kodak Company | 2/83/KRL MC02216 | Rochester, NY 14650 | david.giesen at kodak.com | 1-585-588-0480 Office | www.kodak.com From ggpolo at gmail.com Tue Nov 11 15:40:04 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Tue, 11 Nov 2008 12:40:04 -0200 Subject: [Tkinter-discuss] Custom Colors in tkColorChooser dialog In-Reply-To: References: Message-ID: On Tue, Nov 11, 2008 at 12:11 PM, wrote: > Hi - > > When invoking the tkColorChooser.askcolor() dialog on Windows, a window > pops up that shows on the lefthand side a grid of basic color patches and > two rows of custom color patches. > > The custom color patches by default seem to simply be a set of reds and > purples. The user can modify these, but the modifications only last for > the duration of the program - the next time it starts, the colors are back > to the defaults. Is there any way to modify this set of custom colors via > code? tkColorChooser is platform specific, on windows it actually uses ColorChooser (check msdn for that) to display the color picker dialog. On unix != macosx you will get a generic one which doesn't even have a palette. Even if you want to target only Windows, I don't think you can add a hook (be it through pywin32, ctypes, ..) into windows' colorchooser to load a custom palette. It is possible that there are better functions for this in the windows api (which then could be suggested in the tk bug tracker to replace or use if available instead of ColorChooser), or maybe it is even possible to add a hook in ColorChooser somehow but I don't know how offhand. Now, the less hacky option is to create a widget yourself. tk comes with a demo called tcolor which already supports rgb, cmy and hsb, so all you have to do is put a "pallete bar" on it (and convert it to python =) ) and have total control over it. > I'd like to present the users with a custom template for a program > I'm writing. > > Thanks! > > Dave > > David J. Giesen | Research Scientist | FPEG US Display OLED Materials R+D > | > Eastman Kodak Company | 2/83/KRL MC02216 | Rochester, NY 14650 | > david.giesen at kodak.com | 1-585-588-0480 Office | > www.kodak.com > -- -- Guilherme H. Polo Goncalves From david.giesen at kodak.com Tue Nov 11 17:06:29 2008 From: david.giesen at kodak.com (david.giesen at kodak.com) Date: Tue, 11 Nov 2008 11:06:29 -0500 Subject: [Tkinter-discuss] Custom Colors in tkColorChooser dialog In-Reply-To: Message-ID: Ok - I was afraid of that. Thanks! Dave David J. Giesen | Research Scientist | FPEG US Display OLED Materials R+D | Eastman Kodak Company | 2/83/KRL MC02216 | Rochester, NY 14650 | david.giesen at kodak.com | 1-585-588-0480 Office | www.kodak.com "Guilherme Polo" wrote on 11/11/2008 09:40:04 AM: > On Tue, Nov 11, 2008 at 12:11 PM, wrote: > > Hi - > > > > When invoking the tkColorChooser.askcolor() dialog on Windows, a window > > pops up that shows on the lefthand side a grid of basic color patches and > > two rows of custom color patches. > > > > The custom color patches by default seem to simply be a set of reds and > > purples. The user can modify these, but the modifications only last for > > the duration of the program - the next time it starts, the colors are back > > to the defaults. Is there any way to modify this set of custom colors via > > code? > > tkColorChooser is platform specific, on windows it actually uses > ColorChooser (check msdn for that) to display the color picker dialog. > On unix != macosx you will get a generic one which doesn't even have a > palette. > Even if you want to target only Windows, I don't think you can add a > hook (be it through pywin32, ctypes, ..) into windows' colorchooser to > load a custom palette. It is possible that there are better functions > for this in the windows api (which then could be suggested in the tk > bug tracker to replace or use if available instead of ColorChooser), > or maybe it is even possible to add a hook in ColorChooser somehow but > I don't know how offhand. > > Now, the less hacky option is to create a widget yourself. tk comes > with a demo called tcolor which already supports rgb, cmy and hsb, so > all you have to do is put a "pallete bar" on it (and convert it to > python =) ) and have total control over it. > > > I'd like to present the users with a custom template for a program > > I'm writing. > > > > Thanks! > > > > Dave > > > > David J. Giesen | Research Scientist | FPEG US Display OLED Materials R+D > > | > > Eastman Kodak Company | 2/83/KRL MC02216 | Rochester, NY 14650 | > > david.giesen at kodak.com | 1-585-588-0480 Office | > > www.kodak.com > > > > > -- > -- Guilherme H. Polo Goncalves From allblue_football at yahoo.com Tue Nov 11 19:29:18 2008 From: allblue_football at yahoo.com (Jason Minters) Date: Tue, 11 Nov 2008 10:29:18 -0800 (PST) Subject: [Tkinter-discuss] 64-bit version? Message-ID: <595494.18809.qm@web32905.mail.mud.yahoo.com> Hi all, does anyone have a 64-bit version of TkInter? -Jason From ggpolo at gmail.com Tue Nov 11 20:28:40 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Tue, 11 Nov 2008 17:28:40 -0200 Subject: [Tkinter-discuss] Fwd: 64-bit version? In-Reply-To: References: <595494.18809.qm@web32905.mail.mud.yahoo.com> Message-ID: ---------- Forwarded message ---------- From: Guilherme Polo Date: Tue, Nov 11, 2008 at 5:28 PM Subject: Re: [Tkinter-discuss] 64-bit version? To: allblue_football at yahoo.com On Tue, Nov 11, 2008 at 4:29 PM, Jason Minters wrote: > Hi all, does anyone have a 64-bit version of TkInter? > ActiveState has both python 64bit binary package (linux and windows) and tcl/tk 64bit binary package (linux). > -Jason > -- -- Guilherme H. Polo Goncalves From Allen.Taylor at mdacorporation.com Wed Nov 12 17:37:12 2008 From: Allen.Taylor at mdacorporation.com (Allen Taylor) Date: Wed, 12 Nov 2008 11:37:12 -0500 Subject: [Tkinter-discuss] GUI testing Message-ID: <491ABFE8.FA48.005C.0@mdacorporation.com> Hello all, I've got a Python/Tkinter application that I'd like to automate GUI testing for. I found Dogtail, but it requires the GUI app to be "AT-SPI-aware". I see that there is a binding from Python to AT-SPI (Python atspi package; this is what Dogtail uses to control the app). Has anyone done any development to make this work with Tkinter apps? Or, is there another method by which I can automate GUI testing of my Python/Tk app? Many thanks. Allen B. Taylor MDA 9445 Airport Road Brampton, ON L6S 4J3 905-790-2800 ext. 4350 allen.taylor at mdacorporation.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ggpolo at gmail.com Wed Nov 12 17:45:43 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Wed, 12 Nov 2008 14:45:43 -0200 Subject: [Tkinter-discuss] GUI testing In-Reply-To: <491ABFE8.FA48.005C.0@mdacorporation.com> References: <491ABFE8.FA48.005C.0@mdacorporation.com> Message-ID: On Wed, Nov 12, 2008 at 2:37 PM, Allen Taylor wrote: > Hello all, > I've got a Python/Tkinter application that I'd like to automate GUI testing > for. I found Dogtail, but it requires the GUI app to be "AT-SPI-aware". I > see that there is a binding from Python to AT-SPI (Python atspi package; > this is what Dogtail uses to control the app). Has anyone done > any development to make this work with Tkinter apps? Or, is there another > method by which I can automate GUI testing of my Python/Tk app? I have used the standard unittest way to test ttk widgets. tests for python 2.x can be found at http://svn.python.org/view/sandbox/trunk/ttk-gsoc/src/2.x/test/ right now, soon (like a week maybe) I will be moving that to another branch. It simulates some mouse clicks in some very specific areas, but could be expanded. Maybe you can use some part of it as a basis for something else ? But I don't know what kind of things you want to test for specifically, so these tests may not work for you. > Many thanks. > Allen B. Taylor > MDA > 9445 Airport Road > Brampton, ON L6S 4J3 > 905-790-2800 ext. 4350 > allen.taylor at mdacorporation.com > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > -- -- Guilherme H. Polo Goncalves From Allen.Taylor at mdacorporation.com Thu Nov 13 16:07:32 2008 From: Allen.Taylor at mdacorporation.com (Allen Taylor) Date: Thu, 13 Nov 2008 10:07:32 -0500 Subject: [Tkinter-discuss] GUI testing In-Reply-To: References: <491ABFE8.FA48.005C.0@mdacorporation.com> Message-ID: <491BFC63.FA48.005C.0@mdacorporation.com> Guilherme, So, what is ttk, and how does it relate to Tkinter? The app I have inherited is specifically Tkinter+Pmw. I want to make as few changes to it as possible in order to test drive it with test scripts. Things like waiting for windows to appear, pressing buttons, selecting items in list boxes, extracting values, etc., all from a script. Dogtail looked like just the ticket until I found out that Tk apps don't talk AT-SPI. Switching the app to use GTK is not an option. A bit more web searching yielded another possibility (see http://mail.gnome.org/archives/gnome-accessibility-devel/2006-December/msg00029.html). I just touched base with Daniel Drake (the originator of the referenced thread) and he still suggests using Papi (http://ocemp.sourceforge.net/papi.html), which allows a non-GTK app to be AT-SPI-aware (albeit via ATK) . Perhaps I can hook something into Tkinter. Seems like a lot of work though. Allen >>> "Guilherme Polo" 2008-11-12 11:45 >>> On Wed, Nov 12, 2008 at 2:37 PM, Allen Taylor wrote: > Hello all, > I've got a Python/Tkinter application that I'd like to automate GUI testing > for. I found Dogtail, but it requires the GUI app to be "AT-SPI-aware". I > see that there is a binding from Python to AT-SPI (Python atspi package; > this is what Dogtail uses to control the app). Has anyone done > any development to make this work with Tkinter apps? Or, is there another > method by which I can automate GUI testing of my Python/Tk app? I have used the standard unittest way to test ttk widgets. tests for python 2.x can be found at http://svn.python.org/view/sandbox/trunk/ttk-gsoc/src/2.x/test/ right now, soon (like a week maybe) I will be moving that to another branch. It simulates some mouse clicks in some very specific areas, but could be expanded. Maybe you can use some part of it as a basis for something else ? But I don't know what kind of things you want to test for specifically, so these tests may not work for you. > Many thanks. > Allen B. Taylor > MDA > 9445 Airport Road > Brampton, ON L6S 4J3 > 905-790-2800 ext. 4350 > allen.taylor at mdacorporation.com > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > -- -- Guilherme H. Polo Goncalves _______________________________________________ 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 ggpolo at gmail.com Thu Nov 13 16:19:20 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Thu, 13 Nov 2008 13:19:20 -0200 Subject: [Tkinter-discuss] GUI testing In-Reply-To: <491BFC63.FA48.005C.0@mdacorporation.com> References: <491ABFE8.FA48.005C.0@mdacorporation.com> <491BFC63.FA48.005C.0@mdacorporation.com> Message-ID: On Thu, Nov 13, 2008 at 1:07 PM, Allen Taylor wrote: > Guilherme, > So, what is ttk, and how does it relate to Tkinter? ttk is the short for Tk Themed widget set. It got included into tk8.5, before it was just tile. The relation to Tkinter is that it uses Tk widgets, just like Tkinter, except they are different widgets to some extent, or completely new widgets. But more important, the way you can test them is very much the same. > The app I have inherited > is specifically Tkinter+Pmw. I want to make as few changes to it as possible > in order to test drive it with test scripts. The link I gave you tests the ttk widgets in the python wrapper, but it contains some common "patterns" that you could apply to test any tk widget. > Things like waiting for windows > to appear, pressing buttons, selecting items in list boxes, extracting > values, etc., all from a script. I do that there. What I'm trying to say is that there is some common code in those tests I did that you could use to do yours. You won't be able to get them then change some lines and test all your code (just if your code happens to be very similar to what I'm testing there -- nearly impossible). But you can look at it and understand how the kind of things you are after are done. I don't remember documenting it too well, so some parts could look weird but they are all necessary to run the tests correctly under windows and linux at least (it is very likely that are other specials cases for macosx which are not there, but I can't test for it). > Dogtail looked like just the ticket until I > found out that Tk apps don't talk AT-SPI. Switching the app to use GTK is > not an option. > A bit more web searching yielded another possibility > (see http://mail.gnome.org/archives/gnome-accessibility-devel/2006-December/msg00029.html). > I just touched base with Daniel Drake (the originator of the referenced > thread) and he still suggests using Papi > (http://ocemp.sourceforge.net/papi.html), which allows a non-GTK app to be > AT-SPI-aware (albeit via ATK) . Perhaps I can hook something into Tkinter. I'm not much into this subject of accessibility for testing software, but I would like to hear more about it if you do something towards it. > Seems like a lot of work though. > Allen > -- -- Guilherme H. Polo Goncalves From Vasilis.Vlachoudis at cern.ch Sat Nov 15 21:53:45 2008 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Sat, 15 Nov 2008 21:53:45 +0100 Subject: [Tkinter-discuss] Strange behavior with python 2.5 Message-ID: <491F36D9.4040507@cern.ch> Dear all, The tkMessageBox.askquestion as also several other methods e.g Text.search have changed the return value with python 2.5 wrt to 2.4 Run the following test program (below) with python 2.4 answering yes on askquestion dialogs and change directory in the askdirectory you will get (python 2.4, Tk/Tcl 8.4 Tkinter $Revision 50704$) ans1= yes ans2= yes Run the same example with python 2.5 (Tk/Tcl 8.5 Tkinter $Revision: 50704 $) ans1= yes ans2= yes First the ans1 is unicode instead of str and the second one after the askquestion is _tkinter.Tcl_Obj! Also with python 2.4 tk/tcl 8.5, the Text.search now returns the _tkinter.Tcl_Obj instead of str regardless of opening the tkFileDialog.askdirectory() Best Regards Vasilis # -------------- test program ----------- from Tkinter import * import tkMessageBox import tkFileDialog root = Tk() ans = tkMessageBox.askquestion("Yes/No","Answer YES") print "ans1=",ans,type(ans) d = tkFileDialog.askdirectory(title="Please change directory") ans = tkMessageBox.askquestion("Yes/No","Answer YES") print "ans2=",ans,type(ans) From ggpolo at gmail.com Sat Nov 15 22:41:39 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Sat, 15 Nov 2008 19:41:39 -0200 Subject: [Tkinter-discuss] Strange behavior with python 2.5 In-Reply-To: <491F36D9.4040507@cern.ch> References: <491F36D9.4040507@cern.ch> Message-ID: On Sat, Nov 15, 2008 at 6:53 PM, Vasilis Vlachoudis wrote: > Dear all, > > The tkMessageBox.askquestion as also several other methods e.g Text.search > have changed the return value with python 2.5 wrt to 2.4 > > Run the following test program (below) with python 2.4 answering yes on > askquestion dialogs and change directory in the askdirectory > you will get (python 2.4, Tk/Tcl 8.4 Tkinter $Revision 50704$) > ans1= yes > ans2= yes > > Run the same example with python 2.5 (Tk/Tcl 8.5 Tkinter $Revision: 50704 $) > ans1= yes > ans2= yes > > First the ans1 is unicode instead of str and the second one after the > askquestion is _tkinter.Tcl_Obj! > When you get a _tkinter.Tcl_Obj it means _tkinter wasn't able to detect and convert a received tcl object to a python object. When this happens the best you can do is get the string representation of the object by doing str(ans2) and then convert the value yourself (if you want to convert it to something else different than a string). With Tcl/Tk 8.5 and the current _tkinter you will see this happening very often, as tcl/tk now shares objects as much as it can. _tkinter checks for some specific tcl types but since it may receive any kind of object, like a pixel object, or bytecode object which are part of tcl (which happens to contain the same representation, that is why they got shared) it ends up returning this generic Tcl_Obj. > Also with python 2.4 tk/tcl 8.5, the Text.search now returns the > _tkinter.Tcl_Obj instead of str regardless of opening the > tkFileDialog.askdirectory() > > Best Regards > Vasilis > > # -------------- test program ----------- > from Tkinter import * > import tkMessageBox > import tkFileDialog > root = Tk() > ans = tkMessageBox.askquestion("Yes/No","Answer YES") > print "ans1=",ans,type(ans) > d = tkFileDialog.askdirectory(title="Please change directory") > ans = tkMessageBox.askquestion("Yes/No","Answer YES") > print "ans2=",ans,type(ans) > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -- -- Guilherme H. Polo Goncalves From Kalman_G at msn.com Sun Nov 16 14:07:06 2008 From: Kalman_G at msn.com (Gabor Kalman) Date: Sun, 16 Nov 2008 05:07:06 -0800 Subject: [Tkinter-discuss] Posting a new Thread... Message-ID: Some time ago I successfully subscribed to Tkinter-discuss (with email addres+password). I am having a problem to start a new Thread. I need some help and/or direction (URL?) on how to do this. -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kalman_G at msn.com Sun Nov 16 14:55:50 2008 From: Kalman_G at msn.com (Gabor Kalman) Date: Sun, 16 Nov 2008 05:55:50 -0800 Subject: [Tkinter-discuss] getcolor on Canvas (but without Image) Message-ID: I have a simple Rectangle drawn on Canvas. For example: from Tkinter import * # class Test(Frame): #------------------------------------------------------------- def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.createWidgets() #------------------------------------------------------------ def createWidgets(self): self.draw = Canvas(self, width=600, height=400) self.draw.create_rectangle(100, 100, 200, 150, fill="blue") self.draw.pack(side=LEFT) # test = Test() test.mainloop() Question: ======= How can I retrieve the color on the Canvas AFTER the Rectangle is drawn, say, at the coordinate (110,110) ??? P.S. Of course if the Rectangle would be an Image (!!!) I could do it with: from PIL import Image im = Image.open"Rectangle.jpg") x=110 y=110 pix = im.load() print pix[x, y] But that's NOT what I want. -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Sun Nov 16 15:43:40 2008 From: klappnase at web.de (Michael Lange) Date: Sun, 16 Nov 2008 15:43:40 +0100 Subject: [Tkinter-discuss] Strange behavior with python 2.5 In-Reply-To: References: <491F36D9.4040507@cern.ch> Message-ID: <20081116154340.212956a1.klappnase@web.de> On Sat, 15 Nov 2008 19:41:39 -0200 "Guilherme Polo" wrote: > > When you get a _tkinter.Tcl_Obj it means _tkinter wasn't able to > detect and convert a received tcl object to a python object. When this > happens the best you can do is get the string representation of the > object by doing str(ans2) and then convert the value yourself (if you > want to convert it to something else different than a string). > > With Tcl/Tk 8.5 and the current _tkinter you will see this happening > very often, as tcl/tk now shares objects as much as it can. _tkinter > checks for some specific tcl types but since it may receive any kind > of object, like a pixel object, or bytecode object which are part of > tcl (which happens to contain the same representation, that is why > they got shared) it ends up returning this generic Tcl_Obj. > I also found this behavior quite often with Tk-8.4 on several linux systems, in fact it seemed to me like it is impossible to predict when it will occur so unfortunately the only thing which seems to work reliably is setting Tkinter.wantobjects to False. Michael From ggpolo at gmail.com Sun Nov 16 17:04:19 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Sun, 16 Nov 2008 14:04:19 -0200 Subject: [Tkinter-discuss] Strange behavior with python 2.5 In-Reply-To: <20081116154340.212956a1.klappnase@web.de> References: <491F36D9.4040507@cern.ch> <20081116154340.212956a1.klappnase@web.de> Message-ID: On Sun, Nov 16, 2008 at 12:43 PM, Michael Lange wrote: > On Sat, 15 Nov 2008 19:41:39 -0200 > "Guilherme Polo" wrote: > >> >> When you get a _tkinter.Tcl_Obj it means _tkinter wasn't able to >> detect and convert a received tcl object to a python object. When this >> happens the best you can do is get the string representation of the >> object by doing str(ans2) and then convert the value yourself (if you >> want to convert it to something else different than a string). >> >> With Tcl/Tk 8.5 and the current _tkinter you will see this happening >> very often, as tcl/tk now shares objects as much as it can. _tkinter >> checks for some specific tcl types but since it may receive any kind >> of object, like a pixel object, or bytecode object which are part of >> tcl (which happens to contain the same representation, that is why >> they got shared) it ends up returning this generic Tcl_Obj. >> > > I also found this behavior quite often with Tk-8.4 on several linux systems, > in fact it seemed to me like it is impossible to predict when it will occur > so unfortunately the only thing which seems to work reliably is setting > Tkinter.wantobjects to False. > Setting wantobjects to False is broken in py3k tho. It incurs performance penalty too, since you will be working with strings only and objects won't be shared. At the same time it saves some time in not needing to do any transformations, or any extra attempts to transform, since it will always be a string but I don't believe this gain shadows the loses. > Michael > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -- -- Guilherme H. Polo Goncalves From ggpolo at gmail.com Sun Nov 16 17:20:10 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Sun, 16 Nov 2008 14:20:10 -0200 Subject: [Tkinter-discuss] getcolor on Canvas (but without Image) In-Reply-To: References: Message-ID: On Sun, Nov 16, 2008 at 11:55 AM, Gabor Kalman wrote: > I have a simple Rectangle drawn on Canvas. For example: > > from Tkinter import * > # > class Test(Frame): > #------------------------------------------------------------- > def __init__(self, master=None): > Frame.__init__(self, master) > Pack.config(self) > self.createWidgets() > #------------------------------------------------------------ > def createWidgets(self): > self.draw = Canvas(self, width=600, height=400) > self.draw.create_rectangle(100, 100, 200, 150, fill="blue") > self.draw.pack(side=LEFT) > # > test = Test() > test.mainloop() > > Question: > ======= > > How can I retrieve the color on the Canvas AFTER the Rectangle is drawn, > say, at the coordinate (110,110) ??? > You will need to think a bit different to solve this. Each thing in your Canvas has an id, and you can query any id to discover things about it, like its fill color. So your problem is how to find the id of the item that is positioned in the point (110, 110). For that you use the method find_overlapping which is part of Canvas. rect_id = self.draw.find_overlapping(110, 110, 110, 110)[0] print self.draw.itemcget(rect_id, 'fill') find_overlapping returns a tuple of all items it found in the specified rectangle (x1, y1, x2, y2) so I'm using just the first one (in your example there will be just one). There are variations of the above sample for different questions, so if it doesn't solve your question entirely reconsider detailing it more. > P.S. > > Of course if the Rectangle would be an Image (!!!) I could do it with: > > from PIL import Image > im = Image.open"Rectangle.jpg") > x=110 > y=110 > pix = im.load() > print pix[x, y] > > But that's NOT what I want. > > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > -- -- Guilherme H. Polo Goncalves From timj at tolisgroup.com Sun Nov 16 18:33:19 2008 From: timj at tolisgroup.com (Tim Jones) Date: Sun, 16 Nov 2008 10:33:19 -0700 Subject: [Tkinter-discuss] Posting a new Thread... In-Reply-To: References: Message-ID: <6D1CE682-8CB0-4937-893F-12E061731AEF@tolisgroup.com> Hi - You just did! Simply send a new email with a new subject (versus a reply to an old message that you just change the subject text). Tim On Nov 16, 2008, at 6:07 AM, Gabor Kalman wrote: > Some time ago I successfully subscribed to Tkinter-discuss (with > email addres+password). I am having a problem to start a new Thread. > I need some help and/or direction (URL?) on how to do this. > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss From btkuhn at email.unc.edu Sun Nov 16 18:47:16 2008 From: btkuhn at email.unc.edu (btkuhn at email.unc.edu) Date: Sun, 16 Nov 2008 12:47:16 -0500 Subject: [Tkinter-discuss] How to bind to a drawn object? Message-ID: <20081116124716.lmxb21asg08wkk80@webmail4.isis.unc.edu> Hello everyone, I am trying to create bindable shapes with Tkinter that are dragged when the user drags with the mouse. Here is an example (some code edited out for simplicity). This is all within an "App" class: self.canvas=Canvas(self.display, bg='blue') self.canvas.bind('', self.onDrag) self.x=10 self.y=10 #Draw ball, set up screen layout self.box1=self.drawBox(self.canvas) self.canvas.pack() def drawBox(self,master): newbox=master.create_rectangle(self.x, self.y, self.x+70, self.y+70, width=5, fill='red') return newbox def onDrag(self,event): self.canvas.move(self.box1,event.x-self.x,event.y-self.y) self.x=event.x self.y=event.y This works as written, but it is not good form because it can only be used with box1. is bound to the canvas rather that the box, and "self.box1" is explicitly stated in the onDrag method. Therefore, if I wanted to create 10 boxes (or even 2) I would have to write a new onDrag method for each one. Also, if I want the box to only drag when the user clicks INSIDE the box, I would have to create a new "dimensions" list for each new box, and then use an if statement to see if the mouse is inside the box, etc. I actually tried doing this and it makes the program run extremely slow with only one box, so I don't think this is a good solution. It seems logical to bind to box1 rather than the canvas, and that way the box will react only if the mouse is inside the box, and I could create multiple boxes, each with its own binding to . When I try to do this, though, using something like this: newbox=master.create_rectangle(self.x, self.y, self.x+70, self.y+70, width=5, fill='red') newbox.bind('', self.onDrag) it gives me an error saying that I can't bind this method to this instance. How can I make this work? Thanks! From ggpolo at gmail.com Sun Nov 16 18:57:39 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Sun, 16 Nov 2008 15:57:39 -0200 Subject: [Tkinter-discuss] How to bind to a drawn object? In-Reply-To: <20081116124716.lmxb21asg08wkk80@webmail4.isis.unc.edu> References: <20081116124716.lmxb21asg08wkk80@webmail4.isis.unc.edu> Message-ID: On Sun, Nov 16, 2008 at 3:47 PM, wrote: > Hello everyone, > > I am trying to create bindable shapes with Tkinter that are dragged when the > user drags with the mouse. Here is an example (some code edited out for > simplicity). This is all within an "App" class: > > self.canvas=Canvas(self.display, bg='blue') > self.canvas.bind('', self.onDrag) > self.x=10 > self.y=10 > #Draw ball, set up screen layout > self.box1=self.drawBox(self.canvas) > self.canvas.pack() > def drawBox(self,master): > newbox=master.create_rectangle(self.x, self.y, self.x+70, self.y+70, > width=5, fill='red') > return newbox > def onDrag(self,event): > > self.canvas.move(self.box1,event.x-self.x,event.y-self.y) > self.x=event.x > self.y=event.y > > > > > This works as written, but it is not good form because it can only be used > with box1. is bound to the canvas rather that the box, and > "self.box1" is explicitly stated in the onDrag method. Therefore, if I > wanted to create 10 boxes (or even 2) I would have to write a new onDrag > method for each one. Also, if I want the box to only drag when the user > clicks INSIDE the box, I would have to create a new "dimensions" list for > each new box, and then use an if statement to see if the mouse is inside the > box, etc. I actually tried doing this and it makes the program run extremely > slow with only one box, so I don't think this is a good solution. It seems > logical to bind to box1 rather than the canvas, and that way the > box will react only if the mouse is inside the box, and I could create > multiple boxes, each with its own binding to . When I try to do > this, though, using something like this: > > newbox=master.create_rectangle(self.x, self.y, self.x+70, self.y+70, > width=5, fill='red') > newbox.bind('', self.onDrag) > > it gives me an error saying that I can't bind this method to this instance. Didn't you mean an AttributeError ? The id returned my create_rectangle surely doesn't have a bind method. > How can I make this work? That is why Canvas has a method called tag_bind, to bind an item in the canvas: master.tag_bind(newbox, '', self.on_drag) > > Thanks! > > > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -- -- Guilherme H. Polo Goncalves From btkuhn at email.unc.edu Sun Nov 16 19:24:59 2008 From: btkuhn at email.unc.edu (btkuhn at email.unc.edu) Date: Sun, 16 Nov 2008 13:24:59 -0500 Subject: [Tkinter-discuss] How to bind to a drawn object? In-Reply-To: References: <20081116124716.lmxb21asg08wkk80@webmail4.isis.unc.edu> Message-ID: <20081116132459.j7crhhue0cg4kgcc@webmail4.isis.unc.edu> Quoting Guilherme Polo : > On Sun, Nov 16, 2008 at 3:47 PM, wrote: >> Hello everyone, >> >> I am trying to create bindable shapes with Tkinter that are dragged when the >> user drags with the mouse. Here is an example (some code edited out for >> simplicity). This is all within an "App" class: >> >> self.canvas=Canvas(self.display, bg='blue') >> self.canvas.bind('', self.onDrag) >> self.x=10 >> self.y=10 >> #Draw ball, set up screen layout >> self.box1=self.drawBox(self.canvas) >> self.canvas.pack() >> def drawBox(self,master): >> newbox=master.create_rectangle(self.x, self.y, self.x+70, self.y+70, >> width=5, fill='red') >> return newbox >> def onDrag(self,event): >> >> self.canvas.move(self.box1,event.x-self.x,event.y-self.y) >> self.x=event.x >> self.y=event.y >> >> >> >> >> This works as written, but it is not good form because it can only be used >> with box1. is bound to the canvas rather that the box, and >> "self.box1" is explicitly stated in the onDrag method. Therefore, if I >> wanted to create 10 boxes (or even 2) I would have to write a new onDrag >> method for each one. Also, if I want the box to only drag when the user >> clicks INSIDE the box, I would have to create a new "dimensions" list for >> each new box, and then use an if statement to see if the mouse is inside the >> box, etc. I actually tried doing this and it makes the program run extremely >> slow with only one box, so I don't think this is a good solution. It seems >> logical to bind to box1 rather than the canvas, and that way the >> box will react only if the mouse is inside the box, and I could create >> multiple boxes, each with its own binding to . When I try to do >> this, though, using something like this: >> >> newbox=master.create_rectangle(self.x, self.y, self.x+70, self.y+70, >> width=5, fill='red') >> newbox.bind('', self.onDrag) >> >> it gives me an error saying that I can't bind this method to this instance. > > Didn't you mean an AttributeError ? The id returned my > create_rectangle surely doesn't have a bind method. > >> How can I make this work? > > That is why Canvas has a method called tag_bind, to bind an item in > the canvas: > > master.tag_bind(newbox, '', self.on_drag) > > >> >> Thanks! >> >> >> >> >> _______________________________________________ >> Tkinter-discuss mailing list >> Tkinter-discuss at python.org >> http://mail.python.org/mailman/listinfo/tkinter-discuss >> > > > > -- > -- Guilherme H. Polo Goncalves > Thanks. Yes, you're right, the message is "AttributeError: App instance has no attribute 'on_drag'" However, when I make this change I get no response at all when the program is run. My drawBox function now looks like this: def drawBox(self,master): newbox=master.create_rectangle(self.x, self.y, self.x+70, self.y+70, width=5, fill='red') master.tag_bind(newbox, '', self.onDrag) and my onDrag function looks like this: def onDrag(self,event): self.canvas.move(self,event.x-self.x,event.y-self.y) self.x=event.x self.y=event.y This looks like it should work: it passed newbox as self and the coordinates as event to the onDrag function, but I get no response at all. From Vasilis.Vlachoudis at cern.ch Sun Nov 16 19:59:48 2008 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Sun, 16 Nov 2008 19:59:48 +0100 Subject: [Tkinter-discuss] Strange behavior with python 2.5 In-Reply-To: References: <491F36D9.4040507@cern.ch><20081116154340.212956a1.klappnase@web.de> Message-ID: <2AACD4EB2F123248A064A23843B3A17301498A26@cernxchg47.cern.ch> Finally I didn't understand, is it a problem of Tkinter or Tk/Tcl? In any case it breaks the behavior of many programs. Moreover returning a different object after calling askdirectory it means that there is a problem somewhere that changes the default behavior. Apart from type casting with str() what is the correct solution? Vasilis -----Original Message----- From: tkinter-discuss-bounces+vasilis.vlachoudis=cern.ch at python.org [mailto:tkinter-discuss-bounces+vasilis.vlachoudis=cern.ch at python.org] On Behalf Of Guilherme Polo Sent: Sunday, 16 November 2008 17:04 To: Michael Lange; tkinter-discuss at python.org Subject: Re: [Tkinter-discuss] Strange behavior with python 2.5 On Sun, Nov 16, 2008 at 12:43 PM, Michael Lange wrote: > On Sat, 15 Nov 2008 19:41:39 -0200 > "Guilherme Polo" wrote: > >> >> When you get a _tkinter.Tcl_Obj it means _tkinter wasn't able to >> detect and convert a received tcl object to a python object. When this >> happens the best you can do is get the string representation of the >> object by doing str(ans2) and then convert the value yourself (if you >> want to convert it to something else different than a string). >> >> With Tcl/Tk 8.5 and the current _tkinter you will see this happening >> very often, as tcl/tk now shares objects as much as it can. _tkinter >> checks for some specific tcl types but since it may receive any kind >> of object, like a pixel object, or bytecode object which are part of >> tcl (which happens to contain the same representation, that is why >> they got shared) it ends up returning this generic Tcl_Obj. >> > > I also found this behavior quite often with Tk-8.4 on several linux systems, > in fact it seemed to me like it is impossible to predict when it will occur > so unfortunately the only thing which seems to work reliably is setting > Tkinter.wantobjects to False. > Setting wantobjects to False is broken in py3k tho. It incurs performance penalty too, since you will be working with strings only and objects won't be shared. At the same time it saves some time in not needing to do any transformations, or any extra attempts to transform, since it will always be a string but I don't believe this gain shadows the loses. > Michael > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -- -- Guilherme H. Polo Goncalves _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss at python.org http://mail.python.org/mailman/listinfo/tkinter-discuss From ggpolo at gmail.com Sun Nov 16 20:00:14 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Sun, 16 Nov 2008 17:00:14 -0200 Subject: [Tkinter-discuss] How to bind to a drawn object? In-Reply-To: <20081116132459.j7crhhue0cg4kgcc@webmail4.isis.unc.edu> References: <20081116124716.lmxb21asg08wkk80@webmail4.isis.unc.edu> <20081116132459.j7crhhue0cg4kgcc@webmail4.isis.unc.edu> Message-ID: On Sun, Nov 16, 2008 at 4:24 PM, wrote: > Quoting Guilherme Polo : > >> On Sun, Nov 16, 2008 at 3:47 PM, wrote: >>> >>> Hello everyone, >>> >>> I am trying to create bindable shapes with Tkinter that are dragged when >>> the >>> user drags with the mouse. Here is an example (some code edited out for >>> simplicity). This is all within an "App" class: >>> >>> self.canvas=Canvas(self.display, bg='blue') >>> self.canvas.bind('', self.onDrag) >>> self.x=10 >>> self.y=10 >>> #Draw ball, set up screen layout >>> self.box1=self.drawBox(self.canvas) >>> self.canvas.pack() >>> def drawBox(self,master): >>> newbox=master.create_rectangle(self.x, self.y, self.x+70, self.y+70, >>> width=5, fill='red') >>> return newbox >>> def onDrag(self,event): >>> >>> self.canvas.move(self.box1,event.x-self.x,event.y-self.y) >>> self.x=event.x >>> self.y=event.y >>> >>> >>> >>> >>> This works as written, but it is not good form because it can only be >>> used >>> with box1. is bound to the canvas rather that the box, and >>> "self.box1" is explicitly stated in the onDrag method. Therefore, if I >>> wanted to create 10 boxes (or even 2) I would have to write a new onDrag >>> method for each one. Also, if I want the box to only drag when the user >>> clicks INSIDE the box, I would have to create a new "dimensions" list for >>> each new box, and then use an if statement to see if the mouse is inside >>> the >>> box, etc. I actually tried doing this and it makes the program run >>> extremely >>> slow with only one box, so I don't think this is a good solution. It >>> seems >>> logical to bind to box1 rather than the canvas, and that way >>> the >>> box will react only if the mouse is inside the box, and I could create >>> multiple boxes, each with its own binding to . When I try to >>> do >>> this, though, using something like this: >>> >>> newbox=master.create_rectangle(self.x, self.y, self.x+70, self.y+70, >>> width=5, fill='red') >>> newbox.bind('', self.onDrag) >>> >>> it gives me an error saying that I can't bind this method to this >>> instance. >> >> Didn't you mean an AttributeError ? The id returned my >> create_rectangle surely doesn't have a bind method. >> >>> How can I make this work? >> >> That is why Canvas has a method called tag_bind, to bind an item in the >> canvas: >> >> master.tag_bind(newbox, '', self.on_drag) >> >> >>> >>> Thanks! >>> >> >> -- >> -- Guilherme H. Polo Goncalves >> > > > Thanks. Yes, you're right, the message is "AttributeError: App instance has > no attribute 'on_drag'" However, when I make this change I get no response > at all when the program is run. I suspect there are other things wrong in your app then. > My drawBox function now looks like this: > > def drawBox(self,master): > newbox=master.create_rectangle(self.x, self.y, self.x+70, self.y+70, > width=5, fill='red') > master.tag_bind(newbox, '', self.onDrag) > Don't you want a ButtonPress-1 there too ? > > > and my onDrag function looks like this: > > def onDrag(self,event): > > self.canvas.move(self,event.x-self.x,event.y-self.y) > self.x=event.x > self.y=event.y > This looks like it should work: it passed newbox as self and the coordinates > as event to the onDrag function, but I get no response at all. > Uhm, no, self is the class instance so it is surely not the newbox item. Well, I've done a sample here based on what you are after, check if this works for you: import Tkinter class Boxes(Tkinter.Canvas): def __init__(self, master=None, **kw): Tkinter.Canvas.__init__(self, master, **kw) def create_box(self, x, y, size, **kw): box = self.create_rectangle(x, y, x + size, y + size, **kw) self.tag_bind(box, '', self.on_click) self.tag_bind(box, '', self.on_drag) def on_click(self, event): self.curr_x = event.x self.curr_y = event.y def on_drag(self, event): x, y, _, _ = self.coords('current') self.move('current', (event.x - self.curr_x), (event.y - self.curr_y)) self.curr_x = event.x self.curr_y = event.y app = Boxes(bg='blue') app.create_box(10, 10, 70, width=5, fill='red') app.create_box(20, 20, 70, width=5, fill='yellow') app.pack() app.mainloop() -- -- Guilherme H. Polo Goncalves From ggpolo at gmail.com Sun Nov 16 20:18:54 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Sun, 16 Nov 2008 17:18:54 -0200 Subject: [Tkinter-discuss] Strange behavior with python 2.5 In-Reply-To: <2AACD4EB2F123248A064A23843B3A17301498A26@cernxchg47.cern.ch> References: <491F36D9.4040507@cern.ch> <20081116154340.212956a1.klappnase@web.de> <2AACD4EB2F123248A064A23843B3A17301498A26@cernxchg47.cern.ch> Message-ID: On Sun, Nov 16, 2008 at 4:59 PM, Vasilis Vlachoudis wrote: > Finally I didn't understand, is it a problem of Tkinter or Tk/Tcl? It is not really a problem. But if you want to blame someone, go for Python then. > In > any case it breaks the behavior of many programs. Moreover returning a > different object after calling askdirectory it means that there is a > problem somewhere that changes the default behavior. The good part is that you know you should expect a string being returned from askdirectory, so just convert it. > Apart from type > casting with str() what is the correct solution? Note that there is no cast in Python, doing a str(object) where object is _tkinter.Tcl_Obj gives you a new object. Now, what kind of correct solution are you after ? Tkinter could do more conversions in the Tkinter.py wrapper and other files in lib-tk (or in the tkinter package on py3k), but you would still eventually get these Tcl_Obj objects in other extensions. Maybe _tkinter.c could get improved, but it is an open question on how to improve it in this area, I've done some improvements here by changing the order of conversion attempts and some other things but didn't advance much on it. I've also talked with some tcl developers (when I first saw a Tcl_Obj in Python I found it weird too) about this, looked the perl tk wrapper (done by hobbs, which undoubtly knows tcl very well) and it suffers the same kind of problem, and the more acceptable solution was to leave to the high level wrapper to handle the conversions itself (so this would end in Tkinter.py and other files in lib-tk). The problem is that the _tkinter.c is too generic (which is good), so it never assumes it knows what type of object to expect from tcl, on the other hand, the module calling _tkinter functions knows what it wants to receive so this ends up being the most logical place to convert objects if needed. On the same line there are other things that could be improved in _tkinter and Tkinter, so if you have any patches they are all welcome in bugs.python.org > > Vasilis > > -----Original Message----- > From: tkinter-discuss-bounces+vasilis.vlachoudis=cern.ch at python.org > [mailto:tkinter-discuss-bounces+vasilis.vlachoudis=cern.ch at python.org] > On Behalf Of Guilherme Polo > Sent: Sunday, 16 November 2008 17:04 > To: Michael Lange; tkinter-discuss at python.org > Subject: Re: [Tkinter-discuss] Strange behavior with python 2.5 > > On Sun, Nov 16, 2008 at 12:43 PM, Michael Lange > wrote: >> On Sat, 15 Nov 2008 19:41:39 -0200 >> "Guilherme Polo" wrote: >> >>> >>> When you get a _tkinter.Tcl_Obj it means _tkinter wasn't able to >>> detect and convert a received tcl object to a python object. When > this >>> happens the best you can do is get the string representation of the >>> object by doing str(ans2) and then convert the value yourself (if you >>> want to convert it to something else different than a string). >>> >>> With Tcl/Tk 8.5 and the current _tkinter you will see this happening >>> very often, as tcl/tk now shares objects as much as it can. _tkinter >>> checks for some specific tcl types but since it may receive any kind >>> of object, like a pixel object, or bytecode object which are part of >>> tcl (which happens to contain the same representation, that is why >>> they got shared) it ends up returning this generic Tcl_Obj. >>> >> >> I also found this behavior quite often with Tk-8.4 on several linux > systems, >> in fact it seemed to me like it is impossible to predict when it will > occur >> so unfortunately the only thing which seems to work reliably is > setting >> Tkinter.wantobjects to False. >> > > Setting wantobjects to False is broken in py3k tho. > > It incurs performance penalty too, since you will be working with > strings only and objects won't be shared. At the same time it saves > some time in not needing to do any transformations, or any extra > attempts to transform, since it will always be a string but I don't > believe this gain shadows the loses. > >> Michael >> _______________________________________________ >> Tkinter-discuss mailing list >> Tkinter-discuss at python.org >> http://mail.python.org/mailman/listinfo/tkinter-discuss >> > > > > -- > -- Guilherme H. Polo Goncalves > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -- -- Guilherme H. Polo Goncalves From klappnase at web.de Sun Nov 16 21:59:58 2008 From: klappnase at web.de (Michael Lange) Date: Sun, 16 Nov 2008 21:59:58 +0100 Subject: [Tkinter-discuss] Strange behavior with python 2.5 In-Reply-To: References: <491F36D9.4040507@cern.ch> <20081116154340.212956a1.klappnase@web.de> <2AACD4EB2F123248A064A23843B3A17301498A26@cernxchg47.cern.ch> Message-ID: <20081116215958.3ffdef3a.klappnase@web.de> On Sun, 16 Nov 2008 17:18:54 -0200 "Guilherme Polo" wrote: > On Sun, Nov 16, 2008 at 4:59 PM, Vasilis Vlachoudis > wrote: > > Finally I didn't understand, is it a problem of Tkinter or Tk/Tcl? > > It is not really a problem. But if you want to blame someone, go for > Python then. > If you get unexpected and , if the software you write is supposed to run on different platforms, also unpredictable behavior like this I think it *is* a problem. (...) > >> > > > > Setting wantobjects to False is broken in py3k tho. > > > > It incurs performance penalty too, since you will be working with > > strings only and objects won't be shared. At the same time it saves > > some time in not needing to do any transformations, or any extra > > attempts to transform, since it will always be a string but I don't > > believe this gain shadows the loses. The amounts of bug reports I received before and after changing to wantobjects=False says it does. The problem is that you never seem to know where the TclObjects appear on Python / Tk versions other than your own. So what else to do? Convert everything Tk returns to string? Adding "try...except TclError" everywhere? Do nothing and wait if people will send bug reports? Michael > > > >> Michael > >> _______________________________________________ > >> Tkinter-discuss mailing list > >> Tkinter-discuss at python.org > >> http://mail.python.org/mailman/listinfo/tkinter-discuss > >> > > > > > > > > -- > > -- Guilherme H. Polo Goncalves > > _______________________________________________ > > Tkinter-discuss mailing list > > Tkinter-discuss at python.org > > http://mail.python.org/mailman/listinfo/tkinter-discuss > > > > > > -- > -- Guilherme H. Polo Goncalves > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss From ggpolo at gmail.com Sun Nov 16 22:21:34 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Sun, 16 Nov 2008 19:21:34 -0200 Subject: [Tkinter-discuss] Strange behavior with python 2.5 In-Reply-To: <20081116215958.3ffdef3a.klappnase@web.de> References: <491F36D9.4040507@cern.ch> <20081116154340.212956a1.klappnase@web.de> <2AACD4EB2F123248A064A23843B3A17301498A26@cernxchg47.cern.ch> <20081116215958.3ffdef3a.klappnase@web.de> Message-ID: On Sun, Nov 16, 2008 at 6:59 PM, Michael Lange wrote: > On Sun, 16 Nov 2008 17:18:54 -0200 > "Guilherme Polo" wrote: > >> On Sun, Nov 16, 2008 at 4:59 PM, Vasilis Vlachoudis >> wrote: >> > Finally I didn't understand, is it a problem of Tkinter or Tk/Tcl? >> >> It is not really a problem. But if you want to blame someone, go for >> Python then. >> > > If you get unexpected and , if the software you write is supposed to run on > different platforms, also unpredictable behavior like this I think it *is* a > problem. I meant more in these sense of the conversion raising some exception, but it can be seen in that way too sure. But this doesn't depend on the platform, all them will show this behaviour. > > (...) > >> >> >> > >> > Setting wantobjects to False is broken in py3k tho. >> > >> > It incurs performance penalty too, since you will be working with >> > strings only and objects won't be shared. At the same time it saves >> > some time in not needing to do any transformations, or any extra >> > attempts to transform, since it will always be a string but I don't >> > believe this gain shadows the loses. > > The amounts of bug reports I received before and after changing to > wantobjects=False says it does. Good for you then :) It gets hard to continue arguing about this now, since you apparently solved the question on your side and thus won't have real examples of this problem, and why it couldn't be solved, anymore (or maybe you do, so we can continue on this). > The problem is that you never seem > to know where the TclObjects appear on Python / Tk versions other than your own. > So what else to do? Convert everything Tk returns to string? No, like I said, who calls into _tkinter should know what kind of object to expect so you do the conversion yourself. If you are going to return the object to the user, then surely check if it is what you are expecting it to be. Now, I'm sure this can be improved in Python but you have to invest some time on it. > Adding "try...except TclError" > everywhere? Do nothing and wait if people will send bug reports? > > > Michael > > -- -- Guilherme H. Polo Goncalves From btkuhn at email.unc.edu Mon Nov 17 00:47:08 2008 From: btkuhn at email.unc.edu (btkuhn at email.unc.edu) Date: Sun, 16 Nov 2008 18:47:08 -0500 Subject: [Tkinter-discuss] How to bind to a drawn object? In-Reply-To: References: <20081116124716.lmxb21asg08wkk80@webmail4.isis.unc.edu> <20081116132459.j7crhhue0cg4kgcc@webmail4.isis.unc.edu> Message-ID: <20081116184708.9ly387e5vcwk0s4c@webmail4.isis.unc.edu> Yes, this works great, thanks very much. I don't want to just copy your code though, I'm trying to understand what I'm doing wrong, so I tried modifying my code to more or less mirror your technique. I am now getting an unknown error message that I can't figure out, and I suspect that I am "thinking about things" incorrectly. I've stripped things down, even deleting the onDrag method for now, and still can't identify what I'm doing wrong. Here's the stripped down code; now I'm only trying to draw the box and not worrying about anything else for now: from Tkinter import * WINDOWWIDTH=500 WINDOWHEIGHT=500 class App: def __init__ (self,master): self.x=10 self.y=10 self.display = Frame(master, width=WINDOWWIDTH, height=WINDOWHEIGHT) self.canvas=Canvas(self.display, bg='blue') #Draw boxes, set up screen layout self.box1=self.canvas.drawBox() self.display.pack() self.canvas.pack() def drawBox(self): newbox=self.create_rectangle(self.x, self.y, self.x+70, self.y+70, width=5, fill='red') self.tag_bind(newbox, '', self.onDrag) return newbox root= Tk() app=App(root) root.mainloop() My error is "AttributeError: Canvas instance has no attribute 'drawBox'". I've tried deleting the return statement and just calling "self.canvas.drawBox with the same result. If I deleted the drawBox function and just put the statements in "init", it works correctly. I thought that by calling "self.canvas.drawBox()", I pass "self.canvas" as self, so that in effect I am calling "newbox=self.canvas.create_rectangle(self.x, self.y, self.x+70, self.y+70, width=5, fill='red')". Clearly this is inaccurate because if I write "newbox=self.create_rectangle(self.x, self.y, self.x+70, self.y+70, width=5, fill='red')" in the init, it works correctly. Where am I thinking about this incorrectly? Thanks again, and sorry for all the questions - I am obviously new to this and it has been driving me crazy. Quoting Guilherme Polo : > On Sun, Nov 16, 2008 at 4:24 PM, wrote: >> Quoting Guilherme Polo : >> >>> On Sun, Nov 16, 2008 at 3:47 PM, wrote: >>>> >>>> Hello everyone, >>>> >>>> I am trying to create bindable shapes with Tkinter that are dragged when >>>> the >>>> user drags with the mouse. Here is an example (some code edited out for >>>> simplicity). This is all within an "App" class: >>>> >>>> self.canvas=Canvas(self.display, bg='blue') >>>> self.canvas.bind('', self.onDrag) >>>> self.x=10 >>>> self.y=10 >>>> #Draw ball, set up screen layout >>>> self.box1=self.drawBox(self.canvas) >>>> self.canvas.pack() >>>> def drawBox(self,master): >>>> newbox=master.create_rectangle(self.x, self.y, self.x+70, self.y+70, >>>> width=5, fill='red') >>>> return newbox >>>> def onDrag(self,event): >>>> >>>> self.canvas.move(self.box1,event.x-self.x,event.y-self.y) >>>> self.x=event.x >>>> self.y=event.y >>>> >>>> >>>> >>>> >>>> This works as written, but it is not good form because it can only be >>>> used >>>> with box1. is bound to the canvas rather that the box, and >>>> "self.box1" is explicitly stated in the onDrag method. Therefore, if I >>>> wanted to create 10 boxes (or even 2) I would have to write a new onDrag >>>> method for each one. Also, if I want the box to only drag when the user >>>> clicks INSIDE the box, I would have to create a new "dimensions" list for >>>> each new box, and then use an if statement to see if the mouse is inside >>>> the >>>> box, etc. I actually tried doing this and it makes the program run >>>> extremely >>>> slow with only one box, so I don't think this is a good solution. It >>>> seems >>>> logical to bind to box1 rather than the canvas, and that way >>>> the >>>> box will react only if the mouse is inside the box, and I could create >>>> multiple boxes, each with its own binding to . When I try to >>>> do >>>> this, though, using something like this: >>>> >>>> newbox=master.create_rectangle(self.x, self.y, self.x+70, self.y+70, >>>> width=5, fill='red') >>>> newbox.bind('', self.onDrag) >>>> >>>> it gives me an error saying that I can't bind this method to this >>>> instance. >>> >>> Didn't you mean an AttributeError ? The id returned my >>> create_rectangle surely doesn't have a bind method. >>> >>>> How can I make this work? >>> >>> That is why Canvas has a method called tag_bind, to bind an item in the >>> canvas: >>> >>> master.tag_bind(newbox, '', self.on_drag) >>> >>> >>>> >>>> Thanks! >>>> >>> >>> -- >>> -- Guilherme H. Polo Goncalves >>> >> >> >> Thanks. Yes, you're right, the message is "AttributeError: App instance has >> no attribute 'on_drag'" However, when I make this change I get no response >> at all when the program is run. > > I suspect there are other things wrong in your app then. > >> My drawBox function now looks like this: >> >> def drawBox(self,master): >> newbox=master.create_rectangle(self.x, self.y, self.x+70, self.y+70, >> width=5, fill='red') >> master.tag_bind(newbox, '', self.onDrag) >> > > Don't you want a ButtonPress-1 there too ? > >> >> >> and my onDrag function looks like this: >> >> def onDrag(self,event): >> >> self.canvas.move(self,event.x-self.x,event.y-self.y) >> self.x=event.x >> self.y=event.y >> This looks like it should work: it passed newbox as self and the coordinates >> as event to the onDrag function, but I get no response at all. >> > > Uhm, no, self is the class instance so it is surely not the newbox item. > > Well, I've done a sample here based on what you are after, check if > this works for you: > > import Tkinter > > class Boxes(Tkinter.Canvas): > def __init__(self, master=None, **kw): > Tkinter.Canvas.__init__(self, master, **kw) > > def create_box(self, x, y, size, **kw): > box = self.create_rectangle(x, y, x + size, y + size, **kw) > self.tag_bind(box, '', self.on_click) > self.tag_bind(box, '', self.on_drag) > > def on_click(self, event): > self.curr_x = event.x > self.curr_y = event.y > > def on_drag(self, event): > x, y, _, _ = self.coords('current') > self.move('current', (event.x - self.curr_x), (event.y - self.curr_y)) > self.curr_x = event.x > self.curr_y = event.y > > > app = Boxes(bg='blue') > app.create_box(10, 10, 70, width=5, fill='red') > app.create_box(20, 20, 70, width=5, fill='yellow') > app.pack() > app.mainloop() > > > -- > -- Guilherme H. Polo Goncalves > From ggpolo at gmail.com Mon Nov 17 01:05:56 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Sun, 16 Nov 2008 22:05:56 -0200 Subject: [Tkinter-discuss] How to bind to a drawn object? In-Reply-To: <20081116184708.9ly387e5vcwk0s4c@webmail4.isis.unc.edu> References: <20081116124716.lmxb21asg08wkk80@webmail4.isis.unc.edu> <20081116132459.j7crhhue0cg4kgcc@webmail4.isis.unc.edu> <20081116184708.9ly387e5vcwk0s4c@webmail4.isis.unc.edu> Message-ID: On Sun, Nov 16, 2008 at 9:47 PM, wrote: > Yes, this works great, thanks very much. I don't want to just copy your code > though, I'm trying to understand what I'm doing wrong, so I tried modifying > my code to more or less mirror your technique. I am now getting an unknown > error message that I can't figure out, and I suspect that I am "thinking > about things" incorrectly. I've stripped things down, even deleting the > onDrag method for now, and still can't identify what I'm doing wrong. Here's > the stripped down code; now I'm only trying to draw the box and not worrying > about anything else for now: > > from Tkinter import * > > WINDOWWIDTH=500 > WINDOWHEIGHT=500 > > > class App: def __init__ (self,master): > self.x=10 > self.y=10 > self.display = Frame(master, width=WINDOWWIDTH, > height=WINDOWHEIGHT) > self.canvas=Canvas(self.display, bg='blue') > #Draw boxes, set up screen layout > > self.box1=self.canvas.drawBox() > self.display.pack() > self.canvas.pack() > def drawBox(self): > newbox=self.create_rectangle(self.x, self.y, self.x+70, self.y+70, > width=5, fill='red') > self.tag_bind(newbox, '', self.onDrag) > return newbox > root= Tk() > app=App(root) > root.mainloop() > > My error is "AttributeError: Canvas instance has no attribute 'drawBox'". drawBox is a method of App, not Canvas, so you have to call it as self.drawBox() > I've tried deleting the return statement and just calling > "self.canvas.drawBox with the same result. If I deleted the drawBox function > and just put the statements in "init", it works correctly. I thought that by > calling "self.canvas.drawBox()", I pass "self.canvas" as self, so that in > effect I am calling "newbox=self.canvas.create_rectangle(self.x, self.y, > self.x+70, self.y+70, width=5, fill='red')". Clearly this is inaccurate > because if I write "newbox=self.create_rectangle(self.x, self.y, self.x+70, > self.y+70, width=5, fill='red')" in the init, it works correctly. Where am I > thinking about this incorrectly? > You are never passing self.canvas as self, you may think you are but are not. The easiest form of playing with self as a Tkinter.Canvas is subclassing this class App from Tkinter.Canvas (notice that is what I did in the previous email). It is hard to follow the indentation there too, so if possible put it in a pastebin next time. There are several things wrong, so you might consider reading the python tutorial. > Thanks again, and sorry for all the questions - I am obviously new to this > and it has been driving me crazy. > > > > Quoting Guilherme Polo : > >> On Sun, Nov 16, 2008 at 4:24 PM, wrote: >>> >>> Quoting Guilherme Polo : >>> >>>> On Sun, Nov 16, 2008 at 3:47 PM, wrote: >>>>> >>>>> Hello everyone, >>>>> >>>>> I am trying to create bindable shapes with Tkinter that are dragged >>>>> when >>>>> the >>>>> user drags with the mouse. Here is an example (some code edited out for >>>>> simplicity). This is all within an "App" class: >>>>> >>>>> self.canvas=Canvas(self.display, bg='blue') >>>>> self.canvas.bind('', self.onDrag) >>>>> self.x=10 >>>>> self.y=10 >>>>> #Draw ball, set up screen layout >>>>> self.box1=self.drawBox(self.canvas) >>>>> self.canvas.pack() >>>>> def drawBox(self,master): >>>>> newbox=master.create_rectangle(self.x, self.y, self.x+70, >>>>> self.y+70, >>>>> width=5, fill='red') >>>>> return newbox >>>>> def onDrag(self,event): >>>>> >>>>> self.canvas.move(self.box1,event.x-self.x,event.y-self.y) >>>>> self.x=event.x >>>>> self.y=event.y >>>>> >>>>> >>>>> >>>>> >>>>> This works as written, but it is not good form because it can only be >>>>> used >>>>> with box1. is bound to the canvas rather that the box, and >>>>> "self.box1" is explicitly stated in the onDrag method. Therefore, if I >>>>> wanted to create 10 boxes (or even 2) I would have to write a new >>>>> onDrag >>>>> method for each one. Also, if I want the box to only drag when the user >>>>> clicks INSIDE the box, I would have to create a new "dimensions" list >>>>> for >>>>> each new box, and then use an if statement to see if the mouse is >>>>> inside >>>>> the >>>>> box, etc. I actually tried doing this and it makes the program run >>>>> extremely >>>>> slow with only one box, so I don't think this is a good solution. It >>>>> seems >>>>> logical to bind to box1 rather than the canvas, and that >>>>> way >>>>> the >>>>> box will react only if the mouse is inside the box, and I could create >>>>> multiple boxes, each with its own binding to . When I try to >>>>> do >>>>> this, though, using something like this: >>>>> >>>>> newbox=master.create_rectangle(self.x, self.y, self.x+70, self.y+70, >>>>> width=5, fill='red') >>>>> newbox.bind('', self.onDrag) >>>>> >>>>> it gives me an error saying that I can't bind this method to this >>>>> instance. >>>> >>>> Didn't you mean an AttributeError ? The id returned my >>>> create_rectangle surely doesn't have a bind method. >>>> >>>>> How can I make this work? >>>> >>>> That is why Canvas has a method called tag_bind, to bind an item in the >>>> canvas: >>>> >>>> master.tag_bind(newbox, '', self.on_drag) >>>> >>>> >>>>> >>>>> Thanks! >>>>> >>>> >>>> -- >>>> -- Guilherme H. Polo Goncalves >>>> >>> >>> >>> Thanks. Yes, you're right, the message is "AttributeError: App instance >>> has >>> no attribute 'on_drag'" However, when I make this change I get no >>> response >>> at all when the program is run. >> >> I suspect there are other things wrong in your app then. >> >>> My drawBox function now looks like this: >>> >>> def drawBox(self,master): >>> newbox=master.create_rectangle(self.x, self.y, self.x+70, self.y+70, >>> width=5, fill='red') >>> master.tag_bind(newbox, '', self.onDrag) >>> >> >> Don't you want a ButtonPress-1 there too ? >> >>> >>> >>> and my onDrag function looks like this: >>> >>> def onDrag(self,event): >>> >>> self.canvas.move(self,event.x-self.x,event.y-self.y) >>> self.x=event.x >>> self.y=event.y >>> This looks like it should work: it passed newbox as self and the >>> coordinates >>> as event to the onDrag function, but I get no response at all. >>> >> >> Uhm, no, self is the class instance so it is surely not the newbox item. >> >> Well, I've done a sample here based on what you are after, check if >> this works for you: >> >> import Tkinter >> >> class Boxes(Tkinter.Canvas): >> def __init__(self, master=None, **kw): >> Tkinter.Canvas.__init__(self, master, **kw) >> >> def create_box(self, x, y, size, **kw): >> box = self.create_rectangle(x, y, x + size, y + size, **kw) >> self.tag_bind(box, '', self.on_click) >> self.tag_bind(box, '', self.on_drag) >> >> def on_click(self, event): >> self.curr_x = event.x >> self.curr_y = event.y >> >> def on_drag(self, event): >> x, y, _, _ = self.coords('current') >> self.move('current', (event.x - self.curr_x), (event.y - >> self.curr_y)) >> self.curr_x = event.x >> self.curr_y = event.y >> >> >> app = Boxes(bg='blue') >> app.create_box(10, 10, 70, width=5, fill='red') >> app.create_box(20, 20, 70, width=5, fill='yellow') >> app.pack() >> app.mainloop() >> >> >> -- >> -- Guilherme H. Polo Goncalves >> > > > -- -- Guilherme H. Polo Goncalves From Kalman_G at msn.com Mon Nov 17 18:08:06 2008 From: Kalman_G at msn.com (Gabor Kalman) Date: Mon, 17 Nov 2008 09:08:06 -0800 Subject: [Tkinter-discuss] Top-level window geometry Message-ID: In the code-snipet below, the following is printed as output: 1x1+0+0 Question #1: why??? (is this somekind of a "normalized" or "per-unit" output?) ======= Question#2: the x=0, y=0 position is ignored when the root and the canvas are displayed. Why??? ======== #============================== from Tkinter import * root=Tk() root.geometry('600x400+0+0') #why??????? print root.winfo_geometry() canvas=Canvas(root,bg='green') canvas.pack() -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael.odonnell at uam.es Mon Nov 17 18:47:37 2008 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Mon, 17 Nov 2008 18:47:37 +0100 Subject: [Tkinter-discuss] Top-level window geometry In-Reply-To: References: Message-ID: <47e491110811170947o5411643bk162dbe135ee0deab@mail.gmail.com> Hi Gabor: On Mon, Nov 17, 2008 at 6:08 PM, Gabor Kalman wrote: > In the code-snipet below, the following is printed as output: > > 1x1+0+0 > > Question #1: why??? (is this somekind of a "normalized" or "per-unit" > output?) > ======= A window has default geometry (basically 1x1+0+0) until it is actually displayed. Your root window is not yet displayed at the point at which the print statement is executed. Try the following, which forces pending drawing events to be performed before the second print (with update()): from Tkinter import * root=Tk() root.geometry('600x400+0+0') #why??????? print root.winfo_geometry() root.update() print root.winfo_geometry() Mick From michael.odonnell at uam.es Mon Nov 17 19:01:54 2008 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Mon, 17 Nov 2008 19:01:54 +0100 Subject: [Tkinter-discuss] Tkinter in Python 2.6 under MacOSX Message-ID: <47e491110811171001i6e49e253n19ee6485b9c1da18@mail.gmail.com> Hi all, Last I tried (2 days ago), the python 2.6 installer for MacOSX was broken for Tkinter. Discussion on the web suggests that python tries to link against the wrong version of Tk. Even Idle doesn't launch. Have other tkinter users experienced this? Any easy fixes without requiring me to learn how to compile python from scratch? Mick O'Donnell From dave.opstad at monotypeimaging.com Mon Nov 17 20:08:27 2008 From: dave.opstad at monotypeimaging.com (Dave Opstad) Date: Mon, 17 Nov 2008 11:08:27 -0800 Subject: [Tkinter-discuss] Tkinter in Python 2.6 under MacOSX In-Reply-To: <47e491110811171001i6e49e253n19ee6485b9c1da18@mail.gmail.com> Message-ID: Michael O'Donnell wrote: > Have other tkinter users experienced this? Any easy fixes without > requiring me to learn how to compile python from scratch? Yes, I'm also unable to use Tkinter with python 2.6 on Mac OS X. There is an open bug about this: http://bugs.python.org/issue4017 Dave From michael.odonnell at uam.es Mon Nov 17 20:57:00 2008 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Mon, 17 Nov 2008 20:57:00 +0100 Subject: [Tkinter-discuss] Tkinter in Python 2.6 under MacOSX In-Reply-To: References: <47e491110811171001i6e49e253n19ee6485b9c1da18@mail.gmail.com> Message-ID: <47e491110811171157r662f7740t6db3f1f0fd4b7ea5@mail.gmail.com> > Yes, I'm also unable to use Tkinter with python 2.6 on Mac OS X. There is an > open bug about this: > > http://bugs.python.org/issue4017 I'm just curious, Given Python is the 6th most popular programming language (http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html) And Tkinter is the default GUI extension. How come a broken distribution of Python 2.6 for Mac can stay on the official site for 6 weeks without being fixed, when it seems its a simple matter to make a fixed binary distrib? (and I know this is not the fault of anyone on this list, I'm just expressing a gripe, I would reallly love to see if the new python on mac fixes my unicode problems). Mick On Mon, Nov 17, 2008 at 8:08 PM, Dave Opstad wrote: > Michael O'Donnell wrote: > >> Have other tkinter users experienced this? Any easy fixes without >> requiring me to learn how to compile python from scratch? > > > Dave > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From klappnase at web.de Mon Nov 17 22:08:13 2008 From: klappnase at web.de (Michael Lange) Date: Mon, 17 Nov 2008 22:08:13 +0100 Subject: [Tkinter-discuss] Strange behavior with python 2.5 In-Reply-To: References: <491F36D9.4040507@cern.ch> <20081116154340.212956a1.klappnase@web.de> <2AACD4EB2F123248A064A23843B3A17301498A26@cernxchg47.cern.ch> <20081116215958.3ffdef3a.klappnase@web.de> Message-ID: <20081117220813.fc4ee913.klappnase@web.de> On Sun, 16 Nov 2008 19:21:34 -0200 "Guilherme Polo" wrote: > On Sun, Nov 16, 2008 at 6:59 PM, Michael Lange wrote: > > On Sun, 16 Nov 2008 17:18:54 -0200 > > "Guilherme Polo" wrote: > > > >> On Sun, Nov 16, 2008 at 4:59 PM, Vasilis Vlachoudis > >> wrote: > >> > Finally I didn't understand, is it a problem of Tkinter or Tk/Tcl? > >> > >> It is not really a problem. But if you want to blame someone, go for > >> Python then. > >> > > > > If you get unexpected and , if the software you write is supposed to run on > > different platforms, also unpredictable behavior like this I think it *is* a > > problem. > > I meant more in these sense of the conversion raising some exception, > but it can be seen in that way too sure. But this doesn't depend on > the platform, all them will show this behaviour. > O.k., by "platform" I actually meant different linux / unix systems with different versions of Python / Tk installed. (...) > > Good for you then :) > It gets hard to continue arguing about this now, since you apparently > solved the question on your side and thus won't have real examples of > this problem, and why it couldn't be solved, anymore (or maybe you do, > so we can continue on this). Using Tk-8.5 it is not too hard to find examples: >>> from Tkinter import * >>> root = Tk() >>> t = Text(root) >>> t.pack() >>> t.insert('end', 'foobar') >>> i = t.index('end') >>> i >>> print i 2.0 >>> int(i) Traceback (most recent call last): File "", line 1, in TypeError: int() argument must be a string or a number, not '_tkinter.Tcl_Obj' >>> str(i) '2.0' > > > The problem is that you never seem > > to know where the TclObjects appear on Python / Tk versions other than your own. > > So what else to do? Convert everything Tk returns to string? > > No, like I said, who calls into _tkinter should know what kind of > object to expect so you do the conversion yourself. If you are going > to return the object to the user, then surely check if it is what you > are expecting it to be. > > Now, I'm sure this can be improved in Python but you have to invest > some time on it. So you mean, the only option to fix this is to write patches for Tkinter.py, resp. the other modules in lib-tk, so the return values of "broken" methods are converted from TclObjects into string (or whatever seems adequate)? Michael From ggpolo at gmail.com Mon Nov 17 22:36:52 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Mon, 17 Nov 2008 19:36:52 -0200 Subject: [Tkinter-discuss] Strange behavior with python 2.5 In-Reply-To: <20081117220813.fc4ee913.klappnase@web.de> References: <491F36D9.4040507@cern.ch> <20081116154340.212956a1.klappnase@web.de> <2AACD4EB2F123248A064A23843B3A17301498A26@cernxchg47.cern.ch> <20081116215958.3ffdef3a.klappnase@web.de> <20081117220813.fc4ee913.klappnase@web.de> Message-ID: On Mon, Nov 17, 2008 at 7:08 PM, Michael Lange wrote: > On Sun, 16 Nov 2008 19:21:34 -0200 > "Guilherme Polo" wrote: > >> On Sun, Nov 16, 2008 at 6:59 PM, Michael Lange wrote: >> > On Sun, 16 Nov 2008 17:18:54 -0200 >> > "Guilherme Polo" wrote: >> > >> >> On Sun, Nov 16, 2008 at 4:59 PM, Vasilis Vlachoudis >> >> wrote: >> >> > Finally I didn't understand, is it a problem of Tkinter or Tk/Tcl? >> >> >> >> It is not really a problem. But if you want to blame someone, go for >> >> Python then. >> >> >> > >> > If you get unexpected and , if the software you write is supposed to run on >> > different platforms, also unpredictable behavior like this I think it *is* a >> > problem. >> >> I meant more in these sense of the conversion raising some exception, >> but it can be seen in that way too sure. But this doesn't depend on >> the platform, all them will show this behaviour. >> > > O.k., by "platform" I actually meant different linux / unix systems with > different versions of Python / Tk installed. > > (...) > >> >> Good for you then :) >> It gets hard to continue arguing about this now, since you apparently >> solved the question on your side and thus won't have real examples of >> this problem, and why it couldn't be solved, anymore (or maybe you do, >> so we can continue on this). > > Using Tk-8.5 it is not too hard to find examples: > >>>> from Tkinter import * >>>> root = Tk() >>>> t = Text(root) >>>> t.pack() >>>> t.insert('end', 'foobar') >>>> i = t.index('end') >>>> i > >>>> print i > 2.0 >>>> int(i) > Traceback (most recent call last): > File "", line 1, in > TypeError: int() argument must be a string or a number, not '_tkinter.Tcl_Obj' >>>> str(i) > '2.0' > You surely can find examples, but that is not what I was asking for. I was asking for code examples where this conversion would be trouble some. Nevertheless the example is good in the sense to show that Tkinter was "relatively broken" on that method and now it is fixed on python 2.6 (doing an explicit conversion), and I will check if I can backport the fix to the release25-maint so Python 2.5.3 comes with that fixed too. And while this example doesn't really show what I were expecting, it shows what you should do know in your other wrappers (supposing you are using other wrappers to tcl/tk). You know the method index of Text has to give the user a string representing 'line.char', so if it gives you a Tcl_Obj, then just return its string representation. >> >> > The problem is that you never seem >> > to know where the TclObjects appear on Python / Tk versions other than your own. >> > So what else to do? Convert everything Tk returns to string? >> >> No, like I said, who calls into _tkinter should know what kind of >> object to expect so you do the conversion yourself. If you are going >> to return the object to the user, then surely check if it is what you >> are expecting it to be. >> >> Now, I'm sure this can be improved in Python but you have to invest >> some time on it. > > So you mean, the only option to fix this is to write patches for Tkinter.py, > resp. the other modules in lib-tk, so the return values of "broken" methods > are converted from TclObjects into string (or whatever seems adequate)? > Uhm, I never said that was the only option, did I ? But it is surely the easiest way, if you want to stay in Python (.py) code only. And please note that I'm not saying to always leave it as a string, that breaks the point of expecting objects. > Michael > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -- -- Guilherme H. Polo Goncalves From ggpolo at gmail.com Mon Nov 17 22:48:55 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Mon, 17 Nov 2008 19:48:55 -0200 Subject: [Tkinter-discuss] Tkinter in Python 2.6 under MacOSX In-Reply-To: <47e491110811171157r662f7740t6db3f1f0fd4b7ea5@mail.gmail.com> References: <47e491110811171001i6e49e253n19ee6485b9c1da18@mail.gmail.com> <47e491110811171157r662f7740t6db3f1f0fd4b7ea5@mail.gmail.com> Message-ID: On Mon, Nov 17, 2008 at 5:57 PM, Michael O'Donnell wrote: >> Yes, I'm also unable to use Tkinter with python 2.6 on Mac OS X. There is an >> open bug about this: >> >> http://bugs.python.org/issue4017 > > I'm just curious, > > Given Python is the 6th most popular programming language > (http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html) > > And Tkinter is the default GUI extension. > > How come a broken distribution of Python 2.6 for Mac can stay on the official > site for 6 weeks without being fixed, when it seems its a simple matter to make > a fixed binary distrib? > I particularly don't have a mac to test the installer there, so I can't do much. So if you know how to fix it would be very nice to submit the patch to the bug tracker, because apparently issue4017 stopped progressing. But if you don't, you could try raising this question on python-dev because this is surely annoying. > (and I know this is not the fault of anyone on this list, I'm just > expressing a gripe, > I would reallly love to see if the new python on mac fixes my unicode problems). > > Mick > > On Mon, Nov 17, 2008 at 8:08 PM, Dave Opstad > wrote: >> Michael O'Donnell wrote: >> >>> Have other tkinter users experienced this? Any easy fixes without >>> requiring me to learn how to compile python from scratch? >> > >> >> Dave >> >> _______________________________________________ >> 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 > -- -- Guilherme H. Polo Goncalves From michael.odonnell at uam.es Mon Nov 17 23:58:05 2008 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Mon, 17 Nov 2008 23:58:05 +0100 Subject: [Tkinter-discuss] Tkinter in Python 2.6 under MacOSX In-Reply-To: References: <47e491110811171001i6e49e253n19ee6485b9c1da18@mail.gmail.com> <47e491110811171157r662f7740t6db3f1f0fd4b7ea5@mail.gmail.com> Message-ID: <47e491110811171458i4978a41dvcaadede32c08013a@mail.gmail.com> Hi Guilherme, > can't do much. So if you know how to fix it would be very nice to > submit the patch to the bug tracker, because apparently issue4017 > stopped progressing. Someone posted to the bugtracker the following: -------------------- [Kevin's post of 6.Oct, 02:58] You can avoid this problem by building Python yourself and putting /Library/Frameworks first on the search path for Tcl/Tk. Look in setup.py in the source code, around line 1438 (in the 'detect_tkinter_darwin' function), and either comment out /System/Library or put it underneath /Library/Frameworks. This is what the official build from Python.org should do--look first in /Library/Frameworks and then fall back on /System/Library/Frameworks. I'm not sure why it doesn't. ------------------- If that is all it takes to fix it, I've no idea why no-one has done that and re-released the macosx distro. I'll try and post on the python-dev list to see if I can get some action. Mick On Mon, Nov 17, 2008 at 10:48 PM, Guilherme Polo wrote: > On Mon, Nov 17, 2008 at 5:57 PM, Michael O'Donnell > wrote: >>> Yes, I'm also unable to use Tkinter with python 2.6 on Mac OS X. There is an >>> open bug about this: >>> >>> http://bugs.python.org/issue4017 >> >> I'm just curious, >> >> Given Python is the 6th most popular programming language >> (http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html) >> >> And Tkinter is the default GUI extension. >> >> How come a broken distribution of Python 2.6 for Mac can stay on the official >> site for 6 weeks without being fixed, when it seems its a simple matter to make >> a fixed binary distrib? >> > > I particularly don't have a mac to test the installer there, so I > can't do much. So if you know how to fix it would be very nice to > submit the patch to the bug tracker, because apparently issue4017 > stopped progressing. But if you don't, you could try raising this > question on python-dev because this is surely annoying. > >> (and I know this is not the fault of anyone on this list, I'm just >> expressing a gripe, >> I would reallly love to see if the new python on mac fixes my unicode problems). >> >> Mick >> >> On Mon, Nov 17, 2008 at 8:08 PM, Dave Opstad >> wrote: >>> Michael O'Donnell wrote: >>> >>>> Have other tkinter users experienced this? Any easy fixes without >>>> requiring me to learn how to compile python from scratch? >>> >> >>> >>> Dave >>> >>> _______________________________________________ >>> 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 >> > > > > -- > -- Guilherme H. Polo Goncalves > From kw at codebykevin.com Tue Nov 18 00:23:44 2008 From: kw at codebykevin.com (Kevin Walzer) Date: Mon, 17 Nov 2008 18:23:44 -0500 Subject: [Tkinter-discuss] Tkinter in Python 2.6 under MacOSX In-Reply-To: <47e491110811171001i6e49e253n19ee6485b9c1da18@mail.gmail.com> References: <47e491110811171001i6e49e253n19ee6485b9c1da18@mail.gmail.com> Message-ID: <4921FD00.5000308@codebykevin.com> Michael O'Donnell wrote: > Hi all, > > Last I tried (2 days ago), the python 2.6 installer for MacOSX was > broken for Tkinter. > Discussion on the web suggests that python tries to link against the > wrong version of > Tk. Even Idle doesn't launch. > > Have other tkinter users experienced this? Any easy fixes without > requiring me to learn how to compile python from scratch? > > Mick O'Donnell Nope. You'll have to compile it from scratch. -- Kevin Walzer Code by Kevin http://www.codebykevin.com From fred.mailhot at gmail.com Tue Nov 18 18:38:47 2008 From: fred.mailhot at gmail.com (Fred Mailhot) Date: Tue, 18 Nov 2008 12:38:47 -0500 Subject: [Tkinter-discuss] Tkinter in Python 2.6 under MacOSX In-Reply-To: <47e491110811171157r662f7740t6db3f1f0fd4b7ea5@mail.gmail.com> References: <47e491110811171001i6e49e253n19ee6485b9c1da18@mail.gmail.com> <47e491110811171157r662f7740t6db3f1f0fd4b7ea5@mail.gmail.com> Message-ID: 2008/11/17 Michael O'Donnell : [snip] > I would reallly love to see if the new python on mac fixes my unicode problems). Oh God yes. I've done every kind of voodoo imaginable with Tk8.5 libs and still can't get things to display properly. It's a bit ridiculous. (I'd rewrite everything in PyQt, but I've inherited an app with the Tkinter code kind of spaghetti'd throughout...argh). Fred. From ggpolo at gmail.com Tue Nov 18 19:03:47 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Tue, 18 Nov 2008 16:03:47 -0200 Subject: [Tkinter-discuss] Tkinter in Python 2.6 under MacOSX In-Reply-To: References: <47e491110811171001i6e49e253n19ee6485b9c1da18@mail.gmail.com> <47e491110811171157r662f7740t6db3f1f0fd4b7ea5@mail.gmail.com> Message-ID: On Tue, Nov 18, 2008 at 3:38 PM, Fred Mailhot wrote: > 2008/11/17 Michael O'Donnell : > [snip] >> I would reallly love to see if the new python on mac fixes my unicode problems). > > Oh God yes. I've done every kind of voodoo imaginable with Tk8.5 libs > and still can't > get things to display properly. It's a bit ridiculous. (I'd rewrite > everything in PyQt, But if it is a problem with python on mac then just changing to pyqt won't cut it. Or if it is a problem with python *and* tcl, then I take you have no issues with unicode in pure tcl code, or what ? > but > I've inherited an app with the Tkinter code kind of spaghetti'd > throughout...argh). > > Fred. > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -- -- Guilherme H. Polo Goncalves From fred.mailhot at gmail.com Tue Nov 18 22:13:08 2008 From: fred.mailhot at gmail.com (Fred Mailhot) Date: Tue, 18 Nov 2008 16:13:08 -0500 Subject: [Tkinter-discuss] Tkinter in Python 2.6 under MacOSX In-Reply-To: References: <47e491110811171001i6e49e253n19ee6485b9c1da18@mail.gmail.com> <47e491110811171157r662f7740t6db3f1f0fd4b7ea5@mail.gmail.com> Message-ID: 2008/11/18 Guilherme Polo : [snip] > > But if it is a problem with python on mac then just changing to pyqt > won't cut it. Or if it is a problem with python *and* tcl, then I take > you have no issues with unicode in pure tcl code, or what ? [copied from an earlier post of mine to this list] import Tkinter root = Tkinter.Tk() w1 = Tkinter.Button(root, text=u"\u026E", font=("Lucida Grande",24)) w2 = Tkinter.Label(root, text=u"\u026E", font=("Lucida Grande",24)) w1.pack() w2.pack The Button displays the correct character (a digraph from the International Phonetic Alphabet), whereas the Label displays what looks like a Chinese kanji character...the same problem as in 8.4. Also, I verified someone else's (good) suggestion that it might be an endianness issue, but it's not. My understanding was that this would be resolved with Tk8.5, but no dice. Still hoping this will be addressed. Fred. From michael.odonnell at uam.es Tue Nov 18 22:14:47 2008 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Tue, 18 Nov 2008 22:14:47 +0100 Subject: [Tkinter-discuss] Tkinter in Python 2.6 under MacOSX In-Reply-To: References: <47e491110811171001i6e49e253n19ee6485b9c1da18@mail.gmail.com> Message-ID: <47e491110811181314i12441295w23f7c35e279ce040@mail.gmail.com> > But if it is a problem with python on mac then just changing to pyqt > won't cut it. Or if it is a problem with python *and* tcl, then I take > you have no issues with unicode in pure tcl code, or what ? No, the problem is that Tk8.4 could not display unicode characters properly on Mac (e.g., chinese chars come out as squares) Supposedly in Tk8.5 they changed the font rendering code to something called ATSU code, which knows how to display unicode properly. So they say. As for Tcl, I used it for years (1996-2003) with unicode text, and it was actually a lot better than python, in that it was totally invisible. Was a shock when I switched to python how many unicode related bugs I got. Mick From michael.odonnell at uam.es Tue Nov 18 22:17:41 2008 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Tue, 18 Nov 2008 22:17:41 +0100 Subject: [Tkinter-discuss] Tkinter in Python 2.6 under MacOSX In-Reply-To: References: <47e491110811171001i6e49e253n19ee6485b9c1da18@mail.gmail.com> <47e491110811171157r662f7740t6db3f1f0fd4b7ea5@mail.gmail.com> Message-ID: <47e491110811181317n993bd68u4bf7413e2a88da03@mail.gmail.com> > My understanding was that this would be resolved with Tk8.5, but no > dice. Still hoping this will be addressed. :-( So what was all the fuss about switching to the ATSU code. Mick From kw at codebykevin.com Tue Nov 18 22:51:26 2008 From: kw at codebykevin.com (Kevin Walzer) Date: Tue, 18 Nov 2008 16:51:26 -0500 Subject: [Tkinter-discuss] Tkinter in Python 2.6 under MacOSX In-Reply-To: <47e491110811181317n993bd68u4bf7413e2a88da03@mail.gmail.com> References: <47e491110811171001i6e49e253n19ee6485b9c1da18@mail.gmail.com> <47e491110811171157r662f7740t6db3f1f0fd4b7ea5@mail.gmail.com> <47e491110811181317n993bd68u4bf7413e2a88da03@mail.gmail.com> Message-ID: <492338DE.6030007@codebykevin.com> Michael O'Donnell wrote: >> My understanding was that this would be resolved with Tk8.5, but no >> dice. Still hoping this will be addressed. > > :-( > > So what was all the fuss about switching to the ATSU code. > > Mick ATSUI is a more modern font rendering technology with support for Unicode. The older font technology in Tk 8.4 was based on QuickDraw, which is obsolete. -- Kevin Walzer Code by Kevin http://www.codebykevin.com From ggpolo at gmail.com Wed Nov 19 02:32:52 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Tue, 18 Nov 2008 23:32:52 -0200 Subject: [Tkinter-discuss] Tkinter in Python 2.6 under MacOSX In-Reply-To: References: <47e491110811171001i6e49e253n19ee6485b9c1da18@mail.gmail.com> <47e491110811171157r662f7740t6db3f1f0fd4b7ea5@mail.gmail.com> Message-ID: On Tue, Nov 18, 2008 at 7:13 PM, Fred Mailhot wrote: > 2008/11/18 Guilherme Polo : > [snip] >> >> But if it is a problem with python on mac then just changing to pyqt >> won't cut it. Or if it is a problem with python *and* tcl, then I take >> you have no issues with unicode in pure tcl code, or what ? > > [copied from an earlier post of mine to this list] > > import Tkinter > root = Tkinter.Tk() > w1 = Tkinter.Button(root, text=u"\u026E", font=("Lucida Grande",24)) > w2 = Tkinter.Label(root, text=u"\u026E", font=("Lucida Grande",24)) > w1.pack() > w2.pack > > The Button displays the correct character (a digraph from the > International Phonetic Alphabet), whereas the Label displays what > looks like a Chinese kanji character...the same problem as in 8.4. > > Also, I verified someone else's (good) suggestion that it might be an > endianness issue, but it's not. > > My understanding was that this would be resolved with Tk8.5, but no > dice. Still hoping this will be addressed. > So running Tk 8.5 with python 2.6 under mac wasn't a problem for you ? This is confusing me because the thread was about this, so I was considering you were in the same boat. Anyway, just to confirm: the code you pasted now, if you convert it to tcl code and run from wish (for example) it doesn't work either right ? There are some problems in the current _tkinter wrapper, I just found one now while reading an issue in the bug tracker (http://bugs.python.org/issue1028) and there are probably others around there, so if it doesn't work while using tkinter it doesn't necessarily means it won't in tcl/tk. > Fred. > -- -- Guilherme H. Polo Goncalves From michael.odonnell at uam.es Wed Nov 19 08:15:45 2008 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Wed, 19 Nov 2008 08:15:45 +0100 Subject: [Tkinter-discuss] Tkinter in Python 2.6 under MacOSX In-Reply-To: References: <47e491110811171001i6e49e253n19ee6485b9c1da18@mail.gmail.com> <47e491110811171157r662f7740t6db3f1f0fd4b7ea5@mail.gmail.com> Message-ID: <47e491110811182315j519de0ebqbabc5234e2e6f425@mail.gmail.com> > So running Tk 8.5 with python 2.6 under mac wasn't a problem for you ? > This is confusing me because the thread was about this, so I was > considering you were in the same boat. The problem of the strand is that the BINARY distribution of 2.6 doesn't work on Mac. If you download the source, switch two lines (the search path for tkinter libraries), then compile, it will work. My perception is that it is a bit crazy to expect every single user of python/tkinter or idle on the Mac to know how to compile C programs on the Mac, or to want to. Also, why have 100s of people fix a bug, when it could be fixed once and uploaded as a binary. Mick From kw at codebykevin.com Wed Nov 19 15:11:18 2008 From: kw at codebykevin.com (Kevin Walzer) Date: Wed, 19 Nov 2008 09:11:18 -0500 Subject: [Tkinter-discuss] Tkinter in Python 2.6 under MacOSX In-Reply-To: <47e491110811182315j519de0ebqbabc5234e2e6f425@mail.gmail.com> References: <47e491110811171001i6e49e253n19ee6485b9c1da18@mail.gmail.com> <47e491110811171157r662f7740t6db3f1f0fd4b7ea5@mail.gmail.com> <47e491110811182315j519de0ebqbabc5234e2e6f425@mail.gmail.com> Message-ID: <49241E86.30006@codebykevin.com> Michael O'Donnell wrote: >> So running Tk 8.5 with python 2.6 under mac wasn't a problem for you ? >> This is confusing me because the thread was about this, so I was >> considering you were in the same boat. > > The problem of the strand is that the BINARY distribution of 2.6 doesn't work > on Mac. If you download the source, switch two lines (the search > path for tkinter libraries), then compile, it will work. > > My perception is that it is a bit crazy to expect every single > user of python/tkinter or idle on the Mac to know how to compile > C programs on the Mac, or to want to. Also, why have 100s of > people fix a bug, when it could be fixed once and uploaded > as a binary. > > Mick Unfortunately, the pace of bug fixes in Python development is slow--it's impossible to predict when a bug fix will get rolled into a new release. Unfortunately as well, some bug fixes are difficult, so you have little choice but to wait for the core developer to fix them. (The bug about Python scripts not running in Terminal when you double-clicked them is an example here.) One thing that you *don't* have to wait for is an updated build of Python itself, if the only issue is how the build is linked. The instructions I posted in the bug report at http://bugs.python.org/issue4017 walk you through the process of correctly building Python against Tk 8.5 on the Mac. They are very simple. Comment out a line or to in the "configure.py" file, and then run the build as usual. Here are the steps as outlined in the Mac README file: ./configure --enable-universalsdk make sudo make install This isn't rocket science. All the steps are worked out for you; all you have to do is run the commands. --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From Kalman_G at msn.com Wed Nov 26 20:23:31 2008 From: Kalman_G at msn.com (Gabor Kalman) Date: Wed, 26 Nov 2008 11:23:31 -0800 Subject: [Tkinter-discuss] Detecting (draw) items on Canvas (widget) Message-ID: Question: I have a Canvas (c1) and have created (drawn) a rectangle item on c1. How can I find out that at an xy location I'm over the canvas OR over the rectangle (the latter, of course, is over the Canvas too)? Tried with various "tag"-s, but did not work. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ggpolo at gmail.com Wed Nov 26 21:10:27 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Wed, 26 Nov 2008 18:10:27 -0200 Subject: [Tkinter-discuss] Detecting (draw) items on Canvas (widget) In-Reply-To: References: Message-ID: On Wed, Nov 26, 2008 at 5:23 PM, Gabor Kalman wrote: > > Question: > > I have a Canvas (c1) and have created (drawn) a rectangle item on c1. > How can I find out that at an xy location I'm over the canvas OR over the > rectangle (the latter, of course, is over the Canvas too)? > Tried with various "tag"-s, but did not work. > > What do you mean by finding out if you are over the canvas ? As soon as the mouse pointer enters the canvas, you are over the canvas. For the second part of the question check this: http://mail.python.org/pipermail/tkinter-discuss/2008-November/001737.html as it is a very similar question > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > -- -- Guilherme H. Polo Goncalves From LouisGidney at cromer.demon.co.uk Wed Nov 26 22:28:44 2008 From: LouisGidney at cromer.demon.co.uk (Louis Gidney) Date: Wed, 26 Nov 2008 21:28:44 +0000 Subject: [Tkinter-discuss] Anyone home? Message-ID: <492DBF8C.6090408@cromer.demon.co.uk> Anyone home? Lou From ggpolo at gmail.com Thu Nov 27 00:48:00 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Wed, 26 Nov 2008 21:48:00 -0200 Subject: [Tkinter-discuss] mtTkinter version 0.2 uploaded In-Reply-To: <49084CC0.FA48.005C.0@mdacorporation.com> References: <49084CC0.FA48.005C.0@mdacorporation.com> Message-ID: On Wed, Oct 29, 2008 at 1:45 PM, Allen Taylor wrote: > Fixed some fairly major bugs and uploaded to > http://tkinter.unpythonic.net/wiki/mtTkinter. > Allen Hi Allen, Is there any possibility of including samples that demonstrate bad behaviour against current _tkinter but works when using mtTkinter ? I'm working on redoing _tkinter, as time allows (and have restarted doing it twice I think), and finally it seems to getting to some point now. I've created some tests for when tcl/tk are compiled with thread support and when they are not, but the tests are not compatible with _tkinter at all for now and that is why I'm asking for samples from your side. It is possible that you have more cases of when it fails then I do, so if you can provide any it would help this new _tkinter and other people would understand more clearly what mtTkinter solves. Regards, -- -- Guilherme H. Polo Goncalves From Allen.Taylor at mdacorporation.com Thu Nov 27 15:15:25 2008 From: Allen.Taylor at mdacorporation.com (Allen Taylor) Date: Thu, 27 Nov 2008 09:15:25 -0500 Subject: [Tkinter-discuss] mtTkinter version 0.2 uploaded In-Reply-To: References: <49084CC0.FA48.005C.0@mdacorporation.com> Message-ID: <492E652D.FA48.005C.0@mdacorporation.com> Hi Guilherme, I will cobble something together in the next few days and post it. If you are working on redoing _tkinter, would you consider taking the same approach to thread-safety as I did in mtTkinter? If so, perhaps mtTkinter could be obsoleted. Allen >>> "Guilherme Polo" 2008-11-26 18:48 >>> On Wed, Oct 29, 2008 at 1:45 PM, Allen Taylor wrote: > Fixed some fairly major bugs and uploaded to > http://tkinter.unpythonic.net/wiki/mtTkinter. > Allen Hi Allen, Is there any possibility of including samples that demonstrate bad behaviour against current _tkinter but works when using mtTkinter ? I'm working on redoing _tkinter, as time allows (and have restarted doing it twice I think), and finally it seems to getting to some point now. I've created some tests for when tcl/tk are compiled with thread support and when they are not, but the tests are not compatible with _tkinter at all for now and that is why I'm asking for samples from your side. It is possible that you have more cases of when it fails then I do, so if you can provide any it would help this new _tkinter and other people would understand more clearly what mtTkinter solves. Regards, -- -- Guilherme H. Polo Goncalves -------------- next part -------------- An HTML attachment was scrubbed... URL: From ggpolo at gmail.com Thu Nov 27 15:43:45 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Thu, 27 Nov 2008 12:43:45 -0200 Subject: [Tkinter-discuss] mtTkinter version 0.2 uploaded In-Reply-To: <492E652D.FA48.005C.0@mdacorporation.com> References: <49084CC0.FA48.005C.0@mdacorporation.com> <492E652D.FA48.005C.0@mdacorporation.com> Message-ID: On Thu, Nov 27, 2008 at 12:15 PM, Allen Taylor wrote: > Hi Guilherme, > I will cobble something together in the next few days and post it. > If you are working on redoing _tkinter, would you consider taking the same > approach to thread-safety as I did in mtTkinter? If so, perhaps mtTkinter > could be obsoleted. I'm not approaching the problem exactly as you did, but I'm trying to make it thread safe. I have considered three distinct cases: 1) Python has thread support, Tcl doesn't Tcl_GetCurrentThread() will always return 0 here, so checking this against the initial value returned by Tcl_GetCurrentThread() and stored when the intrepreter was created will not always indicate that the thread that is about to do something is indeed the one that created Tcl. Here I check if PyThread_get_thread_ident() is the same as the one that created the tcl interpreter, if it not, it just re-schedules the call. 2) Python has no thread support, Tcl does I didn't recompile Python without thread support to test this case but basically it would be the inverse of the previous case. The only difference is internal to Tcl. 3) Both have thread support This case is basically the combination of the previous two. The differences from this thing that I'm calling "plumage" and _tkinter in regard to threads are: i) It works (at least in the tests I've done) in all the three cases where tkinter will always fail in the first case; ii) It doesn't use a busy loop in order to get the thread responsible for the interpreter, instead it will re-schedule the call as much as needed (tests needed for possible problems here) > Allen > -- -- Guilherme H. Polo Goncalves From Allen.Taylor at mdacorporation.com Thu Nov 27 15:55:32 2008 From: Allen.Taylor at mdacorporation.com (Allen Taylor) Date: Thu, 27 Nov 2008 09:55:32 -0500 Subject: [Tkinter-discuss] mtTkinter version 0.2 uploaded In-Reply-To: References: <49084CC0.FA48.005C.0@mdacorporation.com> <492E652D.FA48.005C.0@mdacorporation.com> Message-ID: <492E6E94.FA48.005C.0@mdacorporation.com> >>> "Guilherme Polo" 2008-11-27 09:43 >>> >ii) It doesn't use a busy loop in order to get the thread responsible >for the interpreter, instead it will re-schedule the call as much as >needed (tests needed for possible problems here) By "re-schedule", do you mean to use a queuing techique, or do you plan on indefinitely polling? Allen -------------- next part -------------- An HTML attachment was scrubbed... URL: From ggpolo at gmail.com Thu Nov 27 16:23:56 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Thu, 27 Nov 2008 13:23:56 -0200 Subject: [Tkinter-discuss] mtTkinter version 0.2 uploaded In-Reply-To: <492E6E94.FA48.005C.0@mdacorporation.com> References: <49084CC0.FA48.005C.0@mdacorporation.com> <492E652D.FA48.005C.0@mdacorporation.com> <492E6E94.FA48.005C.0@mdacorporation.com> Message-ID: On Thu, Nov 27, 2008 at 12:55 PM, Allen Taylor wrote: >>>> "Guilherme Polo" 2008-11-27 09:43 >>> >>ii) It doesn't use a busy loop in order to get the thread responsible >>for the interpreter, instead it will re-schedule the call as much as >>needed (tests needed for possible problems here) > By "re-schedule", do you mean to use a queuing techique, or do you plan on > indefinitely polling? On Tcl side a queue is always used, but on Python side you don't have these nice functions for enqueueing events for specific threads so I'm hoping that eventually (by using Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS or similar code) the thread I want will be used. > Allen -- -- Guilherme H. Polo Goncalves From Cameron at phaseit.net Fri Nov 28 22:11:52 2008 From: Cameron at phaseit.net (Cameron Laird) Date: Fri, 28 Nov 2008 21:11:52 +0000 Subject: [Tkinter-discuss] Anyone home? In-Reply-To: <492DBF8C.6090408@cromer.demon.co.uk> References: <492DBF8C.6090408@cromer.demon.co.uk> Message-ID: <20081128211152.GA29922@lairds.us> On Wed, Nov 26, 2008 at 09:28:44PM +0000, Louis Gidney wrote: . . . > Anyone home? . . . reveals that tkinter-discuss has been an active mailing list continuously since it was founded almost five years ago. From ggpolo at gmail.com Sat Nov 29 17:54:34 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Sat, 29 Nov 2008 14:54:34 -0200 Subject: [Tkinter-discuss] mtTkinter version 0.2 uploaded In-Reply-To: References: <49084CC0.FA48.005C.0@mdacorporation.com> <492E652D.FA48.005C.0@mdacorporation.com> <492E6E94.FA48.005C.0@mdacorporation.com> Message-ID: On Thu, Nov 27, 2008 at 1:23 PM, Guilherme Polo wrote: > On Thu, Nov 27, 2008 at 12:55 PM, Allen Taylor > wrote: >>>>> "Guilherme Polo" 2008-11-27 09:43 >>> >>>ii) It doesn't use a busy loop in order to get the thread responsible >>>for the interpreter, instead it will re-schedule the call as much as >>>needed (tests needed for possible problems here) >> By "re-schedule", do you mean to use a queuing techique, or do you plan on >> indefinitely polling? > > On Tcl side a queue is always used, but on Python side you don't have > these nice functions for enqueueing events for specific threads so I'm > hoping that eventually (by using > Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS or similar code) the > thread I want will be used. > I was able to work on it more than I expected and now you can find the first version of it at http://code.google.com/p/plumage/ There are probably many problems with it as it is right now, and there are no examples there either, and no documentation.. well, good luck in trying to use it =) I have done some tests here but I need to rearrange them before commiting, but they will appear there tomorrow or even today. Regarding the documentation, well, it is almost an excuse but didn't have the time to document it yet :P I'm also planning to port the Tkinter python code to work with plumage. Finally, anyone attempting to compile will almost surely have to hand edit the Makefile (and of course you need the python-dev package for your distribution -- not even mentioning Windows here, but if you want to adapt the Makefile and something more to compile under Windows.. -- or a python compiled from source, you know). Have fun, -- -- Guilherme H. Polo Goncalves From levi at roxsoftware.com Sun Nov 30 21:50:00 2008 From: levi at roxsoftware.com (Levi Starrett) Date: Sun, 30 Nov 2008 15:50:00 -0500 Subject: [Tkinter-discuss] changing the Entry 'show' option back to normal Message-ID: <577e2bc10811301250i4ac0b125wb852524ff616559b@mail.gmail.com> i'm trying to create a password system with the pmw notebook. i've succeeded in changing the entry show option to '*', but i can't figure out how to change it back to normal. thanks in advance. -Levi -------------- next part -------------- An HTML attachment was scrubbed... URL: