def __init__(self, parent, title, app, manager, key=None, **kw): kw = self.initKw(kw) MfxDialog.__init__(self, parent, title, kw.resizable, kw.default) top_frame, bottom_frame = self.createFrames(kw) self.createBitmaps(top_frame, kw) # if key is None: key = manager.getSelected() self.manager = manager self.key = key self.app = app # padx, pady = kw.padx, kw.pady padx, pady = 5, 5 if self.TreeDataHolder_Class.data is None: self.TreeDataHolder_Class.data = self.TreeData_Class(manager, key) # self.top.wm_minsize(400, 200) if self.top.winfo_screenwidth() >= 800: w1, w2 = 240, 400 else: w1, w2 = 200, 300 paned_window = tkinter.PanedWindow(top_frame) paned_window.pack(expand=True, fill='both') left_frame = tkinter.Frame(paned_window) right_frame = tkinter.Frame(paned_window) paned_window.add(left_frame) paned_window.add(right_frame) font = app.getFont("default") self.tree = self.Tree_Class(self, left_frame, key=key, default=kw.default, font=font, width=w1) self.tree.frame.grid(row=0, column=0, sticky='nsew', padx=padx, pady=pady) if USE_PIL: # var = tkinter.DoubleVar() var.set(app.opt.scale_x) self.scale_x = tkinter.Scale( left_frame, label=_('Scale X:'), from_=0.5, to=4.0, resolution=0.1, orient='horizontal', variable=var, # value=app.opt.scale_x, command=self._updateScale) self.scale_x.grid(row=1, column=0, sticky='ew', padx=padx, pady=pady) # var = tkinter.DoubleVar() var.set(app.opt.scale_y) self.scale_y = tkinter.Scale( left_frame, label=_('Scale Y:'), from_=0.5, to=4.0, resolution=0.1, orient='horizontal', variable=var, # value=app.opt.scale_y, command=self._updateScale) self.scale_y.grid(row=2, column=0, sticky='ew', padx=padx, pady=pady) # self.auto_scale = tkinter.BooleanVar() self.auto_scale.set(app.opt.auto_scale) check = tkinter.Checkbutton(left_frame, text=_('Auto scaling'), variable=self.auto_scale, takefocus=False, command=self._updateAutoScale) check.grid(row=3, column=0, columnspan=2, sticky='w', padx=padx, pady=pady) # self.preserve_aspect = tkinter.BooleanVar() self.preserve_aspect.set(app.opt.preserve_aspect_ratio) self.aspect_check = tkinter.Checkbutton( left_frame, text=_('Preserve aspect ratio'), variable=self.preserve_aspect, takefocus=False, # command=self._updateScale ) self.aspect_check.grid(row=4, column=0, sticky='w', padx=padx, pady=pady) self._updateAutoScale() # left_frame.rowconfigure(0, weight=1) left_frame.columnconfigure(0, weight=1) # self.preview = MfxScrolledCanvas(right_frame, width=w2) 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 # create a preview of the current state self.preview_key = -1 self.preview_images = [] self.scale_images = [] self.updatePreview(key) # focus = self.createButtons(bottom_frame, kw) focus = self.tree.frame self.mainloop(focus, kw.timeout)
def __init__(self, parent, title, app, gameid, bookmark=None, **kw): kw = self.initKw(kw) MfxDialog.__init__(self, parent, title, kw.resizable, kw.default) top_frame, bottom_frame = self.createFrames(kw) self.createBitmaps(top_frame, kw) # self.app = app self.gameid = gameid self.bookmark = bookmark self.random = None 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() if sw >= 1100: w1, w2 = 250, 600 elif sw >= 900: w1, w2 = 250, 500 elif sw >= 800: w1, w2 = 220, 480 else: w1, w2 = 200, 300 # print sw, w1, w2 w2 = max(200, min(w2, 10 + 12 * (app.subsampled_images.CARDW + 10))) # print sw, w1, w2 # padx, pady = kw.padx, kw.pady padx, pady = kw.padx // 2, kw.pady // 2 # PanedWindow paned_window = tkinter.PanedWindow(top_frame) paned_window.pack(expand=True, fill='both') left_frame = tkinter.Frame(paned_window) right_frame = tkinter.Frame(paned_window) paned_window.add(left_frame) paned_window.add(right_frame) # Tree font = app.getFont("default") self.tree = self.Tree_Class(self, left_frame, key=gameid, default=kw.default, font=font, width=w1) self.tree.frame.pack(padx=padx, pady=pady, expand=True, fill='both') # LabelFrame info_frame = tkinter.LabelFrame(right_frame, text=_('About game')) stats_frame = tkinter.LabelFrame(right_frame, text=_('Statistics')) info_frame.grid(row=0, column=0, padx=padx, pady=pady, ipadx=padx, ipady=pady, sticky='nws') stats_frame.grid(row=0, column=1, padx=padx, pady=pady, ipadx=padx, ipady=pady, sticky='nws') # Info self.info_labels = {} for n, t, f, row in ( ('name', _('Name:'), info_frame, 0), ('altnames', _('Alternate names:'), info_frame, 1), ('category', _('Category:'), info_frame, 2), ('type', _('Type:'), info_frame, 3), ('skill_level', _('Skill level:'), info_frame, 4), ('decks', _('Decks:'), info_frame, 5), ('redeals', _('Redeals:'), info_frame, 6), # ('played', _('Played:'), stats_frame, 0), ('won', _('Won:'), stats_frame, 1), ('lost', _('Lost:'), stats_frame, 2), ('time', _('Playing time:'), stats_frame, 3), ('moves', _('Moves:'), stats_frame, 4), ('percent', _('% won:'), stats_frame, 5), ): title_label = tkinter.Label(f, text=t, justify='left', anchor='w') title_label.grid(row=row, column=0, sticky='nw') text_label = tkinter.Label(f, justify='left', anchor='w') text_label.grid(row=row, column=1, sticky='nw') self.info_labels[n] = (title_label, text_label) # info_frame.columnconfigure(1, weight=1) info_frame.rowconfigure(6, weight=1) stats_frame.rowconfigure(6, weight=1) # Canvas self.preview = MfxScrolledCanvas(right_frame, width=w2) self.preview.setTile(app, app.tabletile_index, force=True) self.preview.grid(row=1, column=0, columnspan=3, padx=padx, pady=pady, sticky='nsew') right_frame.columnconfigure(1, weight=1) right_frame.rowconfigure(1, weight=1) # focus = self.createButtons(bottom_frame, kw) # set the scale factor self.preview.canvas.preview = 2 # create a preview of the current game self.preview_key = -1 self.preview_game = None self.preview_app = None self.updatePreview(gameid, animations=0) # focus = self.tree.frame self.mainloop(focus, kw.timeout)