Improve display size calculations
Dieser Commit ist enthalten in:
Ursprung
8f299dda2e
Commit
34fdeb1043
1 geänderte Dateien mit 12 neuen und 22 gelöschten Zeilen
34
pdf-sign
34
pdf-sign
|
@ -238,30 +238,20 @@ def main(args):
|
||||||
root.bind(f'{char}', onkey)
|
root.bind(f'{char}', onkey)
|
||||||
for i, char in enumerate("123456789"): bindDigit(i, char)
|
for i, char in enumerate("123456789"): bindDigit(i, char)
|
||||||
# Canvas and click binding
|
# Canvas and click binding
|
||||||
root._docView=tk.Canvas(root, borderwidth=0, background='#ffffff', confine=True)
|
root._docView=tk.Canvas(root, borderwidth=0, background='#ffffff')
|
||||||
def onDocViewResize(event):
|
docViewMargin=5
|
||||||
canvasMarginX=event.x
|
docViewMinDimension=50
|
||||||
canvasMarginY=event.y
|
def onRootResize(event):
|
||||||
canvasWidth=event.width
|
rootWidth=root.winfo_width()
|
||||||
canvasHeight=event.height
|
rootHeight=root.winfo_height()
|
||||||
(oldMaxWidth, oldMaxHeight)=displayMaxSize()
|
newMaxDisplayDimensions=(max(rootWidth - 2 * docViewMargin, docViewMinDimension),
|
||||||
if(0<canvasMarginX and 0<canvasMarginY):
|
max(rootHeight - 2 * docViewMargin, docViewMinDimension))
|
||||||
apparentScale=max(canvasHeight/oldMaxHeight, canvasWidth/oldMaxWidth, 0.5)
|
if displayMaxSize() != newMaxDisplayDimensions:
|
||||||
newMaxWidth=(canvasWidth+2*canvasMarginX)/apparentScale-10
|
displayMaxSize(newMaxDisplayDimensions)
|
||||||
newMaxHeight=(canvasHeight+2*canvasMarginY)/apparentScale-10
|
|
||||||
else:
|
|
||||||
newMaxWidth=oldMaxWidth/2
|
|
||||||
newMaxHeight=oldMaxHeight/2
|
|
||||||
newMaxWidth=max(newMaxWidth, 10)
|
|
||||||
newMaxHeight=max(newMaxHeight, 10)
|
|
||||||
if abs(oldMaxWidth-newMaxWidth) < 5: newMaxWidth=oldMaxWidth
|
|
||||||
if abs(oldMaxHeight-newMaxHeight) < 5: newMaxHeight=oldMaxHeight
|
|
||||||
if oldMaxWidth != newMaxWidth or oldMaxHeight != newMaxHeight:
|
|
||||||
displayMaxSize((newMaxWidth, newMaxHeight))
|
|
||||||
update()
|
update()
|
||||||
root._docView.pack(expand=1)
|
root._docView.place(x=docViewMargin, y=docViewMargin)
|
||||||
root._docViewIndex=root._docView.create_image(0, 0, anchor=tk.NW)
|
root._docViewIndex=root._docView.create_image(0, 0, anchor=tk.NW)
|
||||||
root._docView.bind('<Configure>', onDocViewResize)
|
root.bind('<Configure>', onRootResize)
|
||||||
root.geometry("800x600")
|
root.geometry("800x600")
|
||||||
@Cell
|
@Cell
|
||||||
def updateTitle():
|
def updateTitle():
|
||||||
|
|
Laden …
Tabelle hinzufügen
In neuem Issue referenzieren