1#!/usr/bin/env python 2# -*- mode: python; coding: utf-8; -*- 3# ---------------------------------------------------------------------------## 4# 5# Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer 6# Copyright (C) 2003 Mt. Hood Playing Card Co. 7# Copyright (C) 2005-2009 Skomoroh 8# 9# This program is free software: you can redistribute it and/or modify 10# it under the terms of the GNU General Public License as published by 11# the Free Software Foundation, either version 3 of the License, or 12# (at your option) any later version. 13# 14# This program is distributed in the hope that it will be useful, 15# but WITHOUT ANY WARRANTY; without even the implied warranty of 16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17# GNU General Public License for more details. 18# 19# You should have received a copy of the GNU General Public License 20# along with this program. If not, see <http://www.gnu.org/licenses/>. 21# 22# ---------------------------------------------------------------------------## 23 24from pysollib.mfxutil import KwStruct 25from pysollib.mygettext import _ 26 27from six.moves import tkinter 28from six.moves import tkinter_ttk as ttk 29 30from .tkwidget import MfxDialog 31 32 33class PlayerOptionsDialog(MfxDialog): 34 def __init__(self, parent, title, app, **kw): 35 kw = self.initKw(kw) 36 MfxDialog.__init__(self, parent, title, kw.resizable, kw.default) 37 top_frame, bottom_frame = self.createFrames(kw) 38 self.createBitmaps(top_frame, kw) 39 self.app = app 40 # 41 self.update_stats_var = tkinter.BooleanVar() 42 self.update_stats_var.set(app.opt.update_player_stats != 0) 43 self.confirm_var = tkinter.BooleanVar() 44 self.confirm_var.set(app.opt.confirm != 0) 45 self.win_animation_var = tkinter.BooleanVar() 46 self.win_animation_var.set(app.opt.win_animation != 0) 47 # 48 frame = ttk.Frame(top_frame) 49 frame.pack(expand=True, fill='both', padx=5, pady=10) 50 widget = ttk.Label(frame, text=_("\nPlease enter your name"), 51 takefocus=0) 52 widget.grid(row=0, column=0, columnspan=2, sticky='ew', padx=0, pady=5) 53 # 54 w = kw.get("e_width", 30) # width in characters 55 names = self.app.getAllUserNames() 56 self.player_var = ttk.Combobox(frame, width=w, values=tuple(names)) 57 self.player_var.current(names.index(app.opt.player)) 58 self.player_var.grid(row=1, column=0, sticky='ew', padx=0, pady=5) 59 # 60 widget = ttk.Checkbutton(frame, variable=self.confirm_var, 61 text=_("Confirm quit")) 62 widget.grid(row=2, column=0, columnspan=2, sticky='ew', padx=0, pady=5) 63 widget = ttk.Checkbutton(frame, variable=self.update_stats_var, 64 text=_("Update statistics and logs")) 65 widget.grid(row=3, column=0, columnspan=2, sticky='ew', padx=0, pady=5) 66 # widget = ttk.Checkbutton(frame, variable=self.win_animation_var, 67 # text="Win animation") 68 # widget.pack(side='top', padx=kw.padx, pady=kw.pady) 69 frame.columnconfigure(0, weight=1) 70 # 71 self.player = self.player_var.get() 72 self.confirm = self.confirm_var.get() 73 self.update_stats = self.update_stats_var.get() 74 self.win_animation = self.win_animation_var.get() 75 # 76 focus = self.createButtons(bottom_frame, kw) 77 self.mainloop(focus, kw.timeout) 78 79 def mDone(self, button): 80 self.button = button 81 self.player = self.player_var.get() 82 self.confirm = self.confirm_var.get() 83 self.update_stats = self.update_stats_var.get() 84 self.win_animation = self.win_animation_var.get() 85 raise SystemExit 86 87 def initKw(self, kw): 88 kw = KwStruct(kw, 89 strings=(_("&OK"), _("&Cancel")), default=0, 90 padx=10, pady=10, 91 ) 92 return MfxDialog.initKw(self, kw) 93