mainWindow.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. 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. self.graph.update()
  27. self.csString.set(self.calibration_state.state_clearname())
  28. self.root.after(30, self.update)
  29. def calibrate(self):
  30. self.calibration_state.reset_state()
  31. self.calibration_state.next_state()
  32. self.down_queue.put("calibrate")
  33. def start_mainwindow(up_queue,down_queue,calibration_state):
  34. root = tk.Tk()
  35. root.title("Tracking System")
  36. view = MainWindow(root,up_queue,down_queue,calibration_state)
  37. view.pack(side="top", fill="both", expand=True)
  38. view.update()
  39. root.mainloop()
  40. if __name__ == "__main__":
  41. root = tk.Tk()
  42. up_queue = queue.Queue()
  43. down_queue = queue.Queue()
  44. root.title("Tracking System")
  45. view = MainWindow(root,up_queue,down_queue,list())
  46. view.pack(side="top", fill="both", expand=True)
  47. view.update()
  48. root.mainloop()