File: pygadgets-products/unzipped/_PyClock/Clock/clockStyles.py
# precoded clock configuration styles (demos/examples)
"""
=================================================================
[SA] Sep-2017: updated for new configs structure, which allows
options to be set either as assignement in the PyGadgets config
file or command-line arguments. Example of arguments mode:
py3 clock.py
-PictureFile /MY-STUFF/Websites/UNION/pygadgets256.png
-BgColor white -InitialSize 400x400 -FgColor cyan
-HhColor brown -MhColor tan
Here, we manually build configs classes and skip files/args,
so the attributes set has to match the defaults set in clock.py.
=================================================================
"""
from clock import ClockPopup
from tkinter import Tk, Button, mainloop
#gifdir = '../gifs/'
gifdir = '../../Gui/gifs/' # [SA] Sep-2017 (and case matters on Linux!)
if __name__ == '__main__':
from sys import argv
if len(argv) > 1:
gifdir = argv[1] + '/' # arg? = gifs dir pathname
# Inheritable attributes set
class Default:
InitialSize='200x200'
DigitalFont=None # default family and size
DigitalFgColor=None # None=FgColor
BgColor='beige' # canvas
FgColor='brown' # ticks
HhColor='black' # hour hand
MhColor='navy' # minute hand
ShColor='blue' # second hand
CogColor='white' # center point
PictureFile=None
# Customization subclasses, arbitrarily deep
class PPClockBig(Default):
InitialSize = '320x'
PictureFile, BgColor, FgColor = gifdir + 'ora-pp.gif', 'tan', 'wheat'
class PPClockSmall(Default):
InitialSize = '175x175'
PictureFile = gifdir + 'ora-pp.gif'
BgColor, FgColor, HhColor, MhColor = 'white', 'red', 'blue', 'orange'
class GilliganClock(Default):
InitialSize = '550x'
PictureFile = gifdir + 'gilligan.gif'
BgColor, FgColor, HhColor, MhColor = 'black', 'white', 'gold', 'yellow'
class LP5EClock(GilliganClock):
InitialSize = '700x'
PictureFile = gifdir + 'lp5e-orm-cat.gif' # 'ora-lp4e.gif'
BgColor = '#112154' # 'navy'
class LP5EClockSmall(LP5EClock):
InitialSize, FgColor = '350x', 'orange'
class Pyref5EClock(Default):
InitialSize, PictureFile = '400x', gifdir + 'ora-pyref5e.gif'
BgColor, FgColor, HhColor = 'black', 'gold', 'brown'
class GreyClock(Default):
BgColor, FgColor, HhColor, MhColor, ShColor = 'grey', 'black', 'black', 'black', 'white'
class CyanClock(Default):
BgColor, FgColor, HhColor, MhColor, ShColor = 'cyan', 'yellow', 'purple', 'orange', 'yellow'
class PythonPoweredClock(Default):
BgColor, InitialSize, PictureFile = 'white', '175x', gifdir + 'pythonPowered.gif'
# Main script logic, when run standalone
if __name__ == '__main__':
root = Tk()
windows = [] # save refs on list to avoid gc (if it matters)
for configClass in [ # clock objects ultimately embed image objects,
Default, # but this works the same today without the list
PPClockBig,
#PPClockSmall,
LP5EClockSmall,
#GilliganClock,
Pyref5EClock,
GreyClock,
CyanClock,
PythonPoweredClock
]:
windows.append(ClockPopup(configClass, configClass.__name__))
b = Button(root, text='Quit Clocks', command=root.quit, font=('system', 20))
b.pack()
root.lift() # [SA] else obscured
root.focus() # [SA] else disabled
root.mainloop()