Files
@ 18d23ce9a53f
Branch filter:
Location: OneEye/src/gui/resizablecanvas.py - annotation
18d23ce9a53f
920 B
text/x-python
settings:
setting and getting parameters
entering setup state
closing on setRecording
setting and getting parameters
entering setup state
closing on setRecording
9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba 9fa3f70d50ba | import tkinter as tk
class ResizableCanvas(tk.Canvas):
def __init__(self, master=None):
tk.Canvas.__init__(self, master, highlightthickness=0)
self._master=master
self._width=0
self._height=0
master.bind("<Configure>", self._onResize)
def configure(self,*args,**kwargs):
if "width" in kwargs: self._width=kwargs["width"]
if "height" in kwargs: self._height=kwargs["height"]
super().configure(*args,**kwargs)
def _onResize(self, event):
wScale=float(event.width)/self._width
hScale=float(event.height)/self._height
scale=min(wScale,hScale)
self._width*=scale
self._height*=scale
self.scale("all",0,0,scale,scale) # rescale all the objects tagged with the "all" tag
x=(event.width-self._width)/2
y=(event.height-self._height)/2
# place the widget, giving it an explicit size
self.place(in_=self._master, x=x, y=y, width=self._width, height=self._height)
return scale
|