From jhultquist at me.com Tue Dec 22 12:04:26 2015 From: jhultquist at me.com (Jeff Hultquist) Date: Tue, 22 Dec 2015 09:04:26 -0800 Subject: [Tkinter-discuss] winfo_id on OS/X Message-ID: I am trying to use tkinter with the Panda3D (panda3d.org ) graphics library. I want to position a graphics window into a tkinter frame. Attached below is some sample code that uses the frame.winfo_id() as the argument to Panda3D?s setParentWindow method. This works on Linux and Windows, but seg-faults on OS/X. It appears the winfo_id is not valid on OS/X. How can we get a proper handle for the parenting of the 3d view into a tkinter frame? FWIW, there is a thread is ongoing on the Panda3D forum, but the answer seems to lie deep inside tkinter. https://www.panda3d.org/forums/viewtopic.php?f=4&t=18449 Many thanks. ---------------------------------- from direct.showbase.ShowBase import ShowBase from panda3d.core import WindowProperties import Tkinter base = ShowBase(windowType='none') base.startTk() frame = base.tkRoot frame.update() id = frame.winfo_id() width = frame.winfo_width() height = frame.winfo_height() props = WindowProperties() props.setParentWindow(id) props.setOrigin(0, 0) props.setSize(width, height) base.makeDefaultPipe() base.openDefaultWindow(props=props) # ?? on OS/X, we segfault here scene = base.loader.loadModel("environment") scene.reparentTo(base.render) base.run() ---------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: From kw at codebykevin.com Wed Dec 23 20:06:28 2015 From: kw at codebykevin.com (Kevin Walzer) Date: Wed, 23 Dec 2015 20:06:28 -0500 Subject: [Tkinter-discuss] winfo_id on OS/X In-Reply-To: References: Message-ID: <567B4514.70200@codebykevin.com> On 12/22/15 12:04 PM, Jeff Hultquist wrote: > I am trying to use tkinter with the Panda3D (panda3d.org > ) graphics library. I want to position a > graphics window into a tkinter frame. > > Attached below is some sample code that uses the frame.winfo_id() as > the argument to Panda3D?s setParentWindow method. > > This works on Linux and Windows, but seg-faults on OS/X. It appears > the winfo_id is not valid on OS/X. > > Using Tk 8.6.4 / trunk on OS X 10.11, the following works just fine for me: >>> import tkinter >>> frame = tkinter.Tk() >>> id = frame.winfo_id() >>> print(id) 140237681823504 Perhaps an older version of Tk is being used? What version of OS X? --Kevin -- Kevin Walzer Code by Kevin/Mobile Code by Kevin http://www.codebykevin.com http://www.wtmobilesoftware.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Wed Dec 23 20:46:12 2015 From: klappnase at web.de (Michael Lange) Date: Thu, 24 Dec 2015 02:46:12 +0100 Subject: [Tkinter-discuss] winfo_id on OS/X In-Reply-To: <567B4514.70200@codebykevin.com> References: <567B4514.70200@codebykevin.com> Message-ID: <20151224024612.564c6e96a6fd44150416a560@web.de> Hi, On Wed, 23 Dec 2015 20:06:28 -0500 Kevin Walzer wrote: (...) > > > Using Tk 8.6.4 / trunk on OS X 10.11, the following works just fine for > me: > > >>> import tkinter > >>> frame = tkinter.Tk() > >>> id = frame.winfo_id() > >>> print(id) > 140237681823504 quoting the link Jeff provided (apparently from "man winfo"): "On the Macintosh the value has no meaning outside Tk." I guess (although I do not have any experience with Tkinter on the Mac) that this value (meaning the "140237681823504") is not recognized by "Mac-Windows" as a valid window-identifier by the Macintosh's window manager (or which ever instance may be responsible for that). Best regards (and a nice Christmas to all of you and your loved ones!) Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Love sometimes expresses itself in sacrifice. -- Kirk, "Metamorphosis", stardate 3220.3 From kw at codebykevin.com Fri Dec 25 21:19:48 2015 From: kw at codebykevin.com (Kevin Walzer) Date: Fri, 25 Dec 2015 21:19:48 -0500 Subject: [Tkinter-discuss] Accelerator keys cross-platform Message-ID: <567DF944.2080107@codebykevin.com> I'm porting a Tkinter application from Mac to Windows and I need a cross-platform way to implement accelerator keys for menu entries. In Tcl, this is very simple: -accelerator "$Command-C" where $Command can be set to "Command" or "Control" depending on the platform. Python does not have as flexible a string substitution as Tcl, so I'm looking for a Pythonic way to do this. Most examples I've seen load entirely separate menus depending on the platform, and I'd rather avoid duplicating code that way. Any suggestions or examples that anyone can share? -- Kevin Walzer Code by Kevin/Mobile Code by Kevin http://www.codebykevin.com http://www.wtmobilesoftware.com From michael.odonnell at uam.es Sat Dec 26 02:57:48 2015 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Sat, 26 Dec 2015 08:57:48 +0100 Subject: [Tkinter-discuss] Accelerator keys cross-platform In-Reply-To: <567DF944.2080107@codebykevin.com> References: <567DF944.2080107@codebykevin.com> Message-ID: Hi Kevin, I initially do: if sys.platform == "darwin": CmdKey="Command-" else: CmdKey="Control-" ...and then I define menu items as: myMenu.add_command(label="Quit", command=self.mainWin.Quit, accelerator=CmdKey+'Q') Mick On 26 December 2015 at 03:19, Kevin Walzer wrote: > I'm porting a Tkinter application from Mac to Windows and I need a > cross-platform way to implement accelerator keys for menu entries. In Tcl, > this is very simple: > > -accelerator "$Command-C" > > where $Command can be set to "Command" or "Control" depending on the > platform. > > Python does not have as flexible a string substitution as Tcl, so I'm > looking for a Pythonic way to do this. Most examples I've seen load entirely > separate menus depending on the platform, and I'd rather avoid duplicating > code that way. Any suggestions or examples that anyone can share? > > -- > Kevin Walzer > Code by Kevin/Mobile Code by Kevin > http://www.codebykevin.com > http://www.wtmobilesoftware.com > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > https://mail.python.org/mailman/listinfo/tkinter-discuss From kw at codebykevin.com Sat Dec 26 09:42:40 2015 From: kw at codebykevin.com (Kevin Walzer) Date: Sat, 26 Dec 2015 09:42:40 -0500 Subject: [Tkinter-discuss] Accelerator keys cross-platform In-Reply-To: References: <567DF944.2080107@codebykevin.com> Message-ID: <567EA760.1060101@codebykevin.com> Mick, On 12/26/15 2:57 AM, Michael O'Donnell wrote: > Hi Kevin, > > I initially do: > > if sys.platform == "darwin": CmdKey="Command-" > else: CmdKey="Control-" > > ...and then I define menu items as: > > myMenu.add_command(label="Quit", command=self.mainWin.Quit, > accelerator=CmdKey+'Q') > > Thanks! How do you handle other keybindings, c.f. window.bind(', lambda event: window.hide()) ? --Kevin -- Kevin Walzer Code by Kevin/Mobile Code by Kevin http://www.codebykevin.com http://www.wtmobilesoftware.com From kw at codebykevin.com Sat Dec 26 10:47:47 2015 From: kw at codebykevin.com (Kevin Walzer) Date: Sat, 26 Dec 2015 10:47:47 -0500 Subject: [Tkinter-discuss] Accelerator keys cross-platform In-Reply-To: <567EA760.1060101@codebykevin.com> References: <567DF944.2080107@codebykevin.com> <567EA760.1060101@codebykevin.com> Message-ID: <567EB6A3.2030007@codebykevin.com> On 12/26/15 9:42 AM, Kevin Walzer wrote: > window.bind(', lambda event: window.hide()) I found the string formatter call, cf: >>> mod = 'Control' >>> print("<{}-f>".format(mod)) Looks like I'm in business! Thanks for the help. -- Kevin Walzer Code by Kevin/Mobile Code by Kevin http://www.codebykevin.com http://www.wtmobilesoftware.com From klappnase at web.de Sun Dec 27 07:31:09 2015 From: klappnase at web.de (Michael Lange) Date: Sun, 27 Dec 2015 13:31:09 +0100 Subject: [Tkinter-discuss] Accelerator keys cross-platform In-Reply-To: <567EB6A3.2030007@codebykevin.com> References: <567DF944.2080107@codebykevin.com> <567EA760.1060101@codebykevin.com> <567EB6A3.2030007@codebykevin.com> Message-ID: <20151227133109.9d7ec4c77bdd269fd39ca4c2@web.de> Hi, On Sat, 26 Dec 2015 10:47:47 -0500 Kevin Walzer wrote: > On 12/26/15 9:42 AM, Kevin Walzer wrote: > > window.bind(', lambda event: window.hide()) > I found the string formatter call, cf: > > >>> mod = 'Control' > >>> print("<{}-f>".format(mod)) > or simply >>> mod = 'Control' >>> print('<%s-f>' % mod) >>> Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. "The combination of a number of things to make existence worthwhile." "Yes, the philosophy of 'none,' meaning 'all.'" -- Spock and Lincoln, "The Savage Curtain", stardate 5906.4