mainWindow.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. self.graph.update()
  24. if self.popup:
  25. self.popup.update()
  26. self.root.after(30, self.update)
  27. def calibrate(self):
  28. self.down_queue.put("calibrate")
  29. pu_root = tk.Tk()
  30. pu_root.title("Calibration")
  31. self.popup = Popup.CalibrationPopUp(pu_root,self.up_queue,self.down_queue,self.calibration_state)
  32. self.popup.pack(side="top", fill="both", expand=True)
  33. if __name__ == "__main__":
  34. root = tk.Tk()
  35. up_queue = queue.Queue()
  36. down_queue = queue.Queue()
  37. root.title("Tracking System")
  38. view = MainWindow(root,up_queue,down_queue,list())
  39. view.pack(side="top", fill="both", expand=True)
  40. view.update()
  41. root.mainloop()