-
Notifications
You must be signed in to change notification settings - Fork 0
/
DrawColorfulCirclesAndControlWithButtons.py
54 lines (38 loc) · 1.65 KB
/
DrawColorfulCirclesAndControlWithButtons.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from tkinter import *
root=Tk()
root.wm_title("Window Title")
root.config(background = "#FFFFFF")
def redCircle():
circleCanvas.create_oval(20, 20, 80, 80, width=0, fill='red')
colorLog.insert(0.0, "Red\n")
def yelCircle():
circleCanvas.create_oval(20, 20, 80, 80, width=0, fill='yellow')
colorLog.insert(0.0, "Yellow\n")
def grnCircle():
circleCanvas.create_oval(20, 20, 80, 80, width=0, fill='green')
colorLog.insert(0.0, "Green\n")
leftFrame=Frame(root, width=400, height = 800)
leftFrame.grid(row=0, column=0, padx=10, pady=2)
Label(leftFrame, text="Instructions:").grid(row=0, column=0, padx=10, pady=2)
Instruct=Label(leftFrame, text="1\n2\n2\n3\n4\n5\n6\n7\n8\n9\n")
Instruct.grid(row=1, column=0, padx=10, pady=2)
try:
imageEx = PhotoImage(file = '/home/pi/1.jpg')
Label(leftFrame, image=imageEx).grid(row=2, column=0, padx=10, pady=2)
except:
print("Image not found")
rightFrame=Frame(root, width=200, height = 600)
rightFrame.grid(row=0, column=1, padx=10, pady=2)
circleCanvas=Canvas(rightFrame, width=100, height=100, bg='white')
circleCanvas.grid(row=0, column=0, padx=10, pady=2)
btnFrame=Frame(rightFrame, width=200, height = 200)
btnFrame.grid(row=1, column=0, padx=10, pady=2)
colorLog=Text(rightFrame, width = 30, height = 10, takefocus=0)
colorLog.grid(row=2, column=0, padx=10, pady=2)
redBtn=Button(btnFrame, text="Red", command=redCircle)
redBtn.grid(row=0, column=0, padx=10, pady=2)
yellowBtn=Button(btnFrame, text="Yellow", command=yelCircle)
yellowBtn.grid(row=0, column=1, padx=10, pady=2)
greenBtn=Button(btnFrame, text="Green", command=grnCircle)
greenBtn.grid(row=0, column=2, padx=10, pady=2)
root.mainloop()