gory patches from Mutah

This commit is contained in:
tTh 2021-01-12 09:12:07 +01:00
parent 2a7624eb75
commit 22fb197e00

View File

@ -12,15 +12,16 @@ class StopWatch(Frame):
self._elapsed = 0.0 self._elapsed = 0.0
self._running = False self._running = False
self.timestr = StringVar() self.timestr = StringVar()
self._label = None
self.makeWidgets() self.makeWidgets()
def makeWidgets(self): def makeWidgets(self):
l = Label(self, textvariable=self.timestr, self._label = Label(self, textvariable=self.timestr,
font = "Helvetica 36 bold", font = "Helvetica 36 bold",
bg = "Grey20", fg = "Yellow", bg = "Grey20", fg = "Yellow",
padx = 30, pady = 30) padx = 30, pady = 30)
self._setTime(self._elapsed) self._setTime(self._elapsed)
l.pack(fill=X, expand=YES, pady=0, padx=0) self._label.pack(fill=X, expand=YES, pady=0, padx=0)
def _update(self): def _update(self):
self._elapsed = time.time() - self._start self._elapsed = time.time() - self._start
@ -60,20 +61,27 @@ class StopWatch(Frame):
def About(self): def About(self):
print "A kludge by tTh" print "A kludge by tTh"
def build_controls(root):
frame = Frame(root)
sw = StopWatch(root)
sw.pack(side=TOP)
Button(frame, text='Start', command=sw.Start).pack(side=LEFT)
Button(frame, text='Stop', command=sw.Stop).pack(side=LEFT)
Button(frame, text='Reset', command=sw.Reset).pack(side=LEFT)
Button(frame, text='Dump', command=sw.Dump).pack(side=LEFT)
Button(frame, text='Quit', command=root.quit).pack(side=LEFT)
frame.pack(side=BOTTOM)
def onsize(*args, **kw):
print args[0].width, args[0].height
# -------------------------------------------------------------------- # --------------------------------------------------------------------
if __name__ == '__main__': if __name__ == '__main__':
def main(): root = Tk()
root = Tk() root.title("Chronometre")
root.title("Chronometre") build_controls(root)
sw = StopWatch(root) root.bind("<Configure>", onsize)
sw.pack(side=TOP) root.mainloop()
Button(root, text='Start', command=sw.Start).pack(side=LEFT)
Button(root, text='Stop', command=sw.Stop).pack(side=LEFT)
Button(root, text='Reset', command=sw.Reset).pack(side=LEFT)
Button(root, text='Dump', command=sw.Dump).pack(side=LEFT)
Button(root, text='Quit', command=root.quit).pack(side=LEFT)
root.mainloop()
main()