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

* 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
This commit is contained in:
skomoroh 2006-11-27 22:15:01 +00:00
parent 4c2c49288b
commit a185020088
19 changed files with 101 additions and 126 deletions

View file

@ -1240,41 +1240,45 @@ Please select a %s type %s.
def getGamesIdSortedById(self): def getGamesIdSortedById(self):
return self.gdb.getGamesIdSortedById() return self.gdb.getGamesIdSortedById()
def getGamesIdSortedByName(self): def getGamesIdSortedByName(self, player=''):
return self.gdb.getGamesIdSortedByName() return self.gdb.getGamesIdSortedByName()
## ##
def getGamesIdSortedByPlayed(self): def getGamesIdSortedByPlayed(self, player=''):
if player == '': player = self.opt.player
def _cmp(a, b): def _cmp(a, b):
wa, la, ta, ma = self.stats.getFullStats(self.opt.player, a) wa, la, ta, ma = self.stats.getFullStats(player, a)
wb, lb, tb, mb = self.stats.getFullStats(self.opt.player, b) wb, lb, tb, mb = self.stats.getFullStats(player, b)
return cmp(wb+lb, wa+la) # reverse return cmp(wb+lb, wa+la) # reverse
games = list(self.gdb.getGamesIdSortedByName()) games = list(self.gdb.getGamesIdSortedByName())
games.sort(_cmp) games.sort(_cmp)
return games return games
def getGamesIdSortedByWon(self): def getGamesIdSortedByWon(self, player=''):
if player == '': player = self.opt.player
def _cmp(a, b): def _cmp(a, b):
wa, la, ta, ma = self.stats.getFullStats(self.opt.player, a) wa, la, ta, ma = self.stats.getFullStats(player, a)
wb, lb, tb, mb = self.stats.getFullStats(self.opt.player, b) wb, lb, tb, mb = self.stats.getFullStats(player, b)
return cmp(wb, wa) # reverse return cmp(wb, wa) # reverse
games = list(self.gdb.getGamesIdSortedByName()) games = list(self.gdb.getGamesIdSortedByName())
games.sort(_cmp) games.sort(_cmp)
return games return games
def getGamesIdSortedByLost(self): def getGamesIdSortedByLost(self, player=''):
if player == '': player = self.opt.player
def _cmp(a, b): def _cmp(a, b):
wa, la, ta, ma = self.stats.getFullStats(self.opt.player, a) wa, la, ta, ma = self.stats.getFullStats(player, a)
wb, lb, tb, mb = self.stats.getFullStats(self.opt.player, b) wb, lb, tb, mb = self.stats.getFullStats(player, b)
return cmp(lb, la) # reverse return cmp(lb, la) # reverse
games = list(self.gdb.getGamesIdSortedByName()) games = list(self.gdb.getGamesIdSortedByName())
games.sort(_cmp) games.sort(_cmp)
return games return games
def getGamesIdSortedByPercent(self): def getGamesIdSortedByPercent(self, player=''):
if player == '': player = self.opt.player
def _cmp(a, b): def _cmp(a, b):
wa, la, ta, ma = self.stats.getFullStats(self.opt.player, a) wa, la, ta, ma = self.stats.getFullStats(player, a)
wb, lb, tb, mb = self.stats.getFullStats(self.opt.player, b) wb, lb, tb, mb = self.stats.getFullStats(player, b)
if wa+la == 0 or wb+lb == 0: if wa+la == 0 or wb+lb == 0:
return cmp(wb+lb, wa+la) # reverse return cmp(wb+lb, wa+la) # reverse
return cmp(float(wb)/(wb+lb), return cmp(float(wb)/(wb+lb),
@ -1283,19 +1287,21 @@ Please select a %s type %s.
games.sort(_cmp) games.sort(_cmp)
return games return games
def getGamesIdSortedByPlayingTime(self): def getGamesIdSortedByPlayingTime(self, player=''):
if player == '': player = self.opt.player
def _cmp(a, b): def _cmp(a, b):
wa, la, ta, ma = self.stats.getFullStats(self.opt.player, a) wa, la, ta, ma = self.stats.getFullStats(player, a)
wb, lb, tb, mb = self.stats.getFullStats(self.opt.player, b) wb, lb, tb, mb = self.stats.getFullStats(player, b)
return cmp(tb, ta) # reverse return cmp(tb, ta) # reverse
games = list(self.gdb.getGamesIdSortedByName()) games = list(self.gdb.getGamesIdSortedByName())
games.sort(_cmp) games.sort(_cmp)
return games return games
def getGamesIdSortedByMoves(self): def getGamesIdSortedByMoves(self, player=''):
if player == '': player = self.opt.player
def _cmp(a, b): def _cmp(a, b):
wa, la, ta, ma = self.stats.getFullStats(self.opt.player, a) wa, la, ta, ma = self.stats.getFullStats(player, a)
wb, lb, tb, mb = self.stats.getFullStats(self.opt.player, b) wb, lb, tb, mb = self.stats.getFullStats(player, b)
return cmp(mb, ma) # reverse return cmp(mb, ma) # reverse
games = list(self.gdb.getGamesIdSortedByName()) games = list(self.gdb.getGamesIdSortedByName())
games.sort(_cmp) games.sort(_cmp)

View file

@ -194,6 +194,7 @@ class Game:
# update display properties # update display properties
self.top.wm_geometry("") # cancel user-specified geometry self.top.wm_geometry("") # cancel user-specified geometry
self.canvas.setInitialSize(self.width, self.height) self.canvas.setInitialSize(self.width, self.height)
self.top.update_idletasks() # apply geometry now
if DEBUG >= 4: if DEBUG >= 4:
MfxCanvasRectangle(self.canvas, 0, 0, self.width, self.height, MfxCanvasRectangle(self.canvas, 0, 0, self.width, self.height,
width=2, fill=None, outline='green') width=2, fill=None, outline='green')
@ -425,13 +426,13 @@ class Game:
if not self.preview: if not self.preview:
wm_map(self.top, maximized=self.app.opt.wm_maximized) wm_map(self.top, maximized=self.app.opt.wm_maximized)
self.top.busyUpdate() self.top.busyUpdate()
self.stopSamples()
#
if TOOLKIT == 'gtk': if TOOLKIT == 'gtk':
## FIXME ## FIXME
if self.top: if self.top:
self.top.update_idletasks() self.top.update_idletasks()
self.top.show_now() self.top.show_now()
#
self.stopSamples()
# let's go # let's go
self.moves.state = self.S_INIT self.moves.state = self.S_INIT
self.startGame() self.startGame()
@ -1015,6 +1016,7 @@ class Game:
### return ### return
if not self.app.opt.animations: if not self.app.opt.animations:
return return
self.setCursor(cursor=CURSOR_WATCH)
self.top.busyUpdate() self.top.busyUpdate()
self.canvas.update_idletasks() self.canvas.update_idletasks()
old_a = self.app.opt.animations old_a = self.app.opt.animations
@ -1252,6 +1254,8 @@ class Game:
# a pure demo game - update demo stats # a pure demo game - update demo stats
self.stats.demo_updated = updated self.stats.demo_updated = updated
self.app.stats.updateStats(None, self, won) self.app.stats.updateStats(None, self, won)
if won:
self.finished = True
return '' return ''
elif self.changed(): elif self.changed():
# must update player stats # must update player stats
@ -1855,7 +1859,6 @@ for %d moves.
image=self.app.gimages.logos[4], strings=(s,), image=self.app.gimages.logos[4], strings=(s,),
separatorwidth=2, timeout=timeout) separatorwidth=2, timeout=timeout)
status = d.status status = d.status
self.finished = True
else: else:
##s = self.app.miscrandom.choice((_("&OK"), _("&OK"))) ##s = self.app.miscrandom.choice((_("&OK"), _("&OK")))
s = _("&OK") s = _("&OK")
@ -1866,7 +1869,6 @@ for %d moves.
text=text, bitmap=bitmap, strings=(s,), text=text, bitmap=bitmap, strings=(s,),
padx=30, timeout=timeout) padx=30, timeout=timeout)
status = d.status status = d.status
self.finished = True
elif finished: elif finished:
##self.stopPlayTimer() ##self.stopPlayTimer()
if not self.top.winfo_ismapped(): if not self.top.winfo_ismapped():

View file

@ -227,8 +227,6 @@ def pysol_init(app, args):
app.loadOptions() app.loadOptions()
# init audio 1) # init audio 1)
warn_thread = 0
warn_pysolsoundserver = 0
app.audio = None app.audio = None
sounds = {'pss': PysolSoundServerModuleClient, sounds = {'pss': PysolSoundServerModuleClient,
'pygame': PyGameAudioClient, 'pygame': PyGameAudioClient,
@ -240,8 +238,8 @@ def pysol_init(app, args):
c = sounds[opts['sound-mod']] c = sounds[opts['sound-mod']]
app.audio = c() app.audio = c()
elif SOUND_MOD == 'auto': elif SOUND_MOD == 'auto':
for c in (PysolSoundServerModuleClient, for c in (PyGameAudioClient,
PyGameAudioClient, PysolSoundServerModuleClient,
OSSAudioClient, OSSAudioClient,
Win32AudioClient, Win32AudioClient,
AbstractAudioClient): AbstractAudioClient):
@ -315,9 +313,6 @@ Please check your %s installation.
app.audio.connectServer(app) app.audio.connectServer(app)
if not app.audio.CAN_PLAY_SOUND: if not app.audio.CAN_PLAY_SOUND:
app.opt.sound = 0 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() app.audio.updateSettings()
# start up the background music # start up the background music
if app.audio.CAN_PLAY_MUSIC: if app.audio.CAN_PLAY_MUSIC:
@ -340,36 +335,6 @@ Please check your %s installation.
loadImage(app.gimages.logos[1])) loadImage(app.gimages.logos[1]))
app.wm_withdraw() 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 # create the progress bar
title = _("Welcome to %s") % PACKAGE title = _("Welcome to %s") % PACKAGE
color = app.opt.colors['table'] color = app.opt.colors['table']

View file

@ -71,7 +71,7 @@ class PysolStatsFormatter:
'percent': app.getGamesIdSortedByPercent, 'percent': app.getGamesIdSortedByPercent,
} }
sort_func = sort_functions[sort_by] sort_func = sort_functions[sort_by]
g = sort_func() g = sort_func(player=player)
twon, tlost, tgames, ttime, tmoves = 0, 0, 0, 0, 0 twon, tlost, tgames, ttime, tmoves = 0, 0, 0, 0, 0
for id in g: for id in g:
name = app.getGameTitleName(id) name = app.getGameTitleName(id)

View file

@ -23,10 +23,6 @@ TkVersion = Tkinter.TkVersion
TclError = Tkinter.TclError TclError = Tkinter.TclError
# internal
_flatten = Tkinter._flatten
class Style(Tkinter.Misc): class Style(Tkinter.Misc):
def __init__(self, master=None): def __init__(self, master=None):
if master is None: if master is None:
@ -84,10 +80,10 @@ class Style(Tkinter.Misc):
"""Sets the current theme to themeName, and refreshes all widgets.""" """Sets the current theme to themeName, and refreshes all widgets."""
return self.tk.call("style", "theme", "use", theme) 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) """Sets the default value of the specified option(s)
in style.""" in style."""
opts = self._options(kw) opts = self._options(cnf, kw)
return self.tk.call("style", "configure", style, *opts) return self.tk.call("style", "configure", style, *opts)
config = configure config = configure
@ -137,18 +133,11 @@ class Widget(Tkinter.Widget, Style):
class Button(Widget, Tkinter.Button): class Button(Widget, Tkinter.Button):
def __init__(self, master=None, cnf={}, **kw): 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) Widget.__init__(self, master, "ttk::button", cnf, kw)
class Checkbutton(Widget, Tkinter.Checkbutton): class Checkbutton(Widget, Tkinter.Checkbutton):
def __init__(self, master=None, cnf={}, **kw): 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) 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) Widget.__init__(self, master, "ttk::frame", cnf, kw)
class SizeGrip(Widget): class Sizegrip(Widget):
def __init__(self, master=None, cnf={}, **kw): def __init__(self, master=None, cnf={}, **kw):
Widget.__init__(self, master, "ttk::sizegrip", 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) return self.tk.call(self._w, "step", amount)
def start(self): def start(self):
self.tk.call("tile::progressbar::start", self._w) self.tk.call("ttk::progressbar::start", self._w)
def stop(self): def stop(self):
self.tk.call("tile::progressbar::stop", self._w) self.tk.call("ttk::progressbar::stop", self._w)
class Radiobutton(Widget, Tkinter.Radiobutton): class Radiobutton(Widget, Tkinter.Radiobutton):
@ -336,9 +325,6 @@ class Scrollbar(Widget, Tkinter.Scrollbar):
class Separator(Widget): class Separator(Widget):
def __init__(self, master=None, cnf={}, **kw): 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) Widget.__init__(self, master, "ttk::separator", cnf, kw)

View file

@ -69,7 +69,7 @@ class ColorsDialog(MfxDialog):
self.not_matching_var.set(app.opt.colors['not_matching']) self.not_matching_var.set(app.opt.colors['not_matching'])
# #
c = Tkinter.Checkbutton(frame, variable=self.use_default_var, 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') c.grid(row=0, column=0, sticky='we')
l = Tk.Label(frame, width=10, height=2, l = Tk.Label(frame, width=10, height=2,
bg=self.text_var.get(), textvariable=self.text_var) bg=self.text_var.get(), textvariable=self.text_var)
@ -87,7 +87,7 @@ class ColorsDialog(MfxDialog):
(_('Hint arrow:'), self.hintarrow_var), (_('Hint arrow:'), self.hintarrow_var),
(_('Highlight not matching:'), self.not_matching_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') ).grid(row=row, column=0, sticky='we')
l = Tk.Label(frame, width=10, height=2, l = Tk.Label(frame, width=10, height=2,
bg=var.get(), textvariable=var) bg=var.get(), textvariable=var)

View file

@ -26,7 +26,7 @@ __all__ = ['create_find_card_dialog',
# imports # imports
import os import os
import Tile as Tkinter import Tkinter
import traceback import traceback
# PySol imports # PySol imports
@ -36,6 +36,8 @@ from tkutil import after, after_cancel
from tkutil import bind, unbind_destroy, makeImage from tkutil import bind, unbind_destroy, makeImage
from tkcanvas import MfxCanvas, MfxCanvasGroup, MfxCanvasImage, MfxCanvasRectangle from tkcanvas import MfxCanvas, MfxCanvasGroup, MfxCanvasImage, MfxCanvasRectangle
from pysollib.settings import PACKAGE
# /*********************************************************************** # /***********************************************************************
# // # //
@ -130,6 +132,7 @@ class FindCardDialog(Tkinter.Toplevel):
i += 1 i += 1
w, h = dx*j+2, dy*i+2 w, h = dx*j+2, dy*i+2
self.canvas.config(width=w, height=h) self.canvas.config(width=w, height=h)
self.wm_iconname(PACKAGE + " - " + game.getTitleName())
def enterEvent(self, suit, rank, rect, group): def enterEvent(self, suit, rank, rect, group):
##print 'enterEvent', suit, rank, self.busy ##print 'enterEvent', suit, rank, self.busy

View file

@ -96,11 +96,11 @@ class FontChooserDialog(MfxDialog):
sb.grid(row=1, column=1, sticky='ns') sb.grid(row=1, column=1, sticky='ns')
bind(self.list_box, '<<ListboxSelect>>', self.fontupdate) bind(self.list_box, '<<ListboxSelect>>', self.fontupdate)
##self.list_box.focus() ##self.list_box.focus()
cb1 = Tkinter.Checkbutton(frame, anchor='w', text=_('Bold'), cb1 = Tkinter.Checkbutton(frame, text=_('Bold'),
command=self.fontupdate, command=self.fontupdate,
variable=self.weight_var) variable=self.weight_var)
cb1.grid(row=2, column=0, columnspan=2, sticky='we') 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, command=self.fontupdate,
variable=self.slant_var) variable=self.slant_var)
cb2.grid(row=3, column=0, columnspan=2, sticky='we') cb2.grid(row=3, column=0, columnspan=2, sticky='we')
@ -182,7 +182,7 @@ class FontsDialog(MfxDialog):
elif font is None: elif font is None:
title = 'Default' title = 'Default'
l = Tkinter.Label(frame, font=font, text=title) 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, b = Tkinter.Button(frame, text=_('Change...'), width=10,
command=lambda l=l, fn=fn: self.selectFont(l, fn)) command=lambda l=l, fn=fn: self.selectFont(l, fn))
b.grid(row=row, column=2) b.grid(row=row, column=2)

View file

@ -1338,7 +1338,8 @@ the next time you restart """)+PACKAGE,
def createThemesMenu(self, menu): def createThemesMenu(self, menu):
style = Tkinter.Style(self.top) style = Tkinter.Style(self.top)
all_themes = style.theme_names() all_themes = list(style.theme_names())
all_themes.sort()
# #
tn = { tn = {
'default': 'Default', 'default': 'Default',

View file

@ -70,7 +70,6 @@ class PlayerOptionsDialog(MfxDialog):
frame = Tkinter.Frame(top_frame) frame = Tkinter.Frame(top_frame)
frame.pack(expand=1, fill='both', padx=5, pady=10) frame.pack(expand=1, fill='both', padx=5, pady=10)
widget = Tkinter.Label(frame, text=_("\nPlease enter your name"), widget = Tkinter.Label(frame, text=_("\nPlease enter your name"),
#justify='left', anchor='w',
takefocus=0) takefocus=0)
widget.grid(row=0, column=0, columnspan=2, sticky='ew', padx=0, pady=5) 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) self.player_var.grid(row=1, column=0, sticky='ew', padx=0, pady=5)
# #
widget = Tkinter.Checkbutton(frame, variable=self.confirm_var, 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.grid(row=2, column=0, columnspan=2, sticky='ew', padx=0, pady=5)
widget = Tkinter.Checkbutton(frame, variable=self.update_stats_var, widget = Tkinter.Checkbutton(frame, variable=self.update_stats_var,
anchor='w',
text=_("Update statistics and logs")) text=_("Update statistics and logs"))
widget.grid(row=3, column=0, columnspan=2, sticky='ew', padx=0, pady=5) widget.grid(row=3, column=0, columnspan=2, sticky='ew', padx=0, pady=5)
### widget = Tkinter.Checkbutton(frame, variable=self.win_animation_var, ### widget = Tkinter.Checkbutton(frame, variable=self.win_animation_var,

View file

@ -239,17 +239,18 @@ class SelectCardsetDialogWithPreview(MfxDialog):
def initKw(self, kw): def initKw(self, kw):
kw = KwStruct(kw, kw = KwStruct(kw,
strings = (_("&Load"), _("&Info..."), _("&Cancel"),), strings = ((_("&Info..."), 10), 'sep',
_("&Load"), _("&Cancel"),),
default=0, default=0,
resizable=1, resizable=1,
) )
return MfxDialog.initKw(self, kw) return MfxDialog.initKw(self, kw)
def mDone(self, button): 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.key = self.tree.selection_key
self.tree.n_expansions = 1 # save xyview in any case 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) cs = self.manager.get(self.tree.selection_key)
if not cs: if not cs:
return return

View file

@ -277,10 +277,10 @@ class SelectGameDialog(MfxDialog):
MfxDialog.destroy(self) MfxDialog.destroy(self)
def mDone(self, button): 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.gameid = self.tree.selection_key
self.tree.n_expansions = 1 # save xyview in any case 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) doc = self.app.getGameRulesFilename(self.tree.selection_key)
if not doc: if not doc:
return return
@ -403,7 +403,8 @@ class SelectGameDialogWithPreview(SelectGameDialog):
def initKw(self, kw): def initKw(self, kw):
kw = KwStruct(kw, kw = KwStruct(kw,
strings=(_("&Select"), _("&Rules"), _("&Cancel"),), strings=((_("&Rules"), 10), 'sep',
_("&Select"), _("&Cancel"),),
default=0, default=0,
) )
return SelectGameDialog.initKw(self, kw) return SelectGameDialog.initKw(self, kw)
@ -513,7 +514,7 @@ class SelectGameDialogWithPreview(SelectGameDialog):
# #
self.updateInfo(gameid) self.updateInfo(gameid)
# #
rules_button = self.buttons[1] rules_button = self.buttons[0]
if self.app.getGameRulesFilename(gameid): if self.app.getGameRulesFilename(gameid):
rules_button.config(state="normal") rules_button.config(state="normal")
else: else:

View file

@ -157,7 +157,8 @@ class SelectTileDialogWithPreview(MfxDialog):
def initKw(self, kw): def initKw(self, kw):
kw = KwStruct(kw, kw = KwStruct(kw,
strings=(_("&OK"), _("&Solid color..."), _("&Cancel"),), strings=((_("&Solid color..."), 10),
'sep', _("&OK"), _("&Cancel"),),
default=0, default=0,
resizable=1, resizable=1,
font=None, font=None,
@ -171,7 +172,7 @@ class SelectTileDialogWithPreview(MfxDialog):
else: else:
self.key = self.tree.selection_key self.key = self.tree.selection_key
self.tree.n_expansions = 1 # save xyview in any case 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, c = tkColorChooser.askcolor(master=self.top,
initialcolor=self.table_color, initialcolor=self.table_color,
title=_("Select table color")) title=_("Select table color"))

View file

@ -110,28 +110,28 @@ class SoundOptionsDialog(MfxDialog):
# #
row = 0 row = 0
w = Tkinter.Checkbutton(frame, variable=self.sound, 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') w.grid(row=row, column=0, columnspan=2, sticky='ew')
# #
if os.name == "nt" and pysolsoundserver: if os.name == "nt" and pysolsoundserver:
row += 1 row += 1
w = Tkinter.Checkbutton(frame, variable=self.sound_mode, w = Tkinter.Checkbutton(frame, variable=self.sound_mode,
text=_("Use DirectX for sound playing"), text=_("Use DirectX for sound playing"),
command=self.mOptSoundDirectX, anchor='w') command=self.mOptSoundDirectX)
w.grid(row=row, column=0, columnspan=2, sticky='ew') w.grid(row=row, column=0, columnspan=2, sticky='ew')
# #
if app.audio.CAN_PLAY_MUSIC: # and app.startup_opt.sound_mode > 0: if app.audio.CAN_PLAY_MUSIC: # and app.startup_opt.sound_mode > 0:
row += 1 row += 1
w = Tkinter.Label(frame, text=_('Sample volume:')) Tkinter.Label(frame, text=_('Sample volume:'), anchor='w'
w.grid(row=row, column=0, sticky='ew') ).grid(row=row, column=0, sticky='ew')
w = PysolScale(frame, from_=0, to=128, resolution=1, w = PysolScale(frame, from_=0, to=128, resolution=1,
orient='horizontal', takefocus=0, orient='horizontal', takefocus=0,
length="3i", #label=_('Sample volume'), length="3i", #label=_('Sample volume'),
variable=self.sample_volume) variable=self.sample_volume)
w.grid(row=row, column=1, sticky='w', padx=5) w.grid(row=row, column=1, sticky='w', padx=5)
row += 1 row += 1
w = Tkinter.Label(frame, text=_('Music volume:')) Tkinter.Label(frame, text=_('Music volume:'), anchor='w'
w.grid(row=row, column=0, sticky='ew', padx=5) ).grid(row=row, column=0, sticky='ew')
w = PysolScale(frame, from_=0, to=128, resolution=1, w = PysolScale(frame, from_=0, to=128, resolution=1,
orient='horizontal', takefocus=0, orient='horizontal', takefocus=0,
length="3i", #label=_('Music volume'), length="3i", #label=_('Music volume'),
@ -154,7 +154,7 @@ class SoundOptionsDialog(MfxDialog):
col = 0 col = 0
for n, t, v in self.samples: for n, t, v in self.samples:
v.set(app.opt.sound_samples[n]) 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) w.grid(row=row, column=col, sticky='ew', padx=3, pady=1)
if col == 1: if col == 1:
col = 0 col = 0

View file

@ -100,8 +100,8 @@ class MfxStatusbar:
b.setText(tooltip) b.setText(tooltip)
return label return label
def _createSizeGrip(self): def _createSizegrip(self):
sg = Tkinter.SizeGrip(self.top_frame) sg = Tkinter.Sizegrip(self.top_frame)
sg.pack(side='right', anchor='se') sg.pack(side='right', anchor='se')
@ -164,7 +164,7 @@ class PysolStatusbar(MfxStatusbar):
l = self._createLabel("info", fill='both', expand=1) l = self._createLabel("info", fill='both', expand=1)
##l.config(text="", justify="left", anchor='w') ##l.config(text="", justify="left", anchor='w')
l.config(padding=(8, 0)) l.config(padding=(8, 0))
self._createSizeGrip() self._createSizegrip()
class HelpStatusbar(MfxStatusbar): class HelpStatusbar(MfxStatusbar):
@ -179,7 +179,7 @@ class HtmlStatusbar(MfxStatusbar):
MfxStatusbar.__init__(self, top, row=row, column=column, columnspan=columnspan) MfxStatusbar.__init__(self, top, row=row, column=column, columnspan=columnspan)
l = self._createLabel("url", fill='both', expand=1) l = self._createLabel("url", fill='both', expand=1)
l.config(justify="left", anchor='w', padding=(8, 0)) l.config(justify="left", anchor='w', padding=(8, 0))
self._createSizeGrip() self._createSizegrip()
# /*********************************************************************** # /***********************************************************************

View file

@ -325,7 +325,6 @@ class TreeFormatter(PysolStatsFormatter):
class AllGames_StatsDialog(MfxDialog): class AllGames_StatsDialog(MfxDialog):
FONT_TYPE = "default"
COLUMNS = ('played', 'won', 'lost', 'time', 'moves', 'percent') COLUMNS = ('played', 'won', 'lost', 'time', 'moves', 'percent')
def __init__(self, parent, title, app, player, **kw): def __init__(self, parent, title, app, player, **kw):
@ -333,7 +332,7 @@ class AllGames_StatsDialog(MfxDialog):
#if parent and parent.winfo_screenheight() < 600: #if parent and parent.winfo_screenheight() < 600:
# lines = 20 # lines = 20
# #
self.font = app.getFont(self.FONT_TYPE) self.font = app.getFont('default')
font = tkFont.Font(parent, self.font) font = tkFont.Font(parent, self.font)
self.font_metrics = font.metrics() self.font_metrics = font.metrics()
self.CHAR_H = self.font_metrics['linespace'] self.CHAR_H = self.font_metrics['linespace']
@ -403,7 +402,7 @@ class AllGames_StatsDialog(MfxDialog):
self.tree.delete(tuple(self.tree_items)) self.tree.delete(tuple(self.tree_items))
self.tree_items = [] self.tree_items = []
formatter = TreeFormatter(self.app, self.tree, self, 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) formatter.writeStats(player, sort_by=self.sort_by)
@ -413,7 +412,6 @@ class AllGames_StatsDialog(MfxDialog):
class FullLog_StatsDialog(AllGames_StatsDialog): class FullLog_StatsDialog(AllGames_StatsDialog):
FONT_TYPE = "fixed"
COLUMNS = ('gamenumber', 'date', 'status') COLUMNS = ('gamenumber', 'date', 'status')
def fillCanvas(self, player, header): def fillCanvas(self, player, header):

View file

@ -177,11 +177,17 @@ class MfxDialog: # ex. _ToplevelDialog
b.pack(side=kw.image_side, padx=kw.image_padx, pady=kw.image_pady) b.pack(side=kw.image_side, padx=kw.image_padx, pady=kw.image_pady)
def createButtons(self, frame, kw): def createButtons(self, frame, kw):
button = column = -1 xbutton = column = -1
padx, pady = kw.get("buttonpadx", 5), kw.get("buttonpady", 5) padx, pady = kw.get("buttonpadx", 5), kw.get("buttonpady", 5)
focus = None focus = None
max_len = 0 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: if type(s) is tuple:
s = s[0] s = s[0]
if s: if s:
@ -194,13 +200,19 @@ class MfxDialog: # ex. _ToplevelDialog
else : button_width = 8 else : button_width = 8
# #
for s in kw.strings: 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: if type(s) is tuple:
assert len(s) == 2 assert len(s) == 2
button = int(s[1]) button = int(s[1])
s = s[0] s = s[0]
if s is None: else:
continue xbutton += 1
button = xbutton
accel_indx = s.find('&') accel_indx = s.find('&')
button_img = None button_img = None
if MfxDialog.button_img: if MfxDialog.button_img:
@ -208,7 +220,6 @@ class MfxDialog: # ex. _ToplevelDialog
s = s.replace('&', '') s = s.replace('&', '')
if button < 0: if button < 0:
widget = Tkinter.Button(frame, text=s, state="disabled") widget = Tkinter.Button(frame, text=s, state="disabled")
button = xbutton
else: else:
widget = Tkinter.Button(frame, text=s, default="normal", widget = Tkinter.Button(frame, text=s, default="normal",
command=(lambda self=self, button=button: self.mDone(button))) command=(lambda self=self, button=button: self.mDone(button)))
@ -217,7 +228,9 @@ class MfxDialog: # ex. _ToplevelDialog
focus.config(default="active") focus.config(default="active")
self.buttons.append(widget) self.buttons.append(widget)
# #
widget.config(width=button_width) column += 1
if column >= sep_column:
widget.config(width=button_width)
if accel_indx >= 0: if accel_indx >= 0:
# key accelerator # key accelerator
widget.config(underline=accel_indx) widget.config(underline=accel_indx)
@ -226,14 +239,13 @@ class MfxDialog: # ex. _ToplevelDialog
# #
if button_img: if button_img:
widget.config(compound='left', image=button_img) widget.config(compound='left', image=button_img)
column += 1
widget.grid(column=column, row=0, sticky="nse", padx=padx, pady=pady) widget.grid(column=column, row=0, sticky="nse", padx=padx, pady=pady)
if focus is not None: if focus is not None:
l = (lambda event=None, self=self, button=kw.default: self.mDone(button)) l = (lambda event=None, self=self, button=kw.default: self.mDone(button))
bind(self.top, "<Return>", l) bind(self.top, "<Return>", l)
bind(self.top, "<KP_Enter>", l) bind(self.top, "<KP_Enter>", l)
# right justify # right justify
frame.columnconfigure(0, weight=1) frame.columnconfigure(sep_column, weight=1)
return focus return focus

View file

@ -354,9 +354,7 @@ class PysolToolbar(PysolToolbarActions):
sep = ToolbarSeparator(self.frame, sep = ToolbarSeparator(self.frame,
position=position, position=position,
toolbar=self, toolbar=self,
width=4, takefocus=0)
takefocus=0,
relief=self.separator_relief)
sep.show(orient=self.orient) sep.show(orient=self.orient)
self._widgets.append(sep) self._widgets.append(sep)
return sep return sep

View file

@ -36,6 +36,8 @@ from tkutil import after, after_cancel
from tkutil import bind, unbind_destroy, makeImage from tkutil import bind, unbind_destroy, makeImage
from tkcanvas import MfxCanvas, MfxCanvasGroup, MfxCanvasImage, MfxCanvasRectangle from tkcanvas import MfxCanvas, MfxCanvasGroup, MfxCanvasImage, MfxCanvasRectangle
from pysollib.settings import PACKAGE
# /*********************************************************************** # /***********************************************************************
# // # //
@ -130,6 +132,7 @@ class FindCardDialog(Tkinter.Toplevel):
i += 1 i += 1
w, h = dx*j+2, dy*i+2 w, h = dx*j+2, dy*i+2
self.canvas.config(width=w, height=h) self.canvas.config(width=w, height=h)
self.wm_iconname(PACKAGE + " - " + game.getTitleName())
def enterEvent(self, suit, rank, rect, group): def enterEvent(self, suit, rank, rect, group):
##print 'enterEvent', suit, rank, self.busy ##print 'enterEvent', suit, rank, self.busy