[Pythonmac-SIG] Tkinter and PyObjC

Jack Jansen jack.jansen at cwi.nl
Wed Sep 6 18:22:54 EDT 2017


From memory (and cobwebbed memory, at that:-) I recall that I never got Tkinter and Cocoa to work together. The runloops got into each others’ ways. Similar for other GUI toolkits (Gtk, for example).

I did (with lots of pulling of hairs and gnashing of teeth) get Cocoa GUI to work together with other NSFoundation stuff (as long as it didn’t touch the gui) by giving it a runloop in a different thread.

But: this was about 6 years ago, things may have progressed since then…

Jack

> On  06-Sep-2017, at 22:57 , Ronald Oussoren <ronaldoussoren at mac.com> wrote:
> 
> 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
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
> https://mail.python.org/mailman/listinfo/pythonmac-sig
> unsubscribe: https://mail.python.org/mailman/options/Pythonmac-SIG

--
Jack Jansen, <Jack.Jansen at cwi.nl>, http://www.cwi.nl/~jack
If I can't dance I don't want to be part of your revolution -- Emma Goldman



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythonmac-sig/attachments/20170907/34d3821a/attachment.html>


More information about the Pythonmac-SIG mailing list