-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestui.py
63 lines (44 loc) · 1.92 KB
/
testui.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
import tkinter as tk
from tkinter import ttk
# Global flag
FLAG = False
class UI:
def __init__(self, master):
master.title("SPTU")
master.geometry("220x120")
frame = tk.Frame(master)
frame.pack()
self.testButton = tk.Button(frame, text="Start Test", command=self.start_test)
self.testButton.grid(row=0, column=0, padx=0, pady=10)
self.quitButton = tk.Button(frame, text="Quit", command=frame.quit)
self.quitButton.grid(row=0, column=1, padx=0, pady=10)
self.device = ttk.Combobox(frame, width=16)
self.device['values'] = ()
self.device.config(state='readonly')
self.device.grid(row=1, column=0, padx=0, pady=0, columnspan=2)
self.status = tk.Label(frame, text="Status: ")
self.status.grid(row=2, column=0, padx=0, pady=10)
self.n_status = tk.Label(frame, text="")
def start_test(self):
if self.device.get() == "":
self.null_device()
else:
global FLAG
FLAG = True
self.device.config(state='disabled')
self.testButton.config(text="Stop test", command=self.stop_test)
# print(self.device.current(), self.device.get())
self.n_status.grid(row=2, column=1, padx=0, pady=10)
def stop_test(self):
global FLAG
FLAG = False
self.device.config(state='readonly')
self.testButton.config(text="Start test", command=self.start_test)
self.n_status.grid_forget()
def status_pass(self):
self.n_status.config(text="PASS", fg="black", bg='green')
def status_fail(self):
self.n_status.config(text="FAIL", fg="black", bg='red')
def null_device(self):
self.n_status.config(text="Null", fg='red')
self.n_status.grid(row=2, column=1, padx=0, pady=10)