| 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 | # |