Please help - Tkinter not doing anything

Protected protected at myshelter.net
Sun May 4 05:39:59 EDT 2008


Good thinking. It was indented with spaces, so I replaced them with tabs.
Now I'm getting a SyntaxError: invalid syntax in root = Tk(). If I split the
code in two parts (with the second one beginning in that line) and run them
separately, I get no errors, but still nothing happens.

class Application(Frame):
    def say_hi(self):
        print "hi there, everyone!"

    def createWidgets(self):
        self.QUIT = Button(self)
        self.QUIT["text"] = "QUIT"
        self.QUIT["fg"]   = "red"
        self.QUIT["command"] =  self.quit

        self.QUIT.pack({"side": "left"})

        self.hi_there = Button(self)
        self.hi_there["text"] = "Hello",
        self.hi_there["command"] = self.say_hi

        self.hi_there.pack({"side": "left"})

    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.pack()
        self.createWidgets()

var root = Tk()
app = Application(master=root)
app.mainloop()
root.destroy()

On Sun, May 4, 2008 at 12:33 PM, Q4 <q4 at invalid.com> wrote:

> On Sun, 4 May 2008 02:23:37 -0700 (PDT), Protected <myshelter at gmail.com>
> wrote:
> > Hello. I'm a complete newbie trying to learn Python. I decided to try
> > some Tkinter examples, including the one from the library reference,
> > but they don't seem to do anything! Shouldn't there be, like, a
> > dialog?
> >
> > I'm running Windows XP and using IDLE. You can assume my version of
> > Python is the latest.
> > --
> > http://mail.python.org/mailman/listinfo/python-list
>
> If you just copy the code from the python doc the indentation might be
> broken.
> Send the code and I'll take a look at it.
>
> Do you get any errors?
>
> --
> My website:
>  http://www.riddergarn.dk/koder/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080504/a2915df7/attachment-0001.html>


More information about the Python-list mailing list