| 376 | return TK.PhotoImage(file=filename, master=self.cv) |
| 377 | |
| 378 | def __init__(self, cv): |
| 379 | self.cv = cv |
| 380 | if isinstance(cv, ScrolledCanvas): |
| 381 | w = self.cv.canvwidth |
| 382 | h = self.cv.canvheight |
| 383 | else: # expected: ordinary TK.Canvas |
| 384 | w = int(self.cv.cget("width")) |
| 385 | h = int(self.cv.cget("height")) |
| 386 | self.cv.config(scrollregion = (-w//2, -h//2, w//2, h//2 )) |
| 387 | self.canvwidth = w |
| 388 | self.canvheight = h |
| 389 | self.xscale = self.yscale = 1.0 |
| 390 | |
| 391 | def _createpoly(self): |
| 392 | """Create an invisible polygon item on canvas self.cv) |