Fix GUI issues
- Fix bug in displaySize() - Use floats and round rather than int to improve error propagation - Wait until after root window is created to bind onDocViewResize, to ignore initial problems. Then set initial root window size explicitly to trigger correct sizing. This fixes #10. - Separate threshold to change displayMaxSize into x & y direction.
Dieser Commit ist enthalten in:
Ursprung
d6adc14fec
Commit
f58854ff5d
1 geänderte Dateien mit 13 neuen und 10 gelöschten Zeilen
23
pdf-sign
23
pdf-sign
|
@ -74,8 +74,8 @@ def main(args):
|
||||||
def displaySize():
|
def displaySize():
|
||||||
(maxWidth, maxHeight)=displayMaxSize()
|
(maxWidth, maxHeight)=displayMaxSize()
|
||||||
(pageWidth, pageHeight)=pageSize()
|
(pageWidth, pageHeight)=pageSize()
|
||||||
scale=min(maxWidth/pageWidth, maxHeight/pageWidth)
|
scale=min(maxWidth/pageWidth, maxHeight/pageHeight)
|
||||||
return (int(pageWidth*scale), int(pageHeight*scale))
|
return (round(pageWidth*scale), round(pageHeight*scale))
|
||||||
@Cell
|
@Cell
|
||||||
def displayPNG():
|
def displayPNG():
|
||||||
(w, h)=displaySize()
|
(w, h)=displaySize()
|
||||||
|
@ -218,19 +218,22 @@ def main(args):
|
||||||
(oldMaxWidth, oldMaxHeight)=displayMaxSize()
|
(oldMaxWidth, oldMaxHeight)=displayMaxSize()
|
||||||
if(0<canvasMarginX and 0<canvasMarginY):
|
if(0<canvasMarginX and 0<canvasMarginY):
|
||||||
apparentScale=max(canvasHeight/oldMaxHeight, canvasWidth/oldMaxWidth, 0.5)
|
apparentScale=max(canvasHeight/oldMaxHeight, canvasWidth/oldMaxWidth, 0.5)
|
||||||
newMaxWidth=int((canvasWidth+2*canvasMarginX)/apparentScale-10)
|
newMaxWidth=(canvasWidth+2*canvasMarginX)/apparentScale-10
|
||||||
newMaxHeight=int((canvasHeight+2*canvasMarginY)/apparentScale-10)
|
newMaxHeight=(canvasHeight+2*canvasMarginY)/apparentScale-10
|
||||||
if(5<abs(oldMaxWidth-newMaxWidth) or 5<abs(oldMaxHeight-newMaxHeight)):
|
|
||||||
displayMaxSize((newMaxWidth, newMaxHeight))
|
|
||||||
update()
|
|
||||||
else:
|
else:
|
||||||
newMaxWidth=max(int(oldMaxWidth/2), 10)
|
newMaxWidth=oldMaxWidth/2
|
||||||
newMaxHeight=max(int(oldMaxHeight/2), 10)
|
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))
|
displayMaxSize((newMaxWidth, newMaxHeight))
|
||||||
update()
|
update()
|
||||||
root._docView.bind('<Configure>', onDocViewResize)
|
|
||||||
root._docView.pack(expand=1)
|
root._docView.pack(expand=1)
|
||||||
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.geometry("800x600")
|
||||||
@Cell
|
@Cell
|
||||||
def updateTitle():
|
def updateTitle():
|
||||||
root.title(f'Signing page {pageNumber()}/{pageCount} of {filePath}')
|
root.title(f'Signing page {pageNumber()}/{pageCount} of {filePath}')
|
||||||
|
|
Laden …
Tabelle hinzufügen
In neuem Issue referenzieren