Path: csiph.com!aioe.org!newsfeed.tele2net.at!newsfeed.utanet.at!feeder2.cambriumusenet.nl!feed.tweaknews.nl!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: John Salerno Newsgroups: comp.lang.python Subject: Re: Is it necessary to call Tk() when writing a GUI app with Tkinter? Date: Thu, 1 Mar 2012 19:15:21 -0800 (PST) Organization: http://groups.google.com Lines: 36 Message-ID: <6008330.241.1330658121340.JavaMail.geo-discussion-forums@ynlt17> References: <27603449.17.1330492001624.JavaMail.geo-discussion-forums@vbbfv2> <6e1c521e-14be-4ec0-9ff0-7f23fd9cd3dc@f14g2000yqe.googlegroups.com> <17153317.324.1330576905540.JavaMail.geo-discussion-forums@yncd8> NNTP-Posting-Host: 76.30.237.113 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1330658121 1911 127.0.0.1 (2 Mar 2012 03:15:21 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 2 Mar 2012 03:15:21 +0000 (UTC) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=76.30.237.113; posting-account=Wdz3OgoAAACumWTKfPjpOEJc3twpMp_1 User-Agent: G2/1.0 Xref: csiph.com comp.lang.python:21113 > EXAMPLE 1: (this works, but is flawed!) > root = tk.Tk() > b = tk.Button(master=None, text='Sloppy Coder') > b.pack() > root.mainloop() > > EXAMPLE 2: (This is how to write code!) > root = tk.Tk() > widgetframe = tk.Frame(root) > b = tk.Button(master=None, text='Sloppy Coder') > b.pack() > root.mainloop() > > EXAMPLE 3: (OOP style) > class App(tk.Tk): > def __init__(self): > tk.Tk.__init__(self) > # something should happen here to justify using OOP > # or here > > class AppFrame(tk.Frame): > def __init__(self, master, **kw): > tk.Frame.__init__(self, master, **kw) > self.createWidgets() > > def createWidgets(self): > b = tk.Button(master=None, text='Push Me') > b.pack() > > if __name__ == '__main__': > app = App() > frame = AppFrame(app) > frame.pack() > app.mainloop() Why is the master argument for Button set to None? Shouldn't it be the Frame object? And shouldn't it also have self as the first argument?