MCPcopy Create free account
hub / github.com/ActiveState/code / __init__

Method __init__

recipes/Python/578875_Analog_Clock/recipe-578875.py:122–155  ·  view source on GitHub ↗
(self,root,deltahours = 0,sImage = True,w = 400,h = 400,useThread = False)

Source from the content-addressed store, hash-verified

120 # @param useThread whether to use a separate thread for running the clock.
121 #
122 def __init__(self,root,deltahours = 0,sImage = True,w = 400,h = 400,useThread = False):
123 self.world = [-1,-1,1,1]
124 self.imgPath = './images/fluminense.png' # image path
125 if hasPIL and os.path.exists (self.imgPath):
126 self.showImage = sImage
127 else:
128 self.showImage = False
129
130 self.setColors()
131 self.circlesize = 0.09
132 self._ALL = 'handles'
133 self.root = root
134 width, height = w, h
135 self.pad = width/16
136
137 if self.showImage:
138 self.fluImg = Image.open(self.imgPath)
139
140 self.root.bind("<Escape>", lambda _ : root.destroy())
141 self.delta = timedelta(hours = deltahours)
142 self.canvas = Canvas(root, width = width, height = height, background = self.bgcolor)
143 viewport = (self.pad,self.pad,width-self.pad,height-self.pad)
144 self.T = mapper(self.world,viewport)
145 self.root.title('Clock')
146 self.canvas.bind("<Configure>",self.resize)
147 self.root.bind("<KeyPress-i>", self.toggleImage)
148 self.canvas.pack(fill=BOTH, expand=YES)
149
150 if useThread:
151 st=makeThread(self.poll)
152 st.debug = True
153 st.start()
154 else:
155 self.poll()
156
157 ## Called when the window changes, by means of a user input.
158 #

Callers 1

__init__Method · 0.45

Calls 11

setColorsMethod · 0.95
pollMethod · 0.95
mapperClass · 0.85
makeThreadClass · 0.85
existsMethod · 0.45
openMethod · 0.45
bindMethod · 0.45
destroyMethod · 0.45
titleMethod · 0.45
packMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected