def create_preference_window(): tk = Tk() tk.title("snake") tk.resizable(False, False) Label(tk, text=WELCOME_TEXT).grid(row=0, column=0, columnspan=4) Label(tk, text="Speed: ").grid(row=1, column=0) speed_box = Spinbox(tk, values=list(Speed), state='readonly') while speed_box.get() != str(Speed.NORMAL): speed_box.invoke('buttonup') speed_box.grid(row=1, column=1) Label(tk, text="Length: ").grid(row=1, column=2) Label(tk, text="Height: ").grid(row=2, column=2) length_box, height_box = Entry(tk), Entry(tk) length_box.insert(0, "20"), height_box.insert(0, "20") length_box.grid(row=1, column=3), height_box.grid(row=2, column=3) state = _WindowState(tk, speed_box, length_box, height_box) Button(tk, text="Start!", command=state.pressing_start).grid(row=3, column=0, columnspan=2) Button(tk, text="Quit", command=state.pressing_quit).grid(row=3, column=2, columnspan=2) tk.mainloop() if state.quit: raise TclError return state.checked_values
class ConfigTimeFrame(RootFrame): def __init__(self, *args, **kw): super(ConfigTimeFrame, self).__init__(*args, **kw) #image de fond self.canevas.create_image(self.canevas_width / 2, self.canevas_height / 2, anchor=CENTER, image=self.photo) #label suivant self.labelSuivant = Label(self, text="Suivant", relief=RAISED) self.labelSuivant.configure(font=self.font, fg=self.colorOrange, bg="white") #time spinbox self.spinboxTime = Spinbox(self, from_=10, to=120, increment=10) self.spinboxTime.focus() self.spinboxTime.configure(font=self.font, fg=self.colorBlue, bg="white") #config time self.labelConfigTime = Label( self, text="Entrer la durée de l'analyse en minute") self.labelConfigTime.configure(font=self.font, fg=self.colorBlue, bg="white") #display self.labelConfigTime.pack(side="top") self.spinboxTime.pack(side="top") self.labelSuivant.pack(side="top") def getTimeConfigured(self): return int(self.spinboxTime.get()) #this method is call by provider action def incrementTimeConfigured(self, event): self.spinboxTime.invoke('buttonup') #this method is call by provider action def decrementTimeConfigured(self, event): self.spinboxTime.invoke('buttondown')