dimanche 30 novembre 2014

TypeError/unbound local error - help!



I'm new to python and stuck with this error....help?

import graphics
from graphics import*

def house():
win=GraphWin(800,500)
win.setCoords(0.0,0.0,3.0,4.0)#reset coordinates
Text(Point(1.5,3.5),"click spot to designate 2 corners of house").draw(win)
p1=win.getMouse()
side1=(Point(p1.getX(),(p1.getY()))).draw(win)
p2=win.getMouse()
side2=(Point(p2.getX(),(p2.getY()))).draw
rectangle = Rectangle(Point(p1.getX()),(Point(p1.getY()))).draw(win)
house = ((side2.getX()-(side1.getX))).draw(win)
return house
house()

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.





================================ RESTART ================================



Traceback (most recent call last):
File "E:\ICS 140\ass 8.py", line 23, in <module>
house()
File "E:\ICS 140\ass 8.py", line 20, in house
Rectangle = Rectangle(Point(p1.getX()),(Point(p1.getY()))).draw(win)
UnboundLocalError: local variable 'Rectangle' referenced before assignment


================================ RESTART ================================



Traceback (most recent call last):
File "E:\ICS 140\ass 8.py", line 23, in <module>
house()
File "E:\ICS 140\ass 8.py", line 20, in house
rectangle = Rectangle(Point(p1.getX()),(Point(p1.getY()))).draw(win)
TypeError: __init__() missing 1 required positional argument: 'y'







Aucun commentaire:

Enregistrer un commentaire