1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

Redid handling of tree window geometry.

This commit is contained in:
Joe R 2021-10-08 21:42:57 -04:00
parent 7824fe1e59
commit d3ef4bd343
4 changed files with 24 additions and 16 deletions

View file

@ -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)

View file

@ -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,

View file

@ -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)

View file

@ -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, "<Escape>", self.mCancel)
bind(self.top, '<Alt-Key>', 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: