From f58854ff5d220fd38408fdc73a50335b79b0b742 Mon Sep 17 00:00:00 2001 From: Axel Svensson Date: Sat, 1 Jun 2024 13:44:53 +0200 Subject: [PATCH] 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. --- pdf-sign | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/pdf-sign b/pdf-sign index 0f4bc5a..c11cb1c 100755 --- a/pdf-sign +++ b/pdf-sign @@ -74,8 +74,8 @@ def main(args): def displaySize(): (maxWidth, maxHeight)=displayMaxSize() (pageWidth, pageHeight)=pageSize() - scale=min(maxWidth/pageWidth, maxHeight/pageWidth) - return (int(pageWidth*scale), int(pageHeight*scale)) + scale=min(maxWidth/pageWidth, maxHeight/pageHeight) + return (round(pageWidth*scale), round(pageHeight*scale)) @Cell def displayPNG(): (w, h)=displaySize() @@ -218,19 +218,22 @@ def main(args): (oldMaxWidth, oldMaxHeight)=displayMaxSize() if(0', onDocViewResize) root._docView.pack(expand=1) root._docViewIndex=root._docView.create_image(0, 0, anchor=tk.NW) + root._docView.bind('', onDocViewResize) + root.geometry("800x600") @Cell def updateTitle(): root.title(f'Signing page {pageNumber()}/{pageCount} of {filePath}')