From a1850200886bcd620b42d3049c0d2f425618d57e Mon Sep 17 00:00:00 2001 From: skomoroh Date: Mon, 27 Nov 2006 22:15:01 +0000 Subject: [PATCH] * changed default sound module to PyGame - removed `sound disabled' dialog * improved Tile binding * misc. bugs fixes git-svn-id: https://pysolfc.svn.sourceforge.net/svnroot/pysolfc/PySolFC/trunk@100 39dd0a4e-7c14-0410-91b3-c4f2d318f732 --- pysollib/app.py | 44 ++++++++++++++++------------ pysollib/game.py | 10 ++++--- pysollib/main.py | 39 ++---------------------- pysollib/stats.py | 2 +- pysollib/tile/Tile.py | 24 ++++----------- pysollib/tile/colorsdialog.py | 4 +-- pysollib/tile/findcarddialog.py | 5 +++- pysollib/tile/fontsdialog.py | 6 ++-- pysollib/tile/menubar.py | 3 +- pysollib/tile/playeroptionsdialog.py | 4 +-- pysollib/tile/selectcardset.py | 7 +++-- pysollib/tile/selectgame.py | 9 +++--- pysollib/tile/selecttile.py | 5 ++-- pysollib/tile/soundoptionsdialog.py | 14 ++++----- pysollib/tile/statusbar.py | 8 ++--- pysollib/tile/tkstats.py | 6 ++-- pysollib/tile/tkwidget.py | 30 +++++++++++++------ pysollib/tile/toolbar.py | 4 +-- pysollib/tk/findcarddialog.py | 3 ++ 19 files changed, 101 insertions(+), 126 deletions(-) diff --git a/pysollib/app.py b/pysollib/app.py index 2deb1ff3..d26fcceb 100644 --- a/pysollib/app.py +++ b/pysollib/app.py @@ -1240,41 +1240,45 @@ Please select a %s type %s. def getGamesIdSortedById(self): return self.gdb.getGamesIdSortedById() - def getGamesIdSortedByName(self): + def getGamesIdSortedByName(self, player=''): return self.gdb.getGamesIdSortedByName() ## - def getGamesIdSortedByPlayed(self): + def getGamesIdSortedByPlayed(self, player=''): + if player == '': player = self.opt.player def _cmp(a, b): - wa, la, ta, ma = self.stats.getFullStats(self.opt.player, a) - wb, lb, tb, mb = self.stats.getFullStats(self.opt.player, b) + wa, la, ta, ma = self.stats.getFullStats(player, a) + wb, lb, tb, mb = self.stats.getFullStats(player, b) return cmp(wb+lb, wa+la) # reverse games = list(self.gdb.getGamesIdSortedByName()) games.sort(_cmp) return games - def getGamesIdSortedByWon(self): + def getGamesIdSortedByWon(self, player=''): + if player == '': player = self.opt.player def _cmp(a, b): - wa, la, ta, ma = self.stats.getFullStats(self.opt.player, a) - wb, lb, tb, mb = self.stats.getFullStats(self.opt.player, b) + wa, la, ta, ma = self.stats.getFullStats(player, a) + wb, lb, tb, mb = self.stats.getFullStats(player, b) return cmp(wb, wa) # reverse games = list(self.gdb.getGamesIdSortedByName()) games.sort(_cmp) return games - def getGamesIdSortedByLost(self): + def getGamesIdSortedByLost(self, player=''): + if player == '': player = self.opt.player def _cmp(a, b): - wa, la, ta, ma = self.stats.getFullStats(self.opt.player, a) - wb, lb, tb, mb = self.stats.getFullStats(self.opt.player, b) + wa, la, ta, ma = self.stats.getFullStats(player, a) + wb, lb, tb, mb = self.stats.getFullStats(player, b) return cmp(lb, la) # reverse games = list(self.gdb.getGamesIdSortedByName()) games.sort(_cmp) return games - def getGamesIdSortedByPercent(self): + def getGamesIdSortedByPercent(self, player=''): + if player == '': player = self.opt.player def _cmp(a, b): - wa, la, ta, ma = self.stats.getFullStats(self.opt.player, a) - wb, lb, tb, mb = self.stats.getFullStats(self.opt.player, b) + wa, la, ta, ma = self.stats.getFullStats(player, a) + wb, lb, tb, mb = self.stats.getFullStats(player, b) if wa+la == 0 or wb+lb == 0: return cmp(wb+lb, wa+la) # reverse return cmp(float(wb)/(wb+lb), @@ -1283,19 +1287,21 @@ Please select a %s type %s. games.sort(_cmp) return games - def getGamesIdSortedByPlayingTime(self): + def getGamesIdSortedByPlayingTime(self, player=''): + if player == '': player = self.opt.player def _cmp(a, b): - wa, la, ta, ma = self.stats.getFullStats(self.opt.player, a) - wb, lb, tb, mb = self.stats.getFullStats(self.opt.player, b) + wa, la, ta, ma = self.stats.getFullStats(player, a) + wb, lb, tb, mb = self.stats.getFullStats(player, b) return cmp(tb, ta) # reverse games = list(self.gdb.getGamesIdSortedByName()) games.sort(_cmp) return games - def getGamesIdSortedByMoves(self): + def getGamesIdSortedByMoves(self, player=''): + if player == '': player = self.opt.player def _cmp(a, b): - wa, la, ta, ma = self.stats.getFullStats(self.opt.player, a) - wb, lb, tb, mb = self.stats.getFullStats(self.opt.player, b) + wa, la, ta, ma = self.stats.getFullStats(player, a) + wb, lb, tb, mb = self.stats.getFullStats(player, b) return cmp(mb, ma) # reverse games = list(self.gdb.getGamesIdSortedByName()) games.sort(_cmp) diff --git a/pysollib/game.py b/pysollib/game.py index ea048ee8..bd8da246 100644 --- a/pysollib/game.py +++ b/pysollib/game.py @@ -194,6 +194,7 @@ class Game: # update display properties self.top.wm_geometry("") # cancel user-specified geometry self.canvas.setInitialSize(self.width, self.height) + self.top.update_idletasks() # apply geometry now if DEBUG >= 4: MfxCanvasRectangle(self.canvas, 0, 0, self.width, self.height, width=2, fill=None, outline='green') @@ -425,13 +426,13 @@ class Game: if not self.preview: wm_map(self.top, maximized=self.app.opt.wm_maximized) self.top.busyUpdate() - self.stopSamples() - # if TOOLKIT == 'gtk': ## FIXME if self.top: self.top.update_idletasks() self.top.show_now() + # + self.stopSamples() # let's go self.moves.state = self.S_INIT self.startGame() @@ -1015,6 +1016,7 @@ class Game: ### return if not self.app.opt.animations: return + self.setCursor(cursor=CURSOR_WATCH) self.top.busyUpdate() self.canvas.update_idletasks() old_a = self.app.opt.animations @@ -1252,6 +1254,8 @@ class Game: # a pure demo game - update demo stats self.stats.demo_updated = updated self.app.stats.updateStats(None, self, won) + if won: + self.finished = True return '' elif self.changed(): # must update player stats @@ -1855,7 +1859,6 @@ for %d moves. image=self.app.gimages.logos[4], strings=(s,), separatorwidth=2, timeout=timeout) status = d.status - self.finished = True else: ##s = self.app.miscrandom.choice((_("&OK"), _("&OK"))) s = _("&OK") @@ -1866,7 +1869,6 @@ for %d moves. text=text, bitmap=bitmap, strings=(s,), padx=30, timeout=timeout) status = d.status - self.finished = True elif finished: ##self.stopPlayTimer() if not self.top.winfo_ismapped(): diff --git a/pysollib/main.py b/pysollib/main.py index ba975f9d..9c612504 100644 --- a/pysollib/main.py +++ b/pysollib/main.py @@ -227,8 +227,6 @@ def pysol_init(app, args): app.loadOptions() # init audio 1) - warn_thread = 0 - warn_pysolsoundserver = 0 app.audio = None sounds = {'pss': PysolSoundServerModuleClient, 'pygame': PyGameAudioClient, @@ -240,8 +238,8 @@ def pysol_init(app, args): c = sounds[opts['sound-mod']] app.audio = c() elif SOUND_MOD == 'auto': - for c in (PysolSoundServerModuleClient, - PyGameAudioClient, + for c in (PyGameAudioClient, + PysolSoundServerModuleClient, OSSAudioClient, Win32AudioClient, AbstractAudioClient): @@ -315,9 +313,6 @@ Please check your %s installation. app.audio.connectServer(app) if not app.audio.CAN_PLAY_SOUND: app.opt.sound = 0 - if not opts["nosound"] and not opts['sound-mod'] and pysolsoundserver and not app.audio.connected: - print >> sys.stderr, "%s: could not connect to pysolsoundserver, sound disabled." % PACKAGE - warn_pysolsoundserver = 1 app.audio.updateSettings() # start up the background music if app.audio.CAN_PLAY_MUSIC: @@ -340,36 +335,6 @@ Please check your %s installation. loadImage(app.gimages.logos[1])) app.wm_withdraw() - # warn about audio problems - if (not opts["nosound"] and os.name == "posix" and - not app.audio and pysolsoundserver is None): - if 1 and app.opt.sound and re.search(r"linux", sys.platform, re.I): - warn_pysolsoundserver = 1 - if thread is None: - warn_thread = 1 - if thread is None: - print >> sys.stderr, "%s: Python thread module not found, sound disabled." % PACKAGE - else: - print >> sys.stderr, "%s: pysolsoundserver module not found, sound disabled." % PACKAGE - sys.stdout.flush() - if not opts["nosound"]: - if warn_thread: - top.update() - d = MfxMessageDialog(top, title=_("%s installation problem") % PACKAGE, - text=_('''\ -Your Python installation is compiled without thread support. - -Sounds and background music will be disabled.'''), - bitmap="warning", strings=(_("&OK"),)) - elif warn_pysolsoundserver: - top.update() - d = MfxMessageDialog(top, title=_("%s installation problem") % PACKAGE, - text=_('''\ -The pysolsoundserver module was not found. - -Sounds and background music will be disabled.'''), - bitmap="warning", strings=(_("&OK"),)) - # create the progress bar title = _("Welcome to %s") % PACKAGE color = app.opt.colors['table'] diff --git a/pysollib/stats.py b/pysollib/stats.py index 340322f8..a6e66879 100644 --- a/pysollib/stats.py +++ b/pysollib/stats.py @@ -71,7 +71,7 @@ class PysolStatsFormatter: 'percent': app.getGamesIdSortedByPercent, } sort_func = sort_functions[sort_by] - g = sort_func() + g = sort_func(player=player) twon, tlost, tgames, ttime, tmoves = 0, 0, 0, 0, 0 for id in g: name = app.getGameTitleName(id) diff --git a/pysollib/tile/Tile.py b/pysollib/tile/Tile.py index e5d05edc..39195c1f 100644 --- a/pysollib/tile/Tile.py +++ b/pysollib/tile/Tile.py @@ -23,10 +23,6 @@ TkVersion = Tkinter.TkVersion TclError = Tkinter.TclError -# internal -_flatten = Tkinter._flatten - - class Style(Tkinter.Misc): def __init__(self, master=None): if master is None: @@ -84,10 +80,10 @@ class Style(Tkinter.Misc): """Sets the current theme to themeName, and refreshes all widgets.""" return self.tk.call("style", "theme", "use", theme) - def configure(self, style, **kw): + def configure(self, style, cnf={}, **kw): """Sets the default value of the specified option(s) in style.""" - opts = self._options(kw) + opts = self._options(cnf, kw) return self.tk.call("style", "configure", style, *opts) config = configure @@ -137,18 +133,11 @@ class Widget(Tkinter.Widget, Style): class Button(Widget, Tkinter.Button): def __init__(self, master=None, cnf={}, **kw): - for opt in ('bd', 'relief', 'padx', 'pady', 'overrelief',): - if kw.has_key(opt): - del kw[opt] Widget.__init__(self, master, "ttk::button", cnf, kw) class Checkbutton(Widget, Tkinter.Checkbutton): def __init__(self, master=None, cnf={}, **kw): - for opt in ('bd', 'anchor', 'selectcolor', 'indicatoron', - 'relief', 'overrelief', 'offrelief', 'padx', 'pady',): - if kw.has_key(opt): - del kw[opt] Widget.__init__(self, master, "ttk::checkbutton", cnf, kw) @@ -187,7 +176,7 @@ class Frame(Widget, Tkinter.Frame): Widget.__init__(self, master, "ttk::frame", cnf, kw) -class SizeGrip(Widget): +class Sizegrip(Widget): def __init__(self, master=None, cnf={}, **kw): Widget.__init__(self, master, "ttk::sizegrip", cnf, kw) @@ -318,10 +307,10 @@ class Progressbar(Widget): return self.tk.call(self._w, "step", amount) def start(self): - self.tk.call("tile::progressbar::start", self._w) + self.tk.call("ttk::progressbar::start", self._w) def stop(self): - self.tk.call("tile::progressbar::stop", self._w) + self.tk.call("ttk::progressbar::stop", self._w) class Radiobutton(Widget, Tkinter.Radiobutton): @@ -336,9 +325,6 @@ class Scrollbar(Widget, Tkinter.Scrollbar): class Separator(Widget): def __init__(self, master=None, cnf={}, **kw): - for opt in ('bd', 'width', 'highlightthickness', 'relief',): - if kw.has_key(opt): - del kw[opt] Widget.__init__(self, master, "ttk::separator", cnf, kw) diff --git a/pysollib/tile/colorsdialog.py b/pysollib/tile/colorsdialog.py index 4cdb4b8b..8714ee2d 100644 --- a/pysollib/tile/colorsdialog.py +++ b/pysollib/tile/colorsdialog.py @@ -69,7 +69,7 @@ class ColorsDialog(MfxDialog): self.not_matching_var.set(app.opt.colors['not_matching']) # c = Tkinter.Checkbutton(frame, variable=self.use_default_var, - text=_("Text foreground:"), anchor='w') + text=_("Text foreground:")) c.grid(row=0, column=0, sticky='we') l = Tk.Label(frame, width=10, height=2, bg=self.text_var.get(), textvariable=self.text_var) @@ -87,7 +87,7 @@ class ColorsDialog(MfxDialog): (_('Hint arrow:'), self.hintarrow_var), (_('Highlight not matching:'), self.not_matching_var), ): - Tkinter.Label(frame, text=title, anchor='w' + Tkinter.Label(frame, text=title, anchor='w', ).grid(row=row, column=0, sticky='we') l = Tk.Label(frame, width=10, height=2, bg=var.get(), textvariable=var) diff --git a/pysollib/tile/findcarddialog.py b/pysollib/tile/findcarddialog.py index 6beda1ed..b8430128 100644 --- a/pysollib/tile/findcarddialog.py +++ b/pysollib/tile/findcarddialog.py @@ -26,7 +26,7 @@ __all__ = ['create_find_card_dialog', # imports import os -import Tile as Tkinter +import Tkinter import traceback # PySol imports @@ -36,6 +36,8 @@ from tkutil import after, after_cancel from tkutil import bind, unbind_destroy, makeImage from tkcanvas import MfxCanvas, MfxCanvasGroup, MfxCanvasImage, MfxCanvasRectangle +from pysollib.settings import PACKAGE + # /*********************************************************************** # // @@ -130,6 +132,7 @@ class FindCardDialog(Tkinter.Toplevel): i += 1 w, h = dx*j+2, dy*i+2 self.canvas.config(width=w, height=h) + self.wm_iconname(PACKAGE + " - " + game.getTitleName()) def enterEvent(self, suit, rank, rect, group): ##print 'enterEvent', suit, rank, self.busy diff --git a/pysollib/tile/fontsdialog.py b/pysollib/tile/fontsdialog.py index 3d288fd6..344572bb 100644 --- a/pysollib/tile/fontsdialog.py +++ b/pysollib/tile/fontsdialog.py @@ -96,11 +96,11 @@ class FontChooserDialog(MfxDialog): sb.grid(row=1, column=1, sticky='ns') bind(self.list_box, '<>', self.fontupdate) ##self.list_box.focus() - cb1 = Tkinter.Checkbutton(frame, anchor='w', text=_('Bold'), + cb1 = Tkinter.Checkbutton(frame, text=_('Bold'), command=self.fontupdate, variable=self.weight_var) cb1.grid(row=2, column=0, columnspan=2, sticky='we') - cb2 = Tkinter.Checkbutton(frame, anchor='w', text=_('Italic'), + cb2 = Tkinter.Checkbutton(frame, text=_('Italic'), command=self.fontupdate, variable=self.slant_var) cb2.grid(row=3, column=0, columnspan=2, sticky='we') @@ -182,7 +182,7 @@ class FontsDialog(MfxDialog): elif font is None: title = 'Default' l = Tkinter.Label(frame, font=font, text=title) - l.grid(row=row, column=1) + l.grid(row=row, column=1, padx=8) b = Tkinter.Button(frame, text=_('Change...'), width=10, command=lambda l=l, fn=fn: self.selectFont(l, fn)) b.grid(row=row, column=2) diff --git a/pysollib/tile/menubar.py b/pysollib/tile/menubar.py index fd47509a..cd3dca80 100644 --- a/pysollib/tile/menubar.py +++ b/pysollib/tile/menubar.py @@ -1338,7 +1338,8 @@ the next time you restart """)+PACKAGE, def createThemesMenu(self, menu): style = Tkinter.Style(self.top) - all_themes = style.theme_names() + all_themes = list(style.theme_names()) + all_themes.sort() # tn = { 'default': 'Default', diff --git a/pysollib/tile/playeroptionsdialog.py b/pysollib/tile/playeroptionsdialog.py index 567249da..69ca93f9 100644 --- a/pysollib/tile/playeroptionsdialog.py +++ b/pysollib/tile/playeroptionsdialog.py @@ -70,7 +70,6 @@ class PlayerOptionsDialog(MfxDialog): frame = Tkinter.Frame(top_frame) frame.pack(expand=1, fill='both', padx=5, pady=10) widget = Tkinter.Label(frame, text=_("\nPlease enter your name"), - #justify='left', anchor='w', takefocus=0) widget.grid(row=0, column=0, columnspan=2, sticky='ew', padx=0, pady=5) # @@ -81,10 +80,9 @@ class PlayerOptionsDialog(MfxDialog): self.player_var.grid(row=1, column=0, sticky='ew', padx=0, pady=5) # widget = Tkinter.Checkbutton(frame, variable=self.confirm_var, - anchor='w', text=_("Confirm quit")) + text=_("Confirm quit")) widget.grid(row=2, column=0, columnspan=2, sticky='ew', padx=0, pady=5) widget = Tkinter.Checkbutton(frame, variable=self.update_stats_var, - anchor='w', text=_("Update statistics and logs")) widget.grid(row=3, column=0, columnspan=2, sticky='ew', padx=0, pady=5) ### widget = Tkinter.Checkbutton(frame, variable=self.win_animation_var, diff --git a/pysollib/tile/selectcardset.py b/pysollib/tile/selectcardset.py index 8c730995..ffeb3093 100644 --- a/pysollib/tile/selectcardset.py +++ b/pysollib/tile/selectcardset.py @@ -239,17 +239,18 @@ class SelectCardsetDialogWithPreview(MfxDialog): def initKw(self, kw): kw = KwStruct(kw, - strings = (_("&Load"), _("&Info..."), _("&Cancel"),), + strings = ((_("&Info..."), 10), 'sep', + _("&Load"), _("&Cancel"),), default=0, resizable=1, ) return MfxDialog.initKw(self, kw) def mDone(self, button): - if button in (0, 2): # Load/Cancel + if button in (0, 1): # Load/Cancel self.key = self.tree.selection_key self.tree.n_expansions = 1 # save xyview in any case - if button == 1: # Info + if button == 10: # Info cs = self.manager.get(self.tree.selection_key) if not cs: return diff --git a/pysollib/tile/selectgame.py b/pysollib/tile/selectgame.py index e250380d..c85d4ebd 100644 --- a/pysollib/tile/selectgame.py +++ b/pysollib/tile/selectgame.py @@ -277,10 +277,10 @@ class SelectGameDialog(MfxDialog): MfxDialog.destroy(self) def mDone(self, button): - if button == 0: # Ok or double click + if button == 0: # Ok or double click self.gameid = self.tree.selection_key self.tree.n_expansions = 1 # save xyview in any case - if button == 1: # Rules + if button == 10: # Rules doc = self.app.getGameRulesFilename(self.tree.selection_key) if not doc: return @@ -403,7 +403,8 @@ class SelectGameDialogWithPreview(SelectGameDialog): def initKw(self, kw): kw = KwStruct(kw, - strings=(_("&Select"), _("&Rules"), _("&Cancel"),), + strings=((_("&Rules"), 10), 'sep', + _("&Select"), _("&Cancel"),), default=0, ) return SelectGameDialog.initKw(self, kw) @@ -513,7 +514,7 @@ class SelectGameDialogWithPreview(SelectGameDialog): # self.updateInfo(gameid) # - rules_button = self.buttons[1] + rules_button = self.buttons[0] if self.app.getGameRulesFilename(gameid): rules_button.config(state="normal") else: diff --git a/pysollib/tile/selecttile.py b/pysollib/tile/selecttile.py index 8cea59fb..0e141420 100644 --- a/pysollib/tile/selecttile.py +++ b/pysollib/tile/selecttile.py @@ -157,7 +157,8 @@ class SelectTileDialogWithPreview(MfxDialog): def initKw(self, kw): kw = KwStruct(kw, - strings=(_("&OK"), _("&Solid color..."), _("&Cancel"),), + strings=((_("&Solid color..."), 10), + 'sep', _("&OK"), _("&Cancel"),), default=0, resizable=1, font=None, @@ -171,7 +172,7 @@ class SelectTileDialogWithPreview(MfxDialog): else: self.key = self.tree.selection_key self.tree.n_expansions = 1 # save xyview in any case - if button == 1: # "Solid color..." + if button == 10: # "Solid color..." c = tkColorChooser.askcolor(master=self.top, initialcolor=self.table_color, title=_("Select table color")) diff --git a/pysollib/tile/soundoptionsdialog.py b/pysollib/tile/soundoptionsdialog.py index bc899e75..411b1736 100644 --- a/pysollib/tile/soundoptionsdialog.py +++ b/pysollib/tile/soundoptionsdialog.py @@ -110,28 +110,28 @@ class SoundOptionsDialog(MfxDialog): # row = 0 w = Tkinter.Checkbutton(frame, variable=self.sound, - text=_("Sound enabled"), anchor='w') + text=_("Sound enabled")) w.grid(row=row, column=0, columnspan=2, sticky='ew') # if os.name == "nt" and pysolsoundserver: row += 1 w = Tkinter.Checkbutton(frame, variable=self.sound_mode, text=_("Use DirectX for sound playing"), - command=self.mOptSoundDirectX, anchor='w') + 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 - w = Tkinter.Label(frame, text=_('Sample volume:')) - w.grid(row=row, column=0, sticky='ew') + Tkinter.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 = Tkinter.Label(frame, text=_('Music volume:')) - w.grid(row=row, column=0, sticky='ew', padx=5) + Tkinter.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'), @@ -154,7 +154,7 @@ class SoundOptionsDialog(MfxDialog): col = 0 for n, t, v in self.samples: v.set(app.opt.sound_samples[n]) - w = Tkinter.Checkbutton(frame, text=t, anchor='w', variable=v) + w = Tkinter.Checkbutton(frame, text=t, variable=v) w.grid(row=row, column=col, sticky='ew', padx=3, pady=1) if col == 1: col = 0 diff --git a/pysollib/tile/statusbar.py b/pysollib/tile/statusbar.py index 0d2578bd..56678136 100644 --- a/pysollib/tile/statusbar.py +++ b/pysollib/tile/statusbar.py @@ -100,8 +100,8 @@ class MfxStatusbar: b.setText(tooltip) return label - def _createSizeGrip(self): - sg = Tkinter.SizeGrip(self.top_frame) + def _createSizegrip(self): + sg = Tkinter.Sizegrip(self.top_frame) sg.pack(side='right', anchor='se') @@ -164,7 +164,7 @@ class PysolStatusbar(MfxStatusbar): l = self._createLabel("info", fill='both', expand=1) ##l.config(text="", justify="left", anchor='w') l.config(padding=(8, 0)) - self._createSizeGrip() + self._createSizegrip() class HelpStatusbar(MfxStatusbar): @@ -179,7 +179,7 @@ class HtmlStatusbar(MfxStatusbar): MfxStatusbar.__init__(self, top, row=row, column=column, columnspan=columnspan) l = self._createLabel("url", fill='both', expand=1) l.config(justify="left", anchor='w', padding=(8, 0)) - self._createSizeGrip() + self._createSizegrip() # /*********************************************************************** diff --git a/pysollib/tile/tkstats.py b/pysollib/tile/tkstats.py index 1d5f4506..fe541279 100644 --- a/pysollib/tile/tkstats.py +++ b/pysollib/tile/tkstats.py @@ -325,7 +325,6 @@ class TreeFormatter(PysolStatsFormatter): class AllGames_StatsDialog(MfxDialog): - FONT_TYPE = "default" COLUMNS = ('played', 'won', 'lost', 'time', 'moves', 'percent') def __init__(self, parent, title, app, player, **kw): @@ -333,7 +332,7 @@ class AllGames_StatsDialog(MfxDialog): #if parent and parent.winfo_screenheight() < 600: # lines = 20 # - self.font = app.getFont(self.FONT_TYPE) + self.font = app.getFont('default') font = tkFont.Font(parent, self.font) self.font_metrics = font.metrics() self.CHAR_H = self.font_metrics['linespace'] @@ -403,7 +402,7 @@ class AllGames_StatsDialog(MfxDialog): self.tree.delete(tuple(self.tree_items)) self.tree_items = [] formatter = TreeFormatter(self.app, self.tree, self, - self.font, self.CHAR_W, self.CHAR_H) + self.font, self.CHAR_W, self.CHAR_H) formatter.writeStats(player, sort_by=self.sort_by) @@ -413,7 +412,6 @@ class AllGames_StatsDialog(MfxDialog): class FullLog_StatsDialog(AllGames_StatsDialog): - FONT_TYPE = "fixed" COLUMNS = ('gamenumber', 'date', 'status') def fillCanvas(self, player, header): diff --git a/pysollib/tile/tkwidget.py b/pysollib/tile/tkwidget.py index 44e8d372..ab1e3617 100644 --- a/pysollib/tile/tkwidget.py +++ b/pysollib/tile/tkwidget.py @@ -177,11 +177,17 @@ class MfxDialog: # ex. _ToplevelDialog b.pack(side=kw.image_side, padx=kw.image_padx, pady=kw.image_pady) def createButtons(self, frame, kw): - button = column = -1 + xbutton = column = -1 padx, pady = kw.get("buttonpadx", 5), kw.get("buttonpady", 5) focus = None max_len = 0 - for s in kw.strings: + if 'sep' in kw.strings: + sep_column = list(kw.strings).index('sep') + strings = kw.strings[sep_column+1:] + else: + sep_column = 0 + strings = kw.strings + for s in strings: if type(s) is tuple: s = s[0] if s: @@ -194,13 +200,19 @@ class MfxDialog: # ex. _ToplevelDialog else : button_width = 8 # for s in kw.strings: - xbutton = button = button + 1 + if s is None: + xbutton += 1 + continue + if s == 'sep': + column += 1 + continue if type(s) is tuple: assert len(s) == 2 button = int(s[1]) s = s[0] - if s is None: - continue + else: + xbutton += 1 + button = xbutton accel_indx = s.find('&') button_img = None if MfxDialog.button_img: @@ -208,7 +220,6 @@ class MfxDialog: # ex. _ToplevelDialog s = s.replace('&', '') if button < 0: widget = Tkinter.Button(frame, text=s, state="disabled") - button = xbutton else: widget = Tkinter.Button(frame, text=s, default="normal", command=(lambda self=self, button=button: self.mDone(button))) @@ -217,7 +228,9 @@ class MfxDialog: # ex. _ToplevelDialog focus.config(default="active") self.buttons.append(widget) # - widget.config(width=button_width) + column += 1 + if column >= sep_column: + widget.config(width=button_width) if accel_indx >= 0: # key accelerator widget.config(underline=accel_indx) @@ -226,14 +239,13 @@ class MfxDialog: # ex. _ToplevelDialog # if button_img: widget.config(compound='left', image=button_img) - column += 1 widget.grid(column=column, row=0, sticky="nse", padx=padx, pady=pady) if focus is not None: l = (lambda event=None, self=self, button=kw.default: self.mDone(button)) bind(self.top, "", l) bind(self.top, "", l) # right justify - frame.columnconfigure(0, weight=1) + frame.columnconfigure(sep_column, weight=1) return focus diff --git a/pysollib/tile/toolbar.py b/pysollib/tile/toolbar.py index 48384c82..50b930fe 100644 --- a/pysollib/tile/toolbar.py +++ b/pysollib/tile/toolbar.py @@ -354,9 +354,7 @@ class PysolToolbar(PysolToolbarActions): sep = ToolbarSeparator(self.frame, position=position, toolbar=self, - width=4, - takefocus=0, - relief=self.separator_relief) + takefocus=0) sep.show(orient=self.orient) self._widgets.append(sep) return sep diff --git a/pysollib/tk/findcarddialog.py b/pysollib/tk/findcarddialog.py index cf55a000..b8430128 100644 --- a/pysollib/tk/findcarddialog.py +++ b/pysollib/tk/findcarddialog.py @@ -36,6 +36,8 @@ from tkutil import after, after_cancel from tkutil import bind, unbind_destroy, makeImage from tkcanvas import MfxCanvas, MfxCanvasGroup, MfxCanvasImage, MfxCanvasRectangle +from pysollib.settings import PACKAGE + # /*********************************************************************** # // @@ -130,6 +132,7 @@ class FindCardDialog(Tkinter.Toplevel): i += 1 w, h = dx*j+2, dy*i+2 self.canvas.config(width=w, height=h) + self.wm_iconname(PACKAGE + " - " + game.getTitleName()) def enterEvent(self, suit, rank, rect, group): ##print 'enterEvent', suit, rank, self.busy