mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
menubar: move more code to the base class.
This commit is contained in:
parent
ee1114fb3b
commit
cde9bc5fb5
3 changed files with 53 additions and 93 deletions
|
@ -77,6 +77,11 @@ class PysolMenubarTk(PysolMenubarTkCommon):
|
||||||
|
|
||||||
def _connect_game_solver_dialog(self, game):
|
def _connect_game_solver_dialog(self, game):
|
||||||
return connect_game_solver_dialog(game)
|
return connect_game_solver_dialog(game)
|
||||||
|
|
||||||
|
def _calcWizardDialog(self):
|
||||||
|
from wizarddialog import WizardDialog
|
||||||
|
return WizardDialog
|
||||||
|
|
||||||
#
|
#
|
||||||
# create the menubar
|
# create the menubar
|
||||||
#
|
#
|
||||||
|
@ -145,50 +150,3 @@ the next time you restart """)+TITLE,
|
||||||
submenu.add_radiobutton(label=n, variable=self.tkopt.theme,
|
submenu.add_radiobutton(label=n, variable=self.tkopt.theme,
|
||||||
value=t, command=self.mOptTheme)
|
value=t, command=self.mOptTheme)
|
||||||
|
|
||||||
def wizardDialog(self, edit=False):
|
|
||||||
from pysollib.wizardutil import write_game, reset_wizard
|
|
||||||
from wizarddialog import WizardDialog
|
|
||||||
|
|
||||||
if edit:
|
|
||||||
reset_wizard(self.game)
|
|
||||||
else:
|
|
||||||
reset_wizard(None)
|
|
||||||
d = WizardDialog(self.top, _('Solitaire Wizard'), self.app)
|
|
||||||
if d.status == 0 and d.button == 0:
|
|
||||||
try:
|
|
||||||
if edit:
|
|
||||||
gameid = write_game(self.app, game=self.game)
|
|
||||||
else:
|
|
||||||
gameid = write_game(self.app)
|
|
||||||
except Exception, err:
|
|
||||||
if DEBUG:
|
|
||||||
traceback.print_exc()
|
|
||||||
d = MfxMessageDialog(self.top, title=_('Save game error'),
|
|
||||||
text=_('''
|
|
||||||
Error while saving game.
|
|
||||||
|
|
||||||
%s
|
|
||||||
''') % str(err),
|
|
||||||
bitmap='error')
|
|
||||||
return
|
|
||||||
|
|
||||||
if SELECT_GAME_MENU:
|
|
||||||
menu = self.menupath[".menubar.select.customgames"][2]
|
|
||||||
select_func = lambda gi: gi.si.game_type == GI.GT_CUSTOM
|
|
||||||
games = map(self.app.gdb.get,
|
|
||||||
self.app.gdb.getGamesIdSortedByName())
|
|
||||||
games = filter(select_func, games)
|
|
||||||
self.updateGamesMenu(menu, games)
|
|
||||||
|
|
||||||
self.tkopt.gameid.set(gameid)
|
|
||||||
self._mSelectGame(gameid, force=True)
|
|
||||||
|
|
||||||
|
|
||||||
def mWizard(self, *event):
|
|
||||||
if self._cancelDrag(break_pause=False): return
|
|
||||||
self.wizardDialog()
|
|
||||||
|
|
||||||
def mWizardEdit(self, *event):
|
|
||||||
if self._cancelDrag(break_pause=False): return
|
|
||||||
self.wizardDialog(edit=True)
|
|
||||||
|
|
||||||
|
|
|
@ -145,49 +145,3 @@ class PysolMenubarTk(PysolMenubarTkCommon):
|
||||||
self.game.showStackDesc()
|
self.game.showStackDesc()
|
||||||
|
|
||||||
|
|
||||||
def wizardDialog(self, edit=False):
|
|
||||||
from pysollib.wizardutil import write_game, reset_wizard
|
|
||||||
from wizarddialog import WizardDialog
|
|
||||||
|
|
||||||
if edit:
|
|
||||||
reset_wizard(self.game)
|
|
||||||
else:
|
|
||||||
reset_wizard(None)
|
|
||||||
d = WizardDialog(self.top, _('Solitaire Wizard'), self.app)
|
|
||||||
if d.status == 0 and d.button == 0:
|
|
||||||
try:
|
|
||||||
if edit:
|
|
||||||
gameid = write_game(self.app, game=self.game)
|
|
||||||
else:
|
|
||||||
gameid = write_game(self.app)
|
|
||||||
except Exception, err:
|
|
||||||
if DEBUG:
|
|
||||||
traceback.print_exc()
|
|
||||||
d = MfxMessageDialog(self.top, title=_('Save game error'),
|
|
||||||
text=_('''
|
|
||||||
Error while saving game.
|
|
||||||
|
|
||||||
%s
|
|
||||||
''') % str(err),
|
|
||||||
bitmap='error')
|
|
||||||
return
|
|
||||||
if SELECT_GAME_MENU:
|
|
||||||
menu = self.menupath[".menubar.select.customgames"][2]
|
|
||||||
select_func = lambda gi: gi.si.game_type == GI.GT_CUSTOM
|
|
||||||
games = map(self.app.gdb.get,
|
|
||||||
self.app.gdb.getGamesIdSortedByName())
|
|
||||||
games = filter(select_func, games)
|
|
||||||
self.updateGamesMenu(menu, games)
|
|
||||||
|
|
||||||
self.tkopt.gameid.set(gameid)
|
|
||||||
self._mSelectGame(gameid, force=True)
|
|
||||||
|
|
||||||
|
|
||||||
def mWizard(self, *event):
|
|
||||||
if self._cancelDrag(break_pause=False): return
|
|
||||||
self.wizardDialog()
|
|
||||||
|
|
||||||
def mWizardEdit(self, *event):
|
|
||||||
if self._cancelDrag(break_pause=False): return
|
|
||||||
self.wizardDialog(edit=True)
|
|
||||||
|
|
||||||
|
|
|
@ -1335,3 +1335,51 @@ Unsupported game for export.
|
||||||
if self.app.toolbar.setCompound(compound):
|
if self.app.toolbar.setCompound(compound):
|
||||||
self.game.updateStatus(player=self.app.opt.player)
|
self.game.updateStatus(player=self.app.opt.player)
|
||||||
self.top.update_idletasks()
|
self.top.update_idletasks()
|
||||||
|
|
||||||
|
def wizardDialog(self, edit=False):
|
||||||
|
from pysollib.wizardutil import write_game, reset_wizard
|
||||||
|
WizardDialog = self._calcWizardDialog()
|
||||||
|
|
||||||
|
if edit:
|
||||||
|
reset_wizard(self.game)
|
||||||
|
else:
|
||||||
|
reset_wizard(None)
|
||||||
|
d = WizardDialog(self.top, _('Solitaire Wizard'), self.app)
|
||||||
|
if d.status == 0 and d.button == 0:
|
||||||
|
try:
|
||||||
|
if edit:
|
||||||
|
gameid = write_game(self.app, game=self.game)
|
||||||
|
else:
|
||||||
|
gameid = write_game(self.app)
|
||||||
|
except Exception, err:
|
||||||
|
if DEBUG:
|
||||||
|
traceback.print_exc()
|
||||||
|
d = MfxMessageDialog(self.top, title=_('Save game error'),
|
||||||
|
text=_('''
|
||||||
|
Error while saving game.
|
||||||
|
|
||||||
|
%s
|
||||||
|
''') % str(err),
|
||||||
|
bitmap='error')
|
||||||
|
return
|
||||||
|
|
||||||
|
if SELECT_GAME_MENU:
|
||||||
|
menu = self.menupath[".menubar.select.customgames"][2]
|
||||||
|
select_func = lambda gi: gi.si.game_type == GI.GT_CUSTOM
|
||||||
|
games = map(self.app.gdb.get,
|
||||||
|
self.app.gdb.getGamesIdSortedByName())
|
||||||
|
games = filter(select_func, games)
|
||||||
|
self.updateGamesMenu(menu, games)
|
||||||
|
|
||||||
|
self.tkopt.gameid.set(gameid)
|
||||||
|
self._mSelectGame(gameid, force=True)
|
||||||
|
|
||||||
|
|
||||||
|
def mWizard(self, *event):
|
||||||
|
if self._cancelDrag(break_pause=False): return
|
||||||
|
self.wizardDialog()
|
||||||
|
|
||||||
|
def mWizardEdit(self, *event):
|
||||||
|
if self._cancelDrag(break_pause=False): return
|
||||||
|
self.wizardDialog(edit=True)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue