From raycores at gmail.com Wed May 2 01:05:54 2012 From: raycores at gmail.com (Lynn Oliver) Date: Tue, 1 May 2012 16:05:54 -0700 Subject: [Tkinter-discuss] window flashes rapidly Message-ID: <72D9F0FB-83E4-46B5-9B55-D02F0CDAA932@gmail.com> I'm using python 2.7.2 with Tcl/Tk 8.5.11, and I'm using a lot of ttk themed widgets in the UI. The layout is a ttk.notebook with a number of frames per tab; some tabs have frames that are created/destroyed based on user selections. Occasionally when I execute the program, either within the debugger or by itself, the entire window flashes rapidly and continues until I terminate the script. I had noticed that certain dimensions in the frames that are dynamically replaced caused the flashing whenever I caused the frames to change, and by making small adjustments it seemed that I had eliminated the problem. However it still happens occasionally--but not repeatably on my system--and now I've gotten a report from a tester that it flashes on his system when he hasn't done anything that causes frames to be created. As soon as he clicks on a certain button widget the entire UI starts flashing. The same scenario doesn't cause it to flash on my system. Does anyone know what causes this? Any suggestions for tracking down and eliminating the problem? Thanks, Lynn From emilianogavilan at gmail.com Wed May 2 04:42:12 2012 From: emilianogavilan at gmail.com (Emiliano Gavilan) Date: Tue, 1 May 2012 23:42:12 -0300 Subject: [Tkinter-discuss] window flashes rapidly In-Reply-To: <72D9F0FB-83E4-46B5-9B55-D02F0CDAA932@gmail.com> References: <72D9F0FB-83E4-46B5-9B55-D02F0CDAA932@gmail.com> Message-ID: 2012/5/1 Lynn Oliver : > I'm using python 2.7.2 with Tcl/Tk 8.5.11, and I'm using a lot of ttk themed widgets in the UI. ?The layout is a ttk.notebook with a number of frames per tab; some tabs have frames that are created/destroyed based on user selections. > > Occasionally when I execute the program, either within the debugger or by itself, the entire window flashes rapidly and continues until I terminate the script. ? I had noticed that certain dimensions in the frames that are dynamically replaced caused the flashing whenever I caused the frames to change, and by making small adjustments it seemed that I had eliminated the problem. > > However it still happens occasionally--but not repeatably on my system--and now I've gotten a report from a tester that it flashes on his system when he hasn't done anything that causes frames to be created. ?As soon as he clicks on a certain button widget the entire UI starts flashing. ?The same scenario doesn't cause it to flash on my system. > > Does anyone know what causes this? ?Any suggestions for tracking down and eliminating the problem? I don't know what you mean by "flashing". If you mean that the main window geometry adjusts continouosly then probably you are mixing pack() and grid() methods on the same master widget. Regards Emiliano From raycores at gmail.com Wed May 2 09:06:34 2012 From: raycores at gmail.com (Lynn Oliver) Date: Wed, 2 May 2012 00:06:34 -0700 Subject: [Tkinter-discuss] window flashes rapidly In-Reply-To: References: <72D9F0FB-83E4-46B5-9B55-D02F0CDAA932@gmail.com> Message-ID: <23B3B6F7-1B35-4B8C-B566-454C86D5011A@gmail.com> I'm not sure whether to describe this as a flicker or rapid flashing; probably what is happening is that the window is being redrawn continuously as fast as possible. The visual effect is like a fast strobe. I don't explicitly use any pack() methods at all, but I'll take a look and see if that's a possibility. Lynn On May 1, 2012, at 7:42 PM, Emiliano Gavilan wrote: > 2012/5/1 Lynn Oliver : >> I'm using python 2.7.2 with Tcl/Tk 8.5.11, and I'm using a lot of ttk themed widgets in the UI. The layout is a ttk.notebook with a number of frames per tab; some tabs have frames that are created/destroyed based on user selections. >> >> Occasionally when I execute the program, either within the debugger or by itself, the entire window flashes rapidly and continues until I terminate the script. I had noticed that certain dimensions in the frames that are dynamically replaced caused the flashing whenever I caused the frames to change, and by making small adjustments it seemed that I had eliminated the problem. >> >> However it still happens occasionally--but not repeatably on my system--and now I've gotten a report from a tester that it flashes on his system when he hasn't done anything that causes frames to be created. As soon as he clicks on a certain button widget the entire UI starts flashing. The same scenario doesn't cause it to flash on my system. >> >> Does anyone know what causes this? Any suggestions for tracking down and eliminating the problem? > > I don't know what you mean by "flashing". If you mean that the main > window geometry adjusts continouosly > then probably you are mixing pack() and grid() methods on the same > master widget. > > Regards > Emiliano From michael.odonnell at uam.es Wed May 2 09:48:15 2012 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Wed, 2 May 2012 17:48:15 +1000 Subject: [Tkinter-discuss] window flashes rapidly In-Reply-To: <23B3B6F7-1B35-4B8C-B566-454C86D5011A@gmail.com> References: <72D9F0FB-83E4-46B5-9B55-D02F0CDAA932@gmail.com> <23B3B6F7-1B35-4B8C-B566-454C86D5011A@gmail.com> Message-ID: Hi Lynn, I do remember seeing this somewhere before, but years ago, and I think it was on a linux box (and the same code behaved well under Windows). What OS are you on? Is it possible to create a short bit of code that replicates the problem and that you can send? (this step by itslef often reveals the problem to yourself) Does your code do any catching of window resizing, and on this basis of this, reformat any widgets? (I once had a problem that in catching a window resize, I re-arranged my panes to the new size, which in itself caused the window resize event to be called). Mick On Wed, May 2, 2012 at 5:06 PM, Lynn Oliver wrote: > I'm not sure whether to describe this as a flicker or rapid flashing; > probably what is happening is that the window is being redrawn continuously > as fast as possible. The visual effect is like a fast strobe. > > I don't explicitly use any pack() methods at all, but I'll take a look and > see if that's a possibility. > > Lynn > > On May 1, 2012, at 7:42 PM, Emiliano Gavilan wrote: > > > 2012/5/1 Lynn Oliver : > >> I'm using python 2.7.2 with Tcl/Tk 8.5.11, and I'm using a lot of ttk > themed widgets in the UI. The layout is a ttk.notebook with a number of > frames per tab; some tabs have frames that are created/destroyed based on > user selections. > >> > >> Occasionally when I execute the program, either within the debugger or > by itself, the entire window flashes rapidly and continues until I > terminate the script. I had noticed that certain dimensions in the frames > that are dynamically replaced caused the flashing whenever I caused the > frames to change, and by making small adjustments it seemed that I had > eliminated the problem. > >> > >> However it still happens occasionally--but not repeatably on my > system--and now I've gotten a report from a tester that it flashes on his > system when he hasn't done anything that causes frames to be created. As > soon as he clicks on a certain button widget the entire UI starts flashing. > The same scenario doesn't cause it to flash on my system. > >> > >> Does anyone know what causes this? Any suggestions for tracking down > and eliminating the problem? > > > > I don't know what you mean by "flashing". If you mean that the main > > window geometry adjusts continouosly > > then probably you are mixing pack() and grid() methods on the same > > master widget. > > > > Regards > > Emiliano > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -- Not sent from my iPhone -------------- next part -------------- An HTML attachment was scrubbed... URL: From camfarnell at bitflipper.ca Wed May 2 14:36:19 2012 From: camfarnell at bitflipper.ca (Cam) Date: Wed, 02 May 2012 09:36:19 -0300 Subject: [Tkinter-discuss] window flashes rapidly In-Reply-To: References: <72D9F0FB-83E4-46B5-9B55-D02F0CDAA932@gmail.com> <23B3B6F7-1B35-4B8C-B566-454C86D5011A@gmail.com> Message-ID: <4FA12A43.8030008@bitflipper.ca> I had a similar issue a couple of years ago but only on Mac, not on Linux or Windows. It was hard to trace because once you got the lollypop of death you had to kill the process; no error report. Alas it was part of a very large program and I was never able to isolate the code that provoked the problem. Cam Farnell On 12-05-02 04:48 AM, Michael O'Donnell wrote: > Hi Lynn, > > I do remember seeing this somewhere before, but years ago, > and I think it was on a linux box (and the same code behaved well > under Windows). > > What OS are you on? > > Is it possible to create a short bit of code that replicates > the problem and that you can send? > (this step by itslef often reveals the problem to > yourself) > > Does your code do any catching of window resizing, > and on this basis of this, reformat any widgets? > (I once had a problem that in catching a window resize, > I re-arranged my panes to the new size, which in itself > caused the window resize event to be called). > > Mick From raycores at gmail.com Wed May 2 17:05:44 2012 From: raycores at gmail.com (Lynn Oliver) Date: Wed, 2 May 2012 08:05:44 -0700 Subject: [Tkinter-discuss] window flashes rapidly In-Reply-To: References: <72D9F0FB-83E4-46B5-9B55-D02F0CDAA932@gmail.com> <23B3B6F7-1B35-4B8C-B566-454C86D5011A@gmail.com> Message-ID: <175BA751-1732-49D9-8C0C-B88FB02F517A@gmail.com> So far I've only seen this problem on a Mac. Do you recall if it was intermittent in your case, with the same code sometimes causing the behavior and other times not? On May 2, 2012, at 12:48 AM, Michael O'Donnell wrote: > Hi Lynn, > > I do remember seeing this somewhere before, but years ago, > and I think it was on a linux box (and the same code behaved well > under Windows). > > What OS are you on? > > Is it possible to create a short bit of code that replicates > the problem and that you can send? > (this step by itslef often reveals the problem to > yourself) > > Does your code do any catching of window resizing, > and on this basis of this, reformat any widgets? > (I once had a problem that in catching a window resize, > I re-arranged my panes to the new size, which in itself > caused the window resize event to be called). > > Mick > > > On Wed, May 2, 2012 at 5:06 PM, Lynn Oliver wrote: > I'm not sure whether to describe this as a flicker or rapid flashing; probably what is happening is that the window is being redrawn continuously as fast as possible. The visual effect is like a fast strobe. > > I don't explicitly use any pack() methods at all, but I'll take a look and see if that's a possibility. > > Lynn > > On May 1, 2012, at 7:42 PM, Emiliano Gavilan wrote: > > > 2012/5/1 Lynn Oliver : > >> I'm using python 2.7.2 with Tcl/Tk 8.5.11, and I'm using a lot of ttk themed widgets in the UI. The layout is a ttk.notebook with a number of frames per tab; some tabs have frames that are created/destroyed based on user selections. > >> > >> Occasionally when I execute the program, either within the debugger or by itself, the entire window flashes rapidly and continues until I terminate the script. I had noticed that certain dimensions in the frames that are dynamically replaced caused the flashing whenever I caused the frames to change, and by making small adjustments it seemed that I had eliminated the problem. > >> > >> However it still happens occasionally--but not repeatably on my system--and now I've gotten a report from a tester that it flashes on his system when he hasn't done anything that causes frames to be created. As soon as he clicks on a certain button widget the entire UI starts flashing. The same scenario doesn't cause it to flash on my system. > >> > >> Does anyone know what causes this? Any suggestions for tracking down and eliminating the problem? > > > > I don't know what you mean by "flashing". If you mean that the main > > window geometry adjusts continouosly > > then probably you are mixing pack() and grid() methods on the same > > master widget. > > > > Regards > > Emiliano > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > > > -- > > Not sent from my iPhone -------------- next part -------------- An HTML attachment was scrubbed... URL: From raycores at gmail.com Wed May 2 18:07:25 2012 From: raycores at gmail.com (Lynn Oliver) Date: Wed, 2 May 2012 09:07:25 -0700 Subject: [Tkinter-discuss] window flashes rapidly In-Reply-To: References: <72D9F0FB-83E4-46B5-9B55-D02F0CDAA932@gmail.com> Message-ID: <6B6FB597-AB23-4898-969B-DB096520ACAB@gmail.com> I did find one instance of pack() used while everything else was grid(). I'm hoping that will resolve the problem. On May 1, 2012, at 7:42 PM, Emiliano Gavilan wrote: > 2012/5/1 Lynn Oliver : >> I'm using python 2.7.2 with Tcl/Tk 8.5.11, and I'm using a lot of ttk themed widgets in the UI. The layout is a ttk.notebook with a number of frames per tab; some tabs have frames that are created/destroyed based on user selections. >> >> Occasionally when I execute the program, either within the debugger or by itself, the entire window flashes rapidly and continues until I terminate the script. I had noticed that certain dimensions in the frames that are dynamically replaced caused the flashing whenever I caused the frames to change, and by making small adjustments it seemed that I had eliminated the problem. >> >> However it still happens occasionally--but not repeatably on my system--and now I've gotten a report from a tester that it flashes on his system when he hasn't done anything that causes frames to be created. As soon as he clicks on a certain button widget the entire UI starts flashing. The same scenario doesn't cause it to flash on my system. >> >> Does anyone know what causes this? Any suggestions for tracking down and eliminating the problem? > > I don't know what you mean by "flashing". If you mean that the main > window geometry adjusts continouosly > then probably you are mixing pack() and grid() methods on the same > master widget. > > Regards > Emiliano From john at hamilton.org.uk Wed May 9 12:55:06 2012 From: john at hamilton.org.uk (hamiljf) Date: Wed, 9 May 2012 03:55:06 -0700 (PDT) Subject: [Tkinter-discuss] ttk.Notebook - how to bind to tab events (tab caption has focus or mouseover) In-Reply-To: <1292448702.15742.1410545839@webmail.messagingengine.com> References: <1292423331.13959.1410465129@webmail.messagingengine.com> <20101215162121.6e33509f.klappnase@web.de> <1292442498.16189.1410527775@webmail.messagingengine.com> <20101215220041.c42c3e8e.klappnase@web.de> <1292448702.15742.1410545839@webmail.messagingengine.com> Message-ID: <1336560906543-4962779.post@n6.nabble.com> Although not quite an answer, I found this useful... _notebooknotify = {} def addopenlistener(self,page,action): self._notebooknotify[str(page)] = action def notify(event): id = str(event.widget.select()) if id in self._notebooknotify: self._notebooknotify[id].run() self.addopenlistener(child,action) # causes action.run() to be invoked every time child is opened and it also give you a good place to put in tracing/logging/etc -- View this message in context: http://python.6.n6.nabble.com/ttk-Notebook-how-to-bind-to-tab-events-tab-caption-has-focus-or-mouseover-tp1978460p4962779.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From john at hamilton.org.uk Wed May 9 13:07:18 2012 From: john at hamilton.org.uk (hamiljf) Date: Wed, 9 May 2012 04:07:18 -0700 (PDT) Subject: [Tkinter-discuss] Which virtual event have I received ? Message-ID: <1336561638150-4962788.post@n6.nabble.com> I want to be able to process more than one event type in an event handler (I know that there may be other ways of doing this, and I might well use them) Now 'real' events are distinguished by event.type having a numeric value listed all over the place, for example in http://infohost.nmt.edu/tcc/help/pubs/tkinter/events.html new mexico tech dox , and I think virtualevents are #35 (not in the list). But how can I tell which of two virtual events an event object represents: the virtual event name doesn't seem to be anywhere around. If there really isn't any way, it would always be possible to write additional handler methods as an alternative. -- View this message in context: http://python.6.n6.nabble.com/Which-virtual-event-have-I-received-tp4962788.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From bryan.oakley at gmail.com Wed May 9 16:44:05 2012 From: bryan.oakley at gmail.com (Bryan Oakley) Date: Wed, 9 May 2012 09:44:05 -0500 Subject: [Tkinter-discuss] Which virtual event have I received ? In-Reply-To: <1336561638150-4962788.post@n6.nabble.com> References: <1336561638150-4962788.post@n6.nabble.com> Message-ID: On Wed, May 9, 2012 at 6:07 AM, hamiljf wrote: > I want to be able to process more than one event type in an event handler > (I > know that there may be other ways of doing this, and I might well use them) > Now 'real' events are distinguished by event.type having a numeric value > listed all over the place, for example in > http://infohost.nmt.edu/tcc/help/pubs/tkinter/events.html new mexico tech > dox , and I think virtualevents are #35 (not in the list). But how can I > tell which of two virtual events an event object represents: the virtual > event name doesn't seem to be anywhere around. If there really isn't any > way, it would always be possible to write additional handler methods as an > alternative. > One simple solution is for your binding to pass the event type into your callback. For example: widget.bind("<>", lambda event, virtual="<>": self.on_virtual(virtual, event)) widget.bind("<>", lambda event, virtual="<>": self.on_virtual(virtual, event)) ... def on_virtual(self, virtual, event): if (virtual == "<>"): ... -------------- next part -------------- An HTML attachment was scrubbed... URL: From Vasilis.Vlachoudis at cern.ch Wed May 9 16:52:36 2012 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Wed, 9 May 2012 14:52:36 +0000 Subject: [Tkinter-discuss] PanedWindow proportional resizing of panes Message-ID: <0BC70B5D93E054469872FFD0FE07220E9A521637@PLOXCHG13.cern.ch> Hi all, in my application I am using the recipe of http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52266 to create a multilistbox. I have modified it to use the panedwindow in order to allow the resize of the rows, like in the code below. My problem(s) (all related to the resizing of the panes) 1. is how to make the resizing of the window to resize proportionally the panes (Now only the last row "Four" expands/reduce its size) 2. when the user manually resize one pane (e.g. drag between two|three, only the panes two and three are resized while I would prefer more a behavior like all other window toolkits that only "two" will be resized, "three" will remain the same and the last one "Four" will be reduced or expanded. 3. How to save/recall the size of the panes. The paneconfig(child,"width") returns a tuple with ('width','','','') from Tkinter import * tk = Tk() paned = PanedWindow(tk, orient=HORIZONTAL, showhandle=0, handlepad=0, handlesize=0, sashwidth=2, opaqueresize=1) paned.pack(side=LEFT, expand=YES, fill=BOTH) for l,w in [("One",5),("Two",10),("Three",15), ("Four",30)]: frame = Frame(paned, border=0) paned.add(frame,minsize=16) lbl = Label(frame, text=l, borderwidth=1, relief=RAISED) lbl.pack(fill=X) lst = Listbox(frame, width=w, background="White") lst.pack(expand=YES, fill=BOTH) for i in range(100): lst.insert(END,"#%d"%(i)) tk.mainloop() Vasilis -------------- next part -------------- An HTML attachment was scrubbed... URL: From emilianogavilan at gmail.com Wed May 9 19:03:11 2012 From: emilianogavilan at gmail.com (Emiliano Gavilan) Date: Wed, 9 May 2012 14:03:11 -0300 Subject: [Tkinter-discuss] PanedWindow proportional resizing of panes In-Reply-To: <0BC70B5D93E054469872FFD0FE07220E9A521637@PLOXCHG13.cern.ch> References: <0BC70B5D93E054469872FFD0FE07220E9A521637@PLOXCHG13.cern.ch> Message-ID: 2012/5/9 Vasilis Vlachoudis : > Hi all, > > in my application I am using the recipe of > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52266 > to create a multilistbox. I have modified it to use the panedwindow in order > to allow the resize of the rows, like in the code below. > My problem(s) (all related to the resizing of the panes) > 1. is how to make the resizing of the window to resize proportionally the > panes (Now only the last row "Four" expands/reduce its size) Set the stretch option to 'always'. > 2. when the user manually resize one pane (e.g. drag between two|three, only > the panes two and three are resized while I would prefer more a behavior > like all other window toolkits that only "two" will be resized, "three" will > remain the same and the last one "Four" will be reduced or expanded. > 3. How to save/recall the size of the panes. The paneconfig(child,"width") > returns a tuple with ('width','','','') Use child.winfo_width() instead. Also, note that the new ttk.Treeview() can work as a multicolumn listbox too. Regards Emiliano From lionkimbro at gmail.com Thu May 10 04:19:55 2012 From: lionkimbro at gmail.com (Lion Kimbro) Date: Wed, 9 May 2012 19:19:55 -0700 Subject: [Tkinter-discuss] Unbinding Individual Events Message-ID: Unbinding individual events from widgets has been a long standing tkinter bug. I've been working on a workaround for tkhelp.py, but never really liked the solutions I came up with. Most involved multiplexing from a single event receiver. Here is a brief demonstration: import tkinter global_tk = tkinter.Tk() def tcl(tcl_code): """Execute tcl code string directly & return the result.""" return global_tk.tk.eval(tcl_code) tl = tkinter.Toplevel(name="top", width=400, height=200) tl.title("testing") That's the setup frame... Now: >>> tl.bind('', lambda evt:print(evt)) '37533768' Moving the mouse over the toplevel, you can see the events roll in. Now we can look at the events in tcl: >>> tcl('bind .top') '' >>> tcl('bind .top ') 'if {"[37533768 %# %b %f %h %k %s %t %w %x %y %A %E %K %N %W %T %X %Y %D]" == "break"} break\n' The important thing to recognize is that the whole string ('if {"[375...]" == "break"} break\n') is the binding -- NOT the individual function item '37533768'. Now if you add another binding -- >>> tl.bind("", lambda evt:print("whoopie!"), add="+") '37531848' You can roll the mouse over, and you'll see TWO event bindings. Now let's look at it in detail: >>> tcl('bind .top ') 'if {"[37533768 %# %b %f %h %k %s %t %w %x %y %A %E %K %N %W %T %X %Y %D]" == "break"} break\n\nif {"[37531848 %# %b %f %h %k %s %t %w %x %y %A %E %K %N %W %T %X %Y %D]" == "break"} break\n' Okay, now let's say we want to remove the first method? We can rebind, cutting it out. First, we isolate the second entry, which we want: >>> scripts = tcl('bind .top ') >>> scripts.split("\n") ['if {"[37533768 %# %b %f %h %k %s %t %w %x %y %A %E %K %N %W %T %X %Y %D]" == "break"} break', '', 'if {"[37531 848 %# %b %f %h %k %s %t %w %x %y %A %E %K %N %W %T %X %Y %D]" == "break"} break', ''] >>> s=scripts.split("\n")[-2] And then bind it: >>> tcl('bind .top {%s}' % s) '' You'll see the "whoopie!" printing, but the first event printer will be gone! So my thought to systematize this is: A. Make a function (fn-A) for making a Python list out all binding strings on a widget-sequence pair. B. Make a function (fn-B) that constructs the binding string for a given function binding. C. Patch(/replace) widget.unbind so that it retrieves all binding strings (via fn-A), and then removes the string that matches fn-B(funcid), and then rebind the widget via the new list I think that should work. My main concern is that, if _tkinter does any reference counting on function uses, then there is a memory hole. Thoughts? -------------- next part -------------- An HTML attachment was scrubbed... URL: From Vasilis.Vlachoudis at cern.ch Thu May 10 10:57:40 2012 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Thu, 10 May 2012 08:57:40 +0000 Subject: [Tkinter-discuss] PanedWindow proportional resizing of panes In-Reply-To: References: <0BC70B5D93E054469872FFD0FE07220E9A521637@PLOXCHG13.cern.ch>, Message-ID: <0BC70B5D93E054469872FFD0FE07220E9A5217D9@PLOXCHG13.cern.ch> Thank you Emiliano, stretch did the job for the resizing of the window. For resizing the columns I now recuperate the position with the sash_coord and sash_place. However the only think I am missing is the to have an event handler when the sash is moved. Is there any event that is sent when the sash is changed? Thanks in advance Vasilis ________________________________________ From: Emiliano Gavilan [emilianogavilan at gmail.com] Sent: 09 May 2012 19:03 To: Vasilis Vlachoudis Cc: tkinter-discuss at python.org Subject: Re: [Tkinter-discuss] PanedWindow proportional resizing of panes 2012/5/9 Vasilis Vlachoudis : > Hi all, > > in my application I am using the recipe of > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52266 > to create a multilistbox. I have modified it to use the panedwindow in order > to allow the resize of the rows, like in the code below. > My problem(s) (all related to the resizing of the panes) > 1. is how to make the resizing of the window to resize proportionally the > panes (Now only the last row "Four" expands/reduce its size) Set the stretch option to 'always'. > 2. when the user manually resize one pane (e.g. drag between two|three, only > the panes two and three are resized while I would prefer more a behavior > like all other window toolkits that only "two" will be resized, "three" will > remain the same and the last one "Four" will be reduced or expanded. > 3. How to save/recall the size of the panes. The paneconfig(child,"width") > returns a tuple with ('width','','','') Use child.winfo_width() instead. Also, note that the new ttk.Treeview() can work as a multicolumn listbox too. Regards Emiliano From klappnase at web.de Thu May 10 11:36:28 2012 From: klappnase at web.de (Michael Lange) Date: Thu, 10 May 2012 11:36:28 +0200 Subject: [Tkinter-discuss] PanedWindow proportional resizing of panes In-Reply-To: <0BC70B5D93E054469872FFD0FE07220E9A5217D9@PLOXCHG13.cern.ch> References: <0BC70B5D93E054469872FFD0FE07220E9A521637@PLOXCHG13.cern.ch> <0BC70B5D93E054469872FFD0FE07220E9A5217D9@PLOXCHG13.cern.ch> Message-ID: <20120510113628.e9ec740d.klappnase@web.de> Hi Vasislis, Thus spoketh Vasilis Vlachoudis unto us on Thu, 10 May 2012 08:57:40 +0000: > Thank you Emiliano, > > stretch did the job for the resizing of the window. > > For resizing the columns I now recuperate the position with the > sash_coord and sash_place. > > However the only think I am missing is the to have an event handler > when the sash is moved. Is there any event that is sent when the sash > is changed? I have not done much testing on this, but I think that at least if you have one widget (Frame or Listbox or so) that covers one entire pane, there should be a event triggered for this widget each time its pane is being resized. Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. "I think they're going to take all this money that we spend now on war and death --" "And make them spend it on life." -- Edith Keeler and Kirk, "The City on the Edge of Forever", stardate unknown. From Vasilis.Vlachoudis at cern.ch Thu May 10 11:45:01 2012 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Thu, 10 May 2012 09:45:01 +0000 Subject: [Tkinter-discuss] PanedWindow proportional resizing of panes In-Reply-To: <20120510113628.e9ec740d.klappnase@web.de> References: <0BC70B5D93E054469872FFD0FE07220E9A521637@PLOXCHG13.cern.ch> <0BC70B5D93E054469872FFD0FE07220E9A5217D9@PLOXCHG13.cern.ch>, <20120510113628.e9ec740d.klappnase@web.de> Message-ID: <0BC70B5D93E054469872FFD0FE07220E9A521808@PLOXCHG13.cern.ch> Thank you both, I did it with the following way binding the Button-1, B1-Motion, ButtonRelease-1 of the panedwindow (as in the panedwindow.tcl) and then performing the resizing of the panes myself. def sashmark(event): global paned, index, dx, dy, sashx index,which = paned.identify(event.x, event.y) if which == "sash": sashx = [paned.sash_coord(i)[0] for i in range(len(paned.panes())-1)] sx, sy = paned.sash_coord(index) dx = sx - event.x dy = sy - event.y sashdrag(event) else: index = -1 def sashdrag(event): global paned, index, dx, dy, sashx if index>=0: ddx = event.x - dx - sashx[index] paned.sash_place(index, event.x-dx, event.y-dy) for i in range(index+1, len(paned.panes())-1): paned.sash_place(i, sashx[i]+ddx, 1) return "break" def sashrelease(event): global sashx del sashx Vasilis ________________________________________ From: tkinter-discuss-bounces+vasilis.vlachoudis=cern.ch at python.org [tkinter-discuss-bounces+vasilis.vlachoudis=cern.ch at python.org] on behalf of Michael Lange [klappnase at web.de] Sent: 10 May 2012 11:36 To: tkinter-discuss at python.org Subject: Re: [Tkinter-discuss] PanedWindow proportional resizing of panes Hi Vasislis, Thus spoketh Vasilis Vlachoudis unto us on Thu, 10 May 2012 08:57:40 +0000: > Thank you Emiliano, > > stretch did the job for the resizing of the window. > > For resizing the columns I now recuperate the position with the > sash_coord and sash_place. > > However the only think I am missing is the to have an event handler > when the sash is moved. Is there any event that is sent when the sash > is changed? I have not done much testing on this, but I think that at least if you have one widget (Frame or Listbox or so) that covers one entire pane, there should be a event triggered for this widget each time its pane is being resized. Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. "I think they're going to take all this money that we spend now on war and death --" "And make them spend it on life." -- Edith Keeler and Kirk, "The City on the Edge of Forever", stardate unknown. _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss at python.org http://mail.python.org/mailman/listinfo/tkinter-discuss From klappnase at web.de Fri May 11 11:59:30 2012 From: klappnase at web.de (Michael Lange) Date: Fri, 11 May 2012 11:59:30 +0200 Subject: [Tkinter-discuss] Unbinding Individual Events In-Reply-To: References: Message-ID: <20120511115930.60112427.klappnase@web.de> Hi, Thus spoketh Lion Kimbro unto us on Wed, 9 May 2012 19:19:55 -0700: (...) > So my thought to systematize this is: > > A. Make a function (fn-A) for making a Python list out all binding > strings on a widget-sequence pair. > B. Make a function (fn-B) that constructs the binding string for a > given function binding. > C. Patch(/replace) widget.unbind so that it retrieves all binding > strings (via fn-A), and then removes the string that matches fn-B > (funcid), and then rebind the widget via the new list > > I think that should work. > > My main concern is that, if _tkinter does any reference counting on > function uses, then there is a memory hole. > > Thoughts? As far as memory holes are concerned, I think cleanly unbinding each single command, so deletecommand() will be executed, should do the trick. Although I agree that the behavior of unbind() is not intuitive, I think that making unbind() backwards incompatible is not a good idea ;) I set up a quick example, it is not perfect but seems to work ok for a start; you see, instead of changing unbind(), I called the function that does the work remove_binding() for now. Best regards Michael ########################################## from Tkinter import * root = Tk() l = Listbox(root) l.pack() def cmd1(event): print '1' def cmd2(event): print '2' def cmd3(event): print '3' b1 = l.bind('', cmd1) b2 = l.bind('', cmd2, 1) b3 = l.bind('', cmd3, 1) def bindings(widget, seq): return [x for x in widget.bind(seq).splitlines() if x.strip()] def _funcid(binding): return binding.split()[1][3:] def remove_binding(widget, seq, index=None, funcid=None): b = bindings(widget, seq) if not index is None: try: binding = b[index] widget.unbind(seq, _funcid(binding)) b.remove(binding) except IndexError: print 'Binding #%d not defined.' % index return elif funcid: binding = None for x in b: if _funcid(x) == funcid: binding = x b.remove(binding) widget.unbind(seq, funcid) break if not binding: print 'Binding "%s" not defined.' % funcid return else: raise ValueError, 'No index or function id defined.' for x in b: widget.bind(seq, '+'+x, 1) def test1(event): remove_binding(l, '', 0) def test2(event): remove_binding(l, '', None, b1) l.bind('<1>', test1) l.bind('<3>', test2) root.mainloop() ############################################### .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Totally illogical, there was no chance. -- Spock, "The Galileo Seven", stardate 2822.3 From lionkimbro at gmail.com Fri May 11 17:52:31 2012 From: lionkimbro at gmail.com (Lion Kimbro) Date: Fri, 11 May 2012 08:52:31 -0700 Subject: [Tkinter-discuss] Unbinding Individual Events In-Reply-To: <20120511115930.60112427.klappnase@web.de> References: <20120511115930.60112427.klappnase@web.de> Message-ID: Beautiful. That's the solution. I've looked online for a long time, and nobody else came up with a solution. All that I found were the skeletal remains of those who needed to do this, but couldn't find a way. I really appreciate that your code works external to tkinter, and that it respects tkinter's quirks without changing it. I also appreciate that it calls .deletecommand, and also unregisters the function identifier with Misc's internal record keeping. May I include this in tkhelp? I'll definitely credit you with writing the solution. I'll likely make stylistic edits to fit the rest of the API, but I'll point back to the archive of your email . On Fri, May 11, 2012 at 2:59 AM, Michael Lange wrote: > Hi, > > Thus spoketh Lion Kimbro > unto us on Wed, 9 May 2012 19:19:55 -0700: > > (...) > > So my thought to systematize this is: > > > > A. Make a function (fn-A) for making a Python list out all binding > > strings on a widget-sequence pair. > > B. Make a function (fn-B) that constructs the binding string for a > > given function binding. > > C. Patch(/replace) widget.unbind so that it retrieves all binding > > strings (via fn-A), and then removes the string that matches fn-B > > (funcid), and then rebind the widget via the new list > > > > I think that should work. > > > > My main concern is that, if _tkinter does any reference counting on > > function uses, then there is a memory hole. > > > > Thoughts? > > As far as memory holes are concerned, I think cleanly unbinding each > single command, so deletecommand() will be executed, should do the trick. > > Although I agree that the behavior of unbind() is not intuitive, I > think that making unbind() backwards incompatible is not a good > idea ;) > > I set up a quick example, it is not perfect but seems to work ok for a > start; you see, instead of changing unbind(), I called the function that > does the work remove_binding() for now. > > Best regards > > Michael > > ########################################## > from Tkinter import * > > root = Tk() > l = Listbox(root) > l.pack() > > def cmd1(event): > print '1' > def cmd2(event): > print '2' > def cmd3(event): > print '3' > > b1 = l.bind('', cmd1) > b2 = l.bind('', cmd2, 1) > b3 = l.bind('', cmd3, 1) > > def bindings(widget, seq): > return [x for x in widget.bind(seq).splitlines() if x.strip()] > > def _funcid(binding): > return binding.split()[1][3:] > > def remove_binding(widget, seq, index=None, funcid=None): > b = bindings(widget, seq) > > if not index is None: > try: > binding = b[index] > widget.unbind(seq, _funcid(binding)) > b.remove(binding) > except IndexError: > print 'Binding #%d not defined.' % index > return > > elif funcid: > binding = None > for x in b: > if _funcid(x) == funcid: > binding = x > b.remove(binding) > widget.unbind(seq, funcid) > break > if not binding: > print 'Binding "%s" not defined.' % funcid > return > else: > raise ValueError, 'No index or function id defined.' > > for x in b: > widget.bind(seq, '+'+x, 1) > > def test1(event): > remove_binding(l, '', 0) > def test2(event): > remove_binding(l, '', None, b1) > > l.bind('<1>', test1) > l.bind('<3>', test2) > > root.mainloop() > ############################################### > > .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. > > Totally illogical, there was no chance. > -- Spock, "The Galileo Seven", stardate 2822.3 > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Fri May 11 20:30:03 2012 From: klappnase at web.de (Michael Lange) Date: Fri, 11 May 2012 20:30:03 +0200 Subject: [Tkinter-discuss] Unbinding Individual Events In-Reply-To: References: <20120511115930.60112427.klappnase@web.de> Message-ID: <20120511203003.7abd91a1.klappnase@web.de> Hi, Thus spoketh Lion Kimbro unto us on Fri, 11 May 2012 08:52:31 -0700: > Beautiful. > That's the solution. > > I've looked online for a long time, and nobody else came up with a > solution. > All that I found were the skeletal remains of those who needed to do > this, but couldn't find a way. > > I really appreciate that your code works external to tkinter, and > that it respects tkinter's quirks without changing it. > I also appreciate that it calls .deletecommand, and also unregisters > the function identifier with Misc's internal record keeping. > > May I include this in tkhelp? Of course, that is perfectly ok with me. I am glad if you have a use for it. Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. A Vulcan can no sooner be disloyal than he can exist without breathing. -- Kirk, "The Menagerie", stardate 3012.4 From michael.odonnell at uam.es Sat May 12 02:38:16 2012 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Sat, 12 May 2012 10:38:16 +1000 Subject: [Tkinter-discuss] Python 3.3.0a3 on Macs Message-ID: Dear all, Just tried the latest release of Python 3.3.0a3 (v3.3.0a3:0b53b70a40a0, May 1 2012, 11:10:44) on my MacOSX Lion. It seems use of tkinter NoteBook breaks: from tkinter import * import tkinter.ttk root = Tk() nb=tkinter.ttk.Notebook(root) nb.pack(expand=True, fill=BOTH) nb.add(Canvas(nb, bg="red"), text="Pane 1") nb.add(Canvas(nb, bg="blue"), text="Pane 2") root.mainloop() Traceback (most recent call last): File "/Users/micko/Google Drive/ALL_FILES/TO DO/CorpusTool30b1/NotebookTest.py", line 5, in nb=tkinter.ttk.Notebook(root) File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/tkinter/ttk.py", line 857, in __init__ Widget.__init__(self, master, "ttk::notebook", kw) File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/tkinter/ttk.py", line 559, in __init__ _load_tile(master) File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/tkinter/ttk.py", line 47, in _load_tile master.tk.eval('package require tile') # TclError may be raised here _tkinter.TclError: can't find package tile Now, I though Tile had been folded into Tkinter. Or do I need to download and install it separately still? (I thought it would be nice if all core Tkinter widgets worked 'out of the box', so i suspect this is a bug) Mick -- Not sent from my iPhone From nad at acm.org Sat May 12 07:18:57 2012 From: nad at acm.org (Ned Deily) Date: Fri, 11 May 2012 22:18:57 -0700 Subject: [Tkinter-discuss] Python 3.3.0a3 on Macs References: Message-ID: In article , "Michael O'Donnell" wrote: > Just tried the latest release of Python 3.3.0a3 > (v3.3.0a3:0b53b70a40a0, May 1 2012, 11:10:44) > on my MacOSX Lion. > > It seems use of tkinter NoteBook breaks: > > from tkinter import * > import tkinter.ttk > root = Tk() > nb=tkinter.ttk.Notebook(root) > nb.pack(expand=True, fill=BOTH) > nb.add(Canvas(nb, bg="red"), text="Pane 1") > nb.add(Canvas(nb, bg="blue"), text="Pane 2") > root.mainloop() > > Traceback (most recent call last): > File "/Users/micko/Google Drive/ALL_FILES/TO > DO/CorpusTool30b1/NotebookTest.py", line 5, in > nb=tkinter.ttk.Notebook(root) > File > "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/tkinter/ttk > .py", > line 857, in __init__ > Widget.__init__(self, master, "ttk::notebook", kw) > File > "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/tkinter/ttk > .py", > line 559, in __init__ > _load_tile(master) > File > "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/tkinter/ttk > .py", > line 47, in _load_tile > master.tk.eval('package require tile') # TclError may be raised here > _tkinter.TclError: can't find package tile > > Now, I though Tile had been folded into Tkinter. Or do I need to > download and install it separately still? Your example works for me on 10.7.4 with the same version of Python 3.3.0a3. Two comments: first, you appear to be using the 32-bit-only version of Python 3.3 from python.org. It's not recommended to use that version on OS X 10.7 unless you need compatibility with OS X 10.5 and earlier. Otherwise, it's better to use the 64-/32-bit installer variant. One reason is that the 32-bit version will usually be more problematic if you need to build and install third-party packages that have C extension modules, although at this alpha stage of 3.3.0 both variants will likely have problems due to the changes in the Xcode 4.3 command line tools. (These will be fixed in an upcoming alpha.) Another reason to use the 64-/32-bit variant is that it is built to use Tcl/Tk 8.5, whereas the 32-bit-only variant uses Tcl/Tk 8.4. Second, assuming the license is acceptable, try installing the latest ActiveTcl, 8.5 for the 64-/32-bit variant or 8.4 for the 32-bit-only variant. There are known problems with the Apple-supplied Tcl/Tk 8.5 in 10.7 (and huge problems with the one in 10.6) that are fixed in the most recent ActiveTcl version. The python.org Pythons will automatically use the ActiveTcl versions if they are installed. See here for more details: http://www.python.org/download/mac/tcltk/ -- Ned Deily, nad at acm.org From klappnase at web.de Sat May 12 11:06:09 2012 From: klappnase at web.de (Michael Lange) Date: Sat, 12 May 2012 11:06:09 +0200 Subject: [Tkinter-discuss] Python 3.3.0a3 on Macs In-Reply-To: References: Message-ID: <20120512110609.0a547865.klappnase@web.de> Hi, Thus spoketh "Michael O'Donnell" unto us on Sat, 12 May 2012 10:38:16 +1000: > Dear all, > > Just tried the latest release of Python 3.3.0a3 > (v3.3.0a3:0b53b70a40a0, May 1 2012, 11:10:44) > on my MacOSX Lion. > > It seems use of tkinter NoteBook breaks: > > from tkinter import * > import tkinter.ttk > root = Tk() > nb=tkinter.ttk.Notebook(root) > nb.pack(expand=True, fill=BOTH) > nb.add(Canvas(nb, bg="red"), text="Pane 1") > nb.add(Canvas(nb, bg="blue"), text="Pane 2") > root.mainloop() > > Traceback (most recent call last): > File "/Users/micko/Google Drive/ALL_FILES/TO > DO/CorpusTool30b1/NotebookTest.py", line 5, in > nb=tkinter.ttk.Notebook(root) > File > "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/tkinter/ttk.py", > line 857, in __init__ Widget.__init__(self, master, "ttk::notebook", kw) > File > "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/tkinter/ttk.py", > line 559, in __init__ _load_tile(master) > File > "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/tkinter/ttk.py", > line 47, in _load_tile master.tk.eval('package require tile') # > TclError may be raised here _tkinter.TclError: can't find package tile > > Now, I though Tile had been folded into Tkinter. Or do I need to > download and install it separately still? This looks like your Python install uses Tk-8.4 , if this is the case you will have to install tile additionally, it is included in Tk only since Tk-8.5 . Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. We have phasers, I vote we blast 'em! -- Bailey, "The Corbomite Maneuver", stardate 1514.2 From michael.odonnell at uam.es Sat May 12 13:40:31 2012 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Sat, 12 May 2012 21:40:31 +1000 Subject: [Tkinter-discuss] Python 3.3.0a3 on Macs In-Reply-To: <20120512110609.0a547865.klappnase@web.de> References: <20120512110609.0a547865.klappnase@web.de> Message-ID: Thanks Ned, Michael, Will try the ActiveState install (have to anyway, to get Numpy to work) Mick On Sat, May 12, 2012 at 7:06 PM, Michael Lange wrote: > Hi, > > Thus spoketh "Michael O'Donnell" > unto us on Sat, 12 May 2012 10:38:16 +1000: > >> Dear all, >> >> ? Just tried the latest release of ?Python 3.3.0a3 >> (v3.3.0a3:0b53b70a40a0, May ?1 2012, 11:10:44) >> on my MacOSX Lion. >> >> It seems use of ?tkinter NoteBook breaks: >> >> from tkinter import * >> import tkinter.ttk >> root = Tk() >> nb=tkinter.ttk.Notebook(root) >> nb.pack(expand=True, fill=BOTH) >> nb.add(Canvas(nb, bg="red"), text="Pane 1") >> nb.add(Canvas(nb, bg="blue"), text="Pane 2") >> root.mainloop() >> >> Traceback (most recent call last): >> ? File "/Users/micko/Google Drive/ALL_FILES/TO >> DO/CorpusTool30b1/NotebookTest.py", line 5, in >> ? ? nb=tkinter.ttk.Notebook(root) >> ? File >> "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/tkinter/ttk.py", >> line 857, in __init__ Widget.__init__(self, master, "ttk::notebook", kw) >> ? File >> "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/tkinter/ttk.py", >> line 559, in __init__ _load_tile(master) >> ? File >> "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/tkinter/ttk.py", >> line 47, in _load_tile master.tk.eval('package require tile') # >> TclError may be raised here _tkinter.TclError: can't find package tile >> >> Now, I though Tile had been folded into Tkinter. Or do I need to >> download and install it separately still? > > This looks like your Python install uses Tk-8.4 , if this is the case you > will have to install tile additionally, it is included in Tk only since > Tk-8.5 . > > Regards > > Michael > > > .-.. .. ...- . ? .-.. --- -. --. ? .- -. -.. ? .--. .-. --- ... .--. . .-. > > We have phasers, I vote we blast 'em! > ? ? ? ? ? ? ? ?-- Bailey, "The Corbomite Maneuver", stardate 1514.2 > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss -- Not sent from my iPhone From juha.k.salo at gmail.com Sat May 19 07:42:37 2012 From: juha.k.salo at gmail.com (Juha Salo) Date: Sat, 19 May 2012 08:42:37 +0300 Subject: [Tkinter-discuss] How to prevent a selection when double-clicking? Message-ID: Hi! Is there a way to get rid of the selection (blue area in the window) after double-clicking on a Text widget? I use Vista and Python 3.2.3. I have the following example: import tkinter as tk root = tk.Tk() def dbclick(e): print('db click') #Can I add some code here to automatically prevent the selection from appearing? txt = tk.Text() txt.insert('insert', 'fooo') txt['state'] = 'disabled' txt.bind('', dbclick) txt.pack() root.mainloop() -------------- next part -------------- An HTML attachment was scrubbed... URL: From bryan.oakley at gmail.com Sat May 19 14:42:52 2012 From: bryan.oakley at gmail.com (Bryan Oakley) Date: Sat, 19 May 2012 07:42:52 -0500 Subject: [Tkinter-discuss] How to prevent a selection when double-clicking? In-Reply-To: References: Message-ID: On Sat, May 19, 2012 at 12:42 AM, Juha Salo wrote: > Hi! > > Is there a way to get rid of the selection (blue area in the window) after > double-clicking on a Text widget? I use Vista and Python 3.2.3. I have the > following example: > > The selection happens on a single click; are you wanting to keep it on a single-click, but remove it on a double click? -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Sun May 20 12:31:42 2012 From: klappnase at web.de (Michael Lange) Date: Sun, 20 May 2012 12:31:42 +0200 Subject: [Tkinter-discuss] How to prevent a selection when double-clicking? In-Reply-To: References: Message-ID: <20120520123142.f3c27ed8.klappnase@web.de> Hi, Thus spoketh Bryan Oakley unto us on Sat, 19 May 2012 07:42:52 -0500: > On Sat, May 19, 2012 at 12:42 AM, Juha Salo > wrote: > > > Hi! > > > > Is there a way to get rid of the selection (blue area in the window) > > after double-clicking on a Text widget? I use Vista and Python 3.2.3. > > I have the following example: > > > > > The selection happens on a single click; are you wanting to keep it on a > single-click, but remove it on a double click? I do not have Vista at hand here, so I cannot tell if it is a single or a double click that causes the selection [1], here on linux it is a double-click that causes the rest of the line, after the "fooo" to be selected if you click "somewhere" in the text or the "fooo" if you click into it. You can get rid of this by either adding a return "break" statement to the dbclick() callback or by adding root.unbind_class('Text', '') to your code *before* the text widget is created (of course this will do the same for all Text widgets in you app though), doing a simple txt.unbind('') does not seem to work, apparently because is it called *after* widget creation. [1] If you want to check the default widget bindings, have a look at text.tcl where these are defined, here the relevant code for single- and double click looks like: bind Text <1> { tk::TextButton1 %W %x %y %W tag remove sel 0.0 end } (...) bind Text { set tk::Priv(selectMode) word tk::TextSelectTo %W %x %y catch {%W mark set insert sel.first} } Looking there is often a better way dealing with default bindings than trying to understand them by clicking into the widget on a trial-and-error base, because considerable confusion may arise by interfering other bindings, for example there is also a binding on text widgets which might fire if you repeatedly double-click into the widget. I hope this helps Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Not one hundred percent efficient, of course ... but nothing ever is. -- Kirk, "Metamorphosis", stardate 3219.8 From michael.odonnell at uam.es Wed May 23 11:11:32 2012 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Wed, 23 May 2012 19:11:32 +1000 Subject: [Tkinter-discuss] Tkinter Windows don't appear under MacOSX Lion Message-ID: Dear all, I use py2app to package my python 2.7.2 program into a distributable. My previously working application seems not to work under MacOSX Lion, windows (the root window, and Toplevel windows) until I use apple-tab to cycle in and then back to the application. I have seen numerous other complaints of this. , e.g., http://stackoverflow.com/questions/9083687/python-tkinter-gui-always-loads-minimized http://stackoverflow.com/questions/8691655/python-put-window-on-top-tkinter-pyobjc http://www.velocityreviews.com/forums/t593134-tkinter-osx-and-lift.html However, these address the main window not appearing on duble clicking the application. What concerns me more is that it seems to apply also to Toplevel windows created within an application. I really don't want to search through the 1000s of lines of my code to find all places where some sort of toplevel (or subclass thereof) is created, insert some hack code which forces the window to appear, given this is a problem that only affects my program on Macs, and then only in Lion. Rather, I would rather understand what is going on, and whether there is perhaps a general fix. Firstly, I note that this only affects me on Mac, and only on Lion. Also, it does not affect my code when run under idle, or when I run my script directly using python. It only happens with a py2app application. For instance, I use the following code in a file called 'test.py': from Tkinter import * tk = Tk() fr=Frame(tk, height=400, width=400) fr.pack() #tk.grab_set() def openWin(): t=Toplevel(tk) Button(t, text="Close", command=lambda w=t: w.destroy()).pack() for i in range(4): for j in range(4): Button(fr, text="Open", command=openWin).grid(row=i, column=j) tk.iconify() tk.update() tk.deiconify() tk.lift() tk.mainloop() Then I use py2app to make an application, e.g., from setuptools import setup import sys sys.argv=[sys.argv[0]] sys.argv.append("py2app") setup( app=['test.py'], data_files=[], options={'py2app': {'argv_emulation': True, 'resources': []}}, setup_requires=['py2app'], ) This makes an application, test.app, which, when double clicked, brings up the application menubar, but no window. If I apple-tab and then apple-tab again (to return to this app), the window appears. Clicking on buttons does NOT open the Toplevel window which should appear (but the window will apear if I cycle in and out of the app). Also if I click multiple buttons, each of the toplevel windows is listed in the list of windows associated with the app (visible by clicking on the app's icon in the doc). Now, after much experimentation, I find if I put a grab_set() in the code (uncommenting line 3 in the test.py), then at least the toplevels appear as expected. Does anyone have any idea why this is so? Why is this line only needed on Lion? Does this happen the same on your macs? I would like to know, as my code may change the grab_set somewhere in the code and stop things working (hard to tell in the spagetti of my program). (using ActivePython 2.7.2.5 (ActiveState Software Inc.) based on Python 2.7.2 (default, Jun 24 2011, 12:20:15) Tk 8.5 Mick -- Not sent from my iPhone -------------- next part -------------- An HTML attachment was scrubbed... URL: From kw at codebykevin.com Wed May 23 13:00:51 2012 From: kw at codebykevin.com (Kevin Walzer) Date: Wed, 23 May 2012 07:00:51 -0400 Subject: [Tkinter-discuss] Tkinter Windows don't appear under MacOSX Lion In-Reply-To: References: Message-ID: <4FBCC363.4090300@codebykevin.com> On 5/23/12 5:11 AM, Michael O'Donnell wrote: > This makes an application, test.app, which, when double clicked, > brings up the application menubar, but no window. If I apple-tab > and then apple-tab again (to return to this app), the window appears. I was able to reproduce the issue on my Lion system (running Python 2.7.3, linked to system Tk 8.5.9). Since I saw no issues with your code, and I don't see these issues in my own, similarly-built Tkinter apps (wrapped with py2app), I looked to see where our setups differed. The only thing I noticed was that you set argv_emulation to true in your setup.py file. Turning off argv_emulation seems to rectify the issue, at least on my system. The wrapped app launches and the toplevel window displays as expected. If you require argv_emulation for some reason, then you may want to file a py2app bug on the MacPython mailing list. Otherwise, can you get by without it? What purpose is it serving in your own apps? -- Kevin Walzer Code by Kevin http://www.codebykevin.com From michael.odonnell at uam.es Wed May 23 14:08:34 2012 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Wed, 23 May 2012 22:08:34 +1000 Subject: [Tkinter-discuss] Tkinter Windows don't appear under MacOSX Lion In-Reply-To: <4FBCC363.4090300@codebykevin.com> References: <4FBCC363.4090300@codebykevin.com> Message-ID: Thank you! The argv_emulation True flag was necessary to get by an earlier bug in py2app, which has (I believe) since been fixed. So i can set this flag to False, and continue (I hope). Thanks again, Mick On Wed, May 23, 2012 at 9:00 PM, Kevin Walzer wrote: > On 5/23/12 5:11 AM, Michael O'Donnell wrote: > >> This makes an application, test.app, which, when double clicked, >> brings up the application menubar, but no window. If I apple-tab >> and then apple-tab again (to return to this app), the window appears. >> > > I was able to reproduce the issue on my Lion system (running Python 2.7.3, > linked to system Tk 8.5.9). > > Since I saw no issues with your code, and I don't see these issues in my > own, similarly-built Tkinter apps (wrapped with py2app), I looked to see > where our setups differed. The only thing I noticed was that you set > argv_emulation to true in your setup.py file. > > Turning off argv_emulation seems to rectify the issue, at least on my > system. The wrapped app launches and the toplevel window displays as > expected. > > If you require argv_emulation for some reason, then you may want to file a > py2app bug on the MacPython mailing list. Otherwise, can you get by without > it? What purpose is it serving in your own apps? > > > -- > Kevin Walzer > Code by Kevin > http://www.codebykevin.com > ______________________________**_________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/**mailman/listinfo/tkinter-**discuss > -- Not sent from my iPhone -------------- next part -------------- An HTML attachment was scrubbed... URL: From dbeck at ualberta.ca Wed May 30 15:07:51 2012 From: dbeck at ualberta.ca (David Beck) Date: Wed, 30 May 2012 07:07:51 -0600 Subject: [Tkinter-discuss] ttk.Scrollbar in Notebook widget freezes Message-ID: <35000138-3BE0-4D3B-A5DC-7F67A4F6D7AC@ualberta.ca> Hello, I am working on an iMac running OS 10.7, TK 8.5.11. I built a simple app containing a Notebook widget, and with Listboxes and linked tkk.Scrollbars on each of three tabs. All of the Scrollbars work the first time I manipulate them, but once the Scrollbar on third tab (the last one created by the script) is manipulated, the others become unresponsive to mouse clicks (though the Scrollbars continue to move when the Listboxes are scrolled using the mouse/trackpad. I first found this issue working with Python 3.2.3 (using IDLE), but the same thing happens with Python 3.3. The problem was recreated by someone on the Python Bug Report list using the same system configuration. I asked someone to try this on a PC (Windows 7, Python 3.2.3, Tkinter 8.5), but the problem wasn't recreated. David Beck -------------- next part -------------- A non-text attachment was scrubbed... Name: Notebook.py Type: text/x-python-script Size: 2904 bytes Desc: not available URL: From matteo at matteolandi.net Thu May 31 00:22:41 2012 From: matteo at matteolandi.net (Matteo Landi) Date: Thu, 31 May 2012 00:22:41 +0200 Subject: [Tkinter-discuss] Deadlock on graceful exit Message-ID: <20120530222241.GB12763@MARble> Hi list, recently I started to work on an application [1] which makes use of the Tkinter module to handle interaction with the user. Simply put, the app is a text widget displaying a file filtered by given criteria, with a handy feature that the window is raised each time a new line is added to the widget. The application mainly consists of three threads: the first one, the file processor, reads the file, filters the lines of interest, and pushes them into a shared queue (henceforth `lines_queue`); the second one, the gui_updater, pops elements from `lines_queue`, and schedule GUI updates using the `after_idle` method of the Tkinter module; finally the last one, the worker spawner, receives commands by the gui (by means of a shared queue, `filters_queue`), and drives the application, terminating or spawning new threads. For example, let's see what happens when you start the application, fill the filter entry and press Enter button: 1 the associated even handler is scheduled (we should be inside the Tkinter mainloop thread), and the filter is pushed into `filters_queue`; 2 the worker spawner receives the new filter, terminate a possibly running working thread, and once done, create a new file processor; 3 the file processor actually processes the file and fills the `lines_queue` with the lines matching given filter; 4 the gui updater schedules GUI updates as soon as items are pushed into `lines_queue` 5 Tkinter mainloop thread updates the gui when idle What happens when the main window is closed? Here is how I implemented the graceful shutdown of the app: 1 a quit event is scheduled and a _special_ message is pushed into both `filter_queue` and `lines_queue` 2 the gui updater threads receives the _special_ message, and terminates 3 the worker spawner receives the message, terminates the working thread and interrupts her execution. 4 Tk.quit() is called after the quit event handler, and we finally quit the mainloop Honestly speaking, I see no issues with the algorithm presented above; however, if I close the window in the middle of updates of the text widget, the applications hangs indefinitely. On the other hand, everything works as expected if I close the app when the file processor, for example, is waiting for new content to filter. I put some logging messages to analyze the deadlock (?!), and noticed that both the worker spawner and the file processor are terminated correctly. The only thread still active for some strange reasons, is the gui updater. Do you see anything wrong with the description presented above? Please say so, because I can't figure it out! Regards, Matteo -- http://www.matteolandi.net From matteo at matteolandi.net Thu May 31 00:23:52 2012 From: matteo at matteolandi.net (Matteo Landi) Date: Thu, 31 May 2012 00:23:52 +0200 Subject: [Tkinter-discuss] Deadlock on graceful exit In-Reply-To: <20120530222241.GB12763@MARble> References: <20120530222241.GB12763@MARble> Message-ID: On Thu, May 31, 2012 at 12:22 AM, Matteo Landi wrote: > Hi list, > recently I started to work on an application [1] which makes use of the Tkinter > module to handle interaction with the user. ?Simply put, the app is a text > widget displaying a file filtered by given criteria, with a handy feature that > the window is raised each time a new line is added to the widget. > > The application mainly consists of three threads: ?the first one, the file > processor, reads the file, filters the lines of interest, and pushes them into > a shared queue (henceforth `lines_queue`); ?the second one, the gui_updater, > pops elements from `lines_queue`, and schedule GUI updates using the > `after_idle` method of the Tkinter module; ?finally the last one, the worker > spawner, receives commands by the gui (by means of a shared queue, > `filters_queue`), and drives the application, terminating or spawning new > threads. > > For example, let's see what happens when you start the application, fill the > filter entry and press Enter button: > 1 the associated even handler is scheduled (we should be inside the Tkinter > ?mainloop thread), and the filter is pushed into `filters_queue`; > 2 the worker spawner receives the new filter, terminate a possibly running > ?working thread, and once done, create a new file processor; > 3 the file processor actually processes the file and fills the `lines_queue` > ?with the lines matching given filter; > 4 the gui updater schedules GUI updates as soon as items are pushed into > ?`lines_queue` > 5 Tkinter mainloop thread updates the gui when idle > > What happens when the main window is closed? ?Here is how I implemented the > graceful shutdown of the app: > 1 a quit event is scheduled and a _special_ message is pushed into both > ?`filter_queue` and `lines_queue` > 2 the gui updater threads receives the _special_ message, and terminates > 3 the worker spawner receives the message, terminates the working thread and > ?interrupts her execution. > 4 Tk.quit() is called after the quit event handler, and we finally quit the > ?mainloop > > Honestly speaking, I see no issues with the algorithm presented above; ?however, > if I close the window in the middle of updates of the text widget, the > applications hangs indefinitely. ?On the other hand, everything works as > expected if I close the app when the file processor, for example, is waiting for > new content to filter. > > I put some logging messages to analyze the deadlock (?!), and noticed that both > the worker spawner and the file processor are terminated correctly. ?The only > thread still active for some strange reasons, is the gui updater. > > Do you see anything wrong with the description presented above? ?Please say so, > because I can't figure it out! > > > Regards, > Matteo > > -- > http://www.matteolandi.net I forgot the link to the application: https://bitbucket.org/iamFIREcracker/logfilter Matteo -- http://www.matteolandi.net/ From wayne at waynewerner.com Thu May 31 12:56:49 2012 From: wayne at waynewerner.com (Wayne Werner) Date: Thu, 31 May 2012 05:56:49 -0500 (CDT) Subject: [Tkinter-discuss] Deadlock on graceful exit In-Reply-To: <20120530222241.GB12763@MARble> References: <20120530222241.GB12763@MARble> Message-ID: On Thu, 31 May 2012, Matteo Landi wrote: > Do you see anything wrong with the description presented above? Please say so, > because I can't figure it out! Yes, though I have not looked at your code, if you're doing what you said and using threads in a Tkinter app. This will almost always lead to horrible, nasty bugs. Instead, use the .after() method in Tkinter, and let your app worry about timing/threading. HTH, Wayne From matteo at matteolandi.net Thu May 31 14:42:14 2012 From: matteo at matteolandi.net (Matteo Landi) Date: Thu, 31 May 2012 14:42:14 +0200 Subject: [Tkinter-discuss] Deadlock on graceful exit In-Reply-To: References: <20120530222241.GB12763@MARble> Message-ID: On Thu, May 31, 2012 at 12:56 PM, Wayne Werner wrote: > > > On Thu, 31 May 2012, Matteo Landi wrote: > >> Do you see anything wrong with the description presented above? ?Please >> say so, >> because I can't figure it out! > > > Yes, though I have not looked at your code, if you're doing what you said > and > using threads in a Tkinter app. This will almost always lead to horrible, > nasty > bugs. Instead, use the .after() method in Tkinter, and let your app worry > about > timing/threading. Hi Wayne, I'm currently using `after_idle` to schedule gui updates: is there anything wrong in using it instead of `after`? Cheers, Matteo -- http://www.matteolandi.net/ From klappnase at web.de Thu May 31 18:03:31 2012 From: klappnase at web.de (Michael Lange) Date: Thu, 31 May 2012 18:03:31 +0200 Subject: [Tkinter-discuss] Deadlock on graceful exit In-Reply-To: References: <20120530222241.GB12763@MARble> Message-ID: <20120531180331.53f1bc85.klappnase@web.de> Hi, Thus spoketh Wayne Werner unto us on Thu, 31 May 2012 05:56:49 -0500 (CDT): > Yes, though I have not looked at your code, if you're doing what you > said and using threads in a Tkinter app. This will almost always lead > to horrible, nasty bugs. Instead, use the .after() method in Tkinter, > and let your app worry about timing/threading. This is actually not true, as long as you take care that Tk always runs in the main program thread and that you must *never* do any calls to Tkinter from within any of the child threads; for interaction between Tkinter and the child threads you can for example use Lock or Condition objects to safely update some variable value from the child thread and an after() loop to query the variable value on the Tk side. However it was my first thought, too, that the problem might be caused by improper separation of the gui from the child thread(s). And now when I look at the code, I see that the child thread starts gui_updater_body() which then calls gui.schedule() which calls Tk.after_idle(). This, as I said above, is one of the things you must avoid in any case, because it will lead to more or less unpredictable behavior. Below I wrote a primitive example of how interaction between Tk and a child thread can be set up safely: ###################################################### from Tkinter import * from threading import Thread, Lock from time import sleep from signal import signal root = Tk() s = IntVar() s.set(0) Label(root, textvariable=s).pack(pady=30, padx=70) x = 0 run = True lock = Lock() def quit(*args): global run # make sure the child stops before we quit run = False root.quit() root.protocol('WM_DELETE_WINDOW', quit) # make sure keyboard interrupt is handled properly signal(2, quit) def poll(): lock.acquire() s.set(x) print 'current value ->', x lock.release() root.after(500, poll) poll() def incr(): global x while run: lock.acquire() x += 1 lock.release() sleep(1) print 'child thread done' t = Thread(target=incr) t.start() root.mainloop() ###################################################### Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Violence in reality is quite different from theory. -- Spock, "The Cloud Minders", stardate 5818.4