-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex19_3.py
More file actions
executable file
·30 lines (24 loc) · 889 Bytes
/
ex19_3.py
File metadata and controls
executable file
·30 lines (24 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python
from swampy.Gui import *
def make_circle():
circle = canvas.circle([0,0], 100, fill='red')
entry = g.en(text='Enter Color')
button2 = g.bu(text='Enter', command=change_color)
global circle, entry
# handle the exception of changing color on a circle not created by
# the order of operations, i.e. does not get to the color change until circle is created.
def change_color():
color = entry.get()
colorList = ['white', 'black', 'red', 'green', 'blue', 'cyan', 'yellow', 'magenta']
if color not in colorList:
print "The color you specified is not valid. Available colors are: "
for i in colorList:
print i
else:
circle.config(fill=color)
g = Gui()
g.title('Gui')
canvas = g.ca(width=500, height=500)
canvas.config(bg='white')
button1 = g.bu(text="Make Circle", command=make_circle)
g.mainloop()