Thanks for your suggestions. I substituted Tk() for _default_root, but I ran into the same problem with an extra window superimposed over the application window. I'm wondering if the problem is associated with my use of my own subclass of Frame as the application rather than just an instance of Frame itself. All the examples I've found for ttk so far use Frame as the application, with all the widgets created in the main body of the Python script, rather than in an application __init__ method.
I'm going to stay with _default_root and its withdraw method for now, since it's an easy workaround for a really bad problem. BTW: I had noticed that the application wasn't returning to the IDLE command prompt when I clicked the Windows "X" button, so I knew the root process was still running after the window was closed. Thanks for telling me about the protocol method and 'WM_DELETE_WINDOW'. I hadn't known about it. I found that calling top.protocol('WM_DELETE_WINDOW', root.destroy) did the trick, although root.quit just made the application hang rather than close. Thanks again for your help. Land -----Original Message----- From: Tkinter-discuss [mailto:tkinter-discuss-bounces+land.d.fleming=nasa....@python.org] On Behalf Of Michael Lange Sent: Friday, January 03, 2014 2:43 AM To: tkinter-discuss@python.org Subject: Re: [Tkinter-discuss] Issues converting TKinter application to Ttk Hi, On Thu, 2 Jan 2014 20:59:44 +0000 "Fleming, Land D. (JSC-ER111)[Jacobs Technology, Inc.]" <land.d.flem...@nasa.gov> wrote: > First problem: > > I found that the styles I defined for widgets in the application were > ignored when I made the application's master an instance of Tk() as > follows: > > root = Tk() > app = App(root, style='My.TPanedwindow', orient=VERTICAL) > > After considerable trial and error (mostly error) I found that the > styles worked as advertised, if I changed the application master to an > instance of Toplevel rather than of Tk: > > top = Toplevel() > app = App(top, style='My.TPanedwindow', orient=VERTICAL) > top.mainloop() I haven't worked much with custom styles so far, so I cannot tell why this happens. Maybe you could try to define the My.TPanedwindow style within the App class to work around this? > Second Problem: > > When the mainloop executed as above, what appeared to be an extraneous > blank window was stacked on top of the application window. This window > didn't appear when I was using basic Tkinter. I noticed that if I > killed the extraneous window by clicking on the "X" in the window's > upper right corner, it also killed the application, which suggested > the "extraneous" window was really the root window. After searching > the documentation and much trial and error, I found that I could get > the root window to go away without killing my app by explicitly > calling > withdraw() on the root before running the mainloop: > > Tkinter._default_root.withdraw() > app.mainloop() > > This would have been a show stopper if I hadn't been able to work > around it, because I couldn't give an application to end users that > pops up a meaningless empty window that they have to close themselves. > I wasn't able to locate much documentation on the root window, and I > only found out about _default_root by looking at Tkinter.py. Further, > I found nothing to indicate that the root had a withdraw method, and > just tried it after running out of all other options I could think of. > Luckily, it worked. The reason that _default_root is not documented is that it is an internal or "private" attribute which at least in theory might be changed by the Tkinter developers, which is told us by the leading underscore character (although I believe in the case of _default_root it is rather safe to use it anyway). The "proper" way to have a Toplevel as main application window is something like: root = Tk() root.withdraw() top = Toplevel(root) # make sure clicking the window's "X" button does not only # close the Toplevel but the application altogether: top.protocol('WM_DELETE_WINDOW', root.quit) (...) root.mainloop() root.destroy() As far as documentation is concerned, there are at least two excellent reference manuals available online: http://effbot.org/tkinterbook/tkinter-index.htm by Frederik Lundh and http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/index.html by John W. Shipman. (the latter however doesn't mention explicitely at the Toplevel page that the Toplevel's methods are also valid for Tk instances, the first one does ;) . Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. One does not thank logic. -- Sarek, "Journey to Babel", stardate 3842.4 _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss