From python at bdurham.com Wed Nov 3 17:28:04 2010 From: python at bdurham.com (python at bdurham.com) Date: Wed, 03 Nov 2010 12:28:04 -0400 Subject: [Tkinter-discuss] Tkinter/ttk compatibility with Citrix/WTS (Windows Terminal Services)? Message-ID: <1288801684.27647.1403415697@webmail.messagingengine.com> Anyone have any experience using Python Tkinter/ttk applications with Citrix or WTS (Windows Terminal Services)? Any concerns, gotchas, or workarounds we should be aware of? I googled this topic [1], [2] and came up with nothing. No news is good news ... but just checking to make sure. Thanks, Malcolm [1] tkinter (citrix | ts|terminal services) [2] tcl (citrix | ts|terminal services) -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at bdurham.com Wed Nov 3 19:55:52 2010 From: python at bdurham.com (python at bdurham.com) Date: Wed, 03 Nov 2010 14:55:52 -0400 Subject: [Tkinter-discuss] Possible to stack frames with frame transparency? (create widget w/gradient background) Message-ID: <1288810552.4463.1403440447@webmail.messagingengine.com> New to Tkinter: Is it possible to stack frames on top of one another and if so, can frames have transparency? My goal is to create widgets with gradient backgrounds. I was hoping I could do this by placing an image in a frame and then placing an identical sized frame over this image frame. This on-top frame would contain all my child widgets. Details: Is it possible to place a frame on top of an image background? From my reading, the only way to do this appears to be to use a Canvas as my container (vs. a Frame). The downside to using a canvas appears to be that Labels do not have transparent backgrounds so any text I place in such a (canvas based) container must be placed with Canvas.create_text() vs. laid out via one of the pack/grid/place layout managers. Am I understanding this right? Thank you, Malcolm -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael.odonnell at uam.es Wed Nov 3 21:25:42 2010 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Wed, 3 Nov 2010 21:25:42 +0100 Subject: [Tkinter-discuss] Possible to stack frames with frame transparency? (create widget w/gradient background) In-Reply-To: <1288810552.4463.1403440447@webmail.messagingengine.com> References: <1288810552.4463.1403440447@webmail.messagingengine.com> Message-ID: Malcom, > New to Tkinter: Is it possible to stack frames on top of one another and if > so, can frames have transparency? Unless things have changed in recent releases of Tcl/Tk, what you are tring to do is not possible. Frames cannot be transparent. Frames cannot usually be stacked on top of each other. As you suggest, this might be done via placing them in a canvas, using the create_window method. But each frame on top of another totally obscures those below. To see what can be done, look at my tkinter-based interface, at: http://www.wagsoft.com/CorpusTool/img/main.jpg The button "Search" is a canvas totally filled with 3 images left, centre and right parts of the button. On top of that I then use create-text to write "Search". I then write it 2 pixels above/left in a different color to create an embossed look. Mick > My goal is to create widgets with gradient backgrounds. I was hoping I could > do this by placing an image in a frame and then placing an identical sized > frame over this image frame. This on-top frame would contain all my child > widgets. > > Details: Is it possible to place a frame on top of an image background? From > my reading, the only way to do this appears to be to use a Canvas as my > container (vs. a Frame). The downside to using a canvas appears to be that > Labels do not have transparent backgrounds so any text I place in such a > (canvas based) container must be placed with Canvas.create_text() vs. laid > out via one of the pack/grid/place layout managers. Am I understanding this > right? > > Thank you, > Malcolm > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > From igor.e.novikov at gmail.com Wed Nov 3 22:50:23 2010 From: igor.e.novikov at gmail.com (Igor Novikov) Date: Wed, 3 Nov 2010 23:50:23 +0200 Subject: [Tkinter-discuss] Possible to stack frames with frame transparency? (create widget w/gradient background) In-Reply-To: <1288810552.4463.1403440447@webmail.messagingengine.com> References: <1288810552.4463.1403440447@webmail.messagingengine.com> Message-ID: On Wed, Nov 3, 2010 at 8:55 PM, wrote: > New to Tkinter: Is it possible to stack frames on top of one another and if > so, can frames have transparency? > > My goal is to create widgets with gradient backgrounds. I was hoping I > could do this by placing an image in a frame and then placing an identical > sized frame over this image frame. This on-top frame would contain all my > child widgets. > > Details: Is it possible to place a frame on top of an image background? > From my reading, the only way to do this appears to be to use a Canvas as my > container (vs. a Frame). The downside to using a canvas appears to be that > Labels do not have transparent backgrounds so any text I place in such a > (canvas based) container must be placed with Canvas.create_text() vs. laid > out via one of the pack/grid/place layout managers. Am I understanding this > right? > > Thank you, > Malcolm > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > I think this could be helpful for you: http://saveimg.ru/pictures/04-11-10/12d35ff67732239776ca2dfe7a483d30.png This is tkCairo extension in work. You can find the code in our repository: http://sk1.svn.sourceforge.net/viewvc/sk1/trunk/subprojects/tkCairo/ tkCairo is modified pycairo project for tk widgetset. So you can use pycairo docs as a cairo command reference. Please note we have implemented Linux support only. But this extension can be easy adopted for win32. Concerning tk Frame stacking you can try using place() manager. All tk widgets are native windows without WM decorations. So you can apply all toplevel methods to widgets if they managed by place() manager. -- Regards, Igor Novikov sK1 Project http://sk1project.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From igor.e.novikov at gmail.com Wed Nov 3 22:51:08 2010 From: igor.e.novikov at gmail.com (Igor Novikov) Date: Wed, 3 Nov 2010 23:51:08 +0200 Subject: [Tkinter-discuss] Possible to stack frames with frame transparency? (create widget w/gradient background) In-Reply-To: References: <1288810552.4463.1403440447@webmail.messagingengine.com> Message-ID: On Wed, Nov 3, 2010 at 11:50 PM, Igor Novikov wrote: > > > On Wed, Nov 3, 2010 at 8:55 PM, wrote: > >> New to Tkinter: Is it possible to stack frames on top of one another and >> if so, can frames have transparency? >> >> My goal is to create widgets with gradient backgrounds. I was hoping I >> could do this by placing an image in a frame and then placing an identical >> sized frame over this image frame. This on-top frame would contain all my >> child widgets. >> >> Details: Is it possible to place a frame on top of an image background? >> From my reading, the only way to do this appears to be to use a Canvas as my >> container (vs. a Frame). The downside to using a canvas appears to be that >> Labels do not have transparent backgrounds so any text I place in such a >> (canvas based) container must be placed with Canvas.create_text() vs. laid >> out via one of the pack/grid/place layout managers. Am I understanding this >> right? >> >> Thank you, >> Malcolm >> >> _______________________________________________ >> Tkinter-discuss mailing list >> Tkinter-discuss at python.org >> http://mail.python.org/mailman/listinfo/tkinter-discuss >> >> > > I think this could be helpful for you: > > http://saveimg.ru/pictures/04-11-10/12d35ff67732239776ca2dfe7a483d30.png > > This is tkCairo extension in work. You can find the code in our repository: > > http://sk1.svn.sourceforge.net/viewvc/sk1/trunk/subprojects/tkCairo/ > > tkCairo is modified pycairo project for tk widgetset. So you can use > pycairo docs > as a cairo command reference. Please note we have implemented Linux support > only. > But this extension can be easy adopted for win32. > > Concerning tk Frame stacking you can try using place() manager. All tk > widgets are > native windows without WM decorations. So you can apply all toplevel > methods > to widgets if they managed by place() manager. > > -- > Regards, > > Igor Novikov > sK1 Project > http://sk1project.org > > > Small addition: tkCairo allows drawing on regular tk Frame widget and you can pack in this Frame any other child widget (on screenshot tk Button is packed into such frame). -- Regards, Igor Novikov sK1 Project http://sk1project.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at bdurham.com Thu Nov 4 17:31:31 2010 From: python at bdurham.com (python at bdurham.com) Date: Thu, 04 Nov 2010 12:31:31 -0400 Subject: [Tkinter-discuss] Possible to stack frames with frame transparency? (create widget w/gradient background) In-Reply-To: References: <1288810552.4463.1403440447@webmail.messagingengine.com> Message-ID: <1288888291.12515.1403611111@webmail.messagingengine.com> Michael, > To see what can be done, look at my tkinter-based interface, > at: http://www.wagsoft.com/CorpusTool/img/main.jpg Nice! So each of your top buttons (Project, Search, Autocode, etc) is actually a custom widget based on a canvas containing 3 images (manually placed via .create_image) and then manually labeled with text via .create_text)? And your canvas backgroundcolors are set to the backgroundcolor of their parent frame? If I understand your technique, you place everything manually vs. using a layout manager like pack/grid? I noticed your buttons are not all the same width - do you have custom width centre images or is there a way to horizontally stretch an image? (I've looked for this capability without success). Thanks for sharing your technique and screenshot. The screenshot really helped me understand what you're saying. Cheers, Malcolm From michael.odonnell at uam.es Thu Nov 4 21:35:16 2010 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Thu, 4 Nov 2010 21:35:16 +0100 Subject: [Tkinter-discuss] Possible to stack frames with frame transparency? (create widget w/gradient background) In-Reply-To: <1288888291.12515.1403611111@webmail.messagingengine.com> References: <1288810552.4463.1403440447@webmail.messagingengine.com> <1288888291.12515.1403611111@webmail.messagingengine.com> Message-ID: Hi Malcom, Full code for these buttons available from: http://www.wagsoft.com/CTButtonCode.zip Run demo.py to see 3 buttons. Buttons change appearance on mouse over and when pressed. Provide your own image parts to make your own buttons. Unfortunately the buttons are tied in with other code for theming my application, also attached. Mick On Thu, Nov 4, 2010 at 5:31 PM, wrote: > Michael, > >> To see what can be done, look at my tkinter-based interface, >> at: http://www.wagsoft.com/CorpusTool/img/main.jpg > > Nice! So each of your top buttons (Project, Search, Autocode, etc) is > actually a custom widget based on a canvas containing 3 images (manually > placed via .create_image) and then manually labeled with text via > .create_text)? And your canvas backgroundcolors are set to the > backgroundcolor of their parent frame? If I understand your technique, > you place everything manually vs. using a layout manager like pack/grid? > > I noticed your buttons are not all the same width - do you have custom > width centre images or is there a way to horizontally stretch an image? > (I've looked for this capability without success). > > Thanks for sharing your technique and screenshot. The screenshot really > helped me understand what you're saying. > > Cheers, > Malcolm > From python at bdurham.com Sat Nov 6 00:10:59 2010 From: python at bdurham.com (python at bdurham.com) Date: Fri, 05 Nov 2010 19:10:59 -0400 Subject: [Tkinter-discuss] Possible to stack frames with frame transparency? (create widget w/gradient background) In-Reply-To: References: <1288810552.4463.1403440447@webmail.messagingengine.com><1288888291.12515.1403611111@webmail.messagingengine.com> Message-ID: <1288998659.2782.1403850497@webmail.messagingengine.com> Hi Michael, > Full code for these buttons available from: > http://www.wagsoft.com/CTButtonCode.zip Thank you very much - I learned a lot from studying your code. Regards, Malcolm From python at bdurham.com Sat Nov 6 00:16:05 2010 From: python at bdurham.com (python at bdurham.com) Date: Fri, 05 Nov 2010 19:16:05 -0400 Subject: [Tkinter-discuss] Undo/redo in Entry widget or use a Text widget instead? Message-ID: <1288998965.3677.1403850799@webmail.messagingengine.com> Is there a way to implement undo/redo in an Entry widget or should we use 1 line Text widgets in place of an Entry widget when we want a textbox like control with undo/redo? Thank you, Malcolm -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at bdurham.com Sun Nov 7 23:05:26 2010 From: python at bdurham.com (python at bdurham.com) Date: Sun, 07 Nov 2010 17:05:26 -0500 Subject: [Tkinter-discuss] Possible to stretch an image via Label() or create_image() without PIL? Message-ID: <1289167526.20726.1404065105@webmail.messagingengine.com> Is it possible to stretch a Tkinter image horizontally or vertically when the image is used in a Label() or painted via create_image() without having to dynamically create stretched images via PIL? Thank you, Malcolm -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at bdurham.com Mon Nov 8 22:45:06 2010 From: python at bdurham.com (python at bdurham.com) Date: Mon, 08 Nov 2010 16:45:06 -0500 Subject: [Tkinter-discuss] Possible to stretch an image via Label() or create_image() without PIL? In-Reply-To: References: <1289167526.20726.1404065105@webmail.messagingengine.com> Message-ID: <1289252706.28321.1404258193@webmail.messagingengine.com> Lion, > PhotoImage has .zoom & .subsample; > You'd still be dynamically creating stretched images, but you wouldn't need PIL. > [1]http://www.pythonware.com/library/tkinter/introduction/x6606-m ethods.htm > Would that work for you? Thank you - that's exactly the solution I was looking for. Regards, Malcolm References 1. http://www.pythonware.com/library/tkinter/introduction/x6606-methods.htm -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Tue Nov 9 12:31:57 2010 From: klappnase at web.de (Michael Lange) Date: Tue, 9 Nov 2010 12:31:57 +0100 Subject: [Tkinter-discuss] winico icon coordinates Message-ID: <20101109123157.b66adcde.klappnase@web.de> Hi all, I am trying to write a cross-platform tray icon wrapper for Tkinter that uses tktray on X and winico on windows. It is working fine so far, however at one point I am stuck with winico. I would like to be able to pop up a "notification balloon" (or however you want to call this) next to the tray icon, which works fine on tktray (which has a bbox method that allows to access the icon's screen coordinates) but I cannot seem to be able to do the same with winico. Does anyone have experience with winico, is this possible at all (maybe I missed something), or maybe is this possible somehow through pywin32 ? Thanks in advance Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. In the strict scientific sense we all feed on death -- even vegetarians. -- Spock, "Wolf in the Fold", stardate 3615.4 From python at bdurham.com Wed Nov 10 14:44:03 2010 From: python at bdurham.com (python at bdurham.com) Date: Wed, 10 Nov 2010 08:44:03 -0500 Subject: [Tkinter-discuss] Possible to create separator lines in a Tkinter Listbox? Message-ID: <1289396643.23538.1404577087@webmail.messagingengine.com> How can I create non-selectable horizontal separator items in a Listbox, eg. separators equivalent to the Tkinter Menu widget's .add_separator()? Using chars like dashes and underscores looks awful. If this functionality is not possible, does anyone have a recommendation on a Unicode char similar to an underscore, but vertically centered, that I might use as a char based separator? Thank you, Malcolm -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at bdurham.com Wed Nov 10 14:48:44 2010 From: python at bdurham.com (python at bdurham.com) Date: Wed, 10 Nov 2010 08:48:44 -0500 Subject: [Tkinter-discuss] Possible to disable individual items in a Tkinter Listbox? Message-ID: <1289396924.24627.1404578103@webmail.messagingengine.com> Is here a way to disable individual items in a Tkinter Listbox? I'm looking for something like .itemconfig( index, state='disabled' ) (doesn't work) or a special character string that one might add to an item's text to cause it to be disabled. Thank you, Malcolm -------------- next part -------------- An HTML attachment was scrubbed... URL: From Cameron at phaseit.net Wed Nov 10 23:29:25 2010 From: Cameron at phaseit.net (Cameron Laird) Date: Wed, 10 Nov 2010 22:29:25 +0000 Subject: [Tkinter-discuss] Possible to disable individual items in a Tkinter Listbox? In-Reply-To: <1289396924.24627.1404578103@webmail.messagingengine.com> References: <1289396924.24627.1404578103@webmail.messagingengine.com> Message-ID: <20101110222925.GA13998@lairds.us> On Wed, Nov 10, 2010 at 08:48:44AM -0500, python at bdurham.com wrote: . . . > Is here a way to disable individual items in a Tkinter Listbox? > > I'm looking for something like .itemconfig( index, > state='disabled' ) (doesn't work) or a special character string > that one might add to an item's text to cause it to be disabled. . . . Unless recent versions have a configuration for this I haven't yet learned, the functionality you're after requires a custom binding. From waynejwerner at gmail.com Thu Nov 11 00:24:10 2010 From: waynejwerner at gmail.com (Wayne Werner) Date: Wed, 10 Nov 2010 17:24:10 -0600 Subject: [Tkinter-discuss] Possible to create separator lines in a Tkinter Listbox? In-Reply-To: <1289396643.23538.1404577087@webmail.messagingengine.com> References: <1289396643.23538.1404577087@webmail.messagingengine.com> Message-ID: On Wed, Nov 10, 2010 at 7:44 AM, wrote: > How can I create non-selectable horizontal separator items in a Listbox, > eg. separators equivalent to the Tkinter Menu widget's .add_separator()? > Using chars like dashes and underscores looks awful. > > If this functionality is not possible, does anyone have a recommendation on > a Unicode char similar to an underscore, but vertically centered, that I > might use as a char based separator? > unichr(8213) looks pretty good. I'm not sure if your original desire is possible, but you could make it non-selectable by binding <> . You'd do something like this: 1. Is current selection one of the separators? 2. If not, OK 3. If so, change selection to the previous item HTH, Wayne -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Thu Nov 11 11:26:19 2010 From: klappnase at web.de (Michael Lange) Date: Thu, 11 Nov 2010 11:26:19 +0100 Subject: [Tkinter-discuss] Possible to create separator lines in a Tkinter Listbox? In-Reply-To: <1289396643.23538.1404577087@webmail.messagingengine.com> References: <1289396643.23538.1404577087@webmail.messagingengine.com> Message-ID: <20101111112619.6faf904f.klappnase@web.de> Hi, Thus spoketh python at bdurham.com unto us on Wed, 10 Nov 2010 08:44:03 -0500: > How can I create non-selectable horizontal separator items in a > Listbox, eg. separators equivalent to the Tkinter Menu widget's > .add_separator()? Using chars like dashes and underscores looks > awful. > > If this functionality is not possible, does anyone have a > recommendation on a Unicode char similar to an underscore, but > vertically centered, that I might use as a char based separator? > and on Wed, 10 Nov 2010 08:48:44 -0500: > Is here a way to disable individual items in a Tkinter Listbox? > > I'm looking for something like .itemconfig( index, > state='disabled' ) (doesn't work) or a special character string > that one might add to an item's text to cause it to be disabled. If this is an option at all for you, maybe you should consider to use some third-party extension to Tk. What you want should be fairly easy to set up with tktreectrl, maybe you can do this with other widgets like tablelist or even the ttk treeview, too, I haven't used these much though, so I cannot tell. If you want to try tktreectrl, the python module comes with a ready to use multi column listbox class, and you can define custom states and apply them to individual items and define the item's appearance by state, just look at the demos and you will probably see te point. tktreectrl can be found here: http://tktreectrl.sourceforge.net/ and the python wrapper: http://klappnase.bubble.org/TkinterTreectrl/ tablelist: http://www.nemethi.de/ and the python module: http://tkinter.unpy.net/wiki/TableListWrapper Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Madness has no purpose. Or reason. But it may have a goal. -- Spock, "The Alternative Factor", stardate 3088.7 From jmcmonagle at velseis.com Thu Nov 11 23:32:58 2010 From: jmcmonagle at velseis.com (John McMonagle) Date: Fri, 12 Nov 2010 08:32:58 +1000 Subject: [Tkinter-discuss] Memory leak with tkinter canvas itemconfigure Message-ID: <4CDC6F1A.3080804@velseis.com.au> Hi, I have an application that configures thousands of canvas rectangle items per second and I have noticed that the memory usage leaks badly. The code below illustrates the problem: #--------------------------------------------------------------- import Tkinter as tk import random r = tk.Tk() c = tk.Canvas(r) c.pack(fill=tk.BOTH, expand=tk.YES) # draw 400 rectangles objs = [] for i in range(20): for j in range(20): obj = c.create_rectangle(i*10, j*10, i*10+10, j*10+10, fill='#888888', outline='#888888') objs.append(obj) def run(): # loop indefinitely and randomly change the canvas item colours while True: obj = random.choice(objs) red = random.randint(0,255) green = random.randint(0,255) blue = random.randint(0,255) colour = '#%02x%02x%02x' %(red, green, blue) c.itemconfigure(obj, fill=colour, outline=colour) r.update() tk.Button(r, text='Run', command=run).pack() tk.Button(r, text='Close', command=r.destroy).pack() r.mainloop() #---------------------------------------------------------------------- So as you can see, each iteration of the while loop just does an itemconfigure on a random item on the canvas and then an update to process the redraw. I've tried periodically deleting the canvas items and redrawing them and even periodically destroying the Canvas object itself and restarting from scratch. Alas, memory is never released. So, I come to the conclusion that the memory leak must be in the Tcl/Tk interpreter. Is there any way of forcing the Tcl/Tk interpreter to release memory ? Can anyone help shed some light on this mystery ? Regards, John McMonagle From michael.odonnell at uam.es Fri Nov 12 04:40:23 2010 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Fri, 12 Nov 2010 04:40:23 +0100 Subject: [Tkinter-discuss] Memory leak with tkinter canvas itemconfigure In-Reply-To: <4CDC6F1A.3080804@velseis.com.au> References: <4CDC6F1A.3080804@velseis.com.au> Message-ID: Hi John, I confirm your memory leakage on the code you sent, on a Windows 7 machine running python 2.7 / Tk 8.5 And when one comments out the c.itemconfigure line, memory usage is constant, so the problem is there. And looking in Tkinter.py, the itemconfigure method on a Canvas object calls _configure on the base class, but the problem is not on the Tkinter side, it is in Tk. Mick On Thu, Nov 11, 2010 at 11:32 PM, John McMonagle wrote: > Hi, > > I have an application that configures thousands of canvas rectangle > items per second and I have noticed that the memory usage leaks badly. > > The code below illustrates the problem: > > #--------------------------------------------------------------- > import Tkinter as tk > import random > > r = tk.Tk() > > c = tk.Canvas(r) > c.pack(fill=tk.BOTH, expand=tk.YES) > > # draw 400 rectangles > objs = [] > for i in range(20): > ? ?for j in range(20): > ? ? ? ?obj = c.create_rectangle(i*10, j*10, i*10+10, j*10+10, > fill='#888888', outline='#888888') > ? ? ? ?objs.append(obj) > > def run(): > ? ?# loop indefinitely and randomly change the canvas item colours > ? ?while True: > ? ? ? ?obj = random.choice(objs) > ? ? ? ?red = random.randint(0,255) > ? ? ? ?green = random.randint(0,255) > ? ? ? ?blue = random.randint(0,255) > ? ? ? ?colour = '#%02x%02x%02x' %(red, green, blue) > ? ? ? ?c.itemconfigure(obj, fill=colour, outline=colour) > ? ? ? ?r.update() > > tk.Button(r, text='Run', command=run).pack() > tk.Button(r, text='Close', command=r.destroy).pack() > > r.mainloop() > #---------------------------------------------------------------------- > > So as you can see, each iteration of the while loop just does an > itemconfigure on a random item on the canvas and then an update to > process the redraw. > > I've tried periodically deleting the canvas items and redrawing them and > even periodically destroying the Canvas object itself and restarting > from scratch. ?Alas, memory is never released. ?So, I come to the > conclusion that the memory leak must be in the Tcl/Tk interpreter. > > Is there any way of forcing the Tcl/Tk interpreter to release memory ? > > Can anyone help shed some light on this mystery ? > > Regards, > > John McMonagle > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From jmcmonagle at velseis.com Fri Nov 12 05:12:35 2010 From: jmcmonagle at velseis.com (John McMonagle) Date: Fri, 12 Nov 2010 14:12:35 +1000 Subject: [Tkinter-discuss] Memory leak with tkinter canvas itemconfigure In-Reply-To: References: <4CDC6F1A.3080804@velseis.com.au> Message-ID: <4CDCBEB3.2000003@velseis.com.au> On 12/11/10 13:40, Michael O'Donnell wrote: > Hi John, > > I confirm your memory leakage on the code you sent, > on a Windows 7 machine running python 2.7 / Tk 8.5 > Thanks for taking the time to confirm. > And when one comments out the c.itemconfigure line, memory usage is > constant, so the problem is there. > That concurs with my observations. > And looking in Tkinter.py, the itemconfigure method on a Canvas object > calls _configure on the base class, but the problem is not on the Tkinter > side, it is in Tk. > Agreed. From python at bdurham.com Fri Nov 12 23:17:07 2010 From: python at bdurham.com (python at bdurham.com) Date: Fri, 12 Nov 2010 17:17:07 -0500 Subject: [Tkinter-discuss] Possible to create separator lines in a Tkinter Listbox? In-Reply-To: References: <1289396643.23538.1404577087@webmail.messagingengine.com> Message-ID: <1289600227.18126.1405035069@webmail.messagingengine.com> Lion, > You may want the "box drawing characters." > [1]http://en.wikipedia.org/wiki/Box-drawing_characters > ???????? Like this ???????? > ?????? and this ?????? Great reference and examples - just what I was looking for. Thank you! Malcolm References 1. http://en.wikipedia.org/wiki/Box-drawing_characters -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at bdurham.com Fri Nov 12 23:19:26 2010 From: python at bdurham.com (python at bdurham.com) Date: Fri, 12 Nov 2010 17:19:26 -0500 Subject: [Tkinter-discuss] Possible to disable individual items in a Tkinter Listbox? In-Reply-To: <20101110222925.GA13998@lairds.us> References: <1289396924.24627.1404578103@webmail.messagingengine.com> <20101110222925.GA13998@lairds.us> Message-ID: <1289600366.18466.1405035433@webmail.messagingengine.com> Cameron, >> Is here a way to disable individual items in a Tkinter Listbox? . > Unless recent versions have a configuration for this I haven't yet learned, the functionality you're after requires a custom binding. A custom binding meets my need. Thank you, Malcolm From python at bdurham.com Fri Nov 12 23:27:29 2010 From: python at bdurham.com (python at bdurham.com) Date: Fri, 12 Nov 2010 17:27:29 -0500 Subject: [Tkinter-discuss] Possible to create separator lines in a Tkinter Listbox? In-Reply-To: <20101111112619.6faf904f.klappnase@web.de> References: <1289396643.23538.1404577087@webmail.messagingengine.com> <20101111112619.6faf904f.klappnase@web.de> Message-ID: <1289600849.20944.1405036439@webmail.messagingengine.com> Hi Michael, > tktreectrl can be found here: http://tktreectrl.sourceforge.net/ > and the python wrapper: http://klappnase.bubble.org/TkinterTreectrl/ > tablelist: http://www.nemethi.de/ > and the python module: http://tkinter.unpy.net/wiki/TableListWrapper Thank you for the links to tkTreeCtrl and TableList. I have not used custom Tk modules before. Where do you recommend I place the custom Tk code in order for Tkinter to find it? I'm using the 32-bit version of Python 2.7 for Windows. Regards, Malcolm From python at bdurham.com Fri Nov 12 23:30:48 2010 From: python at bdurham.com (python at bdurham.com) Date: Fri, 12 Nov 2010 17:30:48 -0500 Subject: [Tkinter-discuss] Possible to create separator lines in a Tkinter Listbox? In-Reply-To: References: <1289396643.23538.1404577087@webmail.messagingengine.com> Message-ID: <1289601048.21588.1405037041@webmail.messagingengine.com> Hi Wayne, > unichr(8213) looks pretty good. I'm not sure if your original desire is possible, but you could make it non-selectable by binding <>. > > 1. Is current selection one of the separators? > 2. If not, OK > 3. If so, change selection to the previous item Thanks! I'm following your strategy and it works well for me. Regards, Malcolm -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at bdurham.com Sat Nov 13 14:59:58 2010 From: python at bdurham.com (python at bdurham.com) Date: Sat, 13 Nov 2010 08:59:58 -0500 Subject: [Tkinter-discuss] Definitive list of all Tkinter events? Message-ID: <1289656798.6312.1405104757@webmail.messagingengine.com> Is there a single, master list of all possible Tkinter events? I've been searching for such a list without success. Thank you, Malcolm -------------- next part -------------- An HTML attachment was scrubbed... URL: From lionkimbro at gmail.com Sat Nov 13 21:37:25 2010 From: lionkimbro at gmail.com (Lion Kimbro) Date: Sat, 13 Nov 2010 12:37:25 -0800 Subject: [Tkinter-discuss] Definitive list of all Tkinter events? In-Reply-To: <1289656798.6312.1405104757@webmail.messagingengine.com> References: <1289656798.6312.1405104757@webmail.messagingengine.com> Message-ID: I can't locate such a list either, for either tkinter or Tk. I've created http://tkinter.unpythonic.net/wiki/Events on the wiki, to note the location of such a list if it is found, ... On Sat, Nov 13, 2010 at 5:59 AM, wrote: > Is there a single, master list of all possible Tkinter events? I've been > searching for such a list without success. > > Thank you, > Malcolm > > _______________________________________________ > 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 Cameron at phaseit.net Sat Nov 13 21:56:55 2010 From: Cameron at phaseit.net (Cameron Laird) Date: Sat, 13 Nov 2010 20:56:55 +0000 Subject: [Tkinter-discuss] Definitive list of all Tkinter events? In-Reply-To: References: <1289656798.6312.1405104757@webmail.messagingengine.com> Message-ID: <20101113205655.GA26452@lairds.us> On Sat, Nov 13, 2010 at 12:37:25PM -0800, Lion Kimbro wrote: . . . > I can't locate such a list either, for either tkinter or Tk. > > I've created > http://tkinter.unpythonic.net/wiki/Events > on the wiki, to note the location of such a list if it is found, ... . . . The page has been updated. From python at bdurham.com Sat Nov 13 23:30:02 2010 From: python at bdurham.com (python at bdurham.com) Date: Sat, 13 Nov 2010 17:30:02 -0500 Subject: [Tkinter-discuss] Definitive list of all Tkinter events? In-Reply-To: References: <1289656798.6312.1405104757@webmail.messagingengine.com> Message-ID: <1289687402.13845.1405148881@webmail.messagingengine.com> Lion, > I've created > [1]http://tkinter.unpythonic.net/wiki/Events > on the wiki, to note the location of such a list if it is found, ... Thank you very much! Regards, Malcolm References 1. http://tkinter.unpythonic.net/wiki/Events -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at bdurham.com Sat Nov 13 23:45:29 2010 From: python at bdurham.com (python at bdurham.com) Date: Sat, 13 Nov 2010 17:45:29 -0500 Subject: [Tkinter-discuss] Definitive list of all Tkinter events? In-Reply-To: <20101113205655.GA26452@lairds.us> References: <1289656798.6312.1405104757@webmail.messagingengine.com> <20101113205655.GA26452@lairds.us> Message-ID: <1289688329.17308.1405148989@webmail.messagingengine.com> Cameron, > The page has been updated: > http://tkinter.unpythonic.net/wiki/Events Thank you! These are excellent references to generic events. How does one discover (virtual) events like <>, <>, <>, <>, etc. Malcolm From python at bdurham.com Mon Nov 15 19:30:09 2010 From: python at bdurham.com (python at bdurham.com) Date: Mon, 15 Nov 2010 13:30:09 -0500 Subject: [Tkinter-discuss] Swap position of 2 widgets positioned in parent container via pack() or grid()? Message-ID: <1289845809.23990.1405412907@webmail.messagingengine.com> Any tips on how I can swap the position of 2 widgets who have been positioned in a parent container via pack() or grid()? Thank you, Malcolm -------------- next part -------------- An HTML attachment was scrubbed... URL: From waynejwerner at gmail.com Mon Nov 15 19:47:34 2010 From: waynejwerner at gmail.com (Wayne Werner) Date: Mon, 15 Nov 2010 12:47:34 -0600 Subject: [Tkinter-discuss] Swap position of 2 widgets positioned in parent container via pack() or grid()? In-Reply-To: <1289845809.23990.1405412907@webmail.messagingengine.com> References: <1289845809.23990.1405412907@webmail.messagingengine.com> Message-ID: On Mon, Nov 15, 2010 at 12:30 PM, wrote: > Any tips on how I can swap the position of 2 widgets who have been > positioned in a parent container via pack() or grid()? > import Tkinter as tk root = tk.Tk() b1 = tk.Button(root, text='hi') b2 = tk.Button(root, text='bye') b1.pack() b2.pack() b1.pack_forget() b1.pack() ------ As for grid I'm not sure how to do it unless you have placed them in different row/column - then you just have to use widget.grid(row=widget2row, column=widget2col) widget2.grid(row=widget1col, column=widget1col) Well, that pattern. HTH, Wayne -------------- next part -------------- An HTML attachment was scrubbed... URL: From Cameron at phaseit.net Tue Nov 16 01:08:14 2010 From: Cameron at phaseit.net (Cameron Laird) Date: Tue, 16 Nov 2010 00:08:14 +0000 Subject: [Tkinter-discuss] Memory leak with tkinter canvas itemconfigure In-Reply-To: References: <4CDC6F1A.3080804@velseis.com.au> Message-ID: <20101116000814.GA18076@lairds.us> On Fri, Nov 12, 2010 at 04:40:23AM +0100, Michael O'Donnell wrote: . . . > I confirm your memory leakage on the code you sent, > on a Windows 7 machine running python 2.7 / Tk 8.5 > > And when one comments out the c.itemconfigure line, memory usage is > constant, so the problem is there. > > And looking in Tkinter.py, the itemconfigure method on a Canvas object > calls _configure on the base class, but the problem is not on the Tkinter > side, it is in Tk. . . . From python at bdurham.com Thu Nov 18 23:56:27 2010 From: python at bdurham.com (python at bdurham.com) Date: Thu, 18 Nov 2010 17:56:27 -0500 Subject: [Tkinter-discuss] Bind to event related to currently selected menu item Message-ID: <1290120987.4850.1406050397@webmail.messagingengine.com> Wondering if there's a menu event I can bind to that's related to the currently selected menu item? By menu item I mean the items that show up in a popup menu like New, Open, Save, etc. Use case: I would like to update a statusbar area of our application with a description of the currently selected menu item. Malcolm -------------- next part -------------- An HTML attachment was scrubbed... URL: From kw at codebykevin.com Fri Nov 19 01:29:19 2010 From: kw at codebykevin.com (Kevin Walzer) Date: Thu, 18 Nov 2010 19:29:19 -0500 Subject: [Tkinter-discuss] Bind to event related to currently selected menu item In-Reply-To: <1290120987.4850.1406050397@webmail.messagingengine.com> References: <1290120987.4850.1406050397@webmail.messagingengine.com> Message-ID: <4CE5C4DF.2000201@codebykevin.com> On 11/18/10 5:56 PM, python at bdurham.com wrote: > Wondering if there's a menu event I can bind to that's related to the > currently selected menu item? By menu item I mean the items that show up > in a popup menu like New, Open, Save, etc. > > Use case: I would like to update a statusbar area of our application > with a description of the currently selected menu item. > Malcolm > Try <>. -- Kevin Walzer Code by Kevin http://www.codebykevin.com From python at bdurham.com Fri Nov 19 23:25:38 2010 From: python at bdurham.com (python at bdurham.com) Date: Fri, 19 Nov 2010 17:25:38 -0500 Subject: [Tkinter-discuss] Looking for example of how to use <> to determine currently selected menu item Message-ID: <1290205538.28531.1406225927@webmail.messagingengine.com> I'm looking for an example of how to use <> to determine currently selected menu item. Use case: Display a context sensitive help message in an application's statusbar as a user navigates through various menu items. Thank you, Malcolm -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Sat Nov 20 00:11:42 2010 From: klappnase at web.de (Michael Lange) Date: Sat, 20 Nov 2010 00:11:42 +0100 Subject: [Tkinter-discuss] Looking for example of how to use <> to determine currently selected menu item In-Reply-To: <1290205538.28531.1406225927@webmail.messagingengine.com> References: <1290205538.28531.1406225927@webmail.messagingengine.com> Message-ID: <20101120001142.c6f03c52.klappnase@web.de> Hi, Thus spoketh python at bdurham.com unto us on Fri, 19 Nov 2010 17:25:38 -0500: > I'm looking for an example of how to use <> to > determine currently selected menu item. > > Use case: Display a context sensitive help message in an > application's statusbar as a user navigates through various menu > items. > Maybe you are better off with a simple Motion event, you can access the menu item under the mouse pointer through the menu's index() method (from the menu manpage: Many of the widget commands for a menu take as one argument an indicator of which entry of the menu to operate on. These indicators are called indexes and may be specified in any of the following forms: (...) @number In this form, number is treated as a y-coordinate in the menu's window; the entry closest to that y-coordinate is used. For example, ``@0'' indicates the top-most entry in the window. ) So, in this simple example, you will surely see the point: ################################ from Tkinter import * root = Tk() m = Menu(root) m.add_command(label='foo') m.add_command(label='bar') m.add_command(label='blah') root.bind('<3>', lambda event: m.tk_popup(event.x_root, event.y_root)) def callback(event): try: print m.entrycget(m.index('@%d' % event.y), 'label') except TclError: print 'this must have been the tearoff or something' m.bind('', callback) root.mainloop() ################################ I hope this helps Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Extreme feminine beauty is always disturbing. -- Spock, "The Cloud Minders", stardate 5818.4 From msa01 at bitflipper.ca Sat Nov 20 04:32:11 2010 From: msa01 at bitflipper.ca (Cam Farnell) Date: Fri, 19 Nov 2010 23:32:11 -0400 Subject: [Tkinter-discuss] Angled text on canvas. In-Reply-To: <1289688329.17308.1405148989@webmail.messagingengine.com> References: <1289656798.6312.1405104757@webmail.messagingengine.com> <20101113205655.GA26452@lairds.us> <1289688329.17308.1405148989@webmail.messagingengine.com> Message-ID: <4CE7413B.5050100@bitflipper.ca> Hmm. Need to draw text on an angle on a canvas but no mention of angled text in the documentation. Does anyone know if there is actually a way to do this or is it time to implement a vector font and do it the hard way? Thanks Cam Farnell From klappnase at web.de Sat Nov 20 16:12:57 2010 From: klappnase at web.de (Michael Lange) Date: Sat, 20 Nov 2010 16:12:57 +0100 Subject: [Tkinter-discuss] Angled text on canvas. In-Reply-To: <4CE7413B.5050100@bitflipper.ca> References: <1289656798.6312.1405104757@webmail.messagingengine.com> <20101113205655.GA26452@lairds.us> <1289688329.17308.1405148989@webmail.messagingengine.com> <4CE7413B.5050100@bitflipper.ca> Message-ID: <20101120161257.dc365e2a.klappnase@web.de> Hi, Thus spoketh Cam Farnell unto us on Fri, 19 Nov 2010 23:32:11 -0400: > Hmm. Need to draw text on an angle on a canvas but no mention of angled > text in the documentation. > > Does anyone know if there is actually a way to do this or is it time to > implement a vector font and do it the hard way? In Tk-8.6 the canvas text element has a new -angle option, so using Tk-8.6 is definitely the best way to do this. If installing Tk-8.6 is not an option for you, you may try Blt which seems to be able to rotate text according to: http://wiki.tcl.tk/3365 or to use tkImg to create a window-image object and then rotate this image as demonstrated in http://wiki.tcl.tk/4022 . The tcl wiki shows a few more examples (see http://wiki.tcl.tk/_/gsearch?S=rotate+text) but they are all more or less a pain in the neck, if possible I recommend using Tk-8.6, it's probably much easier to install it and recompile Python to use it than to set up rotated text with older tk versions. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Yes, it is written. Good shall always destroy evil. -- Sirah the Yang, "The Omega Glory", stardate unknown From python at bdurham.com Sat Nov 20 23:19:18 2010 From: python at bdurham.com (python at bdurham.com) Date: Sat, 20 Nov 2010 17:19:18 -0500 Subject: [Tkinter-discuss] Bind to event related to currently selected menu item In-Reply-To: <4CE5C4DF.2000201@codebykevin.com> References: <1290120987.4850.1406050397@webmail.messagingengine.com> <4CE5C4DF.2000201@codebykevin.com> Message-ID: <1290291558.9970.1406337521@webmail.messagingengine.com> Kevin, > Try <>. Thanks for the recommendation. Any suggestions on how I can determine the currently selected menu item in the event raised by <>? # here's how I create my popup menu popup = tk.Menu( menubar ) popup.bind( '<>', statusbarUpdate ) # here's the command I bind to def statusbarUpdate( event=None ): for key in dir( event ): print key, getattr( event, key ) This outputs the following information as I move between menu items (eg. the event is being raised properly). Note: There seems to be no way to determine the current menu widget (event.widget is a string vs. widget reference). char ?? delta 0 height ?? keycode ?? keysym ?? keysym_num ?? num ?? send_event False serial 238 state 0 time 1585806557 type 35 widget .#52754872.#52754872#52755392 <-- string vs. widget reference width ?? x 36160384 x_root 487 y 53363120 y_root 307 Any suggestions appreciated! Thank you, Malcolm > Wondering if there's a menu event I can bind to that's related to the > currently selected menu item? By menu item I mean the items that show up > in a popup menu like New, Open, Save, etc. > > Use case: I would like to update a statusbar area of our application > with a description of the currently selected menu item. From python at bdurham.com Sun Nov 21 00:09:58 2010 From: python at bdurham.com (python at bdurham.com) Date: Sat, 20 Nov 2010 18:09:58 -0500 Subject: [Tkinter-discuss] Looking for example of how to use <> to determine currently selected menu item In-Reply-To: <20101120001142.c6f03c52.klappnase@web.de> References: <1290205538.28531.1406225927@webmail.messagingengine.com> <20101120001142.c6f03c52.klappnase@web.de> Message-ID: <1290294598.16286.1406344059@webmail.messagingengine.com> Hi Michael, Thank you for your idea to use the event. That works when I use the mouse, but it doesn't work when a user uses the cursor keys to move between menu items. I can trap the <> event - I just need a way to determine the current menu widget and its active index. The event object passed to the function I bind to has event.widget reference to a string vs. a widget. Do you have any ideas on how I can determine the active menu widget and its active index independent of a current event object? Thank you, Malcolm ----- Original message ----- From: "Michael Lange" To: tkinter-discuss at python.org Date: Sat, 20 Nov 2010 00:11:42 +0100 Subject: Re: [Tkinter-discuss] Looking for example of how to use <> to determine currently selected menu item Hi, Thus spoketh python at bdurham.com unto us on Fri, 19 Nov 2010 17:25:38 -0500: > I'm looking for an example of how to use <> to > determine currently selected menu item. > > Use case: Display a context sensitive help message in an > application's statusbar as a user navigates through various menu > items. > Maybe you are better off with a simple Motion event, you can access the menu item under the mouse pointer through the menu's index() method (from the menu manpage: Many of the widget commands for a menu take as one argument an indicator of which entry of the menu to operate on. These indicators are called indexes and may be specified in any of the following forms: (...) @number In this form, number is treated as a y-coordinate in the menu's window; the entry closest to that y-coordinate is used. For example, ``@0'' indicates the top-most entry in the window. ) So, in this simple example, you will surely see the point: ################################ from Tkinter import * root = Tk() m = Menu(root) m.add_command(label='foo') m.add_command(label='bar') m.add_command(label='blah') root.bind('<3>', lambda event: m.tk_popup(event.x_root, event.y_root)) def callback(event): try: print m.entrycget(m.index('@%d' % event.y), 'label') except TclError: print 'this must have been the tearoff or something' m.bind('', callback) root.mainloop() ################################ I hope this helps Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Extreme feminine beauty is always disturbing. -- Spock, "The Cloud Minders", stardate 5818.4 _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss at python.org http://mail.python.org/mailman/listinfo/tkinter-discuss From michael.odonnell at uam.es Sun Nov 21 10:26:24 2010 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Sun, 21 Nov 2010 10:26:24 +0100 Subject: [Tkinter-discuss] Bind to event related to currently selected menu item In-Reply-To: <1290291558.9970.1406337521@webmail.messagingengine.com> References: <1290120987.4850.1406050397@webmail.messagingengine.com> <4CE5C4DF.2000201@codebykevin.com> <1290291558.9970.1406337521@webmail.messagingengine.com> Message-ID: Hi Malcom, Change your statusbarUpdate for the following, which will print out the index of the currently selected menu item: def statusbarUpdate( event=None ): print tk.call(event.widget, "index", "active") Note that this uses tcl/tk code, where Tkinter code should be used, but it seems the corresponding tkinter code is broken, e.g., with def statusbarUpdate( event=None ): print popup.index('active') ...always returns None on changing the menu selection. My test code below from Tkinter import * import tkFont tk = Tk() def statusbarUpdate( event=None ): print tk.call(event.widget, "index", "active") menubar=Menu(tk) tk.config(menu=menubar) popup = Menu( menubar ) menubar.add_cascade(label="MyMenu", menu=popup) popup.bind( '<>', statusbarUpdate ) popup.add_command(label="Option 1") popup.add_command(label="Option 2") popup.add_command(label="Option 3") tk.mainloop() On Sat, Nov 20, 2010 at 11:19 PM, wrote: > Kevin, > >> Try <>. > > Thanks for the recommendation. Any suggestions on how I can determine > the currently selected menu item in the event raised by <>? > > # here's how I create my popup menu > popup = tk.Menu( menubar ) > popup.bind( '<>', statusbarUpdate ) > > # here's the command I bind to > def statusbarUpdate( event=None ): > ? ?for key in dir( event ): > ? ? ? ?print key, getattr( event, key ) > > This outputs the following information as I move between menu items (eg. > the event is being raised properly). > > Note: There seems to be no way to determine the current menu widget > (event.widget is a string vs. widget reference). > > char ?? > delta 0 > height ?? > keycode ?? > keysym ?? > keysym_num ?? > num ?? > send_event False > serial 238 > state 0 > time 1585806557 > type 35 > widget .#52754872.#52754872#52755392 <-- string vs. widget reference > width ?? > x 36160384 > x_root 487 > y 53363120 > y_root 307 > > Any suggestions appreciated! > > Thank you, > Malcolm > > >> Wondering if there's a menu event I can bind to that's related to the >> currently selected menu item? By menu item I mean the items that show up >> in a popup menu like New, Open, Save, etc. >> >> Use case: I would like to update a statusbar area of our application >> with a description of the currently selected menu item. > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From klappnase at web.de Sun Nov 21 12:23:27 2010 From: klappnase at web.de (Michael Lange) Date: Sun, 21 Nov 2010 12:23:27 +0100 Subject: [Tkinter-discuss] Looking for example of how to use <> to determine currently selected menu item In-Reply-To: <1290294598.16286.1406344059@webmail.messagingengine.com> References: <1290205538.28531.1406225927@webmail.messagingengine.com> <20101120001142.c6f03c52.klappnase@web.de> <1290294598.16286.1406344059@webmail.messagingengine.com> Message-ID: <20101121122327.98e105e6.klappnase@web.de> Hi Malcolm, Thus spoketh python at bdurham.com unto us on Sat, 20 Nov 2010 18:09:58 -0500: > Hi Michael, > > Thank you for your idea to use the event. That works when I use > the mouse, but it doesn't work when a user uses the cursor keys to move > between menu items. sure, you're right, I didn't think of that. > > I can trap the <> event - I just need a way to determine the > current menu widget and its active index. > > The event object passed to the function I bind to has event.widget > reference to a string vs. a widget. Do you have any ideas on how I can > determine the active menu widget and its active index independent of a > current event object? Thank god, Tkinter offers a solution which is actually much easier than my first example :) ######################## from Tkinter import * root = Tk() m = Menu(root) m.add_command(label='foo') m.add_command(label='bar') m.add_command(label='blah') root.bind('<3>', lambda event: m.tk_popup(event.x_root, event.y_root)) def callback(event): print event.widget.index('active') m.bind('<>', callback) root.mainloop() ######################### Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Every living thing wants to survive. -- Spock, "The Ultimate Computer", stardate 4731.3 From michael.odonnell at uam.es Sun Nov 21 13:05:49 2010 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Sun, 21 Nov 2010 13:05:49 +0100 Subject: [Tkinter-discuss] Looking for example of how to use <> to determine currently selected menu item In-Reply-To: <20101121122327.98e105e6.klappnase@web.de> References: <1290205538.28531.1406225927@webmail.messagingengine.com> <20101120001142.c6f03c52.klappnase@web.de> <1290294598.16286.1406344059@webmail.messagingengine.com> <20101121122327.98e105e6.klappnase@web.de> Message-ID: Hi Michael, At least in Python 2.5.4 linked to Tk 8.4 (Windows version), the following fails because event.widget holds a string (the tcl/tk widget name), not a Tkinter class. > def callback(event): > ? ?print event.widget.index('active') Maybe fixed in later editions, but if one wants a solution that will work on older versions... Mick From klappnase at web.de Sun Nov 21 13:13:57 2010 From: klappnase at web.de (Michael Lange) Date: Sun, 21 Nov 2010 13:13:57 +0100 Subject: [Tkinter-discuss] Looking for example of how to use <> to determine currently selected menu item In-Reply-To: References: <1290205538.28531.1406225927@webmail.messagingengine.com> <20101120001142.c6f03c52.klappnase@web.de> <1290294598.16286.1406344059@webmail.messagingengine.com> <20101121122327.98e105e6.klappnase@web.de> Message-ID: <20101121131357.0a84c8cb.klappnase@web.de> Hi Mick, Thus spoketh "Michael O'Donnell" unto us on Sun, 21 Nov 2010 13:05:49 +0100: > Hi Michael, > > At least in Python 2.5.4 linked to Tk 8.4 (Windows version), > the following fails because event.widget holds a string (the tcl/tk > widget name), not a Tkinter class. > > > def callback(event): > > ? ?print event.widget.index('active') > > Maybe fixed in later editions, but if one wants a solution that will > work on older versions... I see, this happens only with cascade menus, in my example I only had a popup menu, for which it worked as expected. Right now I am trying to figure out what's wrong with Tkinter (it's definitely a bug within Tkinter.py, and I doubt that it has been fixed since 2.6.5), I'll send another post when I know more. Of course for now you are right, your code "just works" :) Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Uncontrolled power will turn even saints into savages. And we can all be counted on to live down to our lowest impulses. -- Parmen, "Plato's Stepchildren", stardate 5784.3 From klappnase at web.de Sun Nov 21 14:08:34 2010 From: klappnase at web.de (Michael Lange) Date: Sun, 21 Nov 2010 14:08:34 +0100 Subject: [Tkinter-discuss] Bind to event related to currently selected menu item In-Reply-To: References: <1290120987.4850.1406050397@webmail.messagingengine.com> <4CE5C4DF.2000201@codebykevin.com> <1290291558.9970.1406337521@webmail.messagingengine.com> Message-ID: <20101121140834.bdbd333b.klappnase@web.de> Hi, Thus spoketh "Michael O'Donnell" unto us on Sun, 21 Nov 2010 10:26:24 +0100: > Hi Malcom, > > Change your statusbarUpdate for the following, which will print out > the index of the currently selected menu item: > > def statusbarUpdate( event=None ): > print tk.call(event.widget, "index", "active") > > Note that this uses tcl/tk code, where Tkinter code should be used, > but it seems the corresponding tkinter code is broken, e.g., with > > def statusbarUpdate( event=None ): > print popup.index('active') > > ...always returns None on changing the menu selection. I believe this is because the button in the menu is treated as a different widget by Tk, so the correct call would be: def statusbarUpdate(event): print event.widget.index('active') However, using this I get an error: Exception in Tkinter callback Traceback (most recent call last): File "/usr/local/lib/python2.6/lib-tk/Tkinter.py", line 1410, in __call__ return self.func(*args) File "test2.py", line 18, in statusbarUpdate print event.widget.index('active') ValueError: substring not found This is apparently because event.widget is not (as expected) a widget instance but a string which looks like .#153369036.#153369036#153369644 Trying to feed this string to nametowidget() I get the following error: Exception in Tkinter callback Traceback (most recent call last): File "/usr/local/lib/python2.6/lib-tk/Tkinter.py", line 1410, in __call__ return self.func(*args) File "test2.py", line 18, in statusbarUpdate print tk.nametowidget(event.widget)#.index('active') File "/usr/local/lib/python2.6/lib-tk/Tkinter.py", line 1079, in nametowidget w = w.children[n] KeyError: '#153369036' The problem is apparently that the widget name of the menu's "button" is assigned by Tk and there does not seem to be a way to access this subwidget from within Tkinter. Besides this I don't understand why this does not happen with the context menu from my previous example but only with a cascaded menu. This looks to me like a bug in Tkinter, but I don't have an idea how this could ever be fixed (at least without dealing with _tkinter's internals), so we probably will have to stick with Michael's workaround. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Murder is contrary to the laws of man and God. -- M-5 Computer, "The Ultimate Computer", stardate 4731.3 From python at bdurham.com Sun Nov 21 18:35:22 2010 From: python at bdurham.com (python at bdurham.com) Date: Sun, 21 Nov 2010 12:35:22 -0500 Subject: [Tkinter-discuss] Bind to event related to currently selected menu item In-Reply-To: References: <1290120987.4850.1406050397@webmail.messagingengine.com><4CE5C4DF.2000201@codebykevin.com><1290291558.9970.1406337521@webmail.messagingengine.com> Message-ID: <1290360922.16531.1406423667@webmail.messagingengine.com> Michael, Thank you! That's EXACTLY the solution I was looking for :) Regards, Malcolm Change your statusbarUpdate for the following, which will print out the index of the currently selected menu item: def statusbarUpdate( event=None ): print tk.call(event.widget, "index", "active") Note that this uses tcl/tk code, where Tkinter code should be used, but it seems the corresponding tkinter code is broken, e.g., with def statusbarUpdate( event=None ): print popup.index('active') ...always returns None on changing the menu selection. My test code below from Tkinter import * import tkFont tk = Tk() def statusbarUpdate( event=None ): print tk.call(event.widget, "index", "active") menubar=Menu(tk) tk.config(menu=menubar) popup = Menu( menubar ) menubar.add_cascade(label="MyMenu", menu=popup) popup.bind( '<>', statusbarUpdate ) popup.add_command(label="Option 1") popup.add_command(label="Option 2") popup.add_command(label="Option 3") tk.mainloop() On Sat, Nov 20, 2010 at 11:19 PM, wrote: > Kevin, > >> Try <>. > > Thanks for the recommendation. Any suggestions on how I can determine > the currently selected menu item in the event raised by <>? > > # here's how I create my popup menu > popup = tk.Menu( menubar ) > popup.bind( '<>', statusbarUpdate ) > > # here's the command I bind to > def statusbarUpdate( event=None ): > ? ?for key in dir( event ): > ? ? ? ?print key, getattr( event, key ) > > This outputs the following information as I move between menu items (eg. > the event is being raised properly). > > Note: There seems to be no way to determine the current menu widget > (event.widget is a string vs. widget reference). > > char ?? > delta 0 > height ?? > keycode ?? > keysym ?? > keysym_num ?? > num ?? > send_event False > serial 238 > state 0 > time 1585806557 > type 35 > widget .#52754872.#52754872#52755392 <-- string vs. widget reference > width ?? > x 36160384 > x_root 487 > y 53363120 > y_root 307 > >> Wondering if there's a menu event I can bind to that's related to the >> currently selected menu item? By menu item I mean the items that show up >> in a popup menu like New, Open, Save, etc. >> >> Use case: I would like to update a statusbar area of our application >> with a description of the currently selected menu item. From python at bdurham.com Sun Nov 21 18:44:20 2010 From: python at bdurham.com (python at bdurham.com) Date: Sun, 21 Nov 2010 12:44:20 -0500 Subject: [Tkinter-discuss] Looking for example of how to use <> to determine currently selected menu item In-Reply-To: References: <1290205538.28531.1406225927@webmail.messagingengine.com><20101120001142.c6f03c52.klappnase@web.de><1290294598.16286.1406344059@webmail.messagingengine.com><20101121122327.98e105e6.klappnase@web.de> Message-ID: <1290361460.17824.1406424563@webmail.messagingengine.com> Hi Michael(s): > At least in Python 2.5.4 linked to Tk 8.4 (Windows version), > the following fails because event.widget holds a string (the tcl/tk > widget name), not a Tkinter class. > > def callback(event): > ? ?print event.widget.index('active') > > Maybe fixed in later editions This fails in 32-bit Python 2.7 for Windows (linked to Tk 8.5 with ttk/Tile). Malcolm From python at bdurham.com Sun Nov 21 18:56:43 2010 From: python at bdurham.com (python at bdurham.com) Date: Sun, 21 Nov 2010 12:56:43 -0500 Subject: [Tkinter-discuss] Looking for example of how to use <> to determine currently selected menu item In-Reply-To: <20101121131357.0a84c8cb.klappnase@web.de> References: <1290205538.28531.1406225927@webmail.messagingengine.com><20101120001142.c6f03c52.klappnase@web.de><1290294598.16286.1406344059@webmail.messagingengine.com><20101121122327.98e105e6.klappnase@web.de> <20101121131357.0a84c8cb.klappnase@web.de> Message-ID: <1290362203.20180.1406425217@webmail.messagingengine.com> Michael(s): > def callback(event): > ? ?print event.widget.index('active') > > I see, this happens only with cascade menus, in my example I only had a > popup menu, for which it worked as expected. Right now I am trying to > figure out what's wrong with Tkinter (it's definitely a bug within > Tkinter.py, and I doubt that it has been fixed since 2.6.5), I'll send > another post when I know more. Of course for now you are right, your code > "just works" :) I can confirm that this bug still exists in 32-bit Python 2.7 for Windows for both standalone and cascading menus. Malcolm From python at bdurham.com Sun Nov 21 19:00:51 2010 From: python at bdurham.com (python at bdurham.com) Date: Sun, 21 Nov 2010 13:00:51 -0500 Subject: [Tkinter-discuss] Bind to event related to currently selected menu item In-Reply-To: <20101121140834.bdbd333b.klappnase@web.de> References: <1290120987.4850.1406050397@webmail.messagingengine.com><4CE5C4DF.2000201@codebykevin.com><1290291558.9970.1406337521@webmail.messagingengine.com> <20101121140834.bdbd333b.klappnase@web.de> Message-ID: <1290362451.20800.1406425995@webmail.messagingengine.com> Hi Michael, > The problem is apparently that the widget name of the menu's "button" is assigned by Tk and there does not seem to be a way to access this subwidget from within Tkinter. Besides this I don't understand why this does not happen with the context menu from my previous example but only with a cascaded menu. Your example fails for both context and cascading menus under 32-bit Python 2.7 for Windows. I appreciate your and Michael's help. Thank you both! Malcolm Thus spoketh "Michael O'Donnell" unto us on Sun, 21 Nov 2010 10:26:24 +0100: > Hi Malcom, > > Change your statusbarUpdate for the following, which will print out > the index of the currently selected menu item: > > def statusbarUpdate( event=None ): > print tk.call(event.widget, "index", "active") > > Note that this uses tcl/tk code, where Tkinter code should be used, > but it seems the corresponding tkinter code is broken, e.g., with > > def statusbarUpdate( event=None ): > print popup.index('active') > > ...always returns None on changing the menu selection. I believe this is because the button in the menu is treated as a different widget by Tk, so the correct call would be: def statusbarUpdate(event): print event.widget.index('active') However, using this I get an error: Exception in Tkinter callback Traceback (most recent call last): File "/usr/local/lib/python2.6/lib-tk/Tkinter.py", line 1410, in __call__ return self.func(*args) File "test2.py", line 18, in statusbarUpdate print event.widget.index('active') ValueError: substring not found This is apparently because event.widget is not (as expected) a widget instance but a string which looks like .#153369036.#153369036#153369644 Trying to feed this string to nametowidget() I get the following error: Exception in Tkinter callback Traceback (most recent call last): File "/usr/local/lib/python2.6/lib-tk/Tkinter.py", line 1410, in __call__ return self.func(*args) File "test2.py", line 18, in statusbarUpdate print tk.nametowidget(event.widget)#.index('active') File "/usr/local/lib/python2.6/lib-tk/Tkinter.py", line 1079, in nametowidget w = w.children[n] KeyError: '#153369036' The problem is apparently that the widget name of the menu's "button" is assigned by Tk and there does not seem to be a way to access this subwidget from within Tkinter. Besides this I don't understand why this does not happen with the context menu from my previous example but only with a cascaded menu. This looks to me like a bug in Tkinter, but I don't have an idea how this could ever be fixed (at least without dealing with _tkinter's internals), so we probably will have to stick with Michael's workaround. From python at bdurham.com Mon Nov 22 02:18:06 2010 From: python at bdurham.com (python at bdurham.com) Date: Sun, 21 Nov 2010 20:18:06 -0500 Subject: [Tkinter-discuss] Working with tear-off menus (change the "-----" label, customize location/appearance of tear-off window) Message-ID: <1290388686.21953.1406467541@webmail.messagingengine.com> I've been experimenting with Tkinter tear-off menus and have the following questions (relative to Windows): 1. Is there a way to change the default appearance of the "------" menu label that is used to indicate a tear-off menu -OR- is there a way to programmatically convert a menu widget to a torn-off state? Note: The tear-off menu item does not have a 'label' property. 2. Is there a way to customize the location and appearance of the window that contains a tear-off menu? On Windows, the tear-off menus appear at random(?) places on the desktop. And these windows have min/max buttons and are resizable - all behaviors that IMO don't make sense for a floating tear-off menu. What I would like to do is capture a reference to the window of a tear-off and customize it like I would any other Toplevel() window. Is this possible? Note: I can detect the tearoff event by using the tearoffcommand= option when I create a menu. I think this event is where I want to take control of the tear-off menu's window properties? But how to get a reference to the tear-off menu's window (and does it exist yet?). Thank you, Malcolm -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Mon Nov 22 11:45:41 2010 From: klappnase at web.de (Michael Lange) Date: Mon, 22 Nov 2010 11:45:41 +0100 Subject: [Tkinter-discuss] Working with tear-off menus (change the "-----" label, customize location/appearance of tear-off window) In-Reply-To: <1290388686.21953.1406467541@webmail.messagingengine.com> References: <1290388686.21953.1406467541@webmail.messagingengine.com> Message-ID: <20101122114541.278c871a.klappnase@web.de> Hi, Thus spoketh python at bdurham.com unto us on Sun, 21 Nov 2010 20:18:06 -0500: > I've been experimenting with Tkinter tear-off menus and have the > following questions (relative to Windows): > > 1. Is there a way to change the default appearance of the > "------" menu label that is used to indicate a tear-off menu -OR- > is there a way to programmatically convert a menu widget to a > torn-off state? Note: The tear-off menu item does not have a > 'label' property. Not sure, maybe you could find out the tearoff's x and y coords and use event_generate() to trigger the mouse event or so... > > 2. Is there a way to customize the location and appearance of the > window that contains a tear-off menu? On Windows, the tear-off > menus appear at random(?) places on the desktop. And these > windows have min/max buttons and are resizable - all behaviors > that IMO don't make sense for a floating tear-off menu. What I > would like to do is capture a reference to the window of a > tear-off and customize it like I would any other Toplevel() > window. Is this possible? Here on linux (I guess it should be the same on windows) the tearoffcommand takes two arguments, first the menu itself and second the newly created toplevel window, both as strings however, and Tkinter doesn't know about the toplevel, so you will have to use the tcl-syntax again :( See this example: ######################### from Tkinter import * root = Tk() def foo(menu, top): root.nametowidget(menu).add_command(label='baz') root.tk.call('wm', 'resizable', top, '0', '0') m = Menu(root, tearoffcommand=foo) m.add_command(label='foo') m.add_command(label='bar') m.add_command(label='blah') root.bind('<3>', lambda event: m.tk_popup(event.x_root, event.y_root)) root.mainloop() ####################### Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. You are an excellent tactician, Captain. You let your second in command attack while you sit and watch for weakness. -- Khan Noonian Singh, "Space Seed", stardate 3141.9 From jepler at unpythonic.net Mon Nov 22 14:26:41 2010 From: jepler at unpythonic.net (Jeff Epler) Date: Mon, 22 Nov 2010 07:26:41 -0600 Subject: [Tkinter-discuss] Working with tear-off menus (change the "-----" label, customize location/appearance of tear-off window) In-Reply-To: <1290388686.21953.1406467541@webmail.messagingengine.com> References: <1290388686.21953.1406467541@webmail.messagingengine.com> Message-ID: <20101122132641.GB19946@unpythonic.net> You can manually create a tearoff from a menu: % .m clone .mt tearoff and post it at a desired location: % .mt post 100 100 As suggested in the other message, you can use "wm resizeable" to make it not change size: % wm resiz .mt 0 0 (Of course, I only tested this on linux, so on Windows YMMV) Unfortunately, the menu 'clone' subcommand does not seem to be wrapped in Python. You can add it, but it'll be gross and touches stuff that should be considered implementation details of Tkinter (works with all python2.x I'm aware of, though): # ---------------------------------------------------------------------- import Tkinter, types def makewidget(master, klass, path): path = str(path) self = types.InstanceType(klass) self._name = path[len(master._w)+1:] self._w = path self.children = {} master.children[self._name] = self self.master = master self.tk = master.tk return self def tearoff(menu): child = str(menu) + ".tearoff" menu.tk.call((menu, "clone", child, "tearoff")) return makewidget(menu, Tkinter.Menu, child) # ---------------------------------------------------------------------- And then you'll find that 'wm_resizable' is not available because Menu is not a subclass of Wm. Just call it directly through Tk: >>> mt = tearoff(m) >>> mt.tk.call("wm", "resizable", mt, 0, 0) >>> mt.post(100, 100) Jeff From klappnase at web.de Mon Nov 22 17:50:48 2010 From: klappnase at web.de (Michael Lange) Date: Mon, 22 Nov 2010 17:50:48 +0100 Subject: [Tkinter-discuss] Working with tear-off menus (change the "-----" label, customize location/appearance of tear-off window) In-Reply-To: <20101122132641.GB19946@unpythonic.net> References: <1290388686.21953.1406467541@webmail.messagingengine.com> <20101122132641.GB19946@unpythonic.net> Message-ID: <20101122175048.3e1ea2b3.klappnase@web.de> Thus spoketh Jeff Epler unto us on Mon, 22 Nov 2010 07:26:41 -0600: > You can manually create a tearoff from a menu: > % .m clone .mt tearoff > and post it at a desired location: > % .mt post 100 100 > As suggested in the other message, you can use "wm resizeable" to make > it not change size: > % wm resiz .mt 0 0 > (Of course, I only tested this on linux, so on Windows YMMV) > > Unfortunately, the menu 'clone' subcommand does not seem to be wrapped > in Python. You can add it, but it'll be gross and touches stuff that > should be considered implementation details of Tkinter (works with > all python2.x I'm aware of, though): > This is interesting, I never heard about that. And, from man menu I see that menubars are also cloned, which might explain the troubles with the menubars and cascading menus the OP had in the previous thread, I can confirm the same problem with <> with the torn off popup menu, while it works all right with the "normal" one. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. We Klingons believe as you do -- the sick should die. Only the strong should live. -- Kras, "Friday's Child", stardate 3497.2 From python at bdurham.com Mon Nov 22 21:34:12 2010 From: python at bdurham.com (python at bdurham.com) Date: Mon, 22 Nov 2010 15:34:12 -0500 Subject: [Tkinter-discuss] Working with tear-off menus (change the "-----" label, customize location/appearance of tear-off window) In-Reply-To: <20101122132641.GB19946@unpythonic.net> References: <1290388686.21953.1406467541@webmail.messagingengine.com> <20101122132641.GB19946@unpythonic.net> Message-ID: <1290458052.13400.1406630311@webmail.messagingengine.com> Hi Jeff, Thank you! Confirming that your code works under Windows 7 with 32-bit Python 2.7. Regards, Malcolm From: "Jeff Epler" You can manually create a tearoff from a menu: % .m clone .mt tearoff and post it at a desired location: % .mt post 100 100 As suggested in the other message, you can use "wm resizeable" to make it not change size: % wm resiz .mt 0 0 (Of course, I only tested this on linux, so on Windows YMMV) Unfortunately, the menu 'clone' subcommand does not seem to be wrapped in Python. You can add it, but it'll be gross and touches stuff that should be considered implementation details of Tkinter (works with all python2.x I'm aware of, though): # ---------------------------------------------------------------------- import Tkinter, types def makewidget(master, klass, path): path = str(path) self = types.InstanceType(klass) self._name = path[len(master._w)+1:] self._w = path self.children = {} master.children[self._name] = self self.master = master self.tk = master.tk return self def tearoff(menu): child = str(menu) + ".tearoff" menu.tk.call((menu, "clone", child, "tearoff")) return makewidget(menu, Tkinter.Menu, child) # ---------------------------------------------------------------------- And then you'll find that 'wm_resizable' is not available because Menu is not a subclass of Wm. Just call it directly through Tk: >>> mt = tearoff(m) >>> mt.tk.call("wm", "resizable", mt, 0, 0) >>> mt.post(100, 100) From python at bdurham.com Mon Nov 22 21:30:11 2010 From: python at bdurham.com (python at bdurham.com) Date: Mon, 22 Nov 2010 15:30:11 -0500 Subject: [Tkinter-discuss] Working with tear-off menus (change the "-----" label, customize location/appearance of tear-off window) In-Reply-To: <20101122114541.278c871a.klappnase@web.de> References: <1290388686.21953.1406467541@webmail.messagingengine.com> <20101122114541.278c871a.klappnase@web.de> Message-ID: <1290457811.12423.1406629477@webmail.messagingengine.com> Hi Michael, Thank you for your help. Your solution works well (tested under Windows 7 with 32-bit Python 2.7). Regards, Malcolm > 2. Is there a way to customize the location and appearance of the > window that contains a tear-off menu? On Windows, the tear-off > menus appear at random(?) places on the desktop. And these > windows have min/max buttons and are resizable - all behaviors > that IMO don't make sense for a floating tear-off menu. What I > would like to do is capture a reference to the window of a > tear-off and customize it like I would any other Toplevel() > window. Is this possible? Here on linux (I guess it should be the same on windows) the tearoffcommand takes two arguments, first the menu itself and second the newly created toplevel window, both as strings however, and Tkinter doesn't know about the toplevel, so you will have to use the tcl-syntax again :( See this example: from Tkinter import * root = Tk() def foo(menu, top): root.nametowidget(menu).add_command(label='baz') root.tk.call('wm', 'resizable', top, '0', '0') m = Menu(root, tearoffcommand=foo) m.add_command(label='foo') m.add_command(label='bar') m.add_command(label='blah') root.bind('<3>', lambda event: m.tk_popup(event.x_root, event.y_root)) root.mainloop() From python at bdurham.com Mon Nov 22 22:21:44 2010 From: python at bdurham.com (python at bdurham.com) Date: Mon, 22 Nov 2010 16:21:44 -0500 Subject: [Tkinter-discuss] Change the font style (bold, italic, stikethru, normal) of widgets without explictly knowing font? Message-ID: <1290460904.24589.1406637959@webmail.messagingengine.com> Is there a simple way to change the font style of widgets without explictly knowing the widget's font? For example: if I want to toggle the bold state of a widget's text, do I need to determine its font, then build an equivalent font object/expression with the font style I need, and pass that full font description to widget.config() or can I use a shortcut technique that allows me to pass 'bold' or 'normal' to control a widget's font. Thank you, Malcolm -------------- next part -------------- An HTML attachment was scrubbed... URL: From waynejwerner at gmail.com Mon Nov 22 22:39:40 2010 From: waynejwerner at gmail.com (Wayne Werner) Date: Mon, 22 Nov 2010 15:39:40 -0600 Subject: [Tkinter-discuss] Change the font style (bold, italic, stikethru, normal) of widgets without explictly knowing font? In-Reply-To: <1290460904.24589.1406637959@webmail.messagingengine.com> References: <1290460904.24589.1406637959@webmail.messagingengine.com> Message-ID: On Mon, Nov 22, 2010 at 3:21 PM, wrote: > Is there a simple way to change the font style of widgets without explictly > knowing the widget's font? > > For example: if I want to toggle the bold state of a widget's text, do I > need to determine its font, then build an equivalent font object/expression > with the font style I need, and pass that full font description to > widget.config() or can I use a shortcut technique that allows me to pass > 'bold' or 'normal' to control a widget's font. > Label(root, text='Font fun', font=('Arial', 100, 'bold')).config()['font'] returns a tuple - and since you can't modify a tuple, you'll have to determine the current font. There may be a shorter way, but here's what you can do: mylabel.config(font=mylabel.config()['font'][4][:2] + ('normal',)) mylabel.config(font=mylabel.config()['font'][4][:2] + ('bold', 'italics')) And that should work. HTH, Wayne -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Mon Nov 22 23:11:46 2010 From: klappnase at web.de (Michael Lange) Date: Mon, 22 Nov 2010 23:11:46 +0100 Subject: [Tkinter-discuss] Change the font style (bold, italic, stikethru, normal) of widgets without explictly knowing font? In-Reply-To: References: <1290460904.24589.1406637959@webmail.messagingengine.com> Message-ID: <20101122231146.69f59904.klappnase@web.de> Hi, Thus spoketh Wayne Werner unto us on Mon, 22 Nov 2010 15:39:40 -0600: > On Mon, Nov 22, 2010 at 3:21 PM, wrote: > > > Is there a simple way to change the font style of widgets without > > explictly knowing the widget's font? > > > > For example: if I want to toggle the bold state of a widget's text, > > do I need to determine its font, then build an equivalent font > > object/expression with the font style I need, and pass that full font > > description to widget.config() or can I use a shortcut technique that > > allows me to pass 'bold' or 'normal' to control a widget's font. > > > > Label(root, text='Font fun', font=('Arial', 100, 'bold')).config() > ['font'] returns a tuple - and since you can't modify a tuple, you'll > have to determine the current font. There may be a shorter way, but > here's what you can do: If you don't explicitely define the label's font, the font is a string (at least here, on linux): >>> from Tkinter import * >>> l=Label(text='foo') >>> l.pack() >>> l.cget('font') 'Helvetica -12 bold' so you can do: def swapfont(): if 'bold' in l.cget('font'): l.config(font=l.cget('font').replace('bold', 'normal')) elif 'normal' in l.cget('font'): l.config(font=l.cget('font').replace('normal', 'bold')) else: l.config(font=l.cget('font')+' bold') which is not too nice, either. If you want to do fancy things with fonts, I'd try tkFont, with a tkFont.Font() you can easily configure all kinds of font attributes. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. The more complex the mind, the greater the need for the simplicity of play. -- Kirk, "Shore Leave", stardate 3025.8 From python at bdurham.com Tue Nov 23 01:23:28 2010 From: python at bdurham.com (python at bdurham.com) Date: Mon, 22 Nov 2010 19:23:28 -0500 Subject: [Tkinter-discuss] Change the font style (bold, italic, stikethru, normal) of widgets without explictly knowing font? In-Reply-To: References: <1290460904.24589.1406637959@webmail.messagingengine.com> Message-ID: <1290471808.29949.1406667187@webmail.messagingengine.com> Wayne, > mylabel.config(font=mylabel.config()['font'][4][:2] + ('normal',)) > mylabel.config(font=mylabel.config()['font'][4][:2] + ('bold', 'italics')) That works! Thank you, Malcolm -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at bdurham.com Tue Nov 23 01:27:25 2010 From: python at bdurham.com (python at bdurham.com) Date: Mon, 22 Nov 2010 19:27:25 -0500 Subject: [Tkinter-discuss] Change the font style (bold, italic, stikethru, normal) of widgets without explictly knowing font? In-Reply-To: <20101122231146.69f59904.klappnase@web.de> References: <1290460904.24589.1406637959@webmail.messagingengine.com> <20101122231146.69f59904.klappnase@web.de> Message-ID: <1290472045.30670.1406667515@webmail.messagingengine.com> Hi Michael, > If you don't explicitely define the label's font, the font is a string (at least here, on linux): > >>> from Tkinter import * > >>> l=Label(text='foo') > >>> l.pack() > >>> l.cget('font') > 'Helvetica -12 bold' I get strings as well (32-bit Python 2.7 under Windows 7). > If you want to do fancy things with fonts, I'd try tkFont, with a tkFont.Font() you can easily configure all kinds of font attributes. I agree with you - tkFont is definitely the way to go. Thank you, Malcolm From davecortesi at gmail.com Tue Nov 23 22:14:17 2010 From: davecortesi at gmail.com (David Cortesi) Date: Tue, 23 Nov 2010 13:14:17 -0800 Subject: [Tkinter-discuss] how make active python 3 use active tcl on mac os? Message-ID: I apologize that this question is somewhat unique to the ActiveState free products, not the generic Python. I asked the question at the ActiveState support forum but it appears to be dead. I installed ActiveState Python 3.1.4, and also ActiveState Tcl/Tk, both on Mac OS X 10.6. Python3 executing "import * from tkinter" is getting and executing the Apple version of Tcl/Tk which is level 8.5.7. It appears to be getting it from /System/Library/Frameworks/Tk.framework and Tcl.framework. The ActiveTc (level 8.5.9) is in /Library/Frameworks rather than /System/Library Frameworks. It contains a bug fix that I need. Any suggestions on how I tell python3 to find the later Tcl/Tk instead of the Apple one? Also just by the way, how in program code can you check the release level of Tk or ttk? Thanks, Dave Cortesi -------------- next part -------------- An HTML attachment was scrubbed... URL: From nad at acm.org Wed Nov 24 02:11:23 2010 From: nad at acm.org (Ned Deily) Date: Tue, 23 Nov 2010 17:11:23 -0800 Subject: [Tkinter-discuss] how make active python 3 use active tcl on mac os? References: Message-ID: In article , David Cortesi wrote: > I installed ActiveState Python 3.1.4, and also ActiveState Tcl/Tk, both on > Mac OS X 10.6. > > Python3 executing "import * from tkinter" is getting and executing the Apple > version of Tcl/Tk which is level 8.5.7. It appears to be getting it from > /System/Library/Frameworks/Tk.framework and Tcl.framework. > > The ActiveTc (level 8.5.9) is in /Library/Frameworks rather than > /System/Library Frameworks. It contains a bug fix that I need. > > Any suggestions on how I tell python3 to find the later Tcl/Tk instead of > the Apple one? > > Also just by the way, how in program code can you check the release level of > Tk or ttk? I have no direct experience with how the ActiveState folks package up their Python installers but my guess is that the Python 3.1 is launching in 64-bit mode and, at the moment, the only "standard" 64-bit non-X11 Tk is the one Apple supplies in 10.6 /System/Library. The A/S version probably attempts to use it in 64-bit mode. If you don't really need to run in 64-bit, try running it in 32-bit mode which may very well link with the A/S Tk 8.5. I expect that either of these should work: arch -i386 /usr/local/bin/python3.1 or arch -i386 /Library/Frameworks/Python.framework/Versions/3.1/bin/python3 You can tell which Tk is being linked to for the 32- and 64-bit version with: otool -L $(arch -i386 python3 -c 'import _tkinter;\ print(_tkinter.__file__)') otool -L $(arch -x86_64 python3 -c 'import _tkinter;\ print(_tkinter.__file__)') -- Ned Deily, nad at acm.org From sxn02 at yahoo.com Wed Nov 24 07:16:11 2010 From: sxn02 at yahoo.com (Sorin Schwimmer) Date: Tue, 23 Nov 2010 22:16:11 -0800 (PST) Subject: [Tkinter-discuss] simple scrollbar... not so simple Message-ID: <10315.1229.qm@web56001.mail.re3.yahoo.com> Hi all, I have a list of checkboxes and label/entry pairs which I'd like to have in a scrollable widget. So I built something like this (in this example I put just labels): from Tkinter import * r=Tk() tx=Text(r) # hosts the frames and allows scrollbar sb=Scrollbar(r,command=tx.yview) tx['yscrollcommand']=sb.set f=Frame(tx) # hosts my stuff f.grid() tx.grid() sb.grid(row=0,column=1,sticky=NS) for i in range(50): Label(f,text=('line #%d' % i)).grid() r.mainloop() The scrollbar appears, but is inactive (grayed out), and has no slider. What am I missing? Thanks, SxN From michael.odonnell at uam.es Wed Nov 24 08:58:10 2010 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Wed, 24 Nov 2010 08:58:10 +0100 Subject: [Tkinter-discuss] Posible SPAM: simple scrollbar... not so simple In-Reply-To: <10315.1229.qm@web56001.mail.re3.yahoo.com> References: <10315.1229.qm@web56001.mail.re3.yahoo.com> Message-ID: Hi Sorin, I gave up trying to get scrolling frames to work. Much simpler to do it with a Text widget. E.g, for a Text item WGT and a Button item btn: btn=Button(WGT, text="Do it", cmd=self.someCmd) WGT.window_create(END, window=btn) With this method, pack is not needed. The parent of the widgets that you place in the Text widget needs to be the Text widget. Mick On Wed, Nov 24, 2010 at 7:16 AM, Sorin Schwimmer wrote: > Hi all, > > I have a list of checkboxes and label/entry pairs which I'd like to have in a scrollable widget. > > So I built something like this (in this example I put just labels): > > from Tkinter import * > > r=Tk() > tx=Text(r) # hosts the frames and allows scrollbar > sb=Scrollbar(r,command=tx.yview) > tx['yscrollcommand']=sb.set > f=Frame(tx) # hosts my stuff > f.grid() > tx.grid() > sb.grid(row=0,column=1,sticky=NS) > for i in range(50): > ?Label(f,text=('line #%d' % i)).grid() > > r.mainloop() > > The scrollbar appears, but is inactive (grayed out), and has no slider. > > What am I missing? > > Thanks, > SxN > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From davecortesi at gmail.com Wed Nov 24 22:03:17 2010 From: davecortesi at gmail.com (David Cortesi) Date: Wed, 24 Nov 2010 13:03:17 -0800 Subject: [Tkinter-discuss] how make active python 3 use active tcl on mac os? In-Reply-To: References: Message-ID: well, this was interesting, I didn't know about arch. As you supposed, running python3 produces a Python process that Activity Monitor says is "Intel (64 bit)". However, arch -i386 python3 produces exactly the same thing as I get using arch -x86_64, namely, an Intel(64 bit) process (and loading the same _tkinter.so). Hmmm. This would suggest there is only the one architecture defined in its binary? applying otool -L to the _tkinter.so that python3 is loading reports "/System/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl" and etc, so indeed, the Apple Tcl is baked into the dynamic load lib distributed with Python3. I cannot find any other version of _tkinter.so that might have been installed by ActiveTcl. So I'm pretty baffled, as well as disappointed that there's been no response in the ActiveState "support" forum. However, thanks for your help! Dave Cortesi On Tue, Nov 23, 2010 at 5:11 PM, Ned Deily wrote: > > I have no direct experience with how the ActiveState folks package up > their Python installers but my guess is that the Python 3.1 is launching > in 64-bit mode and, at the moment, the only "standard" 64-bit non-X11 Tk > is the one Apple supplies in 10.6 /System/Library. The A/S version > probably attempts to use it in 64-bit mode. If you don't really need to > run in 64-bit, try running it in 32-bit mode which may very well link > with the A/S Tk 8.5. I expect that either of these should work: > > arch -i386 /usr/local/bin/python3.1 > arch -i386 /Library/Frameworks/Python.framework/Versions/3.1/bin/python3 > > You can tell which Tk is being linked to for the 32- and 64-bit version > with: > > otool -L $(arch -i386 python3 -c 'import _tkinter;\ > print(_tkinter.__file__)') > otool -L $(arch -x86_64 python3 -c 'import _tkinter;\ > print(_tkinter.__file__)') > > -- > Ned Deily, > nad at acm.org > > _______________________________________________ > 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 nad at acm.org Wed Nov 24 22:38:55 2010 From: nad at acm.org (Ned Deily) Date: Wed, 24 Nov 2010 13:38:55 -0800 Subject: [Tkinter-discuss] how make active python 3 use active tcl on mac os? References: Message-ID: In article , David Cortesi wrote: > well, this was interesting, I didn't know about arch. As you supposed, > running python3 produces a Python process that Activity Monitor says is > "Intel (64 bit)". > > However, arch -i386 python3 produces exactly the same thing as I get using > arch -x86_64, namely, an Intel(64 bit) process (and loading the same > _tkinter.so). Hmmm. This would suggest there is only the one architecture > defined in its binary? > > applying otool -L to the _tkinter.so that python3 is loading reports > "/System/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl" and etc, so > indeed, the Apple Tcl is baked into the dynamic load lib distributed with > Python3. > > I cannot find any other version of _tkinter.so that might have been > installed by ActiveTcl. So I'm pretty baffled, as well as disappointed that > there's been no response in the ActiveState "support" forum. Ah, sorry, I forgot this was 3.1: unless the ActiveState people backported some stuff from the upcoming Python 3.2, the "arch" trick won't work on OS X 10.6 to select between 32-bit and 64-bit modes. Check the framework bin directory (/Library/Frameworks/Python.framework/Versions/3.1/bin) for something like a python3-32 executable and, if found, try using that. -- Ned Deily, nad at acm.org From sxn02 at yahoo.com Thu Nov 25 00:30:34 2010 From: sxn02 at yahoo.com (Sorin Schwimmer) Date: Wed, 24 Nov 2010 15:30:34 -0800 (PST) Subject: [Tkinter-discuss] simple scrollbar... not so simple Message-ID: <510871.31565.qm@web56004.mail.re3.yahoo.com> Mick, you're right, Tkinter frames are not scrollable. That's why I'm nesting my frame into a Text widget... and am not getting anywhere :-( SxN From michael.odonnell at uam.es Thu Nov 25 09:14:53 2010 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Thu, 25 Nov 2010 09:14:53 +0100 Subject: [Tkinter-discuss] Posible SPAM: Re: simple scrollbar... not so simple In-Reply-To: <510871.31565.qm@web56004.mail.re3.yahoo.com> References: <510871.31565.qm@web56004.mail.re3.yahoo.com> Message-ID: Hi Sorin. Full example with at least vertical scrolling from Tkinter import * class ScrolledText(Frame): def __init__(self, master, **keywords): # Set some defaults if not keywords.has_key("width"): keywords["width"]=24 #if not keywords.has_key("height"): keywords["height"]=20 if not keywords.has_key("bg"): keywords["bg"]="white" if not keywords.has_key("relief"): keywords["relief"]="sunken" Frame.__init__(self, master) self.config(bg=keywords["bg"]) # Scrollbars scrollbar = Scrollbar(self, orient=VERTICAL) # Create the Text wgt self.text=Text(self, yscrollcommand=scrollbar.set, **keywords) scrollbar.config(command=self.text.yview) scrollbar.pack(side=RIGHT, fill=Y) self.text.pack(side=LEFT, fill=BOTH, expand=True) self.scroll=scrollbar tk = Tk() st=ScrolledText(tk) st.pack(expand=True, fill=BOTH) st.text.insert(END, "Buttons:\n") b1=Button(st.text, text="Hello 1") st.text.window_create(END, window=b1) st.text.insert(END, "\n") b2=Button(st.text, text="Hello 2") st.text.window_create(END, window=b2) tk.mainloop() On Thu, Nov 25, 2010 at 12:30 AM, Sorin Schwimmer wrote: > Mick, you're right, Tkinter frames are not scrollable. That's why I'm nesting my frame into a Text widget... and am not getting anywhere :-( > > SxN > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From michael.odonnell at uam.es Thu Nov 25 09:20:45 2010 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Thu, 25 Nov 2010 09:20:45 +0100 Subject: [Tkinter-discuss] how make active python 3 use active tcl on mac os? In-Reply-To: References: Message-ID: Hi David, Sorry for a vague answer, but I had similar problems some years ago and the solution was to recompile python, and in a particular file put the search path for the tk library. Can't remember offhand which file, Mick On Wed, Nov 24, 2010 at 10:38 PM, Ned Deily wrote: > In article > , > ?David Cortesi wrote: > >> well, this was interesting, I didn't know about arch. As you supposed, >> running python3 produces a Python process that Activity Monitor says is >> "Intel (64 bit)". >> >> However, arch -i386 python3 produces exactly the same thing as I get using >> arch -x86_64, namely, an Intel(64 bit) process (and loading the same >> _tkinter.so). Hmmm. This would suggest there is only the one architecture >> defined in its binary? >> >> applying otool -L to the _tkinter.so that python3 is loading reports >> "/System/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl" and etc, so >> indeed, the Apple Tcl is baked into the dynamic load lib distributed with >> Python3. >> >> I cannot find any other version of _tkinter.so that might have been >> installed by ActiveTcl. So I'm pretty baffled, as well as disappointed that >> there's been no response in the ActiveState "support" forum. > > Ah, sorry, I forgot this was 3.1: unless the ActiveState people > backported some stuff from the upcoming Python 3.2, the "arch" trick > won't work on OS X 10.6 to select between 32-bit and 64-bit modes. > Check the framework bin directory > (/Library/Frameworks/Python.framework/Versions/3.1/bin) for something > like a python3-32 executable and, if found, try using that. > > -- > ?Ned Deily, > ?nad at acm.org > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From klappnase at web.de Thu Nov 25 11:07:46 2010 From: klappnase at web.de (Michael Lange) Date: Thu, 25 Nov 2010 11:07:46 +0100 Subject: [Tkinter-discuss] how make active python 3 use active tcl on mac os? In-Reply-To: References: Message-ID: <20101125110746.2006b3ad.klappnase@web.de> Hi, Thus spoketh "Michael O'Donnell" unto us on Thu, 25 Nov 2010 09:20:45 +0100: > Hi David, > > Sorry for a vague answer, but I had similar problems > some years ago and the solution was to recompile > python, and in a particular file put the search path > for the tk library. > > Can't remember offhand which file, I don't know about the mac, here on debian linux I have to do export LD_LIBRARY_PATH=/usr/local/lib before compiling Python, otherwise it fails to find Tcl/Tk. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. I've already got a female to worry about. Her name is the Enterprise. -- Kirk, "The Corbomite Maneuver", stardate 1514.0 From klappnase at web.de Thu Nov 25 11:17:01 2010 From: klappnase at web.de (Michael Lange) Date: Thu, 25 Nov 2010 11:17:01 +0100 Subject: [Tkinter-discuss] simple scrollbar... not so simple In-Reply-To: <510871.31565.qm@web56004.mail.re3.yahoo.com> References: <510871.31565.qm@web56004.mail.re3.yahoo.com> Message-ID: <20101125111701.7147e2ab.klappnase@web.de> Hi, Thus spoketh Sorin Schwimmer unto us on Wed, 24 Nov 2010 15:30:34 -0800 (PST): > Mick, you're right, Tkinter frames are not scrollable. That's why I'm > nesting my frame into a Text widget... and am not getting anywhere :-( That's not exactly true, for example look at the Pmw.ScrolledFrame which works very well. I have also seen other solutions here and there, but imho the Pmw.ScrolledFrame is the best (at least once you found out how to set up the widget's options :) , so I wouldn't bother setting up my own scrolled frame widget. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. No one wants war. -- Kirk, "Errand of Mercy", stardate 3201.7 From sxn02 at yahoo.com Fri Nov 26 07:30:26 2010 From: sxn02 at yahoo.com (Sorin Schwimmer) Date: Thu, 25 Nov 2010 22:30:26 -0800 (PST) Subject: [Tkinter-discuss] simple scrollbar... not so simple Message-ID: <795150.12969.qm@web56007.mail.re3.yahoo.com> Mick, you saved me! My test code looks now like this (I hope HTML tags are honoured): from Tkinter import * r=Tk() tx=Text(r,width=6) # hosts the frames and allows scrollbar sb=Scrollbar(r,command=tx.yview) tx['yscrollcommand']=sb.set f=Frame(tx) # hosts my stuff tx.window_create(END,window=f) tx.grid() sb.grid(row=0,column=1,sticky=NS) for i in range(50): Label(f,text=('line #%d' % i)).grid() r.mainloop() Instead of "grid" for the frame, I used a "window_create", as per your example, and ta-da! it works. The Text width is an arbitrary 6, I don't know how to make it as large as the frame, but not larger, and I also don't know how to show the scroll bar only when needed. But I can live with these two minor shortcomings, and the real application behaves fine. Thank you SxN From sridharr at activestate.com Sat Nov 27 03:01:30 2010 From: sridharr at activestate.com (Sridhar Ratnakumar) Date: Fri, 26 Nov 2010 18:01:30 -0800 Subject: [Tkinter-discuss] how make active python 3 use active tcl on mac os? In-Reply-To: References: Message-ID: <4CF0667A.1040704@activestate.com> On 11/24/2010 1:38 PM, Ned Deily wrote: > Ah, sorry, I forgot this was 3.1: unless the ActiveState people > backported some stuff from the upcoming Python 3.2, the "arch" trick > won't work on OS X 10.6 to select between 32-bit and 64-bit modes. > Check the framework bin directory > (/Library/Frameworks/Python.framework/Versions/3.1/bin) for something > like a python3-32 executable and, if found, try using that. Are you sure `python3-32` (and `python3-64`) are included in Python 3.1.2, or is this something new in 3.1.3 (svn)? I certainly don't see the -32/-64 binaries in ActivePython 3.1.2.4 (based on Python 3.1.2). So if 3.1.2 is supposed to generate these - then this is an ActivePython bug that needs to be fixed. -srid PS: I've responded to the original query here http://goo.gl/LhImx From davecortesi at gmail.com Sat Nov 27 03:12:17 2010 From: davecortesi at gmail.com (David Cortesi) Date: Fri, 26 Nov 2010 18:12:17 -0800 Subject: [Tkinter-discuss] how make active python 3 use active tcl on mac os? In-Reply-To: <4CF0667A.1040704@activestate.com> References: <4CF0667A.1040704@activestate.com> Message-ID: On Fri, Nov 26, 2010 at 6:01 PM, Sridhar Ratnakumar wrote: > On 11/24/2010 1:38 PM, Ned Deily wrote: >> >> Check the framework bin directory >> (/Library/Frameworks/Python.framework/Versions/3.1/bin) for something >> like a python3-32 executable and, if found, try using that. > > I certainly don't see the -32/-64 binaries in ActivePython 3.1.2.4 (based on > Python 3.1.2). So if 3.1.2 is supposed to generate these - then this is an > ActivePython bug that needs to be fixed. I didn't find them; I should have replied to Ned's comment. The ActivePython 3.1.2.4 interpreter is I believe intel-only (not a 'fat' binary with PPC code too) and 64-bit only. Don't know if this is a bug or not (probably not). What appears to be a bug or at least an oversight, is that it can't call ActiveTcl; it's linked to the Apple Tcl. From nad at acm.org Sat Nov 27 04:24:26 2010 From: nad at acm.org (Ned Deily) Date: Fri, 26 Nov 2010 19:24:26 -0800 Subject: [Tkinter-discuss] how make active python 3 use active tcl on mac os? References: <4CF0667A.1040704@activestate.com> Message-ID: In article <4CF0667A.1040704 at activestate.com>, > Are you sure `python3-32` (and `python3-64`) are included in Python > 3.1.2, or is this something new in 3.1.3 (svn)? 3.1.2 and 3.1.3 should be identical in that respect. The most recent 3.1.2 installers with 32-bit/64-bit support that I built (around 3.1.2rc1 time) had them: $cd /Library/Frameworks/Python.framework/Versions/3.1/bin $ ls -l total 528 lrwxr-xr-x 1 root admin 8 Nov 26 18:38 2to3@ -> 2to3-3.1 -rwxrwxr-x 1 root admin 150 Mar 17 2010 2to3-3.1* lrwxr-xr-x 1 root admin 7 Nov 26 18:38 idle3@ -> idle3.1 -rwxrwxr-x 1 root admin 138 Mar 17 2010 idle3.1* lrwxr-xr-x 1 root admin 8 Nov 26 18:38 pydoc3@ -> pydoc3.1 -rwxrwxr-x 1 root admin 123 Mar 17 2010 pydoc3.1* -rwxrwxr-x 2 root admin 24968 Mar 17 2010 python3* lrwxr-xr-x 1 root admin 12 Nov 26 18:38 python3-32@ -> python3.1-32 lrwxr-xr-x 1 root admin 12 Nov 26 18:38 python3-64@ -> python3.1-64 lrwxr-xr-x 1 root admin 13 Nov 26 18:38 python3-all@ -> python3.1-all lrwxr-xr-x 1 root admin 16 Nov 26 18:38 python3-config@ -> python3.1-config lrwxr-xr-x 1 root admin 12 Nov 26 18:38 python3.1@ -> python3.1-32 -rwxrwxr-x 2 root admin 24968 Mar 17 2010 python3.1-32* -rwxrwxr-x 1 root admin 24968 Mar 17 2010 python3.1-64* -rwxrwxr-x 1 root admin 24968 Mar 17 2010 python3.1-all* -rwxrwxr-x 1 root admin 1440 Mar 17 2010 python3.1-config* lrwxr-xr-x 1 root admin 13 Nov 26 18:38 pythonw3@ -> pythonw3.1-32 lrwxr-xr-x 1 root admin 13 Nov 26 18:38 pythonw3-32@ -> pythonw3.1-32 lrwxr-xr-x 1 root admin 13 Nov 26 18:38 pythonw3-64@ -> pythonw3.1-64 lrwxr-xr-x 1 root admin 14 Nov 26 18:38 pythonw3-all@ -> pythonw3.1-all lrwxr-xr-x 1 root admin 13 Nov 26 18:38 pythonw3.1@ -> pythonw3.1-32 -rwxrwxr-x 1 root admin 24968 Mar 17 2010 pythonw3.1-32* -rwxrwxr-x 1 root admin 24968 Mar 17 2010 pythonw3.1-64* -rwxrwxr-x 1 root admin 24968 Mar 17 2010 pythonw3.1-all* $ python3.1-32 -c 'import sys;print(sys.maxsize)' 2147483647 $ python3.1-64 -c 'import sys;print(sys.maxsize)' 9223372036854775807 > I certainly don't see the -32/-64 binaries in ActivePython 3.1.2.4 > (based on Python 3.1.2). So if 3.1.2 is supposed to generate these - > then this is an ActivePython bug that needs to be fixed. As I noted earlier, 32-bit/64-bit 3.1 (and 2.6, for that matter) builds do not support architecture selection via the arch command on 10.6, which will always prefer to launch 64-bit if possible. A feature was added to 2.7 and 3.2 to support this. For 2.6 and 3.1 systems, the standard ./configure options --with-universal-archs="3-way", "intel" or "all" create the separate 32- and -64-bit executables. Running on 10.6 you can see the problem with the ActivePython 3.1.2.4 - it always runs in 64-bit mode: $ python3.1 ActivePython 3.1.2.4 (ActiveState Software Inc.) based on Python 3.1.2 (r312:79147, Oct 22 2010, 10:36:09) [GCC 4.2.1 (Apple Inc. build 5664)] on darwin Type "help", "copyright", "credits" or "license" for more information. Module readline not available. >>> import sys >>> sys.maxsize 9223372036854775807 >>> ^D $ arch -i386 python3.1 -c 'import sys;print(sys.maxsize)' 9223372036854775807 $ arch -x86_64 python3.1 -c 'import sys;print(sys.maxsize)' 9223372036854775807 (Also, I don't have a 10.5 Intel system handy at the moment but I wonder how the ActivePython Tkinter would work at all there since there is no /System/Library/Frameworks/Tk.framework/Versions/8.5/Tcl or Tk). -- Ned Deily, nad at acm.org From davecortesi at gmail.com Sat Nov 27 18:29:47 2010 From: davecortesi at gmail.com (David Cortesi) Date: Sat, 27 Nov 2010 09:29:47 -0800 Subject: [Tkinter-discuss] how make active python 3 use active tcl on mac os? In-Reply-To: References: <4CF0667A.1040704@activestate.com> Message-ID: On Fri, Nov 26, 2010 at 7:24 PM, Ned Deily wrote: > In article <4CF0667A.1040704 at activestate.com>, >> Are you sure `python3-32` (and `python3-64`) are included in Python >> 3.1.2, or is this something new in 3.1.3 (svn)? > > 3.1.2 and 3.1.3 should be identical in that respect. The most recent > 3.1.2 installers with 32-bit/64-bit support that I built (around > 3.1.2rc1 time) had them: > Well, I was afraid I'd have to make an embarrassed apology for overlooking them, but no, or at least not just yet. This is an install from last week: [Sat 11/27] cd /Library/Frameworks/Python.framework/Versions/Current/bin [Sat 11/27] ls -l python* -rwxr-xr-x 2 root admin 24968 Oct 22 10:40 python3* lrwxr-xr-x 1 root admin 16 Nov 25 14:47 python3-config@ -> python3.1-config -rwxr-xr-x 2 root admin 24968 Oct 22 10:40 python3.1* -rwxr-xr-x 1 root admin 1440 Oct 22 10:39 python3.1-config* -rwxr-xr-x 1 root admin 368 Oct 22 10:40 pythonselect* lrwxr-xr-x 1 root admin 10 Nov 25 14:47 pythonw3@ -> pythonw3.1 -rwxr-xr-x 1 root admin 24968 Oct 22 10:40 pythonw3.1* I'd love to see the -32/-64 versions turning up but I did a find at the /Library level for '*-32*' and didn't see them. -------------- next part -------------- An HTML attachment was scrubbed... URL: From nad at acm.org Sat Nov 27 20:53:30 2010 From: nad at acm.org (Ned Deily) Date: Sat, 27 Nov 2010 11:53:30 -0800 Subject: [Tkinter-discuss] how make active python 3 use active tcl on mac os? References: <4CF0667A.1040704@activestate.com> Message-ID: In article , David Cortesi wrote: > On Fri, Nov 26, 2010 at 7:24 PM, Ned Deily wrote: > > In article <4CF0667A.1040704 at activestate.com>, > >> Are you sure `python3-32` (and `python3-64`) are included in Python > >> 3.1.2, or is this something new in 3.1.3 (svn)? > > > > 3.1.2 and 3.1.3 should be identical in that respect. The most recent > > 3.1.2 installers with 32-bit/64-bit support that I built (around > > 3.1.2rc1 time) had them: Just to be clear: I was talking about test installers for the python.org OS X distribution. Srid is the person to talk to about the ActiveState Python distributions so I'm going to bow out of this discussion now. -- Ned Deily, nad at acm.org From rowen at uw.edu Mon Nov 29 20:18:26 2010 From: rowen at uw.edu (Russell E. Owen) Date: Mon, 29 Nov 2010 11:18:26 -0800 Subject: [Tkinter-discuss] how make active python 3 use active tcl on mac os? References: Message-ID: In article , David Cortesi wrote: > I apologize that this question is somewhat unique to the ActiveState free > products, not the generic Python. I asked the question at the ActiveState > support forum but it appears to be dead. > > I installed ActiveState Python 3.1.4, and also ActiveState Tcl/Tk, both on > Mac OS X 10.6. > > Python3 executing "import * from tkinter" is getting and executing the Apple > version of Tcl/Tk which is level 8.5.7. It appears to be getting it from > /System/Library/Frameworks/Tk.framework and Tcl.framework. > > The ActiveTc (level 8.5.9) is in /Library/Frameworks rather than > /System/Library Frameworks. It contains a bug fix that I need. > > Any suggestions on how I tell python3 to find the later Tcl/Tk instead of > the Apple one? > > Also just by the way, how in program code can you check the release level of > Tk or ttk? > > Thanks, > > Dave Cortesi > --------------------------------------------------------------------- > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss I suggest you try python.org python instead of ActiveState Python. At least for 2.6 and 2.7 it will preferentially use ActiveState's Tcl/Tk if found. However, I have not confirmed that with python.org Python 3.1 and I don't know what major version of Tcl/Tk it wants (8.4, 8.5 or 8.6). -- Russell From sridharr at activestate.com Mon Nov 29 23:35:04 2010 From: sridharr at activestate.com (Sridhar Ratnakumar) Date: Mon, 29 Nov 2010 14:35:04 -0800 Subject: [Tkinter-discuss] how make active python 3 use active tcl on mac os? In-Reply-To: References: <4CF0667A.1040704@activestate.com> Message-ID: <1D6567F5-AD77-48DB-96A1-3C8610CEC68F@activestate.com> On 2010-11-26, at 7:24 PM, Ned Deily wrote: >> >> I certainly don't see the -32/-64 binaries in ActivePython 3.1.2.4 >> (based on Python 3.1.2). So if 3.1.2 is supposed to generate these - >> then this is an ActivePython bug that needs to be fixed. > > As I noted earlier, 32-bit/64-bit 3.1 (and 2.6, for that matter) builds > do not support architecture selection via the arch command on 10.6, > which will always prefer to launch 64-bit if possible. A feature was > added to 2.7 and 3.2 to support this. For 2.6 and 3.1 systems, the > standard ./configure options --with-universal-archs="3-way", "intel" or > "all" create the separate 32- and -64-bit executables. Running on 10.6 > you can see the problem with the ActivePython 3.1.2.4 - it always runs > in 64-bit mode: Ok, thanks for this background information. Strangely enough, when I now build ActivePython 3.1.3.5 (to be released by end of this week), I see the -32/-64/-all binaries. It was only missing from the 3.1.2.4 build (was it because of having 3.1.2.3 - ppc+i386 - in /Lib/Frmwrk?). Using the same build: $ python3.1-64 -c 'import sys;print(sys.maxsize)' 9223372036854775807 $ python3.1-32 -c 'import sys;print(sys.maxsize)' 2147483647 Further I will also update the FAQ , which is incorrectly suggesting `arch` for 2.6 and 3.1 too. -srid From davecortesi at gmail.com Tue Nov 30 00:59:07 2010 From: davecortesi at gmail.com (David Cortesi) Date: Mon, 29 Nov 2010 15:59:07 -0800 Subject: [Tkinter-discuss] how make active python 3 use active tcl on mac os? In-Reply-To: References: Message-ID: On Mon, Nov 29, 2010 at 11:18 AM, Russell E. Owen wrote: > > I suggest you try python.org python instead of ActiveState Python. At > least for 2.6 and 2.7 it will preferentially use ActiveState's Tcl/Tk if > found. However, I have not confirmed that with python.org Python 3.1 and > I don't know what major version of Tcl/Tk it wants (8.4, 8.5 or 8.6). > > Re the last, _tkinter.c in the Python 3.1.3 dist says, "Only Tcl/Tk 8.3.1 and later are supported." The version distributed with Mac OS 10.6 is 8.5.7 and ActiveState is currently 8.5.9. Re the main suggestion, apparently the only way to get Python3 for OS X from Python.org is to download the source and build it. I have (you can see) downloaded the package but frankly I find the build instructions in configure* and in the global README and Mac/README to be head-spinning. Yeah, sure, it's just configure; make; sudo make install; -- except if I want it in /Library/Frameworks, it's configure --enable-framework, plus if I want the 32- and 64-bit versions, it's configure --enable-framework --enable-universalsdk --with-universal-archs=intel ... I think. Supposing I did this, will this fix the original problem that I started out to solve, namely, getting Python3 to link to ActiveTCL? It seems not, because Mac/README says "If you want Tkinter support you need to get the OSX AquaTk distribution, this is installed by default on Mac OS X 10.4 or later." In other words, it's going to build _tkinter.so to use */System*/Library/Frameworks/Tcl (Apple's) and not /Library/Frameworks/Tcl (Active's). Where is that configured? I've no idea. Dave Cortesi -------------- next part -------------- An HTML attachment was scrubbed... URL: From rowen at uw.edu Tue Nov 30 01:37:02 2010 From: rowen at uw.edu (Russell Owen) Date: Mon, 29 Nov 2010 16:37:02 -0800 Subject: [Tkinter-discuss] how make active python 3 use active tcl on mac os? In-Reply-To: References: Message-ID: On Nov 29, 2010, at 3:59 PM, David Cortesi wrote: > > On Mon, Nov 29, 2010 at 11:18 AM, Russell E. Owen > wrote: > > I suggest you try python.org python instead of ActiveState Python. At > least for 2.6 and 2.7 it will preferentially use ActiveState's Tcl/ > Tk if > found. However, I have not confirmed that with python.org Python 3.1 > and > I don't know what major version of Tcl/Tk it wants (8.4, 8.5 or 8.6). > > > Re the last, _tkinter.c in the Python 3.1.3 dist says, "Only Tcl/Tk > 8.3.1 and later are supported." The version distributed with Mac OS > 10.6 is 8.5.7 and ActiveState is currently 8.5.9. > > Re the main suggestion, apparently the only way to get Python3 for > OS X from Python.org is to download the source and build it. It does appear that the Mac installer is not yet available. There is such an installer for Python 3.1.2: if you can live with the previous version. > I have (you can see) downloaded the package but frankly I find the > build instructions in configure* and in the global README and Mac/ > README to be head-spinning. Yeah, sure, it's just configure; make; > sudo make install; -- except if I want it in /Library/Frameworks, > it's configure --enable-framework, plus if I want the 32- and 64-bit > versions, it's configure --enable-framework --enable-universalsdk -- > with-universal-archs=intel ... I think. That sounds plausible, but I confess I've not tried it. Do you really need both 32 and 64 bit versions? --enable-framework is essential if you want Aqua Tcl/Tk (it might be the default on Mac OS X, but I prefer not to risk it). > Supposing I did this, will this fix the original problem that I > started out to solve, namely, getting Python3 to link to ActiveTCL? > It seems not, because Mac/README says "If you want Tkinter support > you need to get the OSX AquaTk distribution, this is installed by > default on Mac OS X 10.4 or later." In other words, it's going to > build _tkinter.so to use /System/Library/Frameworks/Tcl (Apple's) > and not /Library/Frameworks/Tcl (Active's). Where is that > configured? I've no idea. I think you are misinterpreting the README. In the past whenever I have built Python from source it has used my own Tcl/Tk (which is from ActiveState). I would be very surprised if that has changed. -- Russell -------------- next part -------------- An HTML attachment was scrubbed... URL: From nad at acm.org Tue Nov 30 06:06:08 2010 From: nad at acm.org (Ned Deily) Date: Mon, 29 Nov 2010 21:06:08 -0800 Subject: [Tkinter-discuss] how make active python 3 use active tcl on mac os? References: Message-ID: In article , David Cortesi wrote: > Supposing I did this, will this fix the original problem that I started out > to solve, namely, getting Python3 to link to ActiveTCL? It seems not, > because Mac/README says "If you want Tkinter support you need to get the OSX > AquaTk distribution, this is installed by default on Mac OS X 10.4 or > later." In other words, it's going to build _tkinter.so to use > */System*/Library/Frameworks/Tcl > (Apple's) and not /Library/Frameworks/Tcl (Active's). Where is that > configured? I've no idea. Don't bother building it yourself. Either use the 3.1.2 installer from here: http://www.python.org/download/releases/3.1.2/ or wait a bit until the 3.1.3 OS X installer becomes available (I don't know how long that will be). Either way, the 32-bit Pythons installed by the python.org installers will use an ActiveState Tcl/Tk 8.4 (from /Library/Frameworks) if available at run time, otherwise they will use the Apple-installed Tcl/Tk 8.4 in /System/Library/Frameworks. -- Ned Deily, nad at acm.org From python at bdurham.com Tue Nov 30 08:46:46 2010 From: python at bdurham.com (python at bdurham.com) Date: Tue, 30 Nov 2010 02:46:46 -0500 Subject: [Tkinter-discuss] Tkinter support different styles of underlining? Message-ID: <1291103206.24625.1407828653@webmail.messagingengine.com> Does Tkinter (directly of via tk/tcl) support different styles of underlining, eg. dotted underlines or squiggly underlines (typically used to indicate a word is misspelled in MS Word or FireFox)? Thank you, Malcolm -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at bdurham.com Tue Nov 30 08:51:49 2010 From: python at bdurham.com (python at bdurham.com) Date: Tue, 30 Nov 2010 02:51:49 -0500 Subject: [Tkinter-discuss] Possible to create equivalent of named font objects for colors? Message-ID: <1291103509.26051.1407830119@webmail.messagingengine.com> Tkinter has a cool way to create named font objects that can be used across widgets. When a named font object is updated, all the widgets that use the named font automatically update their fonts as well. Is there a similar way to implement "named colors", eg. where we can update a "color object" in one place and have all widgets that reference this color object update their colors as well? Thank you, Malcolm -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Tue Nov 30 19:13:22 2010 From: klappnase at web.de (Michael Lange) Date: Tue, 30 Nov 2010 19:13:22 +0100 Subject: [Tkinter-discuss] Possible to create equivalent of named font objects for colors? In-Reply-To: <1291103509.26051.1407830119@webmail.messagingengine.com> References: <1291103509.26051.1407830119@webmail.messagingengine.com> Message-ID: <20101130191322.c9515bbe.klappnase@web.de> Hi, Thus spoketh python at bdurham.com unto us on Tue, 30 Nov 2010 02:51:49 -0500: > Tkinter has a cool way to create named font objects that can be > used across widgets. When a named font object is updated, all the > widgets that use the named font automatically update their fonts > as well. > > Is there a similar way to implement "named colors", eg. where we > can update a "color object" in one place and have all widgets > that reference this color object update their colors as well? This is #30 on the Tk-9.0 wishlist, see: http://wiki.tcl.tk/4055 and to implement this in Python is surely not trivial, so I doubt that such a thing exists (though I agree to you that it would be desirable). Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. "Get back to your stations!" "We're beaming down to the planet, sir." -- Kirk and Mr. Leslie, "This Side of Paradise", stardate 3417.3 From klappnase at web.de Tue Nov 30 20:01:07 2010 From: klappnase at web.de (Michael Lange) Date: Tue, 30 Nov 2010 20:01:07 +0100 Subject: [Tkinter-discuss] Tkinter support different styles of underlining? In-Reply-To: <1291103206.24625.1407828653@webmail.messagingengine.com> References: <1291103206.24625.1407828653@webmail.messagingengine.com> Message-ID: <20101130200107.4cfdbb16.klappnase@web.de> Hi, Thus spoketh python at bdurham.com unto us on Tue, 30 Nov 2010 02:46:46 -0500: > Does Tkinter (directly of via tk/tcl) support different styles of > underlining, eg. dotted underlines or squiggly underlines > (typically used to indicate a word is misspelled in MS Word or > FireFox)? I don't think so, I guess tk internally simply uses an underlined font. However, if you want to use a text widget, you may want to look at the text man page, section TAGS, option bgstipple: -bgstipple bitmap Bitmap specifies a bitmap that is used as a stipple pattern for the background. It may have any of the forms accepted by Tk_GetBitmap. If bitmap has not been specified, or if it is specified as an empty string, then a solid fill will be used for the background. Maybe it is possible to set up a "misspelled" tag using an appropriate bitmap, though it might take some tweaking to adapt one bitmap to be usable with any given font. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. There is an old custom among my people. When a woman saves a man's life, he is grateful. -- Nona, the Kanuto witch woman, "A Private Little War", stardate 4211.8.