mainWindow.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import tkinter as tk
  2. import time
  3. import queue
  4. import gui.graph as Graph
  5. class MainWindow(tk.Frame):
  6. def __init__(self, root, up_queue, down_queue,calibration_state):
  7. self.root = root
  8. self.calibration_state = calibration_state
  9. self.down_queue = down_queue
  10. self.up_queue = up_queue
  11. tk.Frame.__init__(self, root)
  12. self.graph = Graph.Graph(self)
  13. self.graph.pack(fill=tk.BOTH, side=tk.LEFT, expand=True)
  14. self.controls = tk.Frame(self)
  15. self.controls.pack(fill=tk.BOTH, side=tk.RIGHT)
  16. l = tk.Label(self.controls, text="your widgets go here...", anchor="c")
  17. l.pack(side="top", fill="both", expand=True)
  18. calibrate_button = tk.Button(self.controls,text="calibrate",command=self.calibrate)
  19. calibrate_button.pack(side="top")
  20. calibrate_button_next = tk.Button(self.controls,text="calibrate_next",command=self.calibration_state.next_state_gui)
  21. calibrate_button_next.pack(side="top")
  22. self.csString = tk.StringVar()
  23. cs = tk.Label(self.controls, textvariable=self.csString, anchor="c")
  24. cs.pack(side="top", fill="both", expand=True)
  25. def update(self):
  26. ac_data = []
  27. while self.up_queue.qsize() > 0:
  28. name, data = self.up_queue.get()
  29. if name == "ac_data":
  30. ac_data.append(data)
  31. self.graph.update([ac_data])
  32. self.csString.set(self.calibration_state.state_clearname())
  33. self.root.after(30, self.update)
  34. def calibrate(self):
  35. self.down_queue.put("calibrate")
  36. if __name__ == "__main__":
  37. root = tk.Tk()
  38. up_queue = queue.Queue()
  39. down_queue = queue.Queue()
  40. root.title("Tracking System")
  41. view = MainWindow(root,up_queue,down_queue,list())
  42. view.pack(side="top", fill="both", expand=True)
  43. view.update()
  44. root.mainloop()