-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui.py
65 lines (52 loc) · 2.44 KB
/
gui.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
import tkinter as tk
import threading
import queue
class GUI(threading.Thread):
#Tkinter class for background updating of instrument values
request_queue = queue.Queue()
result_queue = queue.Queue()
def __init__(self):
threading.Thread.__init__(self)
def submit_to_tkinter(self,loc, value):
self.request_queue.put((loc, value))
#return result_queue.get()
def update_name(self, loc, name):
"""Name goes in column 1, with row = channel #"""
self.request_queue.put((loc, name))
t = None
label_dict ={}
def run(self):
#global t
def timertick():
try:
loc, value = self.request_queue.get_nowait()
#display_label = self.label_dict[loc[0]][loc[1]]
#display_label.config(text='%s' % (value,))
except queue.Empty:
pass
else:
display_label = self.label_dict[loc[0]][loc[1]]
display_label.config(text='%s' % (value,))
#Wait 10ms then run timertick again
self.t.after(10, timertick)
self.t = tk.Tk()
self.t.configure(width=640, height=480, background ='black')
#Set Headers
tk.Label(self.t, text = 'Channel #', font = ('Calibri',10, 'bold'),bg='white', borderwidth = 0, width=10).grid(row=0, column=0, padx =1, pady=1)
tk.Label(self.t, text = 'Name', font = ('Calibri',10, 'bold'), bg='white', borderwidth = 0, width=10).grid(row=0, column =1,padx =1, pady=1)
tk.Label(self.t, text = 'Voltage',font = ('Calibri',10, 'bold'),bg='white', borderwidth = 0, width=10).grid(row=0, column=2, padx =1, pady=1)
for i in range(1,49):
label_list = []
for j in range(3):
if j == 0:
tklabel = tk.Label(self.t, text='Channel %s' % (i,), font = ('Calibri',10), bg='white', borderwidth = 0, width=10 )
else:
tklabel = tk.Label(self.t,text='', font = ('Calibri',10),bg='white', borderwidth = 0, width = 10)
tklabel.grid(row=i, column=j, padx =1, pady=1)
#print(tklabel)
label_list.append(tklabel)
self.label_dict[i] = label_list
#b = tk.Button(text='test', name='button', command=exit)
#b.place(x=0, y=0)
timertick()
self.t.mainloop()