From subscriptions at cagttraining.com Thu Apr 12 14:32:58 2012 From: subscriptions at cagttraining.com (Bill Felton) Date: Thu, 12 Apr 2012 08:32:58 -0400 Subject: [Tkinter-discuss] Questions about treeview Message-ID: <0BBDC341-E187-41D8-9DDE-829899E90F4A@cagttraining.com> Hi all, Is it true that the ttk treeview widget 'swallows' right-mouse clicks? We have a need that could be met with the treeview if we could only figure out how to get pop-up menus to work in that widget. Our tests seem to show that regardless of where in the containment structure one binds (widget, frmae, outframe, window, app), if the widget at the "bottom" of the stack is a treeview, the mouse button-2 event will not be caught. Also, are there plans to fix the current problems with horizontal scrolling in treeviews? We have used the work-around of having an empty data column that the user can drag to the right; once the drag moves past the visible bounds of the frame containing the treeview the horizontal scrollbar appears. This seems clumsy and un-intuitive, so we're hoping there's another, better, way to get horizontal scrolling to work. regards, Bill From klappnase at web.de Thu Apr 12 16:17:48 2012 From: klappnase at web.de (Michael Lange) Date: Thu, 12 Apr 2012 16:17:48 +0200 Subject: [Tkinter-discuss] Questions about treeview In-Reply-To: <0BBDC341-E187-41D8-9DDE-829899E90F4A@cagttraining.com> References: <0BBDC341-E187-41D8-9DDE-829899E90F4A@cagttraining.com> Message-ID: <20120412161748.9a4c4209.klappnase@web.de> Hi Bill, Thus spoketh Bill Felton unto us on Thu, 12 Apr 2012 08:32:58 -0400: > Hi all, > Is it true that the ttk treeview widget 'swallows' right-mouse clicks? > We have a need that could be met with the treeview if we could only > figure out how to get pop-up menus to work in that widget. Our tests > seem to show that regardless of where in the containment structure one > binds (widget, frmae, outframe, window, app), if the widget > at the "bottom" of the stack is a treeview, the mouse button-2 event > will not be caught. Maybe you simply confuse Button-2 (the button in the middle, under the wheel) and Button-3 ? The following code works here just as expected: from Tkinter import * import ttk root = Tk() t = ttk.Treeview(root) t.pack(fill='both', expand=1) def test(event): print 'hi' t.bind('<3>', test) root.mainloop() > > Also, are there plans to fix the current problems with horizontal > scrolling in treeviews? We have used the work-around of having an > empty data column that the user can drag to the right; once the drag > moves past the visible bounds of the frame containing the treeview the > horizontal scrollbar appears. This seems clumsy and un-intuitive, so > we're hoping there's another, better, way to get horizontal scrolling > to work. I haven't used the treeview much yet, so maybe I am missing something, but I do not see any way to do it. Maybe the problem is the way ttk reports the widget width to the window manager, just a guess though. For some reason you cannot configure the width of a treeview, maybe this is related. I am not sure if this is intentional or a bug, but I am afraid there is not much we can do here, the problem is apparently on the Tcl/Tk side. Maybe you could file a bug report there? Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. No one can guarantee the actions of another. -- Spock, "Day of the Dove", stardate unknown From subscriptions at cagttraining.com Thu Apr 12 17:22:15 2012 From: subscriptions at cagttraining.com (Bill Felton) Date: Thu, 12 Apr 2012 11:22:15 -0400 Subject: [Tkinter-discuss] Questions about treeview In-Reply-To: <20120412161748.9a4c4209.klappnase@web.de> References: <0BBDC341-E187-41D8-9DDE-829899E90F4A@cagttraining.com> <20120412161748.9a4c4209.klappnase@web.de> Message-ID: <35221B91-CC55-4295-A223-ED9E5651809B@cagttraining.com> Hi Michael, On Apr 12, 2012, at 10:17 AM, Michael Lange wrote: >> Is it true that the ttk treeview widget 'swallows' right-mouse clicks? >> We have a need that could be met with the treeview if we could only >> figure out how to get pop-up menus to work in that widget. Our tests >> seem to show that regardless of where in the containment structure one >> binds (widget, frmae, outframe, window, app), if the widget >> at the "bottom" of the stack is a treeview, the mouse button-2 event >> will not be caught. > > Maybe you simply confuse Button-2 (the button in the middle, under the > wheel) and Button-3 ? The following code works here just as expected: > > from Tkinter import * > import ttk > root = Tk() > t = ttk.Treeview(root) > t.pack(fill='both', expand=1) > > def test(event): > print 'hi' > > t.bind('<3>', test) > root.mainloop() I'm working on both Mac and PC with a test for which is current, so using the correct button depending. I know I've got that part right because I get pop-ups everywhere else I expect/need them, just not in the tree. I'm going to do some more testing as another review of the code, and an attempt to mirror your simple test, shows that it's still not working as I would expect, BUT the problem could lie in some wrapper code that exists between the treeview and the parent window. I'll post a follow-up if I can't get things to work. >> Also, are there plans to fix the current problems with horizontal >> scrolling in treeviews? We have used the work-around of having an >> empty data column that the user can drag to the right; once the drag >> moves past the visible bounds of the frame containing the treeview the >> horizontal scrollbar appears. This seems clumsy and un-intuitive, so >> we're hoping there's another, better, way to get horizontal scrolling >> to work. > > I haven't used the treeview much yet, so maybe I am missing something, > but I do not see any way to do it. Maybe the problem is the way > ttk reports the widget width to the window manager, just a guess though. > For some reason you cannot configure the width of a treeview, maybe this > is related. I am not sure if this is intentional or a bug, but I am afraid > there is not much we can do here, the problem is apparently on the Tcl/Tk > side. Maybe you could file a bug report there? > > Regards > > Michael Thanks, I appreciate the situation and will try to get a bug report filed with them. regards, Bill From fukuda_shozo at yahoo.co.jp Fri Apr 13 17:23:20 2012 From: fukuda_shozo at yahoo.co.jp (shoz) Date: Sat, 14 Apr 2012 00:23:20 +0900 Subject: [Tkinter-discuss] TkPhotoImage data-option Message-ID: <4F8844E8.8040101@yahoo.co.jp> Hello, Developers I modified Tkinter on Python 2.7 and use it every time. Because original Tkinter dosen't execute the following code well: f = open("apple.ppm", "rb") pho = Tk.PhotoImage(data=f.read()) I found out what is wrong in Tkinter implement and fixed it. That is: *** org/_tkinter.c --- new/_tkinter.c *************** *** 947,954 **** Tcl_Obj *result; if (PyString_Check(value)) ! return Tcl_NewStringObj(PyString_AS_STRING(value), PyString_GET_SIZE(value)); else if (PyBool_Check(value)) return Tcl_NewBooleanObj(PyObject_IsTrue(value)); else if (PyInt_Check(value)) --- 947,954 ---- Tcl_Obj *result; if (PyString_Check(value)) ! return Tcl_NewByteArrayObj(PyString_AS_STRING(value), PyString_GET_SIZE(value)); else if (PyBool_Check(value)) return Tcl_NewBooleanObj(PyObject_IsTrue(value)); else if (PyInt_Check(value)) The reason seems that Tcl_NewStringObj() expects UTF-8 string as input but PyString_AS_STRING() returns ascii string. Dose anyone verify whether my fixed code is correct or not. Best regards. Shozo From memilanuk at gmail.com Sun Apr 15 01:36:07 2012 From: memilanuk at gmail.com (Monte Milanuk) Date: Sat, 14 Apr 2012 23:36:07 +0000 (UTC) Subject: [Tkinter-discuss] Glade for Tkinter? Message-ID: Has anyone ever considered such a beast? Seems like Glade continues to be popular, and it appears possible to utilize it for other gui packages like wxpython (e.g. wxGlade)... Its far beyond my current (mostly nonexistent) abilities since I'm just a beginner, so you can skip the 'great idea, go for it!' bit ;) It just occurred to me that it might make a good idea for a summer of code project or something like that. Monte From raycores at gmail.com Wed Apr 18 22:57:41 2012 From: raycores at gmail.com (Lynn Oliver) Date: Wed, 18 Apr 2012 13:57:41 -0700 Subject: [Tkinter-discuss] problem changing font settings for ttk themed widgets on Windows Message-ID: <5C37009D-6501-4063-9402-BAE1319F2E9B@gmail.com> On OS X, ttk.Style().configure('TLabelframe.label', font='helvetica 14 bold') works to change the font used by the ttk.LabelFrame widget. On Windows, ttk.Style().configure('TLabelframe.label', font='arial 14 bold') has no effect other than causing ttk.Style().lookup('TLabelframe.label','font' to return the changed font info. ttkButton and ttk.CheckButton also do not allow the font to be changed on Windows. ttk.Label does allow the font to change. I tried creating a derived style but that doesn't work either. Changing the font setting in python27/tcl/tk8.5/ttk/xpTheme.tcl does change the font being displayed. Removing the -font TkDefaultFont setting from the theme settings does not change what is displayed or allow the font to be changed. Any suggestions as to how this actually works? -------------- next part -------------- An HTML attachment was scrubbed... URL: From bharath270392 at gmail.com Thu Apr 19 17:32:58 2012 From: bharath270392 at gmail.com (Bharath Reddy A.) Date: Thu, 19 Apr 2012 21:02:58 +0530 Subject: [Tkinter-discuss] Tkinter GUI freezing Message-ID: Hi all, I have created a GUI using Tkinter. I have a button "GO", which when clicked calls a function (mainFunc). That function takes around 60 seconds to execute and in the mean time outputs many numbers which have to be displayed in a list in the GUI. I have attempted the following: 1. I created a thread whose target = mainFunc, when the button is clicked. I can see the function printing stuff in terminal. But the GUI still freezes. 2. When I tried to create a thread whose target = root.mainloop(), the GUI doesn't display at all, (Python.app launches but the GUI is not displayed), *Can you please help me how to create threads exactly???* I am attaching my code along with the mail main. mainFunction() is the function that takes approx 60 seconds to execute and that should be running in parallel with GUI/ in background. Thanks in advance... -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: interface.py Type: application/octet-stream Size: 7228 bytes Desc: not available URL: From klappnase at web.de Thu Apr 19 20:36:09 2012 From: klappnase at web.de (Michael Lange) Date: Thu, 19 Apr 2012 20:36:09 +0200 Subject: [Tkinter-discuss] Tkinter GUI freezing In-Reply-To: References: Message-ID: <20120419203609.09323b0a.klappnase@web.de> Hi, Thus spoketh "Bharath Reddy A." unto us on Thu, 19 Apr 2012 21:02:58 +0530: > Hi all, > I have created a GUI using Tkinter. > I have a button "GO", which when clicked calls a function (mainFunc). > That function takes around 60 seconds to execute and in the mean time > outputs many numbers which have to be displayed in a list in the GUI. > > I have attempted the following: > > 1. I created a thread whose target = mainFunc, when the button is > clicked. I can see the function printing stuff in terminal. But the > GUI still freezes. > 2. When I tried to create a thread whose target = root.mainloop(), > the GUI doesn't display at all, (Python.app launches but the GUI is not > displayed), One thing you must *never* do is to mix the Tkinter gui thread, which in fact should always be the main program thread, with any child thread. If the gui needs to reflect progress of the callbacks in the child thread, you must never call some Tkinter methods directly from within the child thread, but update some variable values and query them (typically periodically) from the gui thread. > > *Can you please help me how to create threads exactly???* > > I am attaching my code along with the mail > > main. mainFunction() is the function that takes approx 60 seconds to > execute and that should be running in parallel with GUI/ in background. > Thanks in advance... The problem in your code is aparently the following line: thread1 = threading.Thread(target = main.mainFunction(host, uname, passwd, networkPart, startHost, endHost, diction)) This way the mainFunction() call is done just when the interpreter evaluates this line. See the library reference about Thread objects: "class Thread(group=None, target=None, name=None, args=(), kwargs={}) This constructor should always be called with keyword arguments. Arguments are: group should be None; reserved for future extension when a ThreadGroup class is implemented. target is the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called. name is the thread name. By default, a unique name is constructed of the form ``Thread-N'' where N is a small decimal number. args is the argument tuple for the target invocation. Defaults to (). kwargs is a dictionary of keyword arguments for the target invocation. Defaults to {}." I hope this helps Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. You go slow, be gentle. It's no one-way street -- you know how you feel and that's all. It's how the girl feels too. Don't press. If the girl feels anything for you at all, you'll know. -- Kirk, "Charlie X", stardate 1535.8 From michael.odonnell at uam.es Fri Apr 20 14:05:15 2012 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Fri, 20 Apr 2012 22:05:15 +1000 Subject: [Tkinter-discuss] Python 3.2 and binding Mousewheel on Mac Message-ID: Hi All, I am on Macosx Lion running Python 3.2.3 and Tkinter 8.5 The following code breaks on my machine, and given search on the web, has been breaking in different forms since 2005. #======== from tkinter import * def _onMouseWheel(event): print(event) root = Tk() root.bind('',_onMouseWheel) root.mainloop() #======= On my machine works under python 2.7.2. I thought this would be fixed by now. Does anyone know anything about it? Mick From kw at codebykevin.com Fri Apr 20 14:39:19 2012 From: kw at codebykevin.com (Kevin Walzer) Date: Fri, 20 Apr 2012 08:39:19 -0400 Subject: [Tkinter-discuss] Python 3.2 and binding Mousewheel on Mac In-Reply-To: References: Message-ID: <4F9158F7.8000305@codebykevin.com> On 4/20/12 8:05 AM, Michael O'Donnell wrote: > Hi All, > > I am on Macosx Lion running Python 3.2.3 and Tkinter 8.5 > > The following code breaks on my machine, and given > search on the web, has been breaking in different forms since > 2005. > Using the similar code on 10.7.3 with Python 2.7.1, here's the output I get: Seems fine to me. What are you seeing with 3.2? --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From wayne at waynewerner.com Fri Apr 20 15:08:04 2012 From: wayne at waynewerner.com (Wayne Werner) Date: Fri, 20 Apr 2012 08:08:04 -0500 (CDT) Subject: [Tkinter-discuss] Tkinter GUI freezing In-Reply-To: References: Message-ID: On Thu, 19 Apr 2012, Bharath Reddy A. wrote: > Hi all,I have created a GUI using Tkinter.? > I have a button "GO", which when clicked calls a function (mainFunc). > That function takes around 60 seconds to execute and in the mean time outputs many numbers which have to be > displayed in a list in the GUI. > > I have attempted the following: > 1. ?I created a thread whose target = mainFunc, when the button is clicked. I can see the function printing > stuff in terminal. But the GUI still freezes. > 2. ?When I?tried to create a ?thread whose target = root.mainloop(), the GUI doesn't display at all, > (Python.app launches but the GUI is not displayed),? > Can you please help me how to create threads exactly??? You probably don't *really* want to execute a separate thread - it's usually a better idea to let Tkinter handle the parallelism. You can use the .after function (I think the syntax would be main.after(10, mainFunction) for your application, but Google will confirm), and then the .update_idletasks in your mainFunction. I'm assuming there's a loop involved (I haven't taken a look at your code), so you could launch that once every iteration of your loop. It's been a while since I've had the pleasure of mucking with any of that, but it should give you the ability to have a responsive UI while still running your function. HTH, Wayne From lionkimbro at gmail.com Fri Apr 20 21:45:05 2012 From: lionkimbro at gmail.com (Lion Kimbro) Date: Fri, 20 Apr 2012 12:45:05 -0700 Subject: [Tkinter-discuss] Python 3.2 and binding Mousewheel on Mac In-Reply-To: References: Message-ID: Not the answer but a data point: Windows 7 Python 3.2.2 -- worked fine -------------- next part -------------- An HTML attachment was scrubbed... URL: From willielawrence1 at gmail.com Fri Apr 20 19:22:47 2012 From: willielawrence1 at gmail.com (willie.lawrence) Date: Fri, 20 Apr 2012 10:22:47 -0700 (PDT) Subject: [Tkinter-discuss] Serializing tkinter objects Message-ID: <1334942567724-4902671.post@n6.nabble.com> Hello everybody, I'm a new user of this List. OBS: forgive my english (I'm a brazilian student) My question: I want save PhotoImage (Tkinter.PhotoImage or/and PIL.tkImage.PhotoImage) objects, but Tkinter classes cannot be serialized, so I thought in get all pixels and serialize this tuple, when in starting of my program post all pixels. The problem is that is a harmful practice to velocity...Look, load a wallpaper of 1600x1200 pixels... I also try encode the content of file: # ----------- toEncoder.py ----------- import base64 as b64, shelve gifFile = open("image.gif", "wb") # loading the gif image content = gifFile.read() shelveDB = shelve.open("SimpleDb.db") # where I will save shelveDB["myGIF"] = b64.b64encode(content) shelveDB.close() gifFile.close() # ----------- EOF ----------- # ----------- reader.py ----------- from Tkinter import * import shelve db = shelve.open("SimpleDB.db") content = db["myGIF"] top = Tk() img = PhotoImage() img.configure(data=content) testLabel = Label(top, text="test", compound="left", image=img) testLabel.image = img testLabel.grid() db.close() top.mainloop() # ----------- EOF ----------- But, how you can see, I can do it only with GIF Images (using Tkinter.PhotoImage) Anyway, any help is welcome! -- View this message in context: http://python.6.n6.nabble.com/Serializing-tkinter-objects-tp4902671p4902671.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From willielawrence1 at gmail.com Fri Apr 20 19:31:23 2012 From: willielawrence1 at gmail.com (willie.lawrence) Date: Fri, 20 Apr 2012 10:31:23 -0700 (PDT) Subject: [Tkinter-discuss] problem changing font settings for ttk themed widgets on Windows In-Reply-To: <5C37009D-6501-4063-9402-BAE1319F2E9B@gmail.com> References: <5C37009D-6501-4063-9402-BAE1319F2E9B@gmail.com> Message-ID: <1334943083093-4902700.post@n6.nabble.com> Hello, In Windows the fonts are tuples, so you can try: ttk.Style().configure('TLabelframe.label', font=("Arial", 14, "bold")) tell if it works -- View this message in context: http://python.6.n6.nabble.com/problem-changing-font-settings-for-ttk-themed-widgets-on-Windows-tp4895707p4902700.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From michael.odonnell at uam.es Sat Apr 21 00:57:27 2012 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Sat, 21 Apr 2012 08:57:27 +1000 Subject: [Tkinter-discuss] Python 3.2 and binding Mousewheel on Mac In-Reply-To: <4F9158F7.8000305@codebykevin.com> References: <4F9158F7.8000305@codebykevin.com> Message-ID: Hi Kevin, As I mentioned in my email, the code worked fine for me too under 2.7.3. This matches diagnoses of the problem in 2011. I just thought, a year later, the problem would be fixed. Mick On Fri, Apr 20, 2012 at 10:39 PM, Kevin Walzer wrote: > On 4/20/12 8:05 AM, Michael O'Donnell wrote: >> >> Hi All, >> >> ? I am on Macosx Lion running Python 3.2.3 and Tkinter 8.5 >> >> The following ?code breaks on my machine, and given >> search on the web, has been breaking in different forms since >> 2005. >> > Using the similar code on 10.7.3 with Python 2.7.1, here's the output I get: > > > > > > > > > > > > Seems fine to me. What are you seeing with 3.2? > > --Kevin > > -- > Kevin Walzer > Code by Kevin > http://www.codebykevin.com > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss From nad at acm.org Sat Apr 21 19:33:11 2012 From: nad at acm.org (Ned Deily) Date: Sat, 21 Apr 2012 10:33:11 -0700 Subject: [Tkinter-discuss] Python 3.2 and binding Mousewheel on Mac References: <4F9158F7.8000305@codebykevin.com> Message-ID: In article , "Michael O'Donnell" wrote: > Hi Kevin, > > As I mentioned in my email, the code worked fine for me too > under 2.7.3. This matches diagnoses of the problem in 2011. > > I just thought, a year later, the problem would be fixed. Is this the problem you are seeing? http://bugs.python.org/issue10731 -- Ned Deily, nad at acm.org From michael.odonnell at uam.es Sun Apr 22 01:08:31 2012 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Sun, 22 Apr 2012 09:08:31 +1000 Subject: [Tkinter-discuss] Python 3.2 and binding Mousewheel on Mac In-Reply-To: References: <4F9158F7.8000305@codebykevin.com> Message-ID: Hi Ned, > Is this the problem you are seeing? > http://bugs.python.org/issue10731 Yes, I was basically asking if in the year since that was reported, has any progress been made towards a proper fix. Mick From nad at acm.org Sun Apr 22 07:05:56 2012 From: nad at acm.org (Ned Deily) Date: Sat, 21 Apr 2012 22:05:56 -0700 Subject: [Tkinter-discuss] Python 3.2 and binding Mousewheel on Mac References: <4F9158F7.8000305@codebykevin.com> Message-ID: In article , "Michael O'Donnell" wrote: > > Is this the problem you are seeing? > > http://bugs.python.org/issue10731 > Yes, I was basically asking if in the year since that was reported, > has any progress been made towards a proper fix. It's best to ask on the bug tracker. If there have been no updates to an issue, chances are not that no one is working on it. But I've looked into it and it does appear to be a bug in the Cocoa Tcl/Tk 8.5.x implementation as suspected. See the updates to Issue10731 for details. I've opened Tk Toolkit bug 3520202 to report the problem. If someone takes an interest in it there, a fix could appear in a future release of the ActiveState Tcl/Tk 8.5 for OS X. https://sourceforge.net/tracker/?func=detail&aid=3520202&group_id=12997&a tid=112997 -- Ned Deily, nad at acm.org From michael.odonnell at uam.es Sun Apr 22 09:41:43 2012 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Sun, 22 Apr 2012 17:41:43 +1000 Subject: [Tkinter-discuss] Python 3.2 and binding Mousewheel on Mac In-Reply-To: References: <4F9158F7.8000305@codebykevin.com> Message-ID: Thanks Ned, Mick On Sun, Apr 22, 2012 at 3:05 PM, Ned Deily wrote: > In article > , > ?"Michael O'Donnell" wrote: >> > Is this the problem you are seeing? >> > http://bugs.python.org/issue10731 >> Yes, I was basically asking if in the year since that was reported, >> has any progress been made towards a proper fix. > > It's best to ask on the bug tracker. ?If there have been no updates to > an issue, chances are not that no one is working on it. > > But I've looked into it and it does appear to be a bug in the Cocoa > Tcl/Tk 8.5.x implementation as suspected. ?See the updates to Issue10731 > for details. ?I've opened Tk Toolkit bug 3520202 to report the problem. > If someone takes an interest in it there, a fix could appear in a future > release of the ActiveState Tcl/Tk 8.5 for OS X. > > https://sourceforge.net/tracker/?func=detail&aid=3520202&group_id=12997&a > tid=112997 > > -- > ?Ned Deily, > ?nad at acm.org > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss From kw at codebykevin.com Sun Apr 22 14:12:07 2012 From: kw at codebykevin.com (Kevin Walzer) Date: Sun, 22 Apr 2012 08:12:07 -0400 Subject: [Tkinter-discuss] Python 3.2 and binding Mousewheel on Mac In-Reply-To: References: <4F9158F7.8000305@codebykevin.com> Message-ID: <4F93F597.8050301@codebykevin.com> > But I've looked into it and it does appear to be a bug in the Cocoa > Tcl/Tk 8.5.x implementation as suspected. See the updates to Issue10731 > for details. I've opened Tk Toolkit bug 3520202 to report the problem. > If someone takes an interest in it there, a fix could appear in a future > release of the ActiveState Tcl/Tk 8.5 for OS X. > > https://sourceforge.net/tracker/?func=detail&aid=3520202&group_id=12997&a > tid=112997 > Hi Neil, I've been following this thread and have taken a look at the bug report you entered. However, I can't reproduce the issue in Python 2.7 (I don't have 3.x on my system) nor can I reproduce it when run directly from Tk. The equivalent Tk code: pack [text .t] bind all {puts "Mouse wheel event"} produces a string of "Mouse wheel events" statements to standard output, even when using two-fingered scrolling on the trackpad. Given that the Tk-Cocoa 8.5 code behaves as expected when run directly from Tcl/Tk I'm not clear on what bug I'm supposed to be fixing here. If the bug exists solely on the Tkinter side, then that needs to be addressed by the Tkinter developers. If I'm missing something, please clarify, but otherwise I am going to close the bug report as "works for me." --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From michael.odonnell at uam.es Sun Apr 22 14:51:00 2012 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Sun, 22 Apr 2012 22:51:00 +1000 Subject: [Tkinter-discuss] Python 3.2 and binding Mousewheel on Mac In-Reply-To: <4F93F597.8050301@codebykevin.com> References: <4F9158F7.8000305@codebykevin.com> <4F93F597.8050301@codebykevin.com> Message-ID: Hi Kevin, Kevin: I can't reproduce the issue in Python 2.7 (I don't have 3.x on my system) nor can I reproduce it when run directly from Tk. The equivalent Tk code: Mick: On my own Mac, the code works on 2.7.3 but not 3.2. This was also reported by someone back in 2011. Ned's comments on bugs.python explain why this is the case: (http://bugs.python.org/issue10731) To quote Ned: It looks like the problem is that the current Cocoa Tcl/Tk 8.5.x returns an incorrect MouseWheel event. Using the supplied test program and breakpointing in PythonCmd (around Modules/_tkinter.c:2027 in default), I found that it is being called from Tcl for MouseWheel events with an "argc" of 20, which looks suspiciously like the length of argv[1], "4302153816mouse_wheel", rather than the number of arguments which should be more like 3. It may also be an issue that affects Python because _tkinter still uses the older Tcl_CreateCommand interface rather than the newer Tcl_CreateObjCommand. The same Tcl behavior is observed with Python 2.7 _tkinter.c but there the bogus arguments are translated using PyString_FromString which is unaffected by the garbage arguments. It might be possible to workaround this problem in _tkinter but the next step is to open a Tcl/Tk issue against the Cocoa implementation and push for a proper fix there. Mick From kw at codebykevin.com Sun Apr 22 17:00:01 2012 From: kw at codebykevin.com (Kevin Walzer) Date: Sun, 22 Apr 2012 11:00:01 -0400 Subject: [Tkinter-discuss] Python 3.2 and binding Mousewheel on Mac In-Reply-To: References: <4F9158F7.8000305@codebykevin.com> <4F93F597.8050301@codebykevin.com> Message-ID: <4F941CF1.9040900@codebykevin.com> Hi Mick, On 4/22/12 8:51 AM, Michael O'Donnell wrote: > It may also be an issue that > affects Python because _tkinter still uses the older Tcl_CreateCommand > interface rather than the newer Tcl_CreateObjCommand. The same Tcl > behavior is observed with Python 2.7 _tkinter.c but there the bogus > arguments are translated using PyString_FromString which is unaffected > by the garbage arguments. It might be possible to workaround this > problem in _tkinter but the next step is to open a Tcl/Tk issue > against the Cocoa implementation and push for a proper fix there. I did read all the notes that were on the various bug reports, including the portions above that you quote, and I also attempted to reproduce the bug with all the installations at my disposal. To reiterate: 1. According to all available reports, the bug is only visible in a specific combination of Python and Tk: specifically, Python 3.x (with its new under-the-hood Unicode support everywhere) and Tk-Cocoa. 2. Ned's debugging isolated the specific point in tkinter.c where the bug appears. 3. Neil identified a possible fix for the bug on the Python side on the bridge. 4. The bug is not visible when accessed from Tcl/Tk. The two-finger scrolling works as expected. I'm able to fix Tkinter bugs when they are also accessible from Tcl/Tk; the fix on the Tk side is automatically picked up by Tkinter. The recent text input bug patch I committed is an example of this. Adrian Robert, who identified the bug in a Tcl/Tk application he develops, authored the patch, which I then committed, and which then fixed several related bug reports from the Python community. This case, however, is different. I fully accept Tk is returning some sort of output that Python 3.x has difficulty handling, but because that output produces no user-visible errors on the Tcl side of the bridge (and Tcl, remember, is Tk's native language), I am very uncomfortable with diving into to Tk's internals to make changes. Because there are no reproducible errors from Tcl itself, it is not even clear to me what changes should be made. In order to call this a bug in Tk itself rather than a bug in Tkinter, I need someone to put together a Tcl script that reproduces the issue. Then I can proceed with investigating how to fix it. That's how we proceeded with the text input bug. In this case, however, all evidence suggests that the bug occurs at the level of Tkinter/Tk interaction, and all evidence also suggests that a workaround or fix can--and, most likely should--be implemented on the Python side of the bridge. Thanks, Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From nad at acm.org Sun Apr 22 18:02:18 2012 From: nad at acm.org (Ned Deily) Date: Sun, 22 Apr 2012 09:02:18 -0700 Subject: [Tkinter-discuss] Python 3.2 and binding Mousewheel on Mac References: <4F9158F7.8000305@codebykevin.com> <4F93F597.8050301@codebykevin.com> <4F941CF1.9040900@codebykevin.com> Message-ID: In article <4F941CF1.9040900 at codebykevin.com>, Kevin Walzer wrote: > In order to call this a bug in Tk itself rather than a bug in Tkinter, I > need someone to put together a Tcl script that reproduces the issue. > Then I can proceed with investigating how to fix it. That's how we > proceeded with the text input bug. In this case, however, all evidence > suggests that the bug occurs at the level of Tkinter/Tk interaction, and > all evidence also suggests that a workaround or fix can--and, most > likely should--be implemented on the Python side of the bridge. As I understand it, Tkinter uses the Tcl C API to add a new command which is bound to all events of interest; that's how Tkinter gets called back from Tcl. There are two different interfaces for externaI C programs to register as commands; Tkinter still uses the older Tcl_CreateCommand interface. I believe the bug is in how the event callback is being set up for the mouse_wheel event. It might not be visible from a Tcl script. One way to attempt to reproduce it would be to write a simple C program that calls Tcl_CreateCommand to create a new command and then define a Tcl script that binds mouse_wheel events to it. http://www.tcl.tk/man/tcl8.5/TclLib/CrtCommand.htm -- Ned Deily, nad at acm.org From nad at acm.org Sun Apr 22 18:55:42 2012 From: nad at acm.org (Ned Deily) Date: Sun, 22 Apr 2012 09:55:42 -0700 Subject: [Tkinter-discuss] Python 3.2 and binding Mousewheel on Mac References: <4F9158F7.8000305@codebykevin.com> <4F93F597.8050301@codebykevin.com> <4F941CF1.9040900@codebykevin.com> Message-ID: In article , Ned Deily wrote: > In article <4F941CF1.9040900 at codebykevin.com>, > Kevin Walzer wrote: [...] BTW, there has been further discussion on this at the open Tk issue in the Tk bug tracker. It's probably better to keep the discussion in one place there. https://sourceforge.net/tracker/?func=detail&aid=3520202&group_id=12997&a tid=112997 -- Ned Deily, nad at acm.org From michael.odonnell at uam.es Mon Apr 23 00:45:28 2012 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Mon, 23 Apr 2012 08:45:28 +1000 Subject: [Tkinter-discuss] Python 3.2 and binding Mousewheel on Mac In-Reply-To: References: <4F9158F7.8000305@codebykevin.com> <4F93F597.8050301@codebykevin.com> <4F941CF1.9040900@codebykevin.com> Message-ID: Thanks a lot Ned for pursuing this bug for us. According to Donald Fellows, it is now fixed: http://sourceforge.net/tracker/?func=detail&aid=3520202&group_id=12997&atid=112997 I look forward to the next maintenance release of Tcl/Tk to verify it. Mick On Mon, Apr 23, 2012 at 2:55 AM, Ned Deily wrote: > In article , > ?Ned Deily wrote: >> In article <4F941CF1.9040900 at codebykevin.com>, >> ?Kevin Walzer wrote: > [...] > > BTW, there has been further discussion on this at the open Tk issue in > the Tk bug tracker. ?It's probably better to keep the discussion in one > place there. > > https://sourceforge.net/tracker/?func=detail&aid=3520202&group_id=12997&a > tid=112997 > > -- > ?Ned Deily, > ?nad at acm.org > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss From willielawrence1 at gmail.com Tue Apr 24 19:12:13 2012 From: willielawrence1 at gmail.com (willie.lawrence) Date: Tue, 24 Apr 2012 10:12:13 -0700 (PDT) Subject: [Tkinter-discuss] Serializing tkinter objects In-Reply-To: <1334942567724-4902671.post@n6.nabble.com> References: <1334942567724-4902671.post@n6.nabble.com> Message-ID: <1335287533896-4914110.post@n6.nabble.com> Hello every body! I think that I can serialize the tkinter objects with this way: A mode is: # ------- Encoder.py ------------ import base64, shelve # The idea is encode the data file to persist, and than decode to read... pngFile = open("image.png", "rb") content = pngFile.read() content.close() db = shelve.open("Db.db") db["image"] = base64.b64encode(content) db.close() # ------- Reader.py ---------- from Tkinter import * import ImageTk, shelve, base64 db = shelve.open("DB.db") content = base64.b64decode(db["image"]) db.close() top = Tk() _ph = ImageTk.PhotoImage(data=content) l = Label(top, image=_ph) l.grid() top.mainloop() -- View this message in context: http://python.6.n6.nabble.com/Serializing-tkinter-objects-tp4902671p4914110.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From marc.culler at gmail.com Thu Apr 26 17:50:59 2012 From: marc.culler at gmail.com (Marc Culler) Date: Thu, 26 Apr 2012 10:50:59 -0500 Subject: [Tkinter-discuss] Segfault in Image.PhotoImage on OS X Message-ID: This was reported here in February, but no debugging information was provided by the reporter: http://stackoverflow.com/questions/9142786/python-imagetk-photoimage-segfault I can explain the nature of the problem, but I don't know how to fix it correctly. I am using the standard x86_64 Python 2.7.2 package from python.org and I have installed Active State Tcl/Tk 8.11. When I tried using easy_install to install PIL it would not load, claiming that _imaging.so did not exist. In fact, it existed but was only a thin i386 executable. So I compiled Imaging-1.1.7 with export CFLAGS='-arch i386 -arch x86_64' and export TCL_ROOT=/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl I was then able to load the module. However, the following code produced a segfault: import Image import ImageTk import Tkinter W = Tkinter.Tk() Im = Image.open('test_image.jpg') x = ImageTk.PhotoImage(Im) The crash occurs in Tk_GetImageMasterData. More importantly, though, the crash was preceded by the following messages: objc[36554]: Class TKApplication is implemented in both /Library/Frameworks/Tk.framework/Versions/8.5/Tk and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined. objc[36554]: Class TKMenu is implemented in both /Library/Frameworks/Tk.framework/Versions/8.5/Tk and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined. objc[36554]: Class TKContentView is implemented in both /Library/Frameworks/Tk.framework/Versions/8.5/Tk and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined. objc[36554]: Class TKWindow is implemented in both /Library/Frameworks/Tk.framework/Versions/8.5/Tk and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined. Guessing that PIL was finding the System/Library/Frameworks/Tk.Framework instead of /Library/Frameworks/Tk.Framework, I tried hiding the system Tcl and Tk frameworks by renaming them. I was then able to create the PhotoImage and display it. I don't know where those messages come from, and I have never encountered them before. But I am guessing they are from OS X, since they are generated by an objective C program. Evidently _tkinter.so is able to specify which Tk.Framework to use. I don't know its mechanism for doing that. But, somehow, PIL is not doing it, and it ends up using the wrong one. A stack trace of the crash is below. - Marc 0x000000011517bccd in Tk_GetImageMasterData () (gdb) bt #0 0x000000011517bccd in Tk_GetImageMasterData () #1 0x0000000115183d9f in Tk_FindPhoto () #2 0x00000001014fbadc in PyImagingPhotoPut () #3 0x000000011502a05b in TclInvokeStringCommand () #4 0x000000010102142a in TclEvalObjvInternal () #5 0x000000010102261c in Tcl_EvalObjv () #6 0x000000010100646d in Tkapp_Call () #7 0x00000001000c102d in PyEval_EvalFrameEx () #8 0x00000001000c2d29 in PyEval_EvalCodeEx () #9 0x00000001000c0b6a in PyEval_EvalFrameEx () #10 0x00000001000c2d29 in PyEval_EvalCodeEx () #11 0x000000010003da80 in function_call () #12 0x000000010000c5e2 in PyObject_Call () #13 0x000000010001ebcb in instancemethod_call () #14 0x000000010000c5e2 in PyObject_Call () #15 0x00000001000ba5f7 in PyEval_CallObjectWithKeywords () #16 0x0000000100021e5e in PyInstance_New () #17 0x000000010000c5e2 in PyObject_Call () #18 0x00000001000be5f3 in PyEval_EvalFrameEx () #19 0x00000001000c2d29 in PyEval_EvalCodeEx () #20 0x00000001000c2e46 in PyEval_EvalCode () #21 0x00000001000e769c in PyRun_InteractiveOneFlags () #22 0x00000001000e78fe in PyRun_InteractiveLoopFlags () #23 0x00000001000e80e1 in PyRun_AnyFileExFlags () #24 0x00000001000fe77c in Py_Main () #25 0x0000000100000f14 in dyld_stub_strlen () -------------- next part -------------- An HTML attachment was scrubbed... URL: From kw at codebykevin.com Fri Apr 27 03:20:48 2012 From: kw at codebykevin.com (Kevin Walzer) Date: Thu, 26 Apr 2012 21:20:48 -0400 Subject: [Tkinter-discuss] Segfault in Image.PhotoImage on OS X In-Reply-To: References: Message-ID: <4F99F470.1030901@codebykevin.com> On 4/26/12 11:50 AM, Marc Culler wrote: > Guessing that PIL was finding the System/Library/Frameworks/Tk.Framework instead of > /Library/Frameworks/Tk.Framework, I tried hiding the system Tcl and Tk frameworks by > renaming them. I was then able to create the PhotoImage and display it. > > > I don't know where those messages come from, and I have never encountered them before. Sometimes Tk extension libraries will link against /System/Library/Frameworks instead of /Library/Frameworks when they are being compiled--this can cause the kinds of conflicts and crashes that you are seeing. The install_name_tool tool can re-link a binary to the correct framework, see the man page. --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From marc.culler at gmail.com Fri Apr 27 06:04:05 2012 From: marc.culler at gmail.com (Marc Culler) Date: Thu, 26 Apr 2012 23:04:05 -0500 Subject: [Tkinter-discuss] Segfault in Image.PhotoImage on OS X In-Reply-To: References: Message-ID: Kevin Walzer wrote: > Sometimes Tk extension libraries will link against > /System/Library/Frameworks instead of /Library/Frameworks when they are > being compiled--this can cause the kinds of conflicts and crashes that > you are seeing. The install_name_tool tool can re-link a binary to the > correct framework, see the man page. > > Thanks, Kevin. That was the case with _imagingtk.so and install_name_tool fixed it. - Marc -------------- next part -------------- An HTML attachment was scrubbed... URL: From rowen at uw.edu Fri Apr 27 22:10:55 2012 From: rowen at uw.edu (Russell E. Owen) Date: Fri, 27 Apr 2012 13:10:55 -0700 Subject: [Tkinter-discuss] Segfault in Image.PhotoImage on OS X References: Message-ID: In article , Marc Culler wrote: > This was reported here in February, but no debugging information was > provided by the reporter: > http://stackoverflow.com/questions/9142786/python-imagetk-photoimage-segfault > age-segfault> > > I can explain the nature of the problem, but I don't know how to fix > it correctly. > > I am using the standard x86_64 Python 2.7.2 package from python.org and I > have > installed Active State Tcl/Tk 8.11. > > When I tried using easy_install to install PIL it would not load, > claiming that _imaging.so > did not exist. In fact, it existed but was only a thin i386 > executable. So I compiled > Imaging-1.1.7 with > export CFLAGS='-arch i386 -arch x86_64' > and > export TCL_ROOT=/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl > > I was then able to load the module. However, the following code > produced a segfault: > > import Image > import ImageTk > import Tkinter > W = Tkinter.Tk() > Im = Image.open('test_image.jpg') > x = ImageTk.PhotoImage(Im) > > The crash occurs in Tk_GetImageMasterData. More importantly, though, > the crash was > preceded by the following messages: > > objc[36554]: Class TKApplication is implemented in both > /Library/Frameworks/Tk.framework/Versions/8.5/Tk and > /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the > two will be used. Which one is undefined. > objc[36554]: Class TKMenu is implemented in both > /Library/Frameworks/Tk.framework/Versions/8.5/Tk and > /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the > two will be used. Which one is undefined. This sounds like a know bug with XCode 3.2.6 described here: The problem is an incorrect link to /Library/Frameworks. The following fix suggested by "Nertzius" worked for me: cd /Developer/SDKs/MacOSX10.6.sdk/Library; sudo mv Frameworks Frameworks-orig sudo mv Frameworks-orig/Frameworks . sudo rm -rf Frameworks-orig By the way, you can get an unofficial Mac binary installer for PIL, built for python.org python here: -- Russell