mainWindow.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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)
  21. calibrate_button_next.pack(side="top")
  22. cs = tk.Label(self.controls, text=str(self.calibration_state.return_state()), anchor="c")
  23. cs.pack(side="top", fill="both", expand=True)
  24. def update(self):
  25. self.graph.update()
  26. self.root.after(30, self.update)
  27. def calibrate(self):
  28. self.calibration_state.reset_state()
  29. self.calibration_state.next_state()
  30. self.down_queue.put("calibrate")
  31. def start_mainwindow(up_queue,down_queue,calibration_sate):
  32. root = tk.Tk()
  33. root.title("Tracking System")
  34. view = MainWindow(root,up_queue,down_queue,calibration_sate)
  35. view.pack(side="top", fill="both", expand=True)
  36. view.update()
  37. root.mainloop()
  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()