Adjust scrollbars according to window- and canvas-size.
(self)
| 275 | |
| 276 | |
| 277 | def adjustScrolls(self): |
| 278 | """ Adjust scrollbars according to window- and canvas-size. |
| 279 | """ |
| 280 | cwidth = self._canvas.winfo_width() |
| 281 | cheight = self._canvas.winfo_height() |
| 282 | self._canvas.xview_moveto(0.5*(self.canvwidth-cwidth)/self.canvwidth) |
| 283 | self._canvas.yview_moveto(0.5*(self.canvheight-cheight)/self.canvheight) |
| 284 | if cwidth < self.canvwidth or cheight < self.canvheight: |
| 285 | self.hscroll.grid(padx=1, in_ = self, pady=1, row=1, |
| 286 | column=0, rowspan=1, columnspan=1, sticky='news') |
| 287 | self.vscroll.grid(padx=1, in_ = self, pady=1, row=0, |
| 288 | column=1, rowspan=1, columnspan=1, sticky='news') |
| 289 | else: |
| 290 | self.hscroll.grid_forget() |
| 291 | self.vscroll.grid_forget() |
| 292 | |
| 293 | def onResize(self, event): |
| 294 | """self-explanatory""" |