Problem with Tkinter in PyScripter

964 views
Skip to first unread message

Ovchik

unread,
Apr 14, 2012, 10:30:29 PM4/14/12
to PyScripter
Hi all,

Im currently using PyScripter for my coding environment and lately
been having issues with Tkinter code. I dont know much about EXACTLY
what's wrong so was thinking someone could help me. When i execute
some code I get this error and a few others. Please let me know what's
happening? It's the most up-to-date version of PyScripter that is out.

[url=http://postimage.org/image/gyrbda6zj/][img]http://
s19.postimage.org/gyrbda6zj/Tkinter_Error.jpg[/img][/url]

Ovchik

unread,
Apr 14, 2012, 10:32:39 PM4/14/12
to PyScripter
Here is the code that i try to execute when i have this problem...
[code]
try:
# Python2
import Tkinter as tk
except ImportError:
# Python3
import tkinter as tk

# create the main window
root = tk.Tk()
root.title("the drawing canvas")

# create the drawing canvas
canvas = tk.Canvas(root, width=600, height=500, bg='white')
canvas.pack()

# now let's draw a red line on the canvas object
# from coordinate points x=10, y=100 to x=400, y=50
canvas.create_line(10, 100, 400, 50, fill="red")
# another 2 lines
canvas.create_line(10, 100, 400, 75, fill="red")
canvas.create_line(10, 100, 400, 100, fill="red")

# now let's draw a red line on the canvas object
# from coordinate points x=10, y=100 to x=400, y=50
canvas.create_line(400, 100, fill="red")

# a blue rectangle with upper left corner x=10, y=15
# and lower right corner x=150, y=75
canvas.create_rectangle(10, 15, 150, 75, fill="blue")

# an oval is drawn within a given rectangle
# a square will give a circle
rect = (50, 110, 250, 310)
# optionally draw the outline of the rectangle
canvas.create_rectangle(rect)
canvas.create_oval(rect, fill='red')

# a circle in a circle
# outer circle first
rect = (350, 110, 550, 310)
canvas.create_oval(rect, fill='blue')
# now the inner circle
q = 50
rect = (350+q, 110+q, 550-q, 310-q)
canvas.create_oval(rect, fill='yellow')

# some circles drawn with a loop
for x in range(10, 450, 20):
rect = (x, 320, x+160, 480)
canvas.create_oval(rect) #, fill='magenta')

# start the GUI event loop
root.mainloop()
[/code]

PyScripter

unread,
Apr 16, 2012, 11:40:23 PM4/16/12
to pyscr...@googlegroups.com
The problem is in line 25:


canvas.create_line(400, 100, fill="red")

Create_line expects 4 coordinates and you have provided two.   If you comment out this line the code works fine.  The call stack of PyScripter correctly points the error.

Ovchik

unread,
Apr 24, 2012, 9:23:57 PM4/24/12
to PyScripter
Hey, thanks a lot for pointing that out, noob mistake... Thank you all
for your time!!!
> > > s19.postimage.org/gyrbda6zj/Tkinter_Error.jpg[/img][/url]<http://s19.postimage.org/gyrbda6zj/Tkinter_Error.jpg%5B/img%5D%5B/url%5D>
Reply all
Reply to author
Forward
0 new messages