def __init__(self, parent, title, app, **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.update_stats_var = tkinter.BooleanVar() self.update_stats_var.set(app.opt.update_player_stats != 0) self.confirm_var = tkinter.BooleanVar() self.confirm_var.set(app.opt.confirm != 0) self.win_animation_var = tkinter.BooleanVar() self.win_animation_var.set(app.opt.win_animation != 0) # frame = ttk.Frame(top_frame) frame.pack(expand=True, fill='both', padx=5, pady=10) widget = ttk.Label(frame, text=_("\nPlease enter your name"), takefocus=0) widget.grid(row=0, column=0, columnspan=2, sticky='ew', padx=0, pady=5) # w = kw.get("e_width", 30) # width in characters names = self.app.getAllUserNames() self.player_var = ttk.Combobox(frame, width=w, values=tuple(names)) self.player_var.current(names.index(app.opt.player)) self.player_var.grid(row=1, column=0, sticky='ew', padx=0, pady=5) # widget = ttk.Checkbutton(frame, variable=self.confirm_var, text=_("Confirm quit")) widget.grid(row=2, column=0, columnspan=2, sticky='ew', padx=0, pady=5) widget = ttk.Checkbutton(frame, variable=self.update_stats_var, text=_("Update statistics and logs")) widget.grid(row=3, column=0, columnspan=2, sticky='ew', padx=0, pady=5) # widget = ttk.Checkbutton(frame, variable=self.win_animation_var, # text="Win animation") # widget.pack(side='top', padx=kw.padx, pady=kw.pady) frame.columnconfigure(0, weight=1) # self.player = self.player_var.get() self.confirm = self.confirm_var.get() self.update_stats = self.update_stats_var.get() self.win_animation = self.win_animation_var.get() # focus = self.createButtons(bottom_frame, kw) self.mainloop(focus, kw.timeout)
def __init__(self, dialog, parent, app, player, gameid, **kw): ttk.Frame.__init__(self, parent) self.mapped = False self.dialog = dialog self.app = app self.player = player self.gameid = gameid self.items = [] self.formatter = ProgressionFormatter(app, player, gameid) frame = ttk.Frame(self) frame.pack(expand=True, fill='both', padx=5, pady=10) frame.columnconfigure(0, weight=1) # constants w = dialog.tkfont.measure('M') * 42 w = max(w, 500) w = min(w, 600) self.canvas_width, self.canvas_height = w, 325 cond = parent.winfo_screenwidth() < 800 or \ parent.winfo_screenheight() < 600 if cond: self.canvas_width, self.canvas_height = 400, 200 self.xmargin, self.ymargin = 10, 10 self.graph_dx, self.graph_dy = 10, 10 self.played_color = '#ff7ee9' self.won_color = '#00dc28' self.percent_color = 'blue' # create canvas self.canvas = canvas = tkinter.Canvas(frame, bg='#dfe8ff', bd=0, highlightthickness=1, highlightbackground='black', width=self.canvas_width, height=self.canvas_height) canvas.pack(side='left', padx=5) # right frame right_frame = ttk.Frame(frame) right_frame.pack(side='left', fill='x', padx=5) self.all_games_variable = var = tkinter.StringVar() var.set('all') b = ttk.Radiobutton(right_frame, text=_('All games'), variable=var, value='all', command=self.updateGraph) b.pack(fill='x', expand=True, padx=3, pady=1) b = ttk.Radiobutton(right_frame, text=_('Current game'), variable=var, value='current', command=self.updateGraph) b.pack(fill='x', expand=True, padx=3, pady=1) label_frame = ttk.LabelFrame(right_frame, text=_('Statistics for')) label_frame.pack(side='top', fill='x', pady=5) self.variable = var = tkinter.StringVar() var.set('week') for v, t in ( ('week', _('Last 7 days')), ('month', _('Last month')), ('year', _('Last year')), ('all', _('All time')), ): b = ttk.Radiobutton(label_frame, text=t, variable=var, value=v, command=self.updateGraph) b.pack(fill='x', expand=True, padx=3, pady=1) label_frame = ttk.LabelFrame(right_frame, text=_('Show graphs')) label_frame.pack(side='top', fill='x', pady=5) self.played_graph_var = tkinter.BooleanVar() self.played_graph_var.set(True) b = ttk.Checkbutton(label_frame, text=_('Played'), command=self.updateGraph, variable=self.played_graph_var) b.pack(fill='x', expand=True, padx=3, pady=1) self.won_graph_var = tkinter.BooleanVar() self.won_graph_var.set(True) b = ttk.Checkbutton(label_frame, text=_('Won'), command=self.updateGraph, variable=self.won_graph_var) b.pack(fill='x', expand=True, padx=3, pady=1) self.percent_graph_var = tkinter.BooleanVar() self.percent_graph_var.set(True) b = ttk.Checkbutton(label_frame, text=_('% won'), command=self.updateGraph, variable=self.percent_graph_var) b.pack(fill='x', expand=True, padx=3, pady=1) label_frame = ttk.LabelFrame(right_frame, text=_('Date format')) label_frame.pack(side='top', fill='x', pady=5) self.date_format = tkinter.StringVar() self.date_format.set(self.app.opt.date_format) b = ttk.Radiobutton(label_frame, text=_('MM-DD'), command=self.updateDateFormat, variable=self.date_format, value='%m-%d') b.pack(fill='x', expand=True, padx=3, pady=1) b = ttk.Radiobutton(label_frame, text=_('DD-MM'), command=self.updateDateFormat, variable=self.date_format, value='%d-%m') b.pack(fill='x', expand=True, padx=3, pady=1) # self.createGraph() bind(canvas, '<Map>', self.createGraph)
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 self.cardset_values = None # 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 = ttk.PanedWindow(top_frame, orient='horizontal') paned_window.pack(expand=True, fill='both') left_frame = ttk.Frame(paned_window) right_frame = ttk.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 = PysolScale( 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 = PysolScale( 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 = ttk.Checkbutton( left_frame, text=_('Auto scaling'), variable=self.auto_scale, takefocus=False, command=self._updateAutoScale ) check.grid(row=3, column=0, columnspan=2, sticky='ew', padx=padx, pady=pady) # self.preserve_aspect = tkinter.BooleanVar() self.preserve_aspect.set(app.opt.preserve_aspect_ratio) self.aspect_check = ttk.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='ew', 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, init_font, **kw): # print init_font 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.font_family = 'Helvetica' self.font_size = 12 self.font_weight = 'normal' self.font_slant = 'roman' if init_font is not None: assert 2 <= len(init_font) <= 4 assert isinstance(init_font[1], int) self.font_family, self.font_size = init_font[:2] if len(init_font) > 2: if init_font[2] in ['bold', 'normal']: self.font_weight = init_font[2] elif init_font[2] in ['italic', 'roman']: self.font_slant = init_font[2] else: raise ValueError('invalid font style: ' + init_font[2]) if len(init_font) > 3: if init_font[3] in ['bold', 'normal']: self.font_weight = init_font[3] elif init_font[2] in ['italic', 'roman']: self.font_slant = init_font[3] else: raise ValueError('invalid font style: ' + init_font[3]) # self.family_var = tkinter.StringVar() self.weight_var = tkinter.BooleanVar() self.weight_var.set(self.font_weight == 'bold') self.slant_var = tkinter.BooleanVar() self.slant_var.set(self.font_slant == 'italic') self.size_var = tkinter.IntVar() self.size_var.set(self.font_size) # frame = ttk.Frame(top_frame) frame.pack(expand=True, fill='both', padx=5, pady=10) frame.columnconfigure(0, weight=1) # frame.rowconfigure(1, weight=1) self.entry = ttk.Entry(frame) self.entry.grid(row=0, column=0, columnspan=2, sticky='news') self.entry.insert('end', _('abcdefghABCDEFGH')) self.list_box = tkinter.Listbox(frame, width=36, exportselection=False) sb = ttk.Scrollbar(frame) self.list_box.configure(yscrollcommand=sb.set) sb.configure(command=self.list_box.yview) self.list_box.grid(row=1, column=0, sticky='news') # rowspan=4 sb.grid(row=1, column=1, sticky='ns') bind(self.list_box, '<<ListboxSelect>>', self.fontupdate) # self.list_box.focus() cb1 = ttk.Checkbutton(frame, text=_('Bold'), command=self.fontupdate, variable=self.weight_var) cb1.grid(row=2, column=0, columnspan=2, sticky='we') cb2 = ttk.Checkbutton(frame, text=_('Italic'), command=self.fontupdate, variable=self.slant_var) cb2.grid(row=3, column=0, columnspan=2, sticky='we') sc = PysolScale(frame, from_=6, to=40, resolution=1, label=_('Size:'), orient='horizontal', command=self.fontupdate, variable=self.size_var) sc.grid(row=4, column=0, columnspan=2, sticky='news') # font_families = list(tkinter_font.families()) font_families.sort() selected = -1 n = 0 self.list_box.insert('end', *font_families) for font in font_families: if font.lower() == self.font_family.lower(): selected = n break n += 1 if selected >= 0: self.list_box.select_set(selected) self.list_box.see(selected) # focus = self.createButtons(bottom_frame, kw) self.mainloop(focus, kw.timeout) self.font = (self.font_family, self.font_size, self.font_slant, self.font_weight)
def __init__(self, parent, title, app, **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) frame = ttk.Frame(top_frame) frame.pack(expand=True, fill='both', padx=10, pady=10) frame.columnconfigure(0, weight=1) notebook = ttk.Notebook(frame) notebook.pack(expand=True, fill='both') for w in WizardWidgets: if isinstance(w, six.string_types): frame = ttk.Frame(notebook) notebook.add(frame, text=w, sticky='nsew', padding=5) frame.columnconfigure(1, weight=1) row = 0 continue ttk.Label(frame, text=w.label).grid(row=row, column=0) if w.widget == 'preset': if w.variable is None: w.variable = tkinter.StringVar() values = [_(v) for v in w.values] default = _(w.default) values.remove(default) values.sort() values.insert(0, default) def callback(e, w=w): self.presetSelected(e, w) cb = PysolCombo(frame, values=tuple(values), textvariable=w.variable, exportselection=False, selectcommand=callback, state='readonly', width=32) cb.grid(row=row, column=1, sticky='ew', padx=2, pady=2) elif w.widget == 'entry': if w.variable is None: w.variable = tkinter.StringVar() en = ttk.Entry(frame, textvariable=w.variable) en.grid(row=row, column=1, sticky='ew', padx=2, pady=2) elif w.widget == 'menu': if w.variable is None: w.variable = tkinter.StringVar() values = [_(v) for v in w.values] cb = PysolCombo(frame, values=tuple(values), textvariable=w.variable, exportselection=False, state='readonly', width=32) cb.grid(row=row, column=1, sticky='ew', padx=2, pady=2) elif w.widget == 'spin': if w.variable is None: w.variable = tkinter.IntVar() else: # delete all trace callbacks for mod, cbname in w.variable.trace_vinfo(): w.variable.trace_vdelete(mod, cbname) from_, to = w.values # s = Spinbox( # frame, textvariable=w.variable, from_=from_, to=to) s = PysolScale(frame, from_=from_, to=to, resolution=1, orient='horizontal', variable=w.variable) s.grid(row=row, column=1, sticky='ew', padx=2, pady=2) elif w.widget == 'check': if w.variable is None: w.variable = tkinter.BooleanVar() ch = ttk.Checkbutton(frame, variable=w.variable, takefocus=False) ch.grid(row=row, column=1, sticky='ew', padx=2, pady=2) if w.current_value is None: v = w.default else: v = w.current_value if w.widget in ('menu', 'preset'): v = _(v) w.variable.set(v) row += 1 focus = self.createButtons(bottom_frame, kw) self.mainloop(focus, kw.timeout)
def __init__(self, parent, title, app, **kw): self.app = app 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.saved_opt = app.opt.copy() self.sound = tkinter.BooleanVar() self.sound.set(app.opt.sound != 0) self.sound_mode = tkinter.BooleanVar() self.sound_mode.set(app.opt.sound_mode != 0) self.sample_volume = tkinter.IntVar() self.sample_volume.set(app.opt.sound_sample_volume) self.music = tkinter.BooleanVar() self.music.set(app.opt.music != 0) self.music_volume = tkinter.IntVar() self.music_volume.set(app.opt.sound_music_volume) self.samples = [ ('areyousure', _('Are You Sure'), tkinter.BooleanVar()), ('deal', _('Deal'), tkinter.BooleanVar()), ('dealwaste', _('Deal waste'), tkinter.BooleanVar()), ('turnwaste', _('Turn waste'), tkinter.BooleanVar()), ('startdrag', _('Start drag'), tkinter.BooleanVar()), ('drop', _('Drop'), tkinter.BooleanVar()), ('droppair', _('Drop pair'), tkinter.BooleanVar()), ('autodrop', _('Auto drop'), tkinter.BooleanVar()), ('flip', _('Flip'), tkinter.BooleanVar()), ('autoflip', _('Auto flip'), tkinter.BooleanVar()), ('move', _('Move'), tkinter.BooleanVar()), ('nomove', _('No move'), tkinter.BooleanVar()), ('undo', _('Undo'), tkinter.BooleanVar()), ('redo', _('Redo'), tkinter.BooleanVar()), ('autopilotlost', _('Autopilot lost'), tkinter.BooleanVar()), ('autopilotwon', _('Autopilot won'), tkinter.BooleanVar()), ('gamefinished', _('Game finished'), tkinter.BooleanVar()), ('gamelost', _('Game lost'), tkinter.BooleanVar()), ('gamewon', _('Game won'), tkinter.BooleanVar()), ('gameperfect', _('Perfect game'), tkinter.BooleanVar()), ('extra', _('Other'), tkinter.BooleanVar()), ] # frame = ttk.Frame(top_frame) frame.pack(expand=True, fill='both', padx=5, pady=5) frame.columnconfigure(1, weight=1) # row = 0 w = ttk.Checkbutton(frame, variable=self.sound, text=_("Sound enabled")) w.grid(row=row, column=0, columnspan=2, sticky='ew') # if os.name == "nt" and pysolsoundserver: row += 1 w = ttk.Checkbutton(frame, variable=self.sound_mode, text=_("Use DirectX for sound playing"), command=self.mOptSoundDirectX) w.grid(row=row, column=0, columnspan=2, sticky='ew') # if app.audio.CAN_PLAY_MUSIC: # and app.startup_opt.sound_mode > 0: row += 1 ttk.Label(frame, text=_('Sample volume:'), anchor='w').grid(row=row, column=0, sticky='ew') w = PysolScale( frame, from_=0, to=128, resolution=1, orient='horizontal', takefocus=0, length="3i", # label=_('Sample volume'), variable=self.sample_volume) w.grid(row=row, column=1, sticky='w', padx=5) row += 1 w = ttk.Checkbutton(frame, variable=self.music, text=_("Music enabled")) w.grid(row=row, column=0, columnspan=2, sticky='ew') row += 1 ttk.Label(frame, text=_('Music volume:'), anchor='w').grid(row=row, column=0, sticky='ew') w = PysolScale( frame, from_=0, to=128, resolution=1, orient='horizontal', takefocus=0, length="3i", # label=_('Music volume'), variable=self.music_volume) w.grid(row=row, column=1, sticky='w', padx=5) else: # remove "Apply" button kw.strings[1] = None # frame = ttk.LabelFrame(top_frame, text=_('Enable samples')) frame.pack(expand=True, fill='both', padx=5, pady=5) frame.columnconfigure(0, weight=1) frame.columnconfigure(1, weight=1) # row = 0 col = 0 for n, t, v in self.samples: v.set(app.opt.sound_samples[n]) w = ttk.Checkbutton(frame, text=t, variable=v) w.grid(row=row, column=col, sticky='ew', padx=3, pady=1) if col == 1: col = 0 row += 1 else: col = 1 # top_frame.columnconfigure(1, weight=1) # focus = self.createButtons(bottom_frame, kw) self.mainloop(focus, kw.timeout)
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 self.cardset_values = None # padx, pady = kw.padx, kw.pady padx, pady = 4, 4 if self.TreeDataHolder_Class.data is None: self.TreeDataHolder_Class.data = self.TreeData_Class(manager, key) # sw = self.top.winfo_screenwidth() sh = self.top.winfo_screenheight() h = int(sh * .8) w = int(sw * .8) w1 = int(min(275, 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', padx=8, pady=8) left_frame = ttk.Frame(paned_window) right_frame = ttk.Frame(paned_window) paned_window.add(left_frame) paned_window.add(right_frame) notebook = ttk.Notebook(left_frame) notebook.grid(row=0, column=0, sticky='nsew', padx=padx, pady=pady) tree_frame = ttk.Frame(notebook) notebook.add(tree_frame, text=_('Tree View')) search_frame = ttk.Frame(notebook) notebook.add(search_frame, text=_('Search')) # Tree font = app.getFont("default") self.tree = self.Tree_Class(self, tree_frame, key=key, default=kw.default, font=font, width=w1) self.tree.frame.pack(padx=padx, pady=pady, expand=True, fill='both') # Search searchText = tkinter.StringVar() self.list_searchlabel = tkinter.Label(search_frame, text="Search:", justify='left', anchor='w') self.list_searchlabel.pack(side="top", fill='both', ipadx=1) self.list_searchtext = tkinter.Entry(search_frame, textvariable=searchText) self.list_searchtext.pack(side="top", fill='both', padx=padx, pady=pady, ipadx=1) searchText.trace('w', self.performSearch) self.list_scrollbar = tkinter.Scrollbar(search_frame) self.list_scrollbar.pack(side="right", fill='both') self.createBitmaps(search_frame, kw) self.list = tkinter.Listbox(search_frame, exportselection=False) self.list.pack(padx=padx, pady=pady, expand=True, side='left', fill='both', ipadx=1) self.updateSearchList("") bind(self.list, '<<ListboxSelect>>', self.selectSearchResult) bind(self.list, '<FocusOut>', lambda e: self.list.selection_clear(0, 'end')) self.list.config(yscrollcommand=self.list_scrollbar.set) self.list_scrollbar.config(command=self.list.yview) if USE_PIL: # var = tkinter.DoubleVar() var.set(app.opt.scale_x) self.scale_x = PysolScale(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 = PysolScale(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) # # sliders at new position cs = self.manager.get(self.tree.selection_key) var = tkinter.IntVar() self.x_offset = PysolScale(left_frame, label=_('X offset:'), from_=5, to=100, resolution=1, orient='horizontal', variable=var, value=cs.CARD_XOFFSET) self.x_offset.grid(row=3, column=0, sticky='ew', padx=padx, pady=pady) var = tkinter.IntVar() self.y_offset = PysolScale(left_frame, label=_('Y offset:'), from_=5, to=100, resolution=1, orient='horizontal', variable=var, value=cs.CARD_YOFFSET) self.y_offset.grid(row=4, column=0, sticky='ew', padx=padx, pady=pady) self.auto_scale = tkinter.BooleanVar() self.auto_scale.set(app.opt.auto_scale) check = ttk.Checkbutton(left_frame, text=_('Auto scaling'), variable=self.auto_scale, takefocus=False, command=self._updateAutoScale) check.grid(row=5, column=0, columnspan=2, sticky='ew', padx=padx, pady=pady) # self.preserve_aspect = tkinter.BooleanVar() self.preserve_aspect.set(app.opt.preserve_aspect_ratio) self.aspect_check = ttk.Checkbutton( left_frame, text=_('Preserve aspect ratio'), variable=self.preserve_aspect, takefocus=False, # command=self._updateScale ) self.aspect_check.grid(row=6, column=0, sticky='ew', padx=padx, pady=pady) self._updateAutoScale() # left_frame.rowconfigure(0, weight=1) left_frame.columnconfigure(0, weight=1) # 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 # 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, geometry=geometry)