Popup.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import tkinter as tk
  2. import tkinter.messagebox
  3. import time
  4. import queue
  5. class CalibrationPopUp(tk.Frame):
  6. def __init__(self, root, calibration_state):
  7. self.root = root
  8. self.calibration_state = calibration_state
  9. tk.Frame.__init__(self, root)
  10. self.pendingClose = False
  11. self.instruction = tk.Label(self,text="Start Calibration", anchor="c",font=("Courier",18))
  12. self.instruction.pack(side="top", fill="both", expand=True)
  13. button = tk.Button(self,text="OK", command=self.calibration_state.next_state_gui, anchor="c",height=1,width=5)
  14. button.pack(side="top", fill="both", expand=True)
  15. self.cs = tk.Label(self,text=self.calibration_state.state_clearname(), anchor="c")
  16. self.cs.pack(side="top", fill="both", expand=True)
  17. root.bind('<Escape>', self.close)
  18. def update(self):
  19. if not self.root.winfo_exists():
  20. return
  21. self.cs["text"] = self.calibration_state.state_clearname()
  22. if self.calibration_state.get_state() == self.calibration_state.WAITING_POS_1:
  23. self.instruction["text"] = "Move gondola to far left corner!"
  24. elif self.calibration_state.get_state() == self.calibration_state.WAITING_POS_2:
  25. self.instruction["text"] = "Move gondola to far right corner!"
  26. elif self.calibration_state.get_state() == self.calibration_state.CALIBRATION_DONE and not self.pendingClose:
  27. self.pendingClose = True
  28. self.root.after(1500, self.close)
  29. elif self.calibration_state.get_state() == self.calibration_state.CALIBRATION_DONE:
  30. self.instruction["text"] = "Calibration Done!"
  31. else:
  32. self.instruction["text"] = "Processing..."
  33. def close(self):
  34. if self.root.winfo_exists():
  35. self.root.destroy()