In article 
<3d0bf288-fa5d-48e5-9529-db92d420a...@1g2000yqv.googlegroups.com>,
 Rick Johnson <rantingrickjohn...@gmail.com> wrote:

> On Feb 29, 11:24 pm, Terry Reedy <tjre...@udel.edu> wrote:
> > On 2/29/2012 10:22 PM, Rick Johnson wrote:
> 
> > > PS: I would highly suggest against using the "from Tkinter import *".
> > > Instead, use "import Tkinter as tk" and prefix all module contents
> > > with "tk.".
> >
> > I have changed the example to do that. I also showed the alternate to
> > initialize a widget. Here is the current version, tested on Windows 3.2.2.
> >
> > import tkinter as tk
> >
> > class Application(tk.Frame):
> >      def __init__(self, master=None):
> >          tk.Frame.__init__(self, master)
> >          self.pack()
> 
> With all due respect, I would also recommend against "self packing" a
> widget. And i can speak from experience on this issue. There was a
> time when i was self-packing lots of custom compund widgets; then i
> realized later the shortcomings of such action; what if you need to
> use the grid or place geometry mangers instead? So remove the
> self.pack line and add a line to the bottom:
> 
> > root = tk.Tk()
> > app = Application(master=root)
> > app.pack() # <-- added this line
> > app.mainloop()

I agree. Application is simply another widget, like Entry or Canvas. its 
contents should be packed or gridded (as appropriate) into itself, but 
the user should then pack or grid the Application widget as appropriate.

That makes the code much more reusable.

-- Russell

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to