[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版

(yzsuai) #1

class PPClockBig(PhotoClockConfig):
picture, bg, fg = gifdir + 'ora-pp.gif', 'navy', 'green'


class PPClockSmall(ClockConfig):
size = 175
picture = gifdir + 'ora-pp.gif'
bg, fg, hh, mh = 'white', 'red', 'blue', 'orange'


class GilliganClock(ClockConfig):
size = 550
picture = gifdir + 'gilligan.gif'
bg, fg, hh, mh = 'black', 'white', 'green', 'yellow'


class LP4EClock(GilliganClock):
size = 700
picture = gifdir + 'ora-lp4e.gif'
bg = 'navy'


class LP4EClockSmall(LP4EClock):
size, fg = 350, 'orange'


class Pyref4EClock(ClockConfig):
size, picture = 400, gifdir + 'ora-pyref4e.gif'
bg, fg, hh = 'black', 'gold', 'brown'


class GreyClock(ClockConfig):
bg, fg, hh, mh, sh = 'grey', 'black', 'black', 'black', 'white'


class PinkClock(ClockConfig):
bg, fg, hh, mh, sh = 'pink', 'yellow', 'purple', 'orange', 'yellow'


class PythonPoweredClock(ClockConfig):
bg, size, picture = 'white', 175, gifdir + 'pythonPowered.gif'


if name == 'main':
root = Tk()
for configClass in [
ClockConfig,
PPClockBig,
#PPClockSmall,
LP4EClockSmall,
#GilliganClock,
Pyref4EClock,
GreyClock,
PinkClock,
PythonPoweredClock
]:
ClockPopup(configClass, configClass.name)
Button(root, text='Quit Clocks', command=root.quit).pack()
root.mainloop()


Running this script creates the multiple clock display of Figure 11-24. Its configurations
support numerous options; judging from the seven clocks on the display, though, it’s
time to move on to our last example.


PyClock: An Analog/Digital Clock Widget | 761
Free download pdf