Hi Russell,

On 9/24/13 8:23 PM, Russell E. Owen wrote:
Well, naturally the prime purpose is to demonstrate the crash. However,
if you use 8.5.11 or if you comment out the menu-related stuff then you
also will see the button text get larger. I only use the label to access
the option database.

After a bit more digging, I think the bug here is another instance of http://bugs.python.org/issue15853, which caused IDLE to crash. In that case I submitted a patch that worked around the bug by changing how a font was configured in a certain context; see http://hg.python.org/cpython/rev/d089b8fb0f56 for the specifics.

What suggests to me that this bug is similar, or even the same, is that changing your sample code from configuring the font object directly to specifically configuring the font on the button avoids the crash, cf:

btn = Tkinter.Button(root, text="Change Font", command= lambda: btn.configure(font='-size 14'))

Note the difference between font.configure(size=14) and btn.configure(font='-size 14'). In the patch we worked out for IDLE, the mechanism of the fix was the same, but the expected behavior of the code did not change: the font in the button gets bigger.

The reason I focused on a workaround at the Python script level rather than a fix in Tk was partly because I couldn't reproduce the crash in Tcl itself, even by creating and configuring fonts rather than font attributes in a specific widget. That makes fixing the bug in Tk rather hard. It's possible that the bug is caused by some combination of triggers in Tk-Cocoa's fragile event loop that Python exposes more readily than Tcl code.

The upshot of all of this is that I think it would be more productive to tweak application-level code to work around the bug--it's not likely that any fix for Tk-Cocoa's event loop issues is coming any time soon. I realize that may not be the answer you were looking for, and I'm sorry about that. But given the problems still remaining with Tk-Cocoa's event loop, I actually recommend script-level workarounds as a best practice; I do that in my own apps and have not run into a crash in a long time.

--Kevin

--
Kevin Walzer
Code by Kevin/Mobile Code by Kevin
http://www.codebykevin.com
http://www.wtmobilesoftware.com
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to