-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyton_serial_control_flashes_1a1.py
106 lines (78 loc) · 4.58 KB
/
pyton_serial_control_flashes_1a1.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import serial # import the serial library
import time # import the time library
from Tkinter import * #import Tkinter GUI library
def n1():
arduino.write('xn1')
def n2():
arduino.write('xn2')
def n3():
arduino.write('xn3')
def n4():
arduino.write('xn4')
def n5():
arduino.write('xn5')
def t1():
arduino.write('xt1')
def t2():
arduino.write('xt2')
def t3():
arduino.write('xt3')
def t4():
arduino.write('xt4')
def t5():
arduino.write('xt5')
def p1():
arduino.write('xp1')
def p2():
arduino.write('xp2')
def p3():
arduino.write('xp3')
def p4():
arduino.write('xp4')
def p5():
arduino.write('xp5')
print 'Connecting...'
arduino = serial.Serial('COM3', 9600)
time.sleep(3)
print 'Connection established successfully'
appWindow = Tk() # creates the application window (you can use any name)
appWindow.wm_title("niq_ro's Python Control") # displays title at the top left
appWindow.config(bg ="#037481")
mainFrame = Frame(appWindow, bg="#037481") #define the main frame of the GUI
mainFrame.grid() #grid the frame into the App Window
btnFrame = Frame(mainFrame, bg="#037481") #define the frame within the main frame that holds buttons
btnFrame.grid() #grid the frame into the main frame
about = "GUI CONTROL by niq_ro"
name = Label(btnFrame, width=20, height=1, text=about, font="bold", justify=CENTER, bg="#037481")
name.grid(row=0, column=0)
LEDBtn = Button(btnFrame, text="n=1", command=n1, bg="red") #create a button inside the btnFrame with the given features
LEDBtn.grid(row=1, column=1) #grid the button in a specific row and column within the btnFrame
LEDBtn = Button(btnFrame, text="n=2", command=n2, bg="red") #create a button inside the btnFrame with the given features
LEDBtn.grid(row=1, column=2) #grid the button in a specific row and column within the btnFrame
LEDBtn = Button(btnFrame, text="n=3", command=n3, bg="red") #create a button inside the btnFrame with the given features
LEDBtn.grid(row=1, column=3) #grid the button in a specific row and column within the btnFrame
LEDBtn = Button(btnFrame, text="n=4", command=n4, bg="red") #create a button inside the btnFrame with the given features
LEDBtn.grid(row=1, column=4) #grid the button in a specific row and column within the btnFrame
LEDBtn = Button(btnFrame, text="n=5", command=n5, bg="red") #create a button inside the btnFrame with the given features
LEDBtn.grid(row=1, column=5) #grid the button in a specific row and column within the btnFrame
LEDBtn = Button(btnFrame, text="50ms", command=t1, bg="yellow") #create a button inside the btnFrame with the given features
LEDBtn.grid(row=2, column=1) #grid the button in a specific row and column within the btnFrame
LEDBtn = Button(btnFrame, text="100ms", command=t2, bg="yellow") #create a button inside the btnFrame with the given features
LEDBtn.grid(row=2, column=2) #grid the button in a specific row and column within the btnFrame
LEDBtn = Button(btnFrame, text="150ms", command=t3, bg="yellow") #create a button inside the btnFrame with the given features
LEDBtn.grid(row=2, column=3) #grid the button in a specific row and column within the btnFrame
LEDBtn = Button(btnFrame, text="200ms", command=t4, bg="yellow") #create a button inside the btnFrame with the given features
LEDBtn.grid(row=2, column=4) #grid the button in a specific row and column within the btnFrame
LEDBtn = Button(btnFrame, text="250ms", command=t5, bg="yellow") #create a button inside the btnFrame with the given features
LEDBtn.grid(row=2, column=5) #grid the button in a specific row and column within the btnFrame
LEDBtn = Button(btnFrame, text="1s", command=p1, bg="green") #create a button inside the btnFrame with the given features
LEDBtn.grid(row=3, column=1) #grid the button in a specific row and column within the btnFrame
LEDBtn = Button(btnFrame, text="2s", command=p2, bg="green") #create a button inside the btnFrame with the given features
LEDBtn.grid(row=3, column=2) #grid the button in a specific row and column within the btnFrame
LEDBtn = Button(btnFrame, text="3s", command=p3, bg="green") #create a button inside the btnFrame with the given features
LEDBtn.grid(row=3, column=3) #grid the button in a specific row and column within the btnFrame
LEDBtn = Button(btnFrame, text="4s", command=p4, bg="green") #create a button inside the btnFrame with the given features
LEDBtn.grid(row=3, column=4) #grid the button in a specific row and column within the btnFrame
LEDBtn = Button(btnFrame, text="55", command=p5, bg="green") #create a button inside the btnFrame with the given features
LEDBtn.grid(row=3, column=5) #grid the button in a specific row and column within the btnFrame
appWindow.mainloop()# begins main loop