class DisplayClock: def __init__(self): window = Tk() # Create a window window.title("Change Clock Time") # Set title self.clock = StillClock(window) # Create a clock self.clock.pack() frame = Frame(window) frame.pack() Label(frame, text = "Hour: ").pack(side = LEFT) self.hour = IntVar() self.hour.set(self.clock.getHour()) Entry(frame, textvariable = self.hour, width = 2).pack(side = LEFT) Label(frame, text = "Minute: ").pack(side = LEFT) self.minute = IntVar() self.minute.set(self.clock.getMinute()) Entry(frame, textvariable = self.minute, width = 2).pack(side = LEFT) Label(frame, text = "Second: ").pack(side = LEFT) self.second = IntVar() self.second.set(self.clock.getMinute()) Entry(frame, textvariable = self.second, width = 2).pack(side = LEFT) Button(frame, text = "Set New Time", command = self.setNewTime).pack(side = LEFT) window.mainloop() # Create an event loop def setNewTime(self): self.clock.setHour(self.hour.get()) self.clock.setMinute(self.minute.get()) self.clock.setSecond(self.second.get())
class DisplayClock: def __init__(self): window = Tk() # Create a window window.title("Change Clock Time") # Set title self.clock = StillClock(window) # Create a clock self.clock.pack() frame = Frame(window) frame.pack() Label(frame, text="Hour: ").pack(side=LEFT) self.hour = IntVar() self.hour.set(self.clock.getHour()) Entry(frame, textvariable=self.hour, width=2).pack(side=LEFT) Label(frame, text="Minute: ").pack(side=LEFT) self.minute = IntVar() self.minute.set(self.clock.getMinute()) Entry(frame, textvariable=self.minute, width=2).pack(side=LEFT) Label(frame, text="Second: ").pack(side=LEFT) self.second = IntVar() self.second.set(self.clock.getMinute()) Entry(frame, textvariable=self.second, width=2).pack(side=LEFT) Button(frame, text="Set New Time", command=self.setNewTime).pack(side=LEFT) window.mainloop() # Create an event loop def setNewTime(self): self.clock.setHour(self.hour.get()) self.clock.setMinute(self.minute.get()) self.clock.setSecond(self.second.get())
class DisplayClock: def __init__(self): window = Tk() # 윈도우를 생성한다. window.title("시계 시간 변경하기") # 제목을 설정한다. self.clock = StillClock(window) # 시계를 생성한다. self.clock.pack() frame = Frame(window) frame.pack() Label(frame, text="시: ").pack(side=LEFT) self.hour = IntVar() self.hour.set(self.clock.getHour()) Entry(frame, textvariable=self.hour, width=2).pack(side=LEFT) Label(frame, text="분: ").pack(side=LEFT) self.minute = IntVar() self.minute.set(self.clock.getMinute()) Entry(frame, textvariable=self.minute, width=2).pack(side=LEFT) Label(frame, text="초: ").pack(side=LEFT) self.second = IntVar() self.second.set(self.clock.getMinute()) Entry(frame, textvariable=self.second, width=2).pack(side=LEFT) Button(frame, text="새로운 시각 설정", command=self.setNewTime).pack(side=LEFT) window.mainloop() # 이벤트 루프를 생성한다. def setNewTime(self): self.clock.setHour(self.hour.get()) self.clock.setMinute(self.minute.get()) self.clock.setSecond(self.second.get())
class DisplayClock(object): """docstring for DisplayClock""" def __init__(self): super(DisplayClock, self).__init__() # self.arg = arg window=tk.Tk() window.title('change clock time') self.clock=StillClock(window) self.clock.pack() frame=tk.Frame(window) frame.pack() tk.Label(frame,text='hour: ').pack(side=tk.LEFT) self.hour=tk.IntVar() self.hour.set(self.clock.getHour()) tk.Entry(frame,textvariable=self.hour,width=2).pack(side=tk.LEFT) tk.Label(frame,text='minute: ').pack(side=tk.LEFT) self.minute=tk.IntVar() self.minute.set(self.clock.getMinute()) tk.Entry(frame,textvariable=self.minute,width=2).pack(side=tk.LEFT) tk.Label(frame,text='second: ').pack(side=tk.LEFT) self.second=tk.IntVar() self.second.set(self.clock.getSecond()) tk.Entry(frame,textvariable=self.second,width=2).pack(side=tk.LEFT) tk.Button(frame,text='set new time',command=self.setNewTime).pack(side=tk.LEFT) window.mainloop() def setNewTime(self): self.clock.setHour(self.hour.get()) self.clock.setMinute(self.minute.get()) self.clock.setSecond(self.second.get())