From d3ef4bd3439c64c4ddbdec97427f6a3d7d668017 Mon Sep 17 00:00:00 2001 From: Joe R Date: Fri, 8 Oct 2021 21:42:57 -0400 Subject: [PATCH] Redid handling of tree window geometry. --- pysollib/tile/selectcardset.py | 11 +++++++---- pysollib/tile/selectgame.py | 13 +++++++------ pysollib/tile/selecttile.py | 12 +++++++----- pysollib/tile/tkwidget.py | 4 +++- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/pysollib/tile/selectcardset.py b/pysollib/tile/selectcardset.py index f3ff9610..a5780cd9 100644 --- a/pysollib/tile/selectcardset.py +++ b/pysollib/tile/selectcardset.py @@ -226,12 +226,15 @@ class SelectCardsetDialogWithPreview(MfxDialog): if self.TreeDataHolder_Class.data is None: self.TreeDataHolder_Class.data = self.TreeData_Class(manager, key) # - self.top.wm_minsize(400, 200) sw = self.top.winfo_screenwidth() sh = self.top.winfo_screenheight() h = sh * .8 - w1, w2 = min(300, sw // 2.5), max(sw / 2 + ((sw // 2.5) - 300), sw / 2) + w = sw * .8 + w1 = min(250, sw / 2.5) + geometry = ("%dx%d+%d+%d" % (w, h, (sw - w) / 2, (sh - h) / 2)) + self.top.wm_minsize(400, 200) + paned_window = ttk.PanedWindow(top_frame, orient='horizontal') paned_window.pack(expand=True, fill='both') left_frame = ttk.Frame(paned_window) @@ -319,7 +322,7 @@ class SelectCardsetDialogWithPreview(MfxDialog): left_frame.rowconfigure(0, weight=1) left_frame.columnconfigure(0, weight=1) # - self.preview = MfxScrolledCanvas(right_frame, width=w2, height=h) + self.preview = MfxScrolledCanvas(right_frame) self.preview.setTile(app, app.tabletile_index, force=True) self.preview.pack(fill='both', expand=True, padx=padx, pady=pady) self.preview.canvas.preview = 1 @@ -331,7 +334,7 @@ class SelectCardsetDialogWithPreview(MfxDialog): # focus = self.createButtons(bottom_frame, kw) focus = self.tree.frame - self.mainloop(focus, kw.timeout) + self.mainloop(focus, kw.timeout, geometry=geometry) def destroy(self): self.tree.updateNodesWithTree(self.tree.rootnodes, None) diff --git a/pysollib/tile/selectgame.py b/pysollib/tile/selectgame.py index 6b2e7a34..ced9aaec 100644 --- a/pysollib/tile/selectgame.py +++ b/pysollib/tile/selectgame.py @@ -351,12 +351,14 @@ class SelectGameDialogWithPreview(SelectGameDialog): if self.TreeDataHolder_Class.data is None: self.TreeDataHolder_Class.data = self.TreeData_Class(app) # - self.top.wm_minsize(400, 200) sw = self.top.winfo_screenwidth() sh = self.top.winfo_screenheight() h = sh * .8 - w1, w2 = min(250, sw // 2.5), max(sw / 2 + ((sw // 2.5) - 250), sw / 2) + w = sw * .8 + w1 = min(250, sw / 2.5) + geometry = ("%dx%d+%d+%d" % (w, h, (sw - w) / 2, (sh - h) / 2)) + self.top.wm_minsize(400, 200) # print sw, w1, w2 # w2 = max(200, min(w2, 10 + 12 * (app.subsampled_images.CARDW + 10))) @@ -374,8 +376,7 @@ class SelectGameDialogWithPreview(SelectGameDialog): # Tree font = app.getFont("default") self.tree = self.Tree_Class(self, left_frame, key=gameid, - default=kw.default, font=font, width=w1, - height=h) + default=kw.default, font=font, width=w1) self.tree.frame.pack(padx=padx, pady=pady, expand=True, fill='both') # LabelFrame info_frame = ttk.LabelFrame(right_frame, text=_('About game')) @@ -411,7 +412,7 @@ class SelectGameDialogWithPreview(SelectGameDialog): info_frame.rowconfigure(6, weight=1) stats_frame.rowconfigure(6, weight=1) # Canvas - self.preview = MfxScrolledCanvas(right_frame, width=w2) + self.preview = MfxScrolledCanvas(right_frame) self.preview.setTile(app, app.tabletile_index, force=True) self.preview.grid(row=1, column=0, columnspan=3, padx=padx, pady=pady, sticky='nsew') @@ -427,7 +428,7 @@ class SelectGameDialogWithPreview(SelectGameDialog): self.preview_app = None self.updatePreview(gameid, animations=0) # focus = self.tree.frame - self.mainloop(focus, kw.timeout) + self.mainloop(focus, kw.timeout, geometry=geometry) def initKw(self, kw): kw = KwStruct(kw, diff --git a/pysollib/tile/selecttile.py b/pysollib/tile/selecttile.py index 5957f0ac..f01e9f8b 100644 --- a/pysollib/tile/selecttile.py +++ b/pysollib/tile/selecttile.py @@ -127,12 +127,14 @@ class SelectTileDialogWithPreview(MfxDialog): if self.TreeDataHolder_Class.data is None: self.TreeDataHolder_Class.data = self.TreeData_Class(manager, key) # - self.top.wm_minsize(400, 200) sw = self.top.winfo_screenwidth() sh = self.top.winfo_screenheight() h = sh * .8 - w1, w2 = min(250, sw // 2.5), max(sw / 2 + ((sw // 2.5) - 250), sw / 2) + w = sw * .8 + w1 = min(250, sw / 2.5) + geometry = ("%dx%d+%d+%d" % (w, h, (sw - w) / 2, (sh - h) / 2)) + self.top.wm_minsize(400, 200) font = app.getFont("default") padx, pady = 4, 4 @@ -143,8 +145,7 @@ class SelectTileDialogWithPreview(MfxDialog): font=font, width=w1) self.tree.frame.pack(side="left", fill='both', expand=False, padx=padx, pady=pady) - self.preview = MfxScrolledCanvas(frame, width=w2, hbar=0, vbar=0, - height=h) + self.preview = MfxScrolledCanvas(frame, hbar=0, vbar=0) self.preview.pack(side="right", fill='both', expand=True, padx=padx, pady=pady) self.preview.canvas.preview = 1 @@ -154,7 +155,8 @@ class SelectTileDialogWithPreview(MfxDialog): # focus = self.createButtons(bottom_frame, kw) focus = self.tree.frame - self.mainloop(focus, kw.timeout) + + self.mainloop(focus, kw.timeout, geometry=geometry) def destroy(self): self.tree.updateNodesWithTree(self.tree.rootnodes, None) diff --git a/pysollib/tile/tkwidget.py b/pysollib/tile/tkwidget.py index 78c5e3b3..68c811ba 100644 --- a/pysollib/tile/tkwidget.py +++ b/pysollib/tile/tkwidget.py @@ -65,7 +65,7 @@ class MfxDialog: # ex. _ToplevelDialog # self.top.wm_maxsize(w-4, h-32) bind(self.top, "WM_DELETE_WINDOW", self.wmDeleteWindow) - def mainloop(self, focus=None, timeout=0, transient=True): + def mainloop(self, focus=None, timeout=0, transient=True, geometry=""): bind(self.top, "", self.mCancel) bind(self.top, '', self.altKeyEvent) # for accelerators if focus is not None: @@ -78,6 +78,8 @@ class MfxDialog: # ex. _ToplevelDialog if traceback: traceback.print_exc() pass + if geometry != "": + self.top.geometry(geometry) if timeout > 0: self.timer = after(self.top, timeout, self.mTimeout) try: