I'm trying to convert text to a variable name. So far, I've been able to solve most things with Google, but this is really frustrating:
Error:
Traceback (most recent call last):
File "C:/Documents and Settings/Some_Kittens/Desktop/Lab20/worldClock.py", line 33, in <module>
main()
File "C:/Documents and Settings/Some_Kittens/Desktop/Lab20/worldClock.py", line 21, in main
while not Quit.clicked(pt):
NameError: global name 'Quit' is not defined
Code:
from graphics import *
from clock import Clock
from button import Button
def main():
win = GraphWin("World Clock", 200, 250)
worldClock = Clock(win, Point(5,5), Point(200,200))
buttons = ["EST", "UTC", "PST", "Quit"]
xvar = 25
for button in buttons:
vars()[button] = Button(win, Point(xvar,220), 40, 20, button)
xvar = xvar + 50
vars()[button].activate()
pt = win.getMouse()
while not Quit.clicked(pt):
if EST.clicked(pt):
worldClock.showCurrentTime(-5, "EST")
if UTC.clicked(pt):
worldClock.showCurrentTime(0, "UTC")
if PST.clicked(pt):
worldClock.showCurrentTime(-8, "PST")
pt = win.getMouse()
win.close()
main()
The graphics window shows up fine, so I know "Quit" is being defined.