From ronaldoussoren at mac.com Wed Sep 6 16:57:45 2017 From: ronaldoussoren at mac.com (Ronald Oussoren) Date: Wed, 06 Sep 2017 22:57:45 +0200 Subject: [Pythonmac-SIG] Tkinter and PyObjC Message-ID: <3D147DF1-A817-4018-8D0C-1443D2787E1B@mac.com> 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 From jack.jansen at cwi.nl Wed Sep 6 18:22:54 2017 From: jack.jansen at cwi.nl (Jack Jansen) Date: Thu, 7 Sep 2017 00:22:54 +0200 Subject: [Pythonmac-SIG] Tkinter and PyObjC In-Reply-To: <3D147DF1-A817-4018-8D0C-1443D2787E1B@mac.com> References: <3D147DF1-A817-4018-8D0C-1443D2787E1B@mac.com> Message-ID: <64A7F911-C8AE-4856-8670-EFCCA7425197@cwi.nl> 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 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, , 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: From kw at codebykevin.com Wed Sep 6 19:30:43 2017 From: kw at codebykevin.com (Kevin Walzer) Date: Wed, 6 Sep 2017 19:30:43 -0400 Subject: [Pythonmac-SIG] Tkinter and PyObjC In-Reply-To: <3D147DF1-A817-4018-8D0C-1443D2787E1B@mac.com> References: <3D147DF1-A817-4018-8D0C-1443D2787E1B@mac.com> Message-ID: 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 From ronaldoussoren at mac.com Mon Sep 25 03:59:37 2017 From: ronaldoussoren at mac.com (Ronald Oussoren) Date: Mon, 25 Sep 2017 09:59:37 +0200 Subject: [Pythonmac-SIG] ANN: PyObjC 4.0 Message-ID: Hi, I?m happy to announce PyObjC 4.0. The major difference in this release is support for new APIs and frameworks introduced in macOS 10.13 (High Sierra). A minor change is that the documentation is now on readthedocs: > The release notes > contain more detailed information on what has changed. And finally a technical note: this release was cut from the macos10.13-support branch of the repository, I haven?t merged the branch back into default yet. Ronald -------------- next part -------------- An HTML attachment was scrubbed... URL: