On 22/09/14 16:16, itsthewendigo1111 . wrote:

from tkinter import*
master = Tk();

canvas = Canvas(master, width = simpledialog.askinteger("Canvas size",
"Enter width of canvas"))

Its generally a bad idea to mix interactivity with widget creation. Better(and much easier to debug) to query the width first then create the widget:

w = simpledialog.askinteger("Canvas size", "Enter width of canvas")
canvas = Canvas(master, width = w)

Then you can print out the value of w or inspect it in a debugging tool.

Also you create several canvases but store only the last one in your canvas widget. Is that really what you want? Or do you really want to configure several attributes of the same canvas? Inwhich case use the configure method of the widget:
eg:
h = simpledialog....
col = simpledialog....
canvas.configure(height=h, color=col)  #etc...


s1 = canvas.create_rectangle(150,300,450,150, width =
simpledialog.askinteger('Square size', "Enter side length of square"))
s1 = simpledialog.askstring("Square color","Enter color for the square")

Here you have overwritten your square widget variable with
the string value. Is that really what you want?


I'm having trouble with the "width = simpledialog.askinteger".  width
almost makes like a border and not resize the square.

I'm assuming you are referring to the width in the rectangle widget
not the width in the canvas. Have you checked the documentation
of the square to see what the width parameter does?

The size of the rectangle is set by the two points you give it

s1 = canvas.create_rectangle(150,300,450,150,...

So it starts at (150,300) and ends at (450,150) So its size
in pixels is:

150-450 = 300
300-150 = 150

trouble with getting the square to change color.

You need to look at the fill attribute I suspect.


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to