mainWindow.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import tkinter as tk
  2. import tkinter.messagebox
  3. import time
  4. import queue
  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.calibration_state = calibration_state
  10. self.down_queue = down_queue
  11. self.up_queue = up_queue
  12. tk.Frame.__init__(self, root)
  13. self.graph = Graph.Graph(self)
  14. self.graph.pack(fill=tk.BOTH, side=tk.LEFT, expand=True)
  15. self.controls = tk.Frame(self)
  16. self.controls.pack(fill=tk.BOTH, side=tk.RIGHT)
  17. l = tk.Label(self.controls, text="your widgets go here...", anchor="c")
  18. l.pack(side="top", fill="both", expand=True)
  19. calibrate_button = tk.Button(self.controls,text="calibrate",command=self.calibrate)
  20. calibrate_button.pack(side="top")
  21. self.csString = tk.StringVar()
  22. cs = tk.Label(self.controls, textvariable=self.csString, anchor="c")
  23. cs.pack(side="top", fill="both", expand=True)
  24. def update(self):
  25. self.graph.update()
  26. self.csString.set(self.calibration_state.state_clearname())
  27. self.root.after(30, self.update)
  28. def calibrate(self):
  29. self.calibration_state.reset_state()
  30. tkinter.messagebox.showinfo(title="Calibrate", message="Move gondola to far left corner!")
  31. self.calibration_state.next_state()
  32. self.down_queue.put("calibrate")
  33. while self.calibration_state.return_state() != 3:
  34. time.sleep(1)
  35. tkinter.messagebox.showinfo(title="Calibrate", message="Move gondola to far rigth corner!")
  36. self.calibration_state.next_state()
  37. while self.calibration_state.return_state() != 7:
  38. time.sleep(1)
  39. tkinter.messagebox.showinfo(title="Calibrate",message="Calibration Done!") #display new calibration values?
  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()