mainWindow.py 1.6 KB

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