[Pythonmac-SIG] Tkinter and PyObjC

Kevin Walzer kw at codebykevin.com
Wed Sep 6 19:30:43 EDT 2017


Ronald,

On 9/6/17 4:57 PM, Ronald Oussoren wrote:
> I’ve done some quick browsing of the Tk source code and it appears that Tk assumes that -[NSApplication sharedApplication] returns an instance of a Tk-specific private subclass of NSApplication and that won’t be true when the Tk runloop is started before the Cocoa one.
>
> My question: is my analysis correct? And has anyone successfully mixed PyObjC and Tkinter in this way? I guess this issue could be avoided by initialising Tk before calling into Cocoa.

I'd say your analysis is more or less correct. The previous maintianer 
of Tk/Mac, Daniel Steffen, noted this  in a bug report at 
https://core.tcl.tk/tk/tktview/3033786fffffffffffff.

I've had success embedding Cocoa widgets from within Tk (Quicklook 
views, NSToolbar, etc.) where Tk has no direct knowledge of the Cocoa 
bits. But the Tk event loop has to be in charge for this to work because 
of Tk's architecture. I don't think that calling Tk from Cocoa is feasible.

--Kevin

-- 
Kevin Walzer
Code by Kevin/Mobile Code by Kevin
http://www.codebykevin.com
http://www.wtmobilesoftware.com



More information about the Pythonmac-SIG mailing list