From: Urban Wallasch Date: Tue, 4 May 2021 17:24:37 +0000 (+0200) Subject: * Geometry shenanigans, again. X-Git-Tag: v0.1~15 X-Git-Url: https://git.packet-gain.de/?a=commitdiff_plain;h=61dc2e0d59045f75ed83259917af67ea5bafba6b;p=ffpreview.git * Geometry shenanigans, again. --- 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()