1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00
This commit is contained in:
Shlomi Fish 2017-04-17 15:39:19 +03:00
parent 85e604b912
commit 6eebf8729d
8 changed files with 248 additions and 159 deletions

View file

@ -29,7 +29,7 @@ import Tkinter
import ttk
# PySol imports
from pysollib.mygettext import _, n_
from pysollib.mygettext import _
from pysollib.mfxutil import KwStruct, USE_PIL
from pysollib.util import CARDSET
from pysollib.resource import CSI
@ -55,7 +55,8 @@ class SelectCardsetNode(SelectDialogTreeNode):
contents = []
for obj in self.tree.data.all_objects:
if self.select_func(obj):
node = SelectCardsetLeaf(self.tree, self, text=obj.name, key=obj.index)
node = SelectCardsetLeaf(
self.tree, self, text=obj.name, key=obj.index)
contents.append(node)
return contents or self.tree.data.no_contents
@ -69,59 +70,93 @@ class SelectCardsetData(SelectDialogTreeData):
SelectDialogTreeData.__init__(self)
self.all_objects = manager.getAllSortedByName()
self.all_objects = [obj for obj in self.all_objects if not obj.error]
self.no_contents = [ SelectCardsetLeaf(None, None, _("(no cardsets)"), key=None), ]
self.no_contents = [SelectCardsetLeaf(
None, None, _("(no cardsets)"), key=None), ]
#
select_by_type = None
items = CSI.TYPE.items()
items.sort(lambda a, b: cmp(a[1], b[1]))
items.sort(key=lambda x: x[1])
nodes = []
for key, name in items:
if manager.registered_types.get(key):
nodes.append(SelectCardsetNode(None, name, lambda cs, key=key: key == cs.si.type))
nodes.append(
SelectCardsetNode(
None, name, lambda cs, key=key: key == cs.si.type))
if nodes:
select_by_type = SelectCardsetNode(None, _("by Type"), tuple(nodes), expanded=1)
select_by_type = SelectCardsetNode(
None, _("by Type"), tuple(nodes), expanded=1)
#
select_by_style = None
items = CSI.STYLE.items()
items.sort(lambda a, b: cmp(a[1], b[1]))
items.sort(key=lambda x: x[1])
nodes = []
for key, name in items:
if manager.registered_styles.get(key):
nodes.append(SelectCardsetNode(None, name, lambda cs, key=key: key in cs.si.styles))
nodes.append(
SelectCardsetNode(
None, name, lambda cs, key=key: key in cs.si.styles))
if nodes:
nodes.append(SelectCardsetNode(None, _("Uncategorized"), lambda cs: not cs.si.styles))
select_by_style = SelectCardsetNode(None, _("by Style"), tuple(nodes))
nodes.append(
SelectCardsetNode(
None, _("Uncategorized"), lambda cs: not cs.si.styles))
select_by_style = SelectCardsetNode(
None, _("by Style"), tuple(nodes))
#
select_by_nationality = None
items = CSI.NATIONALITY.items()
items.sort(lambda a, b: cmp(a[1], b[1]))
items.sort(key=lambda x: x[1])
nodes = []
for key, name in items:
if manager.registered_nationalities.get(key):
nodes.append(SelectCardsetNode(None, name, lambda cs, key=key: key in cs.si.nationalities))
nodes.append(
SelectCardsetNode(
None, name,
lambda cs, key=key: key in cs.si.nationalities))
if nodes:
nodes.append(SelectCardsetNode(None, _("Uncategorized"), lambda cs: not cs.si.nationalities))
select_by_nationality = SelectCardsetNode(None, _("by Nationality"), tuple(nodes))
nodes.append(
SelectCardsetNode(
None, _("Uncategorized"),
lambda cs: not cs.si.nationalities))
select_by_nationality = SelectCardsetNode(
None, _("by Nationality"), tuple(nodes))
#
select_by_date = None
items = CSI.DATE.items()
items.sort(lambda a, b: cmp(a[1], b[1]))
items.sort(key=lambda x: x[1])
nodes = []
for key, name in items:
if manager.registered_dates.get(key):
nodes.append(SelectCardsetNode(None, name, lambda cs, key=key: key in cs.si.dates))
nodes.append(
SelectCardsetNode(
None, name, lambda cs, key=key: key in cs.si.dates))
if nodes:
nodes.append(SelectCardsetNode(None, _("Uncategorized"), lambda cs: not cs.si.dates))
select_by_date = SelectCardsetNode(None, _("by Date"), tuple(nodes))
nodes.append(
SelectCardsetNode(
None, _("Uncategorized"), lambda cs: not cs.si.dates))
select_by_date = SelectCardsetNode(
None, _("by Date"), tuple(nodes))
#
self.rootnodes = filter(None, (
SelectCardsetNode(None, _("All Cardsets"), lambda cs: 1, expanded=len(self.all_objects)<=12),
SelectCardsetNode(None, _("by Size"), (
SelectCardsetNode(None, _("Tiny cardsets"), lambda cs: cs.si.size == CSI.SIZE_TINY),
SelectCardsetNode(None, _("Small cardsets"), lambda cs: cs.si.size == CSI.SIZE_SMALL),
SelectCardsetNode(None, _("Medium cardsets"), lambda cs: cs.si.size == CSI.SIZE_MEDIUM),
SelectCardsetNode(None, _("Large cardsets"), lambda cs: cs.si.size == CSI.SIZE_LARGE),
SelectCardsetNode(None, _("XLarge cardsets"), lambda cs: cs.si.size == CSI.SIZE_XLARGE),
SelectCardsetNode(
None, _("All Cardsets"),
lambda cs: 1, expanded=len(self.all_objects) <= 12),
SelectCardsetNode(
None, _("by Size"),
(SelectCardsetNode(
None, _("Tiny cardsets"),
lambda cs: cs.si.size == CSI.SIZE_TINY),
SelectCardsetNode(
None, _("Small cardsets"),
lambda cs: cs.si.size == CSI.SIZE_SMALL),
SelectCardsetNode(
None, _("Medium cardsets"),
lambda cs: cs.si.size == CSI.SIZE_MEDIUM),
SelectCardsetNode(
None, _("Large cardsets"),
lambda cs: cs.si.size == CSI.SIZE_LARGE),
SelectCardsetNode(
None, _("XLarge cardsets"),
lambda cs: cs.si.size == CSI.SIZE_XLARGE),
), expanded=1),
select_by_type,
select_by_style,
@ -134,15 +169,19 @@ class SelectCardsetByTypeData(SelectDialogTreeData):
def __init__(self, manager, key):
SelectDialogTreeData.__init__(self)
self.all_objects = manager.getAllSortedByName()
self.no_contents = [ SelectCardsetLeaf(None, None, _("(no cardsets)"), key=None), ]
self.no_contents = [SelectCardsetLeaf(None, None, _("(no cardsets)"),
key=None), ]
#
items = CSI.TYPE.items()
items.sort(lambda a, b: cmp(a[1], b[1]))
items.sort(key=lambda x: x[1])
nodes = []
for key, name in items:
if manager.registered_types.get(key):
nodes.append(SelectCardsetNode(None, name, lambda cs, key=key: key == cs.si.type))
select_by_type = SelectCardsetNode(None, _("by Type"), tuple(nodes), expanded=1)
nodes.append(
SelectCardsetNode(
None, name, lambda cs, key=key: key == cs.si.type))
select_by_type = SelectCardsetNode(
None, _("by Type"), tuple(nodes), expanded=1)
#
self.rootnodes = filter(None, (
select_by_type,
@ -214,7 +253,8 @@ class SelectCardsetDialogWithPreview(MfxDialog):
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)
self.scale_x.grid(
row=1, column=0, sticky='ew', padx=padx, pady=pady)
#
var = Tkinter.DoubleVar()
var.set(app.opt.scale_y)
@ -224,7 +264,8 @@ class SelectCardsetDialogWithPreview(MfxDialog):
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.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)
@ -308,7 +349,7 @@ class SelectCardsetDialogWithPreview(MfxDialog):
cs = self.manager.get(self.tree.selection_key)
if not cs:
return
##title = CARDSET+" "+cs.name
# title = CARDSET+" "+cs.name
title = CARDSET.capitalize()+" "+cs.name
d = CardsetInfoDialog(self.top, title=title, cardset=cs,
images=self.preview_images)
@ -386,6 +427,7 @@ class SelectCardsetByTypeDialogWithPreview(SelectCardsetDialogWithPreview):
# * Cardset Info
# ************************************************************************
class CardsetInfoDialog(MfxDialog):
def __init__(self, parent, title, cardset, images, **kw):
kw = self.initKw(kw)
@ -411,12 +453,12 @@ class CardsetInfoDialog(MfxDialog):
year = str(cardset.year)
frow = 0
for n, t in (
##('Version:', str(cardset.version)),
# ('Version:', str(cardset.version)),
(_('Type:'), CSI.TYPE[cardset.type]),
(_('Styles:'), styles),
(_('Nationality:'), nationalities),
(_('Year:'), year),
##(_('Number of cards:'), str(cardset.ncards)),
# (_('Number of cards:'), str(cardset.ncards)),
(_('Size:'), '%d x %d' % (cardset.CARDW, cardset.CARDH)),
):
if t is not None:
@ -472,7 +514,7 @@ class CardsetInfoDialog(MfxDialog):
padx=padx, pady=pady)
row += 1
##bg = top_frame["bg"]
# bg = top_frame["bg"]
bg = 'white'
text_w = Tkinter.Text(frame, bd=1, relief="sunken", wrap="word",
padx=4, width=64, height=16, bg=bg)
@ -518,4 +560,3 @@ class CardsetInfoDialog(MfxDialog):
else:
self.cardset_values = None
MfxDialog.mDone(self, button)

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- mode: python; coding: utf-8; -*-
# ---------------------------------------------------------------------------##
# ---------------------------------------------------------------------------
#
# Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer
# Copyright (C) 2003 Mt. Hood Playing Card Co.
@ -19,7 +19,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# ---------------------------------------------------------------------------##
# ---------------------------------------------------------------------------
# imports
@ -28,7 +28,7 @@ import ttk
from UserList import UserList
# PySol imports
from pysollib.mygettext import _, n_
from pysollib.mygettext import _
from pysollib.mfxutil import destruct, Struct, KwStruct
from pysollib.mfxutil import format_time
from pysollib.gamedb import GI
@ -62,7 +62,7 @@ class SelectGameNode(SelectDialogTreeNode):
for gi in self.tree.data.all_games_gi:
if gi and self.select_func is None:
# All games
##name = '%s (%s)' % (gi.name, CSI.TYPE_NAME[gi.category])
# name = '%s (%s)' % (gi.name, CSI.TYPE_NAME[gi.category])
name = gi.name
node = SelectGameLeaf(self.tree, self, name, key=gi.id)
contents.append(node)
@ -83,7 +83,8 @@ class SelectGameData(SelectDialogTreeData):
self.all_games_gi = map(app.gdb.get, app.gdb.getGamesIdSortedByName())
self.no_games = [SelectGameLeaf(None, None, _("(no games)"), None), ]
#
s_by_type = s_oriental = s_special = s_original = s_contrib = s_mahjongg = None
s_by_type = s_oriental = s_special = s_original = s_contrib = \
s_mahjongg = None
g = []
for data in (GI.SELECT_GAME_BY_TYPE,
GI.SELECT_ORIENTAL_GAME_BY_TYPE,
@ -97,7 +98,10 @@ class SelectGameData(SelectDialogTreeData):
continue
gg.append(SelectGameNode(None, _(name), select_func))
g.append(gg)
select_mahjongg_game = lambda gi: gi.si.game_type == GI.GT_MAHJONGG
def select_mahjongg_game(gi):
return gi.si.game_type == GI.GT_MAHJONGG
gg = None
if filter(select_mahjongg_game, self.all_games_gi):
gg = SelectGameNode(None, _("Mahjongg Games"),
@ -115,14 +119,15 @@ class SelectGameData(SelectDialogTreeData):
if g[3]:
s_original = SelectGameNode(None, _("Original Games"),
tuple(g[3]))
## if g[4]:
## s_contrib = SelectGameNode(None, "Contributed Games", tuple(g[4]))
# if g[4]:
# s_contrib = SelectGameNode(None, "Contributed Games", tuple(g[4]))
if g[5]:
s_mahjongg = g[5]
#
s_by_compatibility, gg = None, []
for name, games in GI.GAMES_BY_COMPATIBILITY:
select_func = lambda gi, games=games: gi.id in games
def select_func(gi, games=games):
return gi.id in games
if name is None or not filter(select_func, self.all_games_gi):
continue
gg.append(SelectGameNode(None, name, select_func))
@ -132,7 +137,8 @@ class SelectGameData(SelectDialogTreeData):
#
s_by_pysol_version, gg = None, []
for name, games in GI.GAMES_BY_PYSOL_VERSION:
select_func = lambda gi, games=games: gi.id in games
def select_func(gi, games=games):
return gi.id in games
if name is None or not filter(select_func, self.all_games_gi):
continue
name = _("New games in v. ") + name
@ -142,7 +148,8 @@ class SelectGameData(SelectDialogTreeData):
tuple(gg))
s_by_inventors, gg = None, []
for name, games in GI.GAMES_BY_INVENTORS:
select_func = lambda gi, games=games: gi.id in games
def select_func(gi, games=games):
return gi.id in games
if name is None or not filter(select_func, self.all_games_gi):
continue
gg.append(SelectGameNode(None, name, select_func))
@ -150,7 +157,8 @@ class SelectGameData(SelectDialogTreeData):
s_by_inventors = SelectGameNode(None, _("by Inventors"),
tuple(gg))
#
ul_alternate_names = UserList(list(app.gdb.getGamesTuplesSortedByAlternateName()))
ul_alternate_names = UserList(
list(app.gdb.getGamesTuplesSortedByAlternateName()))
#
self.rootnodes = filter(None, (
SelectGameNode(None, _("All Games"), None, expanded=0),
@ -170,7 +178,8 @@ class SelectGameData(SelectDialogTreeData):
lambda gi: gi.skill_level == GI.SL_MOSTLY_LUCK),
SelectGameNode(None, _('Balanced'),
lambda gi: gi.skill_level == GI.SL_BALANCED),
SelectGameNode(None, _('Mostly skill'),
SelectGameNode(
None, _('Mostly skill'),
lambda gi: gi.skill_level == GI.SL_MOSTLY_SKILL),
SelectGameNode(None, _('Skill only'),
lambda gi: gi.skill_level == GI.SL_SKILL),
@ -191,8 +200,10 @@ class SelectGameData(SelectDialogTreeData):
lambda gi: gi.si.ncards == 104),
SelectGameNode(None, _("144 cards"),
lambda gi: gi.si.ncards == 144),
SelectGameNode(None, _("Other number"),
lambda gi: gi.si.ncards not in (32, 48, 52, 64, 78, 104, 144)),
SelectGameNode(
None, _("Other number"),
lambda gi: gi.si.ncards not in (32, 48, 52,
64, 78, 104, 144)),
)),
SelectGameNode(None, _("by Number of Decks"), (
SelectGameNode(None, _("1 deck games"),
@ -215,9 +226,10 @@ class SelectGameData(SelectDialogTreeData):
lambda gi: gi.si.redeals == 3),
SelectGameNode(None, _("Unlimited redeals"),
lambda gi: gi.si.redeals == -1),
## SelectGameNode(None, "Variable redeals",
## lambda gi: gi.si.redeals == -2),
SelectGameNode(None, _("Other number of redeals"),
# SelectGameNode(None, "Variable redeals",
# lambda gi: gi.si.redeals == -2),
SelectGameNode(
None, _("Other number of redeals"),
lambda gi: gi.si.redeals not in (-1, 0, 1, 2, 3)),
)),
s_by_compatibility,
@ -229,7 +241,8 @@ class SelectGameData(SelectDialogTreeData):
lambda gi: gi.si.game_flags & GI.GT_CHILDREN),
SelectGameNode(None, _("Games with Scoring"),
lambda gi: gi.si.game_flags & GI.GT_SCORE),
SelectGameNode(None, _("Games with Separate Decks"),
SelectGameNode(
None, _("Games with Separate Decks"),
lambda gi: gi.si.game_flags & GI.GT_SEPARATE_DECKS),
SelectGameNode(None, _("Open Games (all cards visible)"),
lambda gi: gi.si.game_flags & GI.GT_OPEN),
@ -345,10 +358,10 @@ class SelectGameDialogWithPreview(SelectGameDialog):
w1, w2 = 220, 480
else:
w1, w2 = 200, 300
##print sw, w1, w2
# 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
# print sw, w1, w2
# padx, pady = kw.padx, kw.pady
# padx, pady = kw.padx/2, kw.pady/2
padx, pady = 4, 4
# PanedWindow
@ -372,7 +385,6 @@ class SelectGameDialogWithPreview(SelectGameDialog):
ipadx=4, ipady=4, sticky='nws')
# Info
self.info_labels = {}
i = 0
for n, t, f, row in (
('name', _('Name:'), info_frame, 0),
('altnames', _('Alternate names:'), info_frame, 1),
@ -394,7 +406,7 @@ class SelectGameDialogWithPreview(SelectGameDialog):
text_label = ttk.Label(f, justify='left', anchor='w')
text_label.grid(row=row, column=1, sticky='nw', padx=4)
self.info_labels[n] = (title_label, text_label)
##info_frame.columnconfigure(1, weight=1)
# info_frame.columnconfigure(1, weight=1)
info_frame.rowconfigure(6, weight=1)
stats_frame.rowconfigure(6, weight=1)
# Canvas
@ -413,7 +425,7 @@ class SelectGameDialogWithPreview(SelectGameDialog):
self.preview_game = None
self.preview_app = None
self.updatePreview(gameid, animations=0)
##focus = self.tree.frame
# focus = self.tree.frame
self.mainloop(focus, kw.timeout)
def initKw(self, kw):
@ -496,7 +508,8 @@ class SelectGameDialogWithPreview(SelectGameDialog):
if self.preview_game:
self.preview_game.endGame()
self.preview_game.destruct()
##self.top.wm_title("Select Game - " + self.app.getGameTitleName(gameid))
# self.top.wm_title("Select Game - " +
# self.app.getGameTitleName(gameid))
title = self.app.getGameTitleName(gameid)
self.top.wm_title(_("Playable Preview - ") + title)
#
@ -550,13 +563,19 @@ class SelectGameDialogWithPreview(SelectGameDialog):
GI.SL_SKILL: _('Skill only'),
}
skill_level = sl.get(gi.skill_level)
if gi.redeals == -2: redeals = _('variable')
elif gi.redeals == -1: redeals = _('unlimited')
else: redeals = str(gi.redeals)
if gi.redeals == -2:
redeals = _('variable')
elif gi.redeals == -1:
redeals = _('unlimited')
else:
redeals = str(gi.redeals)
# stats
won, lost, time, moves = self.app.stats.getFullStats(self.app.opt.player, gameid)
if won+lost > 0: percent = "%.1f" % (100.0*won/(won+lost))
else: percent = "0.0"
won, lost, time, moves = self.app.stats.getFullStats(
self.app.opt.player, gameid)
if won+lost > 0:
percent = "%.1f" % (100.0*won/(won+lost))
else:
percent = "0.0"
time = format_time(time)
moves = str(round(moves, 1))
for n, t in (
@ -582,4 +601,3 @@ class SelectGameDialogWithPreview(SelectGameDialog):
title_label.grid()
text_label.grid()
text_label.config(text=t)

View file

@ -23,12 +23,13 @@
# imports
import sys
import Tkinter
import ttk
import tkColorChooser
# PySol imports
from pysollib.mygettext import _, n_
from pysollib.mygettext import _
from pysollib.mfxutil import KwStruct
# Toolkit imports
@ -37,6 +38,10 @@ from selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode
from selecttree import SelectDialogTreeData, SelectDialogTreeCanvas
if sys.version_info > (3,):
basestring = str
# ************************************************************************
# * Nodes
# ************************************************************************
@ -50,7 +55,8 @@ class SelectTileNode(SelectDialogTreeNode):
contents = []
for obj in self.tree.data.all_objects:
if self.select_func(obj):
node = SelectTileLeaf(self.tree, self, text=obj.name, key=obj.index)
node = SelectTileLeaf(
self.tree, self, text=obj.name, key=obj.index)
contents.append(node)
return contents or self.tree.data.no_contents
@ -64,8 +70,10 @@ class SelectTileData(SelectDialogTreeData):
SelectDialogTreeData.__init__(self)
self.all_objects = manager.getAllSortedByName()
self.all_objects = [obj for obj in self.all_objects if not obj.error]
self.all_objects = [tile for tile in self.all_objects if tile.index > 0 and tile.filename]
self.no_contents = [ SelectTileLeaf(None, None, _("(no tiles)"), key=None), ]
self.all_objects = [tile for tile in self.all_objects
if tile.index > 0 and tile.filename]
self.no_contents = [SelectTileLeaf(
None, None, _("(no tiles)"), key=None), ]
e1 = isinstance(key, str) or len(self.all_objects) <= 17
e2 = 1
self.rootnodes = (
@ -77,7 +85,9 @@ class SelectTileData(SelectDialogTreeData):
SelectTileLeaf(None, None, _("Orange"), key="#f79600"),
SelectTileLeaf(None, None, _("Teal"), key="#008286"),
), expanded=e1),
SelectTileNode(None, _("All Backgrounds"), lambda tile: 1, expanded=e2),
SelectTileNode(
None, _("All Backgrounds"),
lambda tile: 1, expanded=e2),
)
@ -199,4 +209,3 @@ class SelectTileDialogWithPreview(MfxDialog):
if self.preview.setTile(self.app, key):
return
self.preview_key = -1

View file

@ -26,29 +26,40 @@ __all__ = ['SelectDialogTreeData']
# Toolkit imports
from tktree import MfxTreeLeaf, MfxTreeNode, MfxTreeInCanvas
from pysollib.ui.tktile.selecttree import BaseSelectDialogTreeLeaf, BaseSelectDialogTreeNode, SelectDialogTreeData, BaseSelectDialogTreeCanvas
from pysollib.ui.tktile.selecttree import BaseSelectDialogTreeLeaf, \
BaseSelectDialogTreeNode, SelectDialogTreeData, \
BaseSelectDialogTreeCanvas
# ************************************************************************
# * Nodes
# ************************************************************************
class SelectDiagCommon:
def _calc_MfxTreeNode(self):
return MfxTreeNode
def _calc_MfxTreeInCanvas(self):
return MfxTreeInCanvas
def _calc_MfxTreeLeaf(self):
return MfxTreeLeaf
class SelectDialogTreeLeaf(SelectDiagCommon, BaseSelectDialogTreeLeaf, MfxTreeLeaf):
class SelectDialogTreeLeaf(SelectDiagCommon,
BaseSelectDialogTreeLeaf, MfxTreeLeaf):
pass
class SelectDialogTreeNode(SelectDiagCommon, BaseSelectDialogTreeNode, MfxTreeNode):
class SelectDialogTreeNode(SelectDiagCommon,
BaseSelectDialogTreeNode, MfxTreeNode):
pass
# ************************************************************************
# * Canvas that shows the tree (left side)
# ************************************************************************
class SelectDialogTreeCanvas(SelectDiagCommon, BaseSelectDialogTreeCanvas, MfxTreeInCanvas):
class SelectDialogTreeCanvas(SelectDiagCommon,
BaseSelectDialogTreeCanvas, MfxTreeInCanvas):
pass

View file

@ -30,16 +30,17 @@ __all__ = [
]
# imports
import ttk
# PySol imports
from pysollib.mygettext import _, n_
from pysollib.mygettext import _
from pysollib.mfxutil import KwStruct
# Toolkit imports
from pysollib.tile.basetilemfxdialog import BaseTileMfxDialog
from tkwidget import PysolCombo
from pysollib.ui.tktile.solverdialog import BaseSolverDialog, solver_dialog, connect_game_solver_dialog, destroy_solver_dialog, reset_solver_dialog
from pysollib.ui.tktile.solverdialog import BaseSolverDialog, \
connect_game_solver_dialog, destroy_solver_dialog, solver_dialog, \
reset_solver_dialog
# ************************************************************************
@ -59,8 +60,10 @@ class SolverDialog(BaseSolverDialog, BaseTileMfxDialog):
cb.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
cb.current(0)
return cb
def _createShowProgressButton(self, frame):
return self._calcToolkit().Checkbutton(frame, variable=self.progress_var,
return self._calcToolkit().Checkbutton(
frame, variable=self.progress_var,
text=_('Show progress'))
def initKw(self, kw):
@ -83,6 +86,8 @@ class SolverDialog(BaseSolverDialog, BaseTileMfxDialog):
self.play_button.config(state='disabled')
solver_dialog = solver_dialog
def create_solver_dialog(parent, game):
global solver_dialog
@ -90,6 +95,5 @@ def create_solver_dialog(parent, game):
solver_dialog.top.wm_deiconify()
solver_dialog.top.tkraise()
except:
##traceback.print_exc()
# traceback.print_exc()
solver_dialog = SolverDialog(parent, game)

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- mode: python; coding: utf-8; -*-
# ---------------------------------------------------------------------------##
# ---------------------------------------------------------------------------
#
# Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer
# Copyright (C) 2003 Mt. Hood Playing Card Co.
@ -19,7 +19,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# ---------------------------------------------------------------------------##
# ---------------------------------------------------------------------------
__all__ = ['SoundOptionsDialog']
@ -29,7 +29,7 @@ import Tkinter
import ttk
# PySol imports
from pysollib.mygettext import _, n_
from pysollib.mygettext import _
from pysollib.mfxutil import KwStruct
from pysollib.settings import TITLE
from pysollib.pysolaudio import pysolsoundserver
@ -186,11 +186,11 @@ class SoundOptionsDialog(MfxDialog):
return self.mDone(0)
def mOptSoundDirectX(self, *event):
##print self.sound_mode.get()
d = MfxMessageDialog(self.top, title=_("Sound preferences info"),
# print self.sound_mode.get()
MfxMessageDialog(
self.top, title=_("Sound preferences info"),
text=_("""\
Changing DirectX settings will take effect
the next time you restart """)+TITLE,
bitmap="warning",
default=0, strings=(_("&OK"),))

View file

@ -25,26 +25,31 @@ __all__ = ['PysolStatusbar',
'HelpStatusbar']
# imports
import os, sys
import os
import sys
import Tkinter
import ttk
# PySol imports
from pysollib.mygettext import _
# Toolkit imports
from tkwidget import MfxTooltip
if __name__ == '__main__':
d = os.path.abspath(os.path.join(sys.path[0], os.pardir, os.pardir))
sys.path.append(d)
import gettext
gettext.install('pysol', d, unicode=True)
# PySol imports
from pysollib.mygettext import _, n_
# Toolkit imports
from tkwidget import MfxTooltip
if sys.version_info > (3,):
unicode = str
# ************************************************************************
# *
# ************************************************************************
class MfxStatusbar:
def __init__(self, top, row, column, columnspan):
self.top = top
@ -90,7 +95,6 @@ class MfxStatusbar:
sg = ttk.Sizegrip(self.top_frame)
sg.pack(side='right', anchor='se')
#
# public methods
#
@ -138,10 +142,12 @@ class MfxStatusbar:
def destroy(self):
for w in self._tooltips:
if w: w.destroy()
if w:
w.destroy()
self._tooltips = []
for w in self._widgets:
if w: w.destroy()
if w:
w.destroy()
self._widgets = []
@ -191,13 +197,13 @@ class TestStatusbar(PysolStatusbar):
self.updateText(moves=999, gamenumber='#0123456789ABCDEF0123')
self.updateText(info='Some info text.')
def statusbar_main(args):
tk = Tkinter.Tk()
statusbar = TestStatusbar(tk, args)
TestStatusbar(tk, args)
tk.mainloop()
return 0
if __name__ == '__main__':
sys.exit(statusbar_main(sys.argv))

View file

@ -10,7 +10,7 @@ use String::ShellQuote qw/ shell_quote /;
# my $cmd = shell_quote( 'flake8', '.' );
my $cmd = shell_quote( 'flake8',
grep { not($_ eq './pysollib/pysoltk.py') } glob('./pysollib/*.py ./pysollib/[cmp]*/*.py ./pysollib/tile/[a-p]*.py') );
grep { not($_ eq './pysollib/pysoltk.py') } glob('./pysollib/*.py ./pysollib/[cmp]*/*.py ./pysollib/tile/[a-s]*.py') );
# TEST
eq_or_diff( scalar(`$cmd`), '', "flake8 is happy with the code." );