[Tutor] Tkinter problem

Alan Gauld alan.gauld at btinternet.com
Sun Jun 15 23:55:14 CEST 2008

"Arden Hall" <arhall1 at comcast.net> wrote

> The source code is:

I don't know if you cut n paste this but there are several errors:

>    from Tkinter import *
>    root = Tk()
>    myContainer1 = Frame(root)
>    myContainer.pack()


>    button1 = Button(myContainer1)
>    button1["text"} = "Hello, World!"

] not }

>    button1[background"] = "green"
>    button1.pack


>    root.mainloop()

> I can execute this, but the button isn't green

After fixing the errors, it works on my XP and Linux boxes.
I haven't tried my Mac but see no reason why it shouldn't.

> I've tried to  write a  bit of code to create a canvas object and 
> put a rectangle in it, but I can't dimension the canvas, change its 
> color,  or get the rectangle to appear.  Any advice or suggestion 
> where to look for documentation would be greatly appreciated.

The online docs for tkinter are quite good.
Start with the Tkinter area on the Python web site.

Try posting more code here if it doesn't work. Cut n Paste by 
Describe what you expect and what you get.

Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list