From 61dc2e0d59045f75ed83259917af67ea5bafba6b Mon Sep 17 00:00:00 2001 From: Urban Wallasch Date: Tue, 4 May 2021 19:24:37 +0200 Subject: [PATCH] * Geometry shenanigans, again. --- ffpreview.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/ffpreview.py b/ffpreview.py index 60f475e..ed217c9 100755 --- a/ffpreview.py +++ b/ffpreview.py @@ -442,6 +442,8 @@ try: tlabel.bind("", lambda event: event.widget.config(bg=scrollframe["background"])) tlabels.append(tlabel) root.title(root.title() + ' [%d]' % thinfo["count"]) + tlwidth = tlabel.winfo_reqwidth() + tlheight = tlabel.winfo_reqheight() except Exception as e: eprint(str(e)) exit(2) @@ -455,13 +457,12 @@ def fill_grid(cols): x = 0; y += 1 def on_resize(event): - lw = tlwidth cols = cfg.grid_columns - cw = cols * lw - rw = root.winfo_width() - scrollbar.winfo_width() + cw = cols * tlwidth + rw = canvas.winfo_width() if rw < cw and cols > 1: cols -= 1 - elif rw > cw + lw: + elif rw > cw + tlwidth: cols += 1 if cols != cfg.grid_columns: cfg.grid_columns = cols @@ -470,14 +471,10 @@ def on_resize(event): ############################################################ # fix window geometry, start main loop -fill_grid(cfg.grid_columns) for il in ilabel: il.destroy() -root.update() -tlwidth = tlabels[0].winfo_width() -tlheight = tlabels[0].winfo_height() canvas.configure(yscrollincrement=tlheight) -root.geometry('%dx%d' % (tlwidth * cfg.grid_columns + scrollbar.winfo_width() + 1, 600) ) +root.geometry('%dx%d' % (tlwidth*cfg.grid_columns+scrollbar.winfo_reqwidth()+1, 5.2*tlheight) ) root.minsize(tlwidth, tlheight) root.bind("", on_resize) root.mainloop() -- 2.30.2