Advertisement
Guest User

Untitled

a guest
May 31st, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. #!/usr/local/bin/env python3
  2. import tkinter as tk # python3
  3. from tkinter import BooleanVar
  4.  
  5. TITLE_FONT = ("Helvetica", 18, "bold")
  6.  
  7. class SampleApp(tk.Tk):
  8.  
  9. def __init__(self, *args, **kwargs):
  10. tk.Tk.__init__(self, *args, **kwargs)
  11. container = tk.Frame(self)
  12. container.pack(side="top", fill="both", expand=True)
  13. container.grid_rowconfigure(0, weight=1)
  14. container.grid_columnconfigure(0, weight=1)
  15. self.Page1_data={"Step1Complete": BooleanVar()}
  16. self.frames = {}
  17. for F in (StartPage, PageFifteen):
  18. page_name = F.__name__
  19. frame = F(container, self)
  20. self.frames[page_name] = frame
  21. frame.grid(row=0, column=0, sticky="nsew")
  22. self.show_frame("StartPage")
  23.  
  24. def show_frame(self, page_name):
  25. frame = self.frames[page_name]
  26. frame.tkraise()
  27.  
  28. class StartPage(tk.Frame):
  29.  
  30.  
  31.  
  32. def __init__(self, parent, controller):
  33. tk.Frame.__init__(self, parent)
  34. self.controller = controller
  35. controller.title("Part B Data Collection")
  36. controller.geometry("600x500")
  37. label = tk.Label(self, text="Welcome to the Part B Test!", font=TITLE_FONT)
  38. label.pack(side="top", fill="x", pady=10)
  39. button1 = tk.Button(self, text="Complete Step 1", command=self.MakeStep1Complete)
  40. button1.place(relx=0.385, rely=0.65)
  41.  
  42.  
  43. def MakeStep1Complete(self):
  44.  
  45. Step1Complete=True
  46. self.controller.Page1_data["Step1Complete"]=Step1Complete
  47. self.controller.show_frame("PageFifteen")
  48.  
  49.  
  50.  
  51.  
  52. class PageFifteen(tk.Frame):
  53.  
  54.  
  55.  
  56. def StatusCheck(self):
  57. Step1Complete=self.controller.Page1_data["Step1Complete"]
  58. print("True or false: at Step 15, Step 1 completed -a ")
  59. print(Step1Complete)
  60.  
  61.  
  62.  
  63.  
  64. def __init__(self, parent, controller):
  65. tk.Frame.__init__(self, parent)
  66. self.controller = controller
  67. label = tk.Label(self, text="Check the data", font=TITLE_FONT)
  68. label.pack(side="top", fill="x", pady=10)
  69.  
  70. self.StatusCheck()
  71.  
  72. tk.Label(self, text="Click on each of the buttons below to review the data you have inputted").place(relx=0.15, rely=0.12)
  73.  
  74. Step1Complete=self.controller.Page1_data["Step1Complete"].get()
  75. print("True or false: at Step 15, Step 1 completed - b")
  76. print(Step1Complete)
  77.  
  78. button17=tk.Button(self, text="Check if we did everything",
  79.  
  80. command=self.StatusCheck)
  81. button17.place(relx=0.7, rely=0.75)
  82.  
  83. if __name__ == "__main__":
  84. app = SampleApp()
  85. app.mainloop()
  86.  
  87. True or false: at Step 15, Step 1 completed -a
  88. PY_VAR1045
  89. True or false: at Step 15, Step 1 completed - b
  90. False
  91. True or false: at Step 15, Step 1 completed -a
  92. True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement