[Pythonmac-SIG] Tkinter and PyObjC
Ronald Oussoren
ronaldoussoren at mac.com
Wed Sep 6 16:57:45 EDT 2017
Hi,
I’m kind of hoping that a Tkinter or Tk expert is reading this…
A PyObjC user tries to call Tkinter from a Cocoa program (that is, the Cocoa runloop starts before the Tkinter one) and gets an error message:
-[NSApplication _setup:]: unrecognized selector sent to instance
Furthermore the Tkinter GUI doesn’t work. PyObjC’s issue about this:
https://bitbucket.org/ronaldoussoren/pyobjc/issues/201/tkinter-method-tk-failed-with-error
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.
Ronald
More information about the Pythonmac-SIG
mailing list