mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Made the new flake8 and travis happier.
Fix the warnings.
This commit is contained in:
parent
5c85816641
commit
38bfb88971
55 changed files with 565 additions and 553 deletions
|
@ -23,12 +23,12 @@ eval('import pysollib.games.special')
|
|||
|
||||
try:
|
||||
os.mkdir('html')
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
os.mkdir('html/rules')
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
pysollib_path = os.path.join(sys.path[0], pysollib_dir)
|
||||
|
|
|
@ -425,13 +425,13 @@ class Application:
|
|||
# try to load statistics
|
||||
try:
|
||||
self.loadStatistics()
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
pass
|
||||
# try to load comments
|
||||
try:
|
||||
self.loadComments()
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
pass
|
||||
# startup information
|
||||
|
@ -444,7 +444,7 @@ class Application:
|
|||
game = None
|
||||
try:
|
||||
game = tmpgame._loadGame(self.fn.holdgame, self)
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
game = None
|
||||
if game:
|
||||
|
@ -463,7 +463,7 @@ class Application:
|
|||
self.nextgame.loadedgame = tmpgame._loadGame(
|
||||
self.commandline.loadgame, self)
|
||||
self.nextgame.loadedgame.gstats.holded = 0
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
self.nextgame.loadedgame = None
|
||||
elif self.commandline.game is not None:
|
||||
|
@ -541,7 +541,7 @@ class Application:
|
|||
self.game.gstats.holded = 1
|
||||
self.game._saveGame(self.fn.holdgame)
|
||||
self.opt.game_holded = self.game.id
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
pass
|
||||
self.wm_save_state()
|
||||
|
@ -573,25 +573,25 @@ class Application:
|
|||
# save options
|
||||
try:
|
||||
self.saveOptions()
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
pass
|
||||
# save statistics
|
||||
try:
|
||||
self.saveStatistics()
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
pass
|
||||
# save comments
|
||||
try:
|
||||
self.saveComments()
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
pass
|
||||
# shut down audio
|
||||
try:
|
||||
self.audio.destroy()
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
pass
|
||||
|
||||
|
@ -1074,7 +1074,7 @@ Please select a %s type %s.
|
|||
self.opt.__dict__.update(opt.__dict__)
|
||||
try:
|
||||
os.remove(self.fn.opt)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
self.opt.load(self.fn.opt_cfg)
|
||||
self.opt.setConstants()
|
||||
|
|
|
@ -2904,9 +2904,9 @@ Congratulations, you did it !
|
|||
# try to detect a redo move in order to keep our history
|
||||
redo = 0
|
||||
if moves.index + 1 < len(moves.history):
|
||||
l, m = len(current), moves.history[moves.index]
|
||||
if l == len(m):
|
||||
for i in range(l):
|
||||
mylen, m = len(current), moves.history[moves.index]
|
||||
if mylen == len(m):
|
||||
for i in range(mylen):
|
||||
a1 = current[i]
|
||||
a2 = m[i]
|
||||
if a1.__class__ is not a2.__class__ or \
|
||||
|
@ -3022,7 +3022,7 @@ Congratulations, you did it !
|
|||
try:
|
||||
self._dumpGame(p, bookmark=2)
|
||||
bm = (file.getvalue(), self.moves.index)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
self.gsaveinfo.bookmarks[n] = bm
|
||||
|
@ -3049,7 +3049,7 @@ Congratulations, you did it !
|
|||
assert game.id == self.id
|
||||
# save state for undoGotoBookmark
|
||||
self.setBookmark(-1, confirm=0)
|
||||
except:
|
||||
except Exception:
|
||||
del self.gsaveinfo.bookmarks[n]
|
||||
self.setCursor(cursor=self.app.top_cursor)
|
||||
else:
|
||||
|
@ -3093,7 +3093,7 @@ but this could also be a bug you might want to report."""))
|
|||
self.setCursor(cursor=self.app.top_cursor)
|
||||
MfxExceptionDialog(self.top, ex, title=_("Load game error"),
|
||||
text=_("Error while loading game"))
|
||||
except:
|
||||
except Exception:
|
||||
self.updateMenus()
|
||||
self.setCursor(cursor=self.app.top_cursor)
|
||||
MfxMessageDialog(self.top, title=_("Load game error"),
|
||||
|
|
|
@ -640,9 +640,9 @@ class GameManager:
|
|||
|
||||
def getGamesIdSortedById(self):
|
||||
if self.__games_by_id is None:
|
||||
l = list(self.__games.keys())
|
||||
l.sort()
|
||||
self.__games_by_id = tuple(l)
|
||||
lst = list(self.__games.keys())
|
||||
lst.sort()
|
||||
self.__games_by_id = tuple(lst)
|
||||
return self.__games_by_id
|
||||
|
||||
def getGamesIdSortedByName(self):
|
||||
|
|
|
@ -283,8 +283,8 @@ class RoyalFamily(Cruel):
|
|||
RowStack_Class = UD_AC_RowStack
|
||||
|
||||
def createGame(self):
|
||||
l = Cruel.createGame(self)
|
||||
l.createRoundText(self.s.talon, 'sw')
|
||||
lay = Cruel.createGame(self)
|
||||
lay.createRoundText(self.s.talon, 'sw')
|
||||
|
||||
def _shuffleHook(self, cards):
|
||||
# move Kings to bottom of the Talon (i.e. last cards to be dealt)
|
||||
|
@ -300,8 +300,8 @@ class Indefatigable(Cruel):
|
|||
RowStack_Class = UD_SS_RowStack
|
||||
|
||||
def createGame(self):
|
||||
l = Cruel.createGame(self)
|
||||
l.createRoundText(self.s.talon, 'sw')
|
||||
lay = Cruel.createGame(self)
|
||||
lay.createRoundText(self.s.talon, 'sw')
|
||||
|
||||
def _shuffleHook(self, cards):
|
||||
# move Aces to bottom of the Talon (i.e. last cards to be dealt)
|
||||
|
@ -323,8 +323,8 @@ class Perseverance(Cruel, BakersDozen):
|
|||
Solver_Class = None
|
||||
|
||||
def createGame(self):
|
||||
l = Cruel.createGame(self)
|
||||
l.createRoundText(self.s.talon, 'sw')
|
||||
lay = Cruel.createGame(self)
|
||||
lay.createRoundText(self.s.talon, 'sw')
|
||||
|
||||
def _shuffleHook(self, cards):
|
||||
# move Kings to bottom of each stack (???)
|
||||
|
|
|
@ -346,9 +346,9 @@ class CastlesEnd(Bastion):
|
|||
ReserveStack_Class = CastlesEnd_Reserve
|
||||
|
||||
def createGame(self):
|
||||
l = Bastion.createGame(self)
|
||||
lay = Bastion.createGame(self)
|
||||
self.base_rank = None
|
||||
tx, ty, ta, tf = l.getTextAttr(self.s.foundations[-1], 'se')
|
||||
tx, ty, ta, tf = lay.getTextAttr(self.s.foundations[-1], 'se')
|
||||
font = self.app.getFont('canvas_default')
|
||||
self.texts.info = MfxCanvasText(self.canvas, tx, ty,
|
||||
anchor=ta, font=font)
|
||||
|
@ -423,11 +423,11 @@ class Chessboard(Fortress):
|
|||
RowStack_Class = StackWrapper(Chessboard_RowStack, mod=13)
|
||||
|
||||
def createGame(self):
|
||||
l = Fortress.createGame(self)
|
||||
tx, ty, ta, tf = l.getTextAttr(self.s.foundations[-1], "e")
|
||||
lay = Fortress.createGame(self)
|
||||
tx, ty, ta, tf = lay.getTextAttr(self.s.foundations[-1], "e")
|
||||
font = self.app.getFont("canvas_default")
|
||||
self.texts.info = MfxCanvasText(
|
||||
self.canvas, tx + l.XM, ty, anchor=ta, font=font)
|
||||
self.canvas, tx + lay.XM, ty, anchor=ta, font=font)
|
||||
|
||||
def updateText(self):
|
||||
if self.preview > 1:
|
||||
|
|
|
@ -85,68 +85,68 @@ class Canfield(Game):
|
|||
def createGame(self, rows=4, max_rounds=-1, num_deal=3,
|
||||
text=True, round_text=False):
|
||||
# create layout
|
||||
l, s = Layout(self), self.s
|
||||
lay, s = Layout(self), self.s
|
||||
decks = self.gameinfo.decks
|
||||
|
||||
# set window
|
||||
if self.INITIAL_RESERVE_FACEUP == 1:
|
||||
yoffset = l.YOFFSET # min(l.YOFFSET, 14)
|
||||
yoffset = lay.YOFFSET # min(lay.YOFFSET, 14)
|
||||
else:
|
||||
yoffset = 10
|
||||
if self.INITIAL_RESERVE_CARDS > 30:
|
||||
yoffset = 5
|
||||
# (piles up to 20 cards are playable in default window size)
|
||||
h = max(3*l.YS, l.YS+self.INITIAL_RESERVE_CARDS*yoffset)
|
||||
h = max(3*lay.YS, lay.YS+self.INITIAL_RESERVE_CARDS*yoffset)
|
||||
if round_text:
|
||||
h += l.TEXT_HEIGHT
|
||||
h += lay.TEXT_HEIGHT
|
||||
self.setSize(
|
||||
l.XM + (2+max(rows, 4*decks))*l.XS + l.XM,
|
||||
l.YM + l.YS + l.TEXT_HEIGHT + h)
|
||||
lay.XM + (2+max(rows, 4*decks))*lay.XS + lay.XM,
|
||||
lay.YM + lay.YS + lay.TEXT_HEIGHT + h)
|
||||
|
||||
# extra settings
|
||||
self.base_card = None
|
||||
|
||||
# create stacks
|
||||
x, y = l.XM, l.YM
|
||||
x, y = lay.XM, lay.YM
|
||||
s.talon = self.Talon_Class(x, y, self,
|
||||
max_rounds=max_rounds, num_deal=num_deal)
|
||||
l.createText(s.talon, "s")
|
||||
lay.createText(s.talon, "s")
|
||||
if round_text:
|
||||
l.createRoundText(s.talon, 'sss')
|
||||
x += l.XS
|
||||
lay.createRoundText(s.talon, 'sss')
|
||||
x += lay.XS
|
||||
s.waste = WasteStack(x, y, self)
|
||||
l.createText(s.waste, "s")
|
||||
x += l.XM
|
||||
y = l.YM
|
||||
lay.createText(s.waste, "s")
|
||||
x += lay.XM
|
||||
y = lay.YM
|
||||
for i in range(4):
|
||||
for j in range(decks):
|
||||
x += l.XS
|
||||
x += lay.XS
|
||||
s.foundations.append(self.Foundation_Class(x, y, self, i,
|
||||
mod=13, max_move=0))
|
||||
if text:
|
||||
if rows > 4 * decks:
|
||||
tx, ty, ta, tf = l.getTextAttr(None, "se")
|
||||
tx, ty = x + tx + l.XM, y + ty
|
||||
tx, ty, ta, tf = lay.getTextAttr(None, "se")
|
||||
tx, ty = x + tx + lay.XM, y + ty
|
||||
else:
|
||||
tx, ty, ta, tf = l.getTextAttr(None, "ss")
|
||||
tx, ty, ta, tf = lay.getTextAttr(None, "ss")
|
||||
tx, ty = x + tx, y + ty
|
||||
font = self.app.getFont("canvas_default")
|
||||
self.texts.info = MfxCanvasText(self.canvas, tx, ty,
|
||||
anchor=ta, font=font)
|
||||
x, y = l.XM, l.YM + l.YS + l.TEXT_HEIGHT
|
||||
x, y = lay.XM, lay.YM + lay.YS + lay.TEXT_HEIGHT
|
||||
if round_text:
|
||||
y += l.TEXT_HEIGHT
|
||||
y += lay.TEXT_HEIGHT
|
||||
s.reserves.append(self.ReserveStack_Class(x, y, self))
|
||||
s.reserves[0].CARD_YOFFSET = yoffset
|
||||
x, y = l.XM + 2 * l.XS + l.XM, l.YM + l.YS
|
||||
x, y = lay.XM + 2 * lay.XS + lay.XM, lay.YM + lay.YS
|
||||
if text:
|
||||
y += l.TEXT_HEIGHT
|
||||
y += lay.TEXT_HEIGHT
|
||||
for i in range(rows):
|
||||
s.rows.append(self.RowStack_Class(x, y, self))
|
||||
x += l.XS
|
||||
x += lay.XS
|
||||
|
||||
# define stack-groups
|
||||
l.defaultStackGroups()
|
||||
lay.defaultStackGroups()
|
||||
|
||||
#
|
||||
# game extras
|
||||
|
@ -359,43 +359,43 @@ class EagleWing(Canfield):
|
|||
def createGame(self):
|
||||
# Canfield.createGame(self, rows=8, max_rounds=3, num_deal=1)
|
||||
# create layout
|
||||
l, s = Layout(self), self.s
|
||||
lay, s = Layout(self), self.s
|
||||
|
||||
# set window
|
||||
self.setSize(l.XM + 9*l.XS + l.XM, l.YM + 4*l.YS)
|
||||
self.setSize(lay.XM + 9*lay.XS + lay.XM, lay.YM + 4*lay.YS)
|
||||
|
||||
# extra settings
|
||||
self.base_card = None
|
||||
|
||||
# create stacks
|
||||
x, y = l.XM, l.YM
|
||||
x, y = lay.XM, lay.YM
|
||||
s.talon = WasteTalonStack(x, y, self, max_rounds=3, num_deal=1)
|
||||
l.createText(s.talon, "s")
|
||||
l.createRoundText(s.talon, 'ne', dx=l.XS)
|
||||
x += l.XS
|
||||
lay.createText(s.talon, "s")
|
||||
lay.createRoundText(s.talon, 'ne', dx=lay.XS)
|
||||
x += lay.XS
|
||||
s.waste = WasteStack(x, y, self)
|
||||
l.createText(s.waste, "s")
|
||||
lay.createText(s.waste, "s")
|
||||
for i in range(4):
|
||||
x = l.XM + (i+3)*l.XS
|
||||
x = lay.XM + (i+3)*lay.XS
|
||||
s.foundations.append(
|
||||
self.Foundation_Class(x, y, self, i, mod=13, max_move=0))
|
||||
tx, ty, ta, tf = l.getTextAttr(None, "se")
|
||||
tx, ty = x + tx + l.XM, y + ty
|
||||
tx, ty, ta, tf = lay.getTextAttr(None, "se")
|
||||
tx, ty = x + tx + lay.XM, y + ty
|
||||
font = self.app.getFont("canvas_default")
|
||||
self.texts.info = MfxCanvasText(
|
||||
self.canvas, tx, ty, anchor=ta, font=font)
|
||||
ry = l.YM + 2*l.YS
|
||||
ry = lay.YM + 2*lay.YS
|
||||
for i in range(8):
|
||||
x = l.XM + (i + (i >= 4))*l.XS
|
||||
y = ry - (0.2, 0.4, 0.6, 0.4, 0.4, 0.6, 0.4, 0.2)[i]*l.CH
|
||||
x = lay.XM + (i + (i >= 4))*lay.XS
|
||||
y = ry - (0.2, 0.4, 0.6, 0.4, 0.4, 0.6, 0.4, 0.2)[i]*lay.CH
|
||||
s.rows.append(self.RowStack_Class(x, y, self))
|
||||
x, y = l.XM + 4*l.XS, ry
|
||||
x, y = lay.XM + 4*lay.XS, ry
|
||||
s.reserves.append(self.ReserveStack_Class(x, y, self))
|
||||
# s.reserves[0].CARD_YOFFSET = 0
|
||||
l.createText(s.reserves[0], "s")
|
||||
lay.createText(s.reserves[0], "s")
|
||||
|
||||
# define stack-groups
|
||||
l.defaultStackGroups()
|
||||
lay.defaultStackGroups()
|
||||
|
||||
shallHighlightMatch = Game._shallHighlightMatch_SSW
|
||||
|
||||
|
@ -414,33 +414,34 @@ class Gate(Game):
|
|||
|
||||
def createGame(self):
|
||||
# create layout
|
||||
l, s = Layout(self), self.s
|
||||
lay, s = Layout(self), self.s
|
||||
|
||||
# set window
|
||||
w, h = max(8*l.XS, 6*l.XS+8*l.XOFFSET), l.YM+3*l.YS+12*l.YOFFSET
|
||||
self.setSize(w+l.XM, h)
|
||||
w = max(8*lay.XS, 6*lay.XS+8*lay.XOFFSET)
|
||||
h = lay.YM+3*lay.YS+12*lay.YOFFSET
|
||||
self.setSize(w+lay.XM, h)
|
||||
|
||||
# create stacks
|
||||
y = l.YM
|
||||
for x in (l.XM, l.XM+w-l.XS-4*l.XOFFSET):
|
||||
y = lay.YM
|
||||
for x in (lay.XM, lay.XM+w-lay.XS-4*lay.XOFFSET):
|
||||
stack = OpenStack(x, y, self, max_accept=0)
|
||||
stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0
|
||||
stack.CARD_XOFFSET, stack.CARD_YOFFSET = lay.XOFFSET, 0
|
||||
s.reserves.append(stack)
|
||||
x, y = l.XM+(w-4*l.XS)//2, l.YM
|
||||
x, y = lay.XM+(w-4*lay.XS)//2, lay.YM
|
||||
for i in range(4):
|
||||
s.foundations.append(SS_FoundationStack(x, y, self, suit=i))
|
||||
x += l.XS
|
||||
x, y = l.XM+(w-8*l.XS)//2, l.YM+l.YS
|
||||
x += lay.XS
|
||||
x, y = lay.XM+(w-8*lay.XS)//2, lay.YM+lay.YS
|
||||
for i in range(8):
|
||||
s.rows.append(AC_RowStack(x, y, self))
|
||||
x += l.XS
|
||||
s.talon = WasteTalonStack(l.XM, h-l.YS, self, max_rounds=1)
|
||||
l.createText(s.talon, "n")
|
||||
s.waste = WasteStack(l.XM+l.XS, h-l.YS, self)
|
||||
l.createText(s.waste, "n")
|
||||
x += lay.XS
|
||||
s.talon = WasteTalonStack(lay.XM, h-lay.YS, self, max_rounds=1)
|
||||
lay.createText(s.talon, "n")
|
||||
s.waste = WasteStack(lay.XM+lay.XS, h-lay.YS, self)
|
||||
lay.createText(s.waste, "n")
|
||||
|
||||
# define stack-groups
|
||||
l.defaultStackGroups()
|
||||
lay.defaultStackGroups()
|
||||
|
||||
#
|
||||
# game overrides
|
||||
|
@ -480,36 +481,36 @@ class LittleGate(Gate):
|
|||
|
||||
def createGame(self, rows=4):
|
||||
# create layout
|
||||
l, s = Layout(self), self.s
|
||||
lay, s = Layout(self), self.s
|
||||
|
||||
# set window
|
||||
max_rows = max(7, rows+3)
|
||||
w, h = l.XM+max_rows*l.XS, l.YM+2*l.YS+12*l.YOFFSET
|
||||
w, h = lay.XM+max_rows*lay.XS, lay.YM+2*lay.YS+12*lay.YOFFSET
|
||||
self.setSize(w, h)
|
||||
|
||||
# create stacks
|
||||
y = l.YM+l.YS+l.TEXT_HEIGHT
|
||||
for x in (l.XM, w-l.XS):
|
||||
y = lay.YM+lay.YS+lay.TEXT_HEIGHT
|
||||
for x in (lay.XM, w-lay.XS):
|
||||
stack = self.ReserveStack_Class(x, y, self)
|
||||
stack.CARD_XOFFSET, stack.CARD_YOFFSET = 0, l.YOFFSET
|
||||
stack.CARD_XOFFSET, stack.CARD_YOFFSET = 0, lay.YOFFSET
|
||||
s.reserves.append(stack)
|
||||
x, y = l.XM+(max_rows-4)*l.XS, l.YM
|
||||
x, y = lay.XM+(max_rows-4)*lay.XS, lay.YM
|
||||
for i in range(4):
|
||||
s.foundations.append(SS_FoundationStack(x, y, self, suit=i))
|
||||
x += l.XS
|
||||
x, y = l.XM+(max_rows-rows)*l.XS//2, l.YM+l.YS+l.TEXT_HEIGHT
|
||||
x += lay.XS
|
||||
x, y = lay.XM+(max_rows-rows)*lay.XS//2, lay.YM+lay.YS+lay.TEXT_HEIGHT
|
||||
for i in range(rows):
|
||||
s.rows.append(self.RowStack_Class(x, y, self))
|
||||
x += l.XS
|
||||
s.talon = WasteTalonStack(l.XM, l.YM, self, max_rounds=1)
|
||||
l.createText(s.talon, "s")
|
||||
s.waste = WasteStack(l.XM+l.XS, l.YM, self)
|
||||
l.createText(s.waste, "s")
|
||||
x += lay.XS
|
||||
s.talon = WasteTalonStack(lay.XM, lay.YM, self, max_rounds=1)
|
||||
lay.createText(s.talon, "s")
|
||||
s.waste = WasteStack(lay.XM+lay.XS, lay.YM, self)
|
||||
lay.createText(s.waste, "s")
|
||||
|
||||
# define stack-groups
|
||||
l.defaultStackGroups()
|
||||
lay.defaultStackGroups()
|
||||
|
||||
return l
|
||||
return lay
|
||||
|
||||
|
||||
class Doorway(LittleGate):
|
||||
|
@ -519,14 +520,14 @@ class Doorway(LittleGate):
|
|||
ReserveStack_Class = ReserveStack
|
||||
|
||||
def createGame(self):
|
||||
l = LittleGate.createGame(self, rows=5)
|
||||
lay = LittleGate.createGame(self, rows=5)
|
||||
king_stack, queen_stack = self.s.reserves
|
||||
tx, ty, ta, tf = l.getTextAttr(king_stack, "s")
|
||||
tx, ty, ta, tf = lay.getTextAttr(king_stack, "s")
|
||||
font = self.app.getFont("canvas_default")
|
||||
king_stack.texts.misc = MfxCanvasText(self.canvas, tx, ty,
|
||||
anchor=ta, font=font,
|
||||
text=_('King'))
|
||||
tx, ty, ta, tf = l.getTextAttr(queen_stack, "s")
|
||||
tx, ty, ta, tf = lay.getTextAttr(queen_stack, "s")
|
||||
font = self.app.getFont("canvas_default")
|
||||
queen_stack.texts.misc = MfxCanvasText(self.canvas, tx, ty,
|
||||
anchor=ta, font=font,
|
||||
|
@ -660,36 +661,37 @@ class Duke(Game):
|
|||
RowStack_Class = AC_RowStack
|
||||
|
||||
def createGame(self):
|
||||
l, s = Layout(self), self.s
|
||||
lay, s = Layout(self), self.s
|
||||
|
||||
w, h = l.XM + 6*l.XS + 4*l.XOFFSET, \
|
||||
l.YM + l.TEXT_HEIGHT + 2*l.YS + 12*l.YOFFSET
|
||||
w, h = lay.XM + 6*lay.XS + 4*lay.XOFFSET, \
|
||||
lay.YM + lay.TEXT_HEIGHT + 2*lay.YS + 12*lay.YOFFSET
|
||||
self.setSize(w, h)
|
||||
|
||||
x, y = l.XM, l.YM
|
||||
x, y = lay.XM, lay.YM
|
||||
s.talon = WasteTalonStack(x, y, self, max_rounds=3)
|
||||
l.createText(s.talon, 's')
|
||||
l.createRoundText(s.talon, 'ne', dx=l.XS)
|
||||
x += l.XS
|
||||
lay.createText(s.talon, 's')
|
||||
lay.createRoundText(s.talon, 'ne', dx=lay.XS)
|
||||
x += lay.XS
|
||||
s.waste = WasteStack(x, y, self)
|
||||
l.createText(s.waste, 's')
|
||||
x += l.XS+4*l.XOFFSET
|
||||
y = l.YM
|
||||
lay.createText(s.waste, 's')
|
||||
x += lay.XS+4*lay.XOFFSET
|
||||
y = lay.YM
|
||||
for i in range(4):
|
||||
s.foundations.append(self.Foundation_Class(x, y, self, suit=i))
|
||||
x += l.XS
|
||||
x0, y0, w = l.XM, l.YM+l.YS+2*l.TEXT_HEIGHT, l.XS+2*l.XOFFSET
|
||||
x += lay.XS
|
||||
x0, y0, w = lay.XM, lay.YM+lay.YS+2*lay.TEXT_HEIGHT,\
|
||||
lay.XS+2*lay.XOFFSET
|
||||
for i, j in ((0, 0), (0, 1), (1, 0), (1, 1)):
|
||||
x, y = x0+i*w, y0+j*l.YS
|
||||
x, y = x0+i*w, y0+j*lay.YS
|
||||
stack = self.ReserveStack_Class(x, y, self, max_accept=0)
|
||||
stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0
|
||||
stack.CARD_XOFFSET, stack.CARD_YOFFSET = lay.XOFFSET, 0
|
||||
s.reserves.append(stack)
|
||||
x, y = l.XM+2*l.XS+4*l.XOFFSET, l.YM+l.YS
|
||||
x, y = lay.XM+2*lay.XS+4*lay.XOFFSET, lay.YM+lay.YS
|
||||
for i in range(4):
|
||||
s.rows.append(self.RowStack_Class(x, y, self))
|
||||
x += l.XS
|
||||
x += lay.XS
|
||||
|
||||
l.defaultStackGroups()
|
||||
lay.defaultStackGroups()
|
||||
|
||||
def startGame(self):
|
||||
for i in range(3):
|
||||
|
@ -741,51 +743,51 @@ class Skippy(Canfield):
|
|||
|
||||
def createGame(self):
|
||||
# create layout
|
||||
l, s = Layout(self), self.s
|
||||
lay, s = Layout(self), self.s
|
||||
|
||||
# set window
|
||||
playcards = 8
|
||||
w0 = l.XS+playcards*l.XOFFSET
|
||||
w = l.XM+l.XS//2+max(10*l.XS, l.XS+4*w0)
|
||||
h = l.YM+5*l.YS+l.TEXT_HEIGHT
|
||||
w0 = lay.XS+playcards*lay.XOFFSET
|
||||
w = lay.XM+lay.XS//2+max(10*lay.XS, lay.XS+4*w0)
|
||||
h = lay.YM+5*lay.YS+lay.TEXT_HEIGHT
|
||||
self.setSize(w, h)
|
||||
|
||||
# extra settings
|
||||
self.base_card = None
|
||||
|
||||
# create stacks
|
||||
x, y = l.XM, l.YM
|
||||
x, y = lay.XM, lay.YM
|
||||
s.talon = WasteTalonStack(x, y, self, max_rounds=1)
|
||||
l.createText(s.talon, 's')
|
||||
x += l.XS
|
||||
lay.createText(s.talon, 's')
|
||||
x += lay.XS
|
||||
s.waste = WasteStack(x, y, self)
|
||||
l.createText(s.waste, 's')
|
||||
x = self.width - 8*l.XS
|
||||
lay.createText(s.waste, 's')
|
||||
x = self.width - 8*lay.XS
|
||||
for i in range(8):
|
||||
s.foundations.append(SS_FoundationStack(x, y, self,
|
||||
suit=i % 4, mod=13))
|
||||
x += l.XS
|
||||
tx, ty, ta, tf = l.getTextAttr(None, "ss")
|
||||
tx, ty = x-l.XS+tx, y+ty
|
||||
x += lay.XS
|
||||
tx, ty, ta, tf = lay.getTextAttr(None, "ss")
|
||||
tx, ty = x-lay.XS+tx, y+ty
|
||||
font = self.app.getFont("canvas_default")
|
||||
self.texts.info = MfxCanvasText(self.canvas, tx, ty,
|
||||
anchor=ta, font=font)
|
||||
x, y = l.XM, l.YM+l.YS+l.TEXT_HEIGHT
|
||||
x, y = lay.XM, lay.YM+lay.YS+lay.TEXT_HEIGHT
|
||||
for i in range(4):
|
||||
s.reserves.append(ReserveStack(x, y, self))
|
||||
y += l.YS
|
||||
y = l.YM+l.YS+l.TEXT_HEIGHT
|
||||
y += lay.YS
|
||||
y = lay.YM+lay.YS+lay.TEXT_HEIGHT
|
||||
for i in range(4):
|
||||
x = l.XM+l.XS+l.XS//2
|
||||
x = lay.XM+lay.XS+lay.XS//2
|
||||
for j in range(4):
|
||||
stack = RK_RowStack(x, y, self, max_move=1, mod=13)
|
||||
s.rows.append(stack)
|
||||
stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0
|
||||
stack.CARD_XOFFSET, stack.CARD_YOFFSET = lay.XOFFSET, 0
|
||||
x += w0
|
||||
y += l.YS
|
||||
y += lay.YS
|
||||
|
||||
# define stack-groups
|
||||
l.defaultStackGroups()
|
||||
lay.defaultStackGroups()
|
||||
|
||||
def startGame(self):
|
||||
self.base_card = None
|
||||
|
@ -818,32 +820,33 @@ class Skippy(Canfield):
|
|||
|
||||
class Lafayette(Game):
|
||||
def createGame(self):
|
||||
l, s = Layout(self), self.s
|
||||
self.setSize(l.XM+8*l.XS, l.YM+2*l.YS+12*l.YOFFSET)
|
||||
lay, s = Layout(self), self.s
|
||||
self.setSize(lay.XM+8*lay.XS, lay.YM+2*lay.YS+12*lay.YOFFSET)
|
||||
|
||||
x, y = l.XM, l.YM
|
||||
x, y = lay.XM, lay.YM
|
||||
for i in range(4):
|
||||
s.foundations.append(SS_FoundationStack(x, y, self, suit=i))
|
||||
s.foundations.append(SS_FoundationStack(x+4*l.XS, y, self, suit=i,
|
||||
s.foundations.append(SS_FoundationStack(x+4*lay.XS, y, self,
|
||||
suit=i,
|
||||
base_rank=KING, dir=-1))
|
||||
x += l.XS
|
||||
x, y = l.XM, l.YM+l.YS
|
||||
x += lay.XS
|
||||
x, y = lay.XM, lay.YM+lay.YS
|
||||
s.talon = WasteTalonStack(x, y, self, max_rounds=UNLIMITED_REDEALS,
|
||||
num_deal=3)
|
||||
l.createText(s.talon, 'ne')
|
||||
y += l.YS
|
||||
lay.createText(s.talon, 'ne')
|
||||
y += lay.YS
|
||||
s.waste = WasteStack(x, y, self)
|
||||
l.createText(s.waste, 'ne')
|
||||
x, y = l.XM+2*l.XS, l.YM+l.YS
|
||||
lay.createText(s.waste, 'ne')
|
||||
x, y = lay.XM+2*lay.XS, lay.YM+lay.YS
|
||||
for i in range(4):
|
||||
s.rows.append(AC_RowStack(x, y, self, base_rank=6))
|
||||
x += l.XS
|
||||
x += l.XS
|
||||
x += lay.XS
|
||||
x += lay.XS
|
||||
stack = OpenStack(x, y, self)
|
||||
s.reserves.append(stack)
|
||||
stack.CARD_YOFFSET = l.YOFFSET
|
||||
stack.CARD_YOFFSET = lay.YOFFSET
|
||||
|
||||
l.defaultStackGroups()
|
||||
lay.defaultStackGroups()
|
||||
|
||||
def startGame(self):
|
||||
for i in range(13):
|
||||
|
|
|
@ -342,13 +342,13 @@ class ThreeShufflesAndADraw(LaBelleLucie):
|
|||
ThreeShufflesAndADraw_RowStack, base_rank=NO_RANK)
|
||||
|
||||
def createGame(self):
|
||||
l = LaBelleLucie.createGame(self)
|
||||
lay = LaBelleLucie.createGame(self)
|
||||
s = self.s
|
||||
# add a reserve stack
|
||||
x, y = s.rows[3].x, s.rows[-1].y
|
||||
s.reserves.append(ThreeShufflesAndADraw_ReserveStack(x, y, self))
|
||||
# redefine the stack-groups
|
||||
l.defaultStackGroups()
|
||||
lay.defaultStackGroups()
|
||||
# extra settings
|
||||
self.draw_done = 0
|
||||
|
||||
|
@ -450,18 +450,18 @@ class Intelligence(Fan):
|
|||
RowStack_Class = StackWrapper(Intelligence_RowStack, base_rank=NO_RANK)
|
||||
|
||||
def createGame(self, rows=(5, 5, 5, 3)):
|
||||
l = Fan.createGame(self, rows)
|
||||
lay = Fan.createGame(self, rows)
|
||||
s = self.s
|
||||
# add a reserve stack
|
||||
x, y = s.talon.x - l.XS, s.talon.y
|
||||
x, y = s.talon.x - lay.XS, s.talon.y
|
||||
s.reserves.append(
|
||||
Intelligence_ReserveStack(
|
||||
x, y, self, max_move=0, max_accept=0,
|
||||
max_cards=UNLIMITED_CARDS))
|
||||
l.createText(s.reserves[0], "sw")
|
||||
l.createRoundText(s.talon, 'nn')
|
||||
lay.createText(s.reserves[0], "sw")
|
||||
lay.createRoundText(s.talon, 'nn')
|
||||
# redefine the stack-groups
|
||||
l.defaultStackGroups()
|
||||
lay.defaultStackGroups()
|
||||
|
||||
def startGame(self):
|
||||
talon = self.s.talon
|
||||
|
|
|
@ -235,8 +235,8 @@ class Elevator_RowStack(Golf_RowStack):
|
|||
|
||||
def basicIsBlocked(self):
|
||||
r, step = self.game.s.rows, self.STEP
|
||||
i, n, l = self.id, 1, len(step)
|
||||
while i < l:
|
||||
i, n, mylen = self.id, 1, len(step)
|
||||
while i < mylen:
|
||||
i = i + step[i]
|
||||
n = n + 1
|
||||
for j in range(i, i+n):
|
||||
|
|
|
@ -75,24 +75,24 @@ class Klondike(Game):
|
|||
|
||||
def createGame(self, max_rounds=-1, num_deal=1, **layout):
|
||||
# create layout
|
||||
l, s = Layout(self), self.s
|
||||
lay, s = Layout(self), self.s
|
||||
kwdefault(layout, rows=7, waste=1, texts=1, playcards=16)
|
||||
self.Layout_Method.__get__(l, l.__class__)(**layout)
|
||||
# self.__class__.Layout_Method(l, **layout)
|
||||
self.setSize(l.size[0], l.size[1])
|
||||
self.Layout_Method.__get__(lay, lay.__class__)(**layout)
|
||||
# self.__class__.Layout_Method(lay, **layout)
|
||||
self.setSize(lay.size[0], lay.size[1])
|
||||
# create stacks
|
||||
s.talon = self.Talon_Class(l.s.talon.x, l.s.talon.y, self,
|
||||
s.talon = self.Talon_Class(lay.s.talon.x, lay.s.talon.y, self,
|
||||
max_rounds=max_rounds, num_deal=num_deal)
|
||||
if l.s.waste:
|
||||
s.waste = WasteStack(l.s.waste.x, l.s.waste.y, self)
|
||||
for r in l.s.foundations:
|
||||
if lay.s.waste:
|
||||
s.waste = WasteStack(lay.s.waste.x, lay.s.waste.y, self)
|
||||
for r in lay.s.foundations:
|
||||
s.foundations.append(
|
||||
self.Foundation_Class(r.x, r.y, self, suit=r.suit))
|
||||
for r in l.s.rows:
|
||||
for r in lay.s.rows:
|
||||
s.rows.append(self.RowStack_Class(r.x, r.y, self))
|
||||
# default
|
||||
l.defaultAll()
|
||||
return l
|
||||
lay.defaultAll()
|
||||
return lay
|
||||
|
||||
def startGame(self, flip=0, reverse=1):
|
||||
for i in range(1, len(self.s.rows)):
|
||||
|
@ -115,11 +115,11 @@ class VegasKlondike(Klondike):
|
|||
getGameBalance = Game.getGameScoreCasino
|
||||
|
||||
def createGame(self, max_rounds=1):
|
||||
l = Klondike.createGame(self, max_rounds=max_rounds)
|
||||
lay = Klondike.createGame(self, max_rounds=max_rounds)
|
||||
self.texts.score = MfxCanvasText(self.canvas,
|
||||
8, self.height - 8, anchor="sw",
|
||||
font=self.app.getFont("canvas_large"))
|
||||
return l
|
||||
return lay
|
||||
|
||||
def updateText(self):
|
||||
if self.preview > 1:
|
||||
|
@ -140,8 +140,8 @@ class VegasKlondike(Klondike):
|
|||
|
||||
class CasinoKlondike(VegasKlondike):
|
||||
def createGame(self):
|
||||
l = VegasKlondike.createGame(self, max_rounds=3)
|
||||
l.createRoundText(self.s.talon, 'ne', dx=l.XS)
|
||||
lay = VegasKlondike.createGame(self, max_rounds=3)
|
||||
lay.createRoundText(self.s.talon, 'ne', dx=lay.XS)
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
@ -174,9 +174,9 @@ class Chinaman(ThumbAndPouch):
|
|||
RowStack_Class = StackWrapper(BO_RowStack, base_rank=KING)
|
||||
|
||||
def createGame(self):
|
||||
l = Klondike.createGame(self, num_deal=3,
|
||||
lay = Klondike.createGame(self, num_deal=3,
|
||||
max_rounds=2, round_text=True)
|
||||
l.createRoundText(self.s.talon, 'ne', dx=l.XS)
|
||||
lay.createRoundText(self.s.talon, 'ne', dx=lay.XS)
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
@ -297,8 +297,8 @@ class PasSeul(Eastcliff):
|
|||
|
||||
class BlindAlleys(Eastcliff):
|
||||
def createGame(self):
|
||||
l = Klondike.createGame(self, max_rounds=2, rows=6, round_text=True)
|
||||
l.createRoundText(self.s.talon, 'ne', dx=l.XS)
|
||||
lay = Klondike.createGame(self, max_rounds=2, rows=6, round_text=True)
|
||||
lay.createRoundText(self.s.talon, 'ne', dx=lay.XS)
|
||||
|
||||
def _shuffleHook(self, cards):
|
||||
# move Aces to top of the Talon (i.e. first cards to be dealt)
|
||||
|
@ -345,9 +345,9 @@ class Usk(Somerset):
|
|||
Solver_Class = None
|
||||
|
||||
def createGame(self):
|
||||
l = Klondike.createGame(self, max_rounds=2, rows=10,
|
||||
lay = Klondike.createGame(self, max_rounds=2, rows=10,
|
||||
waste=False, texts=False, round_text=True)
|
||||
l.createRoundText(self.s.talon, 'ne')
|
||||
lay.createRoundText(self.s.talon, 'ne')
|
||||
|
||||
def redealCards(self):
|
||||
n = 0
|
||||
|
@ -435,8 +435,8 @@ class EightTimesEight(Klondike):
|
|||
|
||||
class AchtmalAcht(EightTimesEight):
|
||||
def createGame(self):
|
||||
l = Klondike.createGame(self, rows=8, max_rounds=3, round_text=True)
|
||||
l.createRoundText(self.s.talon, 'sw', dx=-l.XS)
|
||||
lay = Klondike.createGame(self, rows=8, max_rounds=3, round_text=True)
|
||||
lay.createRoundText(self.s.talon, 'sw', dx=-lay.XS)
|
||||
|
||||
|
||||
class EightByEight_RowStack(RK_RowStack):
|
||||
|
@ -454,9 +454,9 @@ class EightByEight(EightTimesEight):
|
|||
RowStack_Class = EightByEight_RowStack
|
||||
|
||||
def createGame(self):
|
||||
l = Klondike.createGame(self, rows=8, playcards=20,
|
||||
lay = Klondike.createGame(self, rows=8, playcards=20,
|
||||
max_rounds=3, round_text=True)
|
||||
l.createRoundText(self.s.talon, 'ne', dx=l.XS)
|
||||
lay.createRoundText(self.s.talon, 'ne', dx=lay.XS)
|
||||
|
||||
shallHighlightMatch = Game._shallHighlightMatch_RK
|
||||
|
||||
|
@ -482,17 +482,18 @@ class Batsford(Klondike):
|
|||
kwdefault(layout, rows=10, max_rounds=1, playcards=22)
|
||||
round_text = (layout['max_rounds'] > 1)
|
||||
layout['round_text'] = round_text
|
||||
l = Klondike.createGame(self, **layout)
|
||||
lay = Klondike.createGame(self, **layout)
|
||||
s = self.s
|
||||
x, y = l.XM, self.height - l.YS
|
||||
x, y = lay.XM, self.height - lay.YS
|
||||
s.reserves.append(Batsford_ReserveStack(x, y, self, max_cards=3))
|
||||
self.setRegion(
|
||||
s.reserves, (-999, y - l.YM - l.CH//2, x + l.XS - l.CW//2, 999999),
|
||||
s.reserves, (-999, y - lay.YM - lay.CH//2,
|
||||
x + lay.XS - lay.CW//2, 999999),
|
||||
priority=1)
|
||||
l.createText(s.reserves[0], "se")
|
||||
lay.createText(s.reserves[0], "se")
|
||||
if round_text:
|
||||
l.createRoundText(self.s.talon, 'ne', dx=l.XS)
|
||||
l.defaultStackGroups()
|
||||
lay.createRoundText(self.s.talon, 'ne', dx=lay.XS)
|
||||
lay.defaultStackGroups()
|
||||
|
||||
|
||||
class BatsfordAgain(Batsford):
|
||||
|
@ -506,8 +507,8 @@ class BatsfordAgain(Batsford):
|
|||
|
||||
class Jumbo(Klondike):
|
||||
def createGame(self):
|
||||
l = Klondike.createGame(self, rows=9, max_rounds=2, round_text=True)
|
||||
l.createRoundText(self.s.talon, 'ne', dx=l.XS)
|
||||
lay = Klondike.createGame(self, rows=9, max_rounds=2, round_text=True)
|
||||
lay.createRoundText(self.s.talon, 'ne', dx=lay.XS)
|
||||
|
||||
def startGame(self, flip=0):
|
||||
for i in range(9):
|
||||
|
@ -534,15 +535,15 @@ class Stonewall(Klondike):
|
|||
DEAL = (0, 1, 0, 1, -1, 0, 1)
|
||||
|
||||
def createGame(self):
|
||||
l = Klondike.createGame(self, rows=6, waste=0, max_rounds=1, texts=0)
|
||||
lay = Klondike.createGame(self, rows=6, waste=0, max_rounds=1, texts=0)
|
||||
s = self.s
|
||||
h = max(self.height, l.YM+4*l.YS)
|
||||
self.setSize(self.width + l.XM+4*l.XS, h)
|
||||
h = max(self.height, lay.YM+4*lay.YS)
|
||||
self.setSize(self.width + lay.XM+4*lay.XS, h)
|
||||
for i in range(4):
|
||||
for j in range(4):
|
||||
x, y = self.width + (j-4)*l.XS, l.YM + i*l.YS
|
||||
x, y = self.width + (j-4)*lay.XS, lay.YM + i*lay.YS
|
||||
s.reserves.append(OpenStack(x, y, self, max_accept=0))
|
||||
l.defaultStackGroups()
|
||||
lay.defaultStackGroups()
|
||||
|
||||
def startGame(self):
|
||||
frames = 0
|
||||
|
@ -580,17 +581,17 @@ class KingAlbert(Klondike):
|
|||
RESERVES = (2, 2, 2, 1)
|
||||
|
||||
def createGame(self):
|
||||
l = Klondike.createGame(
|
||||
lay = Klondike.createGame(
|
||||
self, max_rounds=1, rows=self.ROWS, waste=0, texts=0)
|
||||
s = self.s
|
||||
rw, rh = max(self.RESERVES), len(self.RESERVES)
|
||||
h = max(self.height, l.YM+rh*l.YS)
|
||||
self.setSize(self.width + 2*l.XM+rw*l.XS, h)
|
||||
h = max(self.height, lay.YM+rh*lay.YS)
|
||||
self.setSize(self.width + 2*lay.XM+rw*lay.XS, h)
|
||||
for i in range(rh):
|
||||
for j in range(self.RESERVES[i]):
|
||||
x, y = self.width + (j-rw)*l.XS, l.YM + i*l.YS
|
||||
x, y = self.width + (j-rw)*lay.XS, lay.YM + i*lay.YS
|
||||
s.reserves.append(OpenStack(x, y, self, max_accept=0))
|
||||
l.defaultStackGroups()
|
||||
lay.defaultStackGroups()
|
||||
|
||||
def startGame(self):
|
||||
Klondike.startGame(self, flip=1, reverse=0)
|
||||
|
@ -669,39 +670,40 @@ class Jane(Klondike):
|
|||
RowStack_Class = StackWrapper(AC_RowStack, mod=13, base_rank=NO_RANK)
|
||||
|
||||
def createGame(self, max_rounds=1, rows=7, reserves=7, playcards=16):
|
||||
l, s = Layout(self), self.s
|
||||
lay, s = Layout(self), self.s
|
||||
maxrows = max(rows, 7)
|
||||
w = l.XM+maxrows*l.XS+l.XM+2*l.XS
|
||||
h = max(l.YM+2*l.YS+playcards*l.YOFFSET+l.TEXT_HEIGHT, l.YM+4*l.YS)
|
||||
w = lay.XM+maxrows*lay.XS+lay.XM+2*lay.XS
|
||||
h = max(lay.YM+2*lay.YS+playcards*lay.YOFFSET+lay.TEXT_HEIGHT,
|
||||
lay.YM+4*lay.YS)
|
||||
self.setSize(w, h)
|
||||
|
||||
x, y = l.XM, l.YM
|
||||
x, y = lay.XM, lay.YM
|
||||
s.talon = self.Talon_Class(x, y, self, max_rounds=max_rounds)
|
||||
l.createText(s.talon, 's')
|
||||
x += l.XS
|
||||
lay.createText(s.talon, 's')
|
||||
x += lay.XS
|
||||
s.waste = WasteStack(x, y, self)
|
||||
|
||||
x += 2*l.XS
|
||||
x += 2*lay.XS
|
||||
for i in range(4):
|
||||
s.foundations.append(self.Foundation_Class(x, y, self, suit=i))
|
||||
x += l.XS
|
||||
x += lay.XS
|
||||
|
||||
x, y = l.XM, l.YM+l.YS+l.TEXT_HEIGHT
|
||||
x, y = lay.XM, lay.YM+lay.YS+lay.TEXT_HEIGHT
|
||||
for i in range(rows):
|
||||
s.rows.append(self.RowStack_Class(x, y, self))
|
||||
x += l.XS
|
||||
x += lay.XS
|
||||
|
||||
x0, y = self.width - 2*l.XS, l.YM
|
||||
x0, y = self.width - 2*lay.XS, lay.YM
|
||||
for i in range(reserves):
|
||||
x = x0 + ((i+1) & 1) * l.XS
|
||||
x = x0 + ((i+1) & 1) * lay.XS
|
||||
stack = OpenStack(x, y, self, max_accept=0)
|
||||
stack.CARD_YOFFSET = l.YM // 3
|
||||
stack.CARD_YOFFSET = lay.YM // 3
|
||||
s.reserves.append(stack)
|
||||
y = y + l.YS // 2
|
||||
y = y + lay.YS // 2
|
||||
# not needed, as no cards may be placed on the reserves
|
||||
# self.setRegion(s.reserves, (x0-l.XM//2, -999, 999999, 999999),
|
||||
# self.setRegion(s.reserves, (x0-lay.XM//2, -999, 999999, 999999),
|
||||
# priority=1)
|
||||
l.defaultStackGroups()
|
||||
lay.defaultStackGroups()
|
||||
self.sg.dropstacks.append(s.talon)
|
||||
|
||||
def startGame(self, flip=0, reverse=1):
|
||||
|
@ -748,33 +750,34 @@ class Senate(Jane):
|
|||
|
||||
playcards = 10
|
||||
|
||||
l, s = Layout(self), self.s
|
||||
self.setSize(l.XM+(rows+7)*l.XS, l.YM+2*(l.YS+playcards*l.YOFFSET))
|
||||
lay, s = Layout(self), self.s
|
||||
self.setSize(lay.XM+(rows+7)*lay.XS,
|
||||
lay.YM+2*(lay.YS+playcards*lay.YOFFSET))
|
||||
|
||||
x, y = l.XM, l.YM
|
||||
x, y = lay.XM, lay.YM
|
||||
for i in range(rows):
|
||||
s.rows.append(SS_RowStack(x, y, self))
|
||||
x += l.XS
|
||||
x += lay.XS
|
||||
|
||||
for y in l.YM, l.YM+l.YS+playcards*l.YOFFSET:
|
||||
x = l.XM+rows*l.XS+l.XS//2
|
||||
for y in lay.YM, lay.YM+lay.YS+playcards*lay.YOFFSET:
|
||||
x = lay.XM+rows*lay.XS+lay.XS//2
|
||||
for i in range(4):
|
||||
stack = OpenStack(x, y, self, max_accept=0)
|
||||
stack.CARD_XOFFSET, stack.CARD_YOFFSET = 0, l.YOFFSET
|
||||
stack.CARD_XOFFSET, stack.CARD_YOFFSET = 0, lay.YOFFSET
|
||||
s.reserves.append(stack)
|
||||
x += l.XS
|
||||
x = l.XM+(rows+5)*l.XS
|
||||
x += lay.XS
|
||||
x = lay.XM+(rows+5)*lay.XS
|
||||
for i in range(2):
|
||||
y = l.YM+l.YS
|
||||
y = lay.YM+lay.YS
|
||||
for j in range(4):
|
||||
s.foundations.append(SS_FoundationStack(x, y, self, suit=j))
|
||||
y += l.YS
|
||||
x += l.XS
|
||||
x, y = self.width-l.XS, l.YM
|
||||
y += lay.YS
|
||||
x += lay.XS
|
||||
x, y = self.width-lay.XS, lay.YM
|
||||
s.talon = AgnesBernauer_Talon(x, y, self)
|
||||
l.createText(s.talon, 'nw')
|
||||
lay.createText(s.talon, 'nw')
|
||||
|
||||
l.defaultStackGroups()
|
||||
lay.defaultStackGroups()
|
||||
|
||||
def startGame(self):
|
||||
self.s.talon.dealRow(rows=self.s.foundations, frames=0)
|
||||
|
@ -808,29 +811,29 @@ class Phoenix(Klondike):
|
|||
|
||||
def createGame(self):
|
||||
|
||||
l, s = Layout(self), self.s
|
||||
self.setSize(l.XM + 10*l.XS, l.YM + 4*(l.YS+l.YM))
|
||||
lay, s = Layout(self), self.s
|
||||
self.setSize(lay.XM + 10*lay.XS, lay.YM + 4*(lay.YS+lay.YM))
|
||||
|
||||
for i in range(2):
|
||||
x = l.XM + i*l.XS
|
||||
x = lay.XM + i*lay.XS
|
||||
for j in range(4):
|
||||
y = l.YM + j*(l.YS+l.YM)
|
||||
y = lay.YM + j*(lay.YS+lay.YM)
|
||||
s.reserves.append(OpenStack(x, y, self, max_accept=0))
|
||||
for i in range(2):
|
||||
x = l.XM + (8+i)*l.XS
|
||||
x = lay.XM + (8+i)*lay.XS
|
||||
for j in range(4):
|
||||
y = l.YM + j*(l.YS+l.YM)
|
||||
y = lay.YM + j*(lay.YS+lay.YM)
|
||||
s.reserves.append(OpenStack(x, y, self, max_accept=0))
|
||||
for i in range(4):
|
||||
s.foundations.append(
|
||||
SS_FoundationStack(l.XM+(3+i)*l.XS, l.YM, self, i))
|
||||
SS_FoundationStack(lay.XM+(3+i)*lay.XS, lay.YM, self, i))
|
||||
for i in range(6):
|
||||
s.rows.append(
|
||||
self.RowStack_Class(l.XM+(2+i)*l.XS, l.YM+l.YS, self))
|
||||
self.RowStack_Class(lay.XM+(2+i)*lay.XS, lay.YM+lay.YS, self))
|
||||
s.talon = InitialDealTalonStack(
|
||||
l.XM+int(4.5*l.XS), l.YM+3*(l.YS+l.YM), self)
|
||||
lay.XM+int(4.5*lay.XS), lay.YM+3*(lay.YS+lay.YM), self)
|
||||
|
||||
l.defaultStackGroups()
|
||||
lay.defaultStackGroups()
|
||||
|
||||
def startGame(self):
|
||||
for i in range(6):
|
||||
|
@ -856,8 +859,8 @@ class Lanes(Klondike):
|
|||
RowStack_Class = StackWrapper(AC_RowStack, base_rank=ANY_RANK, max_move=1)
|
||||
|
||||
def createGame(self):
|
||||
l = Klondike.createGame(self, rows=6, max_rounds=2, round_text=True)
|
||||
l.createRoundText(self.s.talon, 'ne', dx=l.XS)
|
||||
lay = Klondike.createGame(self, rows=6, max_rounds=2, round_text=True)
|
||||
lay.createRoundText(self.s.talon, 'ne', dx=lay.XS)
|
||||
|
||||
def _shuffleHook(self, cards):
|
||||
# move Aces to top of the Talon (i.e. first cards to be dealt)
|
||||
|
@ -918,8 +921,8 @@ class Q_C_(Klondike):
|
|||
RowStack_Class = StackWrapper(SS_RowStack, base_rank=ANY_RANK, max_move=1)
|
||||
|
||||
def createGame(self):
|
||||
l = Klondike.createGame(self, rows=6, max_rounds=2)
|
||||
l.createRoundText(self.s.talon, 'sss')
|
||||
lay = Klondike.createGame(self, rows=6, max_rounds=2)
|
||||
lay.createRoundText(self.s.talon, 'sss')
|
||||
|
||||
def startGame(self):
|
||||
for i in range(3):
|
||||
|
@ -1044,30 +1047,30 @@ class SevenDevils(Klondike):
|
|||
|
||||
def createGame(self):
|
||||
|
||||
l, s = Layout(self), self.s
|
||||
self.setSize(l.XM + 10*l.XS, l.YM+3*l.YS+12*l.YOFFSET)
|
||||
lay, s = Layout(self), self.s
|
||||
self.setSize(lay.XM + 10*lay.XS, lay.YM+3*lay.YS+12*lay.YOFFSET)
|
||||
|
||||
x, y = l.XM, l.YM
|
||||
x, y = lay.XM, lay.YM
|
||||
for i in range(8):
|
||||
s.foundations.append(SS_FoundationStack(x, y, self, suit=i//2))
|
||||
x += l.XS
|
||||
x, y = l.XM+l.XS//2, l.YM+l.YS
|
||||
x += lay.XS
|
||||
x, y = lay.XM+lay.XS//2, lay.YM+lay.YS
|
||||
for i in range(7):
|
||||
s.rows.append(self.RowStack_Class(x, y, self))
|
||||
x += l.XS
|
||||
x0, y = self.width - 2*l.XS, l.YM
|
||||
x += lay.XS
|
||||
x0, y = self.width - 2*lay.XS, lay.YM
|
||||
for i in range(7):
|
||||
x = x0 + ((i+1) & 1) * l.XS
|
||||
x = x0 + ((i+1) & 1) * lay.XS
|
||||
s.reserves.append(OpenStack(x, y, self, max_accept=0))
|
||||
y += l.YS // 2
|
||||
x, y = l.XM, self.height-l.YS
|
||||
y += lay.YS // 2
|
||||
x, y = lay.XM, self.height-lay.YS
|
||||
s.talon = WasteTalonStack(x, y, self, max_rounds=1)
|
||||
l.createText(s.talon, 'n')
|
||||
x += l.XS
|
||||
lay.createText(s.talon, 'n')
|
||||
x += lay.XS
|
||||
s.waste = WasteStack(x, y, self)
|
||||
l.createText(s.waste, 'n')
|
||||
lay.createText(s.waste, 'n')
|
||||
|
||||
l.defaultStackGroups()
|
||||
lay.defaultStackGroups()
|
||||
|
||||
def startGame(self, flip=0, reverse=1):
|
||||
Klondike.startGame(self)
|
||||
|
@ -1099,9 +1102,9 @@ class MovingLeft(Klondike):
|
|||
|
||||
class Souter(MovingLeft):
|
||||
def createGame(self):
|
||||
l = Klondike.createGame(self, max_rounds=2, rows=10,
|
||||
lay = Klondike.createGame(self, max_rounds=2, rows=10,
|
||||
playcards=24, round_text=True)
|
||||
l.createRoundText(self.s.talon, 'ne', dx=l.XS)
|
||||
lay.createRoundText(self.s.talon, 'ne', dx=lay.XS)
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
@ -1186,8 +1189,8 @@ class Whitehorse(Klondike):
|
|||
|
||||
class Boost(Klondike):
|
||||
def createGame(self):
|
||||
l = Klondike.createGame(self, rows=4, max_rounds=3, round_text=True)
|
||||
l.createRoundText(self.s.talon, 'ne', dx=l.XS)
|
||||
lay = Klondike.createGame(self, rows=4, max_rounds=3, round_text=True)
|
||||
lay.createRoundText(self.s.talon, 'ne', dx=lay.XS)
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
@ -1198,8 +1201,8 @@ class GoldRush(Klondike):
|
|||
Talon_Class = CanfieldRush_Talon
|
||||
|
||||
def createGame(self):
|
||||
l = Klondike.createGame(self, max_rounds=3, round_text=True)
|
||||
l.createRoundText(self.s.talon, 'ne', dx=l.XS)
|
||||
lay = Klondike.createGame(self, max_rounds=3, round_text=True)
|
||||
lay.createRoundText(self.s.talon, 'ne', dx=lay.XS)
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
@ -1231,41 +1234,41 @@ class LuckyThirteen(Game):
|
|||
RowStack_Class = StackWrapper(RK_RowStack, base_rank=NO_RANK)
|
||||
|
||||
def createGame(self, xoffset=0, playcards=0):
|
||||
l, s = Layout(self), self.s
|
||||
lay, s = Layout(self), self.s
|
||||
if xoffset:
|
||||
xoffset = l.XOFFSET
|
||||
w0 = l.XS+playcards*l.XOFFSET
|
||||
self.setSize(l.XM + 5*w0, l.YM+4*l.YS)
|
||||
xoffset = lay.XOFFSET
|
||||
w0 = lay.XS+playcards*lay.XOFFSET
|
||||
self.setSize(lay.XM + 5*w0, lay.YM+4*lay.YS)
|
||||
|
||||
x, y = l.XM, l.YM+l.YS
|
||||
x, y = lay.XM, lay.YM+lay.YS
|
||||
for i in range(5):
|
||||
stack = self.RowStack_Class(x, y, self, max_move=1)
|
||||
s.rows.append(stack)
|
||||
stack.CARD_XOFFSET = xoffset
|
||||
stack.CARD_YOFFSET = 0
|
||||
x += w0
|
||||
x, y = l.XM+w0, l.YM+2*l.YS
|
||||
x, y = lay.XM+w0, lay.YM+2*lay.YS
|
||||
for i in range(3):
|
||||
stack = self.RowStack_Class(x, y, self, max_move=1)
|
||||
s.rows.append(stack)
|
||||
stack.CARD_XOFFSET = xoffset
|
||||
stack.CARD_YOFFSET = 0
|
||||
x += w0
|
||||
x, y = l.XM, l.YM+3*l.YS
|
||||
x, y = lay.XM, lay.YM+3*lay.YS
|
||||
for i in range(5):
|
||||
stack = self.RowStack_Class(x, y, self, max_move=1)
|
||||
s.rows.append(stack)
|
||||
stack.CARD_XOFFSET = xoffset
|
||||
stack.CARD_YOFFSET = 0
|
||||
x += w0
|
||||
x, y = (self.width-4*l.XS)//2, l.YM
|
||||
x, y = (self.width-4*lay.XS)//2, lay.YM
|
||||
for i in range(4):
|
||||
s.foundations.append(SS_FoundationStack(x, y, self, suit=i))
|
||||
x += l.XS
|
||||
x, y = l.XM, self.height-l.YS
|
||||
x += lay.XS
|
||||
x, y = lay.XM, self.height-lay.YS
|
||||
s.talon = InitialDealTalonStack(x, y, self, max_rounds=1)
|
||||
|
||||
l.defaultStackGroups()
|
||||
lay.defaultStackGroups()
|
||||
|
||||
def startGame(self):
|
||||
self.s.talon.dealRow(frames=0)
|
||||
|
@ -1311,32 +1314,32 @@ class Legion(Klondike):
|
|||
class BigBertha(Game):
|
||||
|
||||
def createGame(self):
|
||||
l, s = Layout(self), self.s
|
||||
self.setSize(l.XM+15*l.XS, l.YM+3*l.YS+15*l.YOFFSET)
|
||||
lay, s = Layout(self), self.s
|
||||
self.setSize(lay.XM+15*lay.XS, lay.YM+3*lay.YS+15*lay.YOFFSET)
|
||||
|
||||
x, y = l.XM, l.YM
|
||||
x, y = lay.XM, lay.YM
|
||||
s.talon = InitialDealTalonStack(x, y, self)
|
||||
|
||||
x, y = l.XM+3.5*l.XS, l.YM
|
||||
x, y = lay.XM+3.5*lay.XS, lay.YM
|
||||
for i in range(8):
|
||||
s.foundations.append(SS_FoundationStack(x, y, self,
|
||||
suit=i % 4, max_cards=12))
|
||||
x += l.XS
|
||||
x += lay.XS
|
||||
|
||||
x, y = l.XM, l.YM+l.YS
|
||||
x, y = lay.XM, lay.YM+lay.YS
|
||||
for i in range(15):
|
||||
s.rows.append(AC_RowStack(x, y, self))
|
||||
x += l.XS
|
||||
x += lay.XS
|
||||
|
||||
x, y = l.XM, self.height-l.YS
|
||||
x, y = lay.XM, self.height-lay.YS
|
||||
for i in range(14):
|
||||
s.reserves.append(OpenStack(x, y, self, max_accept=0))
|
||||
x += l.XS
|
||||
x += lay.XS
|
||||
|
||||
s.foundations.append(RK_FoundationStack(x, y, self, suit=ANY_SUIT,
|
||||
base_rank=KING, dir=0, max_cards=8))
|
||||
|
||||
l.defaultStackGroups()
|
||||
lay.defaultStackGroups()
|
||||
|
||||
def startGame(self):
|
||||
for i in range(5):
|
||||
|
@ -1406,9 +1409,9 @@ class EightSages(Klondike):
|
|||
RowStack_Class = EightSages_Row
|
||||
|
||||
def createGame(self):
|
||||
l = Klondike.createGame(self, max_rounds=2, rows=8,
|
||||
lay = Klondike.createGame(self, max_rounds=2, rows=8,
|
||||
playcards=12, round_text=True)
|
||||
l.createRoundText(self.s.talon, 'ne', dx=l.XS)
|
||||
lay.createRoundText(self.s.talon, 'ne', dx=lay.XS)
|
||||
|
||||
def startGame(self):
|
||||
self.startDealSample()
|
||||
|
|
|
@ -759,7 +759,7 @@ class AnnoDomini(Numerica):
|
|||
RowStack_Class = StackWrapper(AC_RowStack, mod=13)
|
||||
|
||||
def createGame(self):
|
||||
l = Numerica.createGame(
|
||||
lay = Numerica.createGame(
|
||||
self, max_rounds=3, waste_max_cards=UNLIMITED_CARDS)
|
||||
year = str(time.localtime()[0])
|
||||
i = 0
|
||||
|
@ -772,7 +772,7 @@ class AnnoDomini(Numerica):
|
|||
d = JACK
|
||||
s.cap.base_rank = d
|
||||
i += 1
|
||||
l.createRoundText(self.s.talon, 'nn')
|
||||
lay.createRoundText(self.s.talon, 'nn')
|
||||
|
||||
def startGame(self):
|
||||
self.startDealSample()
|
||||
|
|
|
@ -528,13 +528,14 @@ class GreatWall(AbstractFlowerGame):
|
|||
return
|
||||
for i in range(4):
|
||||
stack = self.s.foundations[i]
|
||||
l = len(stack.cards) // 12
|
||||
if l == 0:
|
||||
mylen = len(stack.cards) // 12
|
||||
if mylen == 0:
|
||||
text = ""
|
||||
elif l == 4:
|
||||
elif mylen == 4:
|
||||
text = _("Filled")
|
||||
else:
|
||||
text = str(l) + (_("st"), _("nd"), _("rd"), _("th"))[l - 1] \
|
||||
text = str(mylen) + \
|
||||
(_("st"), _("nd"), _("rd"), _("th"))[mylen - 1] \
|
||||
+ _(" Deck")
|
||||
stack.texts.misc.config(text=text)
|
||||
|
||||
|
|
|
@ -189,11 +189,11 @@ class Matrix3(Game):
|
|||
if self.busy:
|
||||
return 0
|
||||
s = self.s.rows
|
||||
l = len(s) - 1
|
||||
for r in s[:l]:
|
||||
mylen = len(s) - 1
|
||||
for r in s[:mylen]:
|
||||
if not r.cards or not r.cards[0].rank == r.id:
|
||||
return 0
|
||||
self.s.talon.dealRow(rows=s[l:], frames=0)
|
||||
self.s.talon.dealRow(rows=s[mylen:], frames=0)
|
||||
return 1
|
||||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
|
|
|
@ -153,8 +153,8 @@ class Grandfather(RussianSolitaire):
|
|||
Talon_Class = StackWrapper(Grandfather_Talon, max_rounds=3)
|
||||
|
||||
def createGame(self):
|
||||
l = Yukon.createGame(self)
|
||||
l.createRoundText(self.s.talon, 'nn')
|
||||
layout = Yukon.createGame(self)
|
||||
layout.createRoundText(self.s.talon, 'nn')
|
||||
|
||||
def startGame(self):
|
||||
frames = 0
|
||||
|
@ -309,14 +309,15 @@ class Abacus(Rushdike):
|
|||
RowStack_Class = Abacus_RowStack
|
||||
|
||||
def createGame(self):
|
||||
l = Rushdike.createGame(self)
|
||||
layout = Rushdike.createGame(self)
|
||||
help = (_('''\
|
||||
Club: A 2 3 4 5 6 7 8 9 T J Q K
|
||||
Spade: 2 4 6 8 T Q A 3 5 7 9 J K
|
||||
Heart: 3 6 9 Q 2 5 8 J A 4 7 T K
|
||||
Diamond: 4 8 Q 3 7 J 2 6 T A 5 9 K'''))
|
||||
self.texts.help = MfxCanvasText(self.canvas,
|
||||
l.XM, self.height - l.YM, text=help,
|
||||
layout.XM, self.height - layout.YM,
|
||||
text=help,
|
||||
anchor="sw",
|
||||
font=self.app.getFont("canvas_fixed"))
|
||||
|
||||
|
@ -405,21 +406,21 @@ class TenAcross(Yukon):
|
|||
|
||||
def createGame(self, **layout):
|
||||
# create layout
|
||||
l, s = Layout(self), self.s
|
||||
lay, s = Layout(self), self.s
|
||||
kwdefault(layout, rows=10, reserves=2, texts=0)
|
||||
self.Layout_Method(l, **layout)
|
||||
self.setSize(l.size[0], l.size[1])
|
||||
self.Layout_Method(lay, **layout)
|
||||
self.setSize(lay.size[0], lay.size[1])
|
||||
# create stacks
|
||||
s.talon = InitialDealTalonStack(l.s.talon.x, l.s.talon.y, self)
|
||||
for r in l.s.foundations:
|
||||
s.talon = InitialDealTalonStack(lay.s.talon.x, lay.s.talon.y, self)
|
||||
for r in lay.s.foundations:
|
||||
self.s.foundations.append(
|
||||
self.Foundation_Class(r.x, r.y, self, suit=r.suit))
|
||||
for r in l.s.rows:
|
||||
for r in lay.s.rows:
|
||||
s.rows.append(self.RowStack_Class(r.x, r.y, self))
|
||||
for r in l.s.reserves:
|
||||
for r in lay.s.reserves:
|
||||
self.s.reserves.append(ReserveStack(r.x, r.y, self))
|
||||
# default
|
||||
l.defaultAll()
|
||||
lay.defaultAll()
|
||||
|
||||
#
|
||||
# game overrides
|
||||
|
|
|
@ -132,7 +132,7 @@ def help_html(app, document, dir_, top=None):
|
|||
# viewer = None
|
||||
viewer.updateHistoryXYView()
|
||||
viewer.display(doc, relpath=0)
|
||||
except:
|
||||
except Exception:
|
||||
# traceback.print_exc()
|
||||
top = make_help_toplevel(app, title=TITLE+_(" Help"))
|
||||
if top.winfo_screenwidth() < 800 or top.winfo_screenheight() < 600:
|
||||
|
@ -153,5 +153,5 @@ def help_html(app, document, dir_, top=None):
|
|||
def destroy_help_html():
|
||||
try:
|
||||
help_html_viewer.destroy()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
|
|
@ -86,7 +86,7 @@ class Images:
|
|||
return None
|
||||
try:
|
||||
img = loadImage(file=f)
|
||||
except:
|
||||
except Exception:
|
||||
return None
|
||||
w, h = img.width(), img.height()
|
||||
if self.CARDW < 0:
|
||||
|
@ -103,7 +103,7 @@ class Images:
|
|||
d = os.path.join('images', 'cards', 'bottoms')
|
||||
try:
|
||||
imagedir = self.d.findDir(cs_type, d)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
if not USE_PIL or imagedir is None:
|
||||
# load image
|
||||
|
@ -117,7 +117,7 @@ class Images:
|
|||
d = os.path.join('images', 'cards', 'bottoms', cs_type)
|
||||
try:
|
||||
fn = self.d.findImage(filename, d)
|
||||
except:
|
||||
except Exception:
|
||||
fn = None
|
||||
img = createBottom(self._card[0], color, fn)
|
||||
return img
|
||||
|
|
|
@ -38,9 +38,9 @@ def init():
|
|||
|
||||
if os.name == 'nt' and 'LANG' not in os.environ:
|
||||
try:
|
||||
l = locale.getdefaultlocale()
|
||||
os.environ['LANG'] = l[0]
|
||||
except:
|
||||
loc = locale.getdefaultlocale()
|
||||
os.environ['LANG'] = loc[0]
|
||||
except Exception:
|
||||
pass
|
||||
# locale.setlocale(locale.LC_ALL, '')
|
||||
|
||||
|
@ -66,7 +66,7 @@ def init():
|
|||
if 'PYSOL_DEBUG' in os.environ:
|
||||
try:
|
||||
pysollib.settings.DEBUG = int(os.environ['PYSOL_DEBUG'])
|
||||
except:
|
||||
except Exception:
|
||||
pysollib.settings.DEBUG = 1
|
||||
print(('PySol debugging: set DEBUG to', pysollib.settings.DEBUG))
|
||||
|
||||
|
@ -135,7 +135,7 @@ def init():
|
|||
pysollib.settings.USE_FREECELL_SOLVER = True
|
||||
if os.name == 'posix':
|
||||
os.wait() # kill zombi
|
||||
except:
|
||||
except Exception:
|
||||
# traceback.print_exc()
|
||||
pass
|
||||
os.environ['FREECELL_SOLVER_QUIET'] = '1'
|
||||
|
|
|
@ -174,7 +174,7 @@ def pysol_init(app, args):
|
|||
if not os.path.exists(d):
|
||||
try:
|
||||
os.makedirs(d)
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
pass
|
||||
|
||||
|
@ -191,7 +191,7 @@ def pysol_init(app, args):
|
|||
# load options
|
||||
try:
|
||||
app.loadOptions()
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
pass
|
||||
|
||||
|
@ -232,7 +232,7 @@ def pysol_init(app, args):
|
|||
app.dn.plugins):
|
||||
try:
|
||||
app.loadPlugins(dir)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
GAME_DB.setCallback(None)
|
||||
|
||||
|
@ -257,7 +257,7 @@ def pysol_init(app, args):
|
|||
app.audio = c()
|
||||
app.audio.startServer()
|
||||
app.audio.connectServer(app)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
# success
|
||||
|
|
|
@ -145,7 +145,7 @@ def win32_getusername():
|
|||
user = os.environ.get('USERNAME', '').strip()
|
||||
try:
|
||||
user = unicode(user, locale.getpreferredencoding())
|
||||
except:
|
||||
except Exception:
|
||||
user = ''
|
||||
return user
|
||||
|
||||
|
@ -304,6 +304,6 @@ def openURL(url):
|
|||
webbrowser.open(url)
|
||||
except OSError: # raised on windows if link is unreadable
|
||||
pass
|
||||
except:
|
||||
except Exception:
|
||||
return 0
|
||||
return 1
|
||||
|
|
|
@ -235,9 +235,9 @@ class ATurnStackMove(AtomicMove):
|
|||
to_stack = game.allstacks[self.to_stack_id]
|
||||
assert len(from_stack.cards) > 0
|
||||
assert len(to_stack.cards) == 0
|
||||
l = len(from_stack.cards)
|
||||
for i in range(l):
|
||||
# unhide = (i >= l - 2)
|
||||
mylen = len(from_stack.cards)
|
||||
for i in range(mylen):
|
||||
# unhide = (i >= mylen - 2)
|
||||
unhide = 1
|
||||
# print 1, unhide, from_stack.getCard().__dict__
|
||||
card = from_stack.removeCard(unhide=unhide, update=0)
|
||||
|
@ -254,9 +254,9 @@ class ATurnStackMove(AtomicMove):
|
|||
to_stack = game.allstacks[self.from_stack_id]
|
||||
assert len(from_stack.cards) > 0
|
||||
assert len(to_stack.cards) == 0
|
||||
l = len(from_stack.cards)
|
||||
for i in range(l):
|
||||
# unhide = (i >= l - 2)
|
||||
mylen = len(from_stack.cards)
|
||||
for i in range(mylen):
|
||||
# unhide = (i >= mylen - 2)
|
||||
unhide = 1
|
||||
card = from_stack.removeCard(unhide=unhide, update=0)
|
||||
assert not card.face_up
|
||||
|
|
|
@ -560,7 +560,7 @@ class Options:
|
|||
val = config[section][key]
|
||||
except KeyError:
|
||||
val = None
|
||||
except:
|
||||
except Exception:
|
||||
print_err('load option error: %s: %s' % (section, key))
|
||||
traceback.print_exc()
|
||||
val = None
|
||||
|
@ -627,14 +627,14 @@ class Options:
|
|||
if recent_gameid is not None:
|
||||
try:
|
||||
self.recent_gameid = [int(i) for i in recent_gameid]
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
|
||||
favorite_gameid = self._getOption('general', 'favorite_gameid', 'list')
|
||||
if favorite_gameid is not None:
|
||||
try:
|
||||
self.favorite_gameid = [int(i) for i in favorite_gameid]
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
|
||||
visible_buttons = self._getOption('general', 'visible_buttons', 'list')
|
||||
|
@ -663,7 +663,7 @@ class Options:
|
|||
if val is not None:
|
||||
try:
|
||||
val[1] = int(val[1])
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
else:
|
||||
val = tuple(val)
|
||||
|
@ -687,7 +687,7 @@ class Options:
|
|||
if val is not None:
|
||||
try:
|
||||
self.cardset[int(key)] = val
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
for key, t in (('scale_cards', 'bool'),
|
||||
('scale_x', 'float'),
|
||||
|
@ -704,13 +704,13 @@ class Options:
|
|||
val = [int(i) for i in val]
|
||||
assert len(val) == 2
|
||||
self.games_geometry[int(key)] = val
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
game_geometry = self._getOption('general', 'game_geometry', 'list')
|
||||
if game_geometry is not None:
|
||||
try:
|
||||
self.game_geometry = tuple(int(i) for i in game_geometry)
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
|
||||
# cards offsets
|
||||
|
@ -719,5 +719,5 @@ class Options:
|
|||
val = [int(i) for i in val]
|
||||
assert len(val) == 2
|
||||
self.offsets[key] = val
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
|
|
|
@ -70,7 +70,7 @@ class AbstractAudioClient:
|
|||
try:
|
||||
if self._connectServer():
|
||||
self.connected = 1
|
||||
except:
|
||||
except Exception:
|
||||
if traceback:
|
||||
traceback.print_exc()
|
||||
self.destroy()
|
||||
|
@ -102,7 +102,7 @@ class AbstractAudioClient:
|
|||
self.sample_priority = priority
|
||||
self.sample_loop = loop
|
||||
return 1
|
||||
except:
|
||||
except Exception:
|
||||
if traceback:
|
||||
traceback.print_exc()
|
||||
return 0
|
||||
|
@ -112,7 +112,7 @@ class AbstractAudioClient:
|
|||
return
|
||||
try:
|
||||
self._stopSamples()
|
||||
except:
|
||||
except Exception:
|
||||
if traceback:
|
||||
traceback.print_exc()
|
||||
self.sample_priority = -1
|
||||
|
@ -123,7 +123,7 @@ class AbstractAudioClient:
|
|||
return
|
||||
try:
|
||||
self._stopSamplesLoop()
|
||||
except:
|
||||
except Exception:
|
||||
if traceback:
|
||||
traceback.print_exc()
|
||||
self.sample_priority = -1
|
||||
|
@ -184,7 +184,7 @@ class PysolSoundServerModuleClient(AbstractAudioClient):
|
|||
self.audiodev = pysolsoundserver
|
||||
self.audiodev.init()
|
||||
self.server = 1
|
||||
except:
|
||||
except Exception:
|
||||
if traceback:
|
||||
traceback.print_exc()
|
||||
self.server = None
|
||||
|
@ -236,7 +236,7 @@ class PysolSoundServerModuleClient(AbstractAudioClient):
|
|||
% (music.absname, music.index, 0, loop,
|
||||
music.volume))
|
||||
self.cmd("startqueue")
|
||||
except:
|
||||
except Exception:
|
||||
if traceback:
|
||||
traceback.print_exc()
|
||||
|
||||
|
@ -253,7 +253,7 @@ class PysolSoundServerModuleClient(AbstractAudioClient):
|
|||
try:
|
||||
self.cmd("setwavvol %d" % s)
|
||||
self.cmd("setmusvol %d" % m)
|
||||
except:
|
||||
except Exception:
|
||||
if traceback:
|
||||
traceback.print_exc()
|
||||
|
||||
|
@ -286,7 +286,7 @@ class Win32AudioClient(AbstractAudioClient):
|
|||
try:
|
||||
a.PlaySound(filename, flags)
|
||||
return 1
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
return 0
|
||||
|
||||
|
@ -352,7 +352,7 @@ class OSSAudioServer:
|
|||
# audiodev.close()
|
||||
# self.audiodev = ossaudiodev.open('w')
|
||||
return 1
|
||||
except:
|
||||
except Exception:
|
||||
if traceback:
|
||||
traceback.print_exc()
|
||||
return 0
|
||||
|
@ -373,7 +373,7 @@ class OSSAudioServer:
|
|||
self.sound_priority = priority
|
||||
self._busy = False
|
||||
return 1
|
||||
except:
|
||||
except Exception:
|
||||
if traceback:
|
||||
traceback.print_exc()
|
||||
self._busy = False
|
||||
|
@ -469,7 +469,7 @@ class PyGameAudioClient(AbstractAudioClient):
|
|||
self.sound = self.mixer.Sound(filename)
|
||||
self.sound.set_volume(vol)
|
||||
self.sound_channel = self.sound.play(loop)
|
||||
except:
|
||||
except Exception:
|
||||
if traceback:
|
||||
traceback.print_exc()
|
||||
pass
|
||||
|
@ -501,7 +501,7 @@ class PyGameAudioClient(AbstractAudioClient):
|
|||
while self.music and self.music.get_busy():
|
||||
self._wait(200)
|
||||
self._wait(300)
|
||||
except:
|
||||
except Exception:
|
||||
# if traceback: traceback.print_exc()
|
||||
self._wait(1000)
|
||||
|
||||
|
|
|
@ -206,7 +206,7 @@ class SelectCardsetDialogWithPreview(MfxDialog):
|
|||
for n in names:
|
||||
f = os.path.join(cs.dir, n + cs.ext)
|
||||
self.preview_images.append(loadImage(file=f))
|
||||
except:
|
||||
except Exception:
|
||||
self.preview_key = -1
|
||||
self.preview_images = []
|
||||
return
|
||||
|
|
|
@ -331,7 +331,7 @@ class HTMLViewer:
|
|||
try: # if app
|
||||
default_font = self.app.getFont('sans')
|
||||
fixed_font = self.app.getFont('fixed')
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
default_font = ('times new roman', 12)
|
||||
fixed_font = ('courier', 12)
|
||||
|
@ -428,7 +428,7 @@ class HTMLViewer:
|
|||
# self.app.game.stopDemo()
|
||||
# self.app.game._cancelDrag()
|
||||
pass
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# ftp: and http: would work if we use urllib, but this widget is
|
||||
|
@ -465,7 +465,7 @@ to open the following URL:
|
|||
self.errorDialog(
|
||||
_('Unable to service request:\n') + url + '\n\n' + str(ex))
|
||||
return
|
||||
except:
|
||||
except Exception:
|
||||
if file:
|
||||
file.close()
|
||||
self.errorDialog(_('Unable to service request:\n') + url)
|
||||
|
@ -548,7 +548,7 @@ to open the following URL:
|
|||
return self.images[fn]
|
||||
try:
|
||||
img = gdk.pixbuf_new_from_file(fn)
|
||||
except:
|
||||
except Exception:
|
||||
img = None
|
||||
self.images[fn] = img
|
||||
return img
|
||||
|
@ -569,7 +569,7 @@ to open the following URL:
|
|||
def tkhtml_main(args):
|
||||
try:
|
||||
url = args[1]
|
||||
except:
|
||||
except Exception:
|
||||
url = os.path.join(os.pardir, os.pardir, 'data', 'html', 'index.html')
|
||||
top = gtk.Window()
|
||||
table = gtk.Table()
|
||||
|
|
|
@ -276,9 +276,9 @@ def bind(widget, sequence, func, add=None):
|
|||
if k in __bindings:
|
||||
__bindings[k].append((wrap, func))
|
||||
else:
|
||||
l = [(wrap, func)]
|
||||
widget.connect(signal, _wrap_event, l)
|
||||
__bindings[k] = l
|
||||
lst = [(wrap, func)]
|
||||
widget.connect(signal, _wrap_event, lst)
|
||||
__bindings[k] = lst
|
||||
|
||||
|
||||
def unbind_destroy(widget):
|
||||
|
|
|
@ -111,9 +111,9 @@ class ResourceManager:
|
|||
|
||||
def getAllSortedByName(self):
|
||||
if self._objects_by_name is None:
|
||||
l = [(obj.getSortKey(), obj) for obj in self._objects]
|
||||
l.sort()
|
||||
self._objects_by_name = tuple([item[1] for item in l])
|
||||
lst = [(obj.getSortKey(), obj) for obj in self._objects]
|
||||
lst.sort()
|
||||
self._objects_by_name = tuple([item[1] for item in lst])
|
||||
return self._objects_by_name
|
||||
|
||||
#
|
||||
|
|
|
@ -523,11 +523,12 @@ class Stack:
|
|||
if from_stack is self or self.basicIsBlocked():
|
||||
return False
|
||||
cap = self.cap
|
||||
l = len(cards)
|
||||
if l < cap.min_accept or l > cap.max_accept:
|
||||
mylen = len(cards)
|
||||
if mylen < cap.min_accept or mylen > cap.max_accept:
|
||||
return False
|
||||
l = l + len(self.cards)
|
||||
if l > cap.max_cards: # note: we don't check cap.min_cards here
|
||||
mylen = mylen + len(self.cards)
|
||||
# note: we don't check cap.min_cards here
|
||||
if mylen > cap.max_cards:
|
||||
return False
|
||||
for c in cards:
|
||||
if not c.face_up:
|
||||
|
@ -557,11 +558,12 @@ class Stack:
|
|||
if self.basicIsBlocked():
|
||||
return False
|
||||
cap = self.cap
|
||||
l = len(cards)
|
||||
if l < cap.min_move or l > cap.max_move:
|
||||
mylen = len(cards)
|
||||
if mylen < cap.min_move or mylen > cap.max_move:
|
||||
return False
|
||||
l = len(self.cards) - l
|
||||
if l < cap.min_cards: # note: we don't check cap.max_cards here
|
||||
mylen = len(self.cards) - mylen
|
||||
# note: we don't check cap.max_cards here
|
||||
if mylen < cap.min_cards:
|
||||
return False
|
||||
return cardsFaceUp(cards)
|
||||
|
||||
|
@ -1325,8 +1327,8 @@ class Stack:
|
|||
def createShadows(self, cards, dx=0, dy=0):
|
||||
if not self.game.app.opt.shadow or self.canvas.preview > 1:
|
||||
return ()
|
||||
l = len(cards)
|
||||
if l == 0 or l > self.max_shadow_cards:
|
||||
mylen = len(cards)
|
||||
if mylen == 0 or mylen > self.max_shadow_cards:
|
||||
return ()
|
||||
images = self.game.app.images
|
||||
cx, cy = cards[0].x, cards[0].y
|
||||
|
@ -1350,7 +1352,7 @@ class Stack:
|
|||
if c.x != cx or abs(c.y - cy) != images.CARD_YOFFSET:
|
||||
return ()
|
||||
cy = c.y
|
||||
img0, img1 = images.getShadow(0), images.getShadow(l)
|
||||
img0, img1 = images.getShadow(0), images.getShadow(mylen)
|
||||
c0 = cards[-1]
|
||||
if self.CARD_YOFFSET[0] < 0:
|
||||
c0 = cards[0]
|
||||
|
@ -1359,7 +1361,7 @@ class Stack:
|
|||
if c.y != cy or abs(c.x - cx) != images.CARD_XOFFSET:
|
||||
return ()
|
||||
cx = c.x
|
||||
img0, img1 = images.getShadow(-l), images.getShadow(1)
|
||||
img0, img1 = images.getShadow(-mylen), images.getShadow(1)
|
||||
c0 = cards[-1]
|
||||
if self.CARD_XOFFSET[0] < 0:
|
||||
c0 = cards[0]
|
||||
|
@ -1496,12 +1498,12 @@ class Stack:
|
|||
fill="", outline=color, width=4,
|
||||
group=self.group)
|
||||
drag.shadows.append(r)
|
||||
# l = MfxCanvasLine(self.canvas, xx0, yy0, xx0+w, yy0+h,
|
||||
# mylen = MfxCanvasLine(self.canvas, xx0, yy0, xx0+w, yy0+h,
|
||||
# fill=color, width=4)
|
||||
# drag.shadows.append(l)
|
||||
# l = MfxCanvasLine(self.canvas, xx0, yy0+h, xx0+w, yy0,
|
||||
# drag.shadows.append(mylen)
|
||||
# mylen = MfxCanvasLine(self.canvas, xx0, yy0+h, xx0+w, yy0,
|
||||
# fill=color, width=4)
|
||||
# drag.shadows.append(l)
|
||||
# drag.shadows.append(mylen)
|
||||
return
|
||||
#
|
||||
shade = Image.new('RGBA', (w, h))
|
||||
|
|
|
@ -181,10 +181,11 @@ class FontsDialog(MfxDialog):
|
|||
[str(i) for i in font if i not in ('roman', 'normal')])
|
||||
elif font is None:
|
||||
title = 'Default'
|
||||
l = ttk.Label(frame, font=font, text=title)
|
||||
l.grid(row=row, column=1, padx=8)
|
||||
label = ttk.Label(frame, font=font, text=title)
|
||||
label.grid(row=row, column=1, padx=8)
|
||||
b = ttk.Button(frame, text=_('Change...'), width=10,
|
||||
command=lambda l=l, fn=fn: self.selectFont(l, fn))
|
||||
command=lambda label=label,
|
||||
fn=fn: self.selectFont(label, fn))
|
||||
b.grid(row=row, column=2)
|
||||
row += 1
|
||||
#
|
||||
|
|
|
@ -387,7 +387,7 @@ class SelectCardsetDialogWithPreview(MfxDialog):
|
|||
for n in names:
|
||||
f = os.path.join(cs.dir, n + cs.ext)
|
||||
self.preview_images.append(loadImage(file=f))
|
||||
except:
|
||||
except Exception:
|
||||
self.preview_key = -1
|
||||
self.preview_images = []
|
||||
return
|
||||
|
@ -461,12 +461,12 @@ class CardsetInfoDialog(MfxDialog):
|
|||
(_('Size:'), '%d x %d' % (cardset.CARDW, cardset.CARDH)),
|
||||
):
|
||||
if t is not None:
|
||||
l = ttk.Label(info_frame, text=n,
|
||||
label = ttk.Label(info_frame, text=n,
|
||||
anchor='w', justify='left')
|
||||
l.grid(row=frow, column=0, sticky='nw', padx=4)
|
||||
l = ttk.Label(info_frame, text=t,
|
||||
label.grid(row=frow, column=0, sticky='nw', padx=4)
|
||||
label = ttk.Label(info_frame, text=t,
|
||||
anchor='w', justify='left')
|
||||
l.grid(row=frow, column=1, sticky='nw', padx=4)
|
||||
label.grid(row=frow, column=1, sticky='nw', padx=4)
|
||||
frow += 1
|
||||
if images:
|
||||
try:
|
||||
|
@ -474,15 +474,15 @@ class CardsetInfoDialog(MfxDialog):
|
|||
im = choice(images)
|
||||
f = os.path.join(cardset.dir, cardset.backname)
|
||||
self.back_image = loadImage(file=f) # store the image
|
||||
l = ttk.Label(info_frame, image=im, padding=5)
|
||||
l.grid(row=0, column=2, rowspan=frow+1, sticky='ne')
|
||||
l = ttk.Label(info_frame, image=self.back_image,
|
||||
label = ttk.Label(info_frame, image=im, padding=5)
|
||||
label.grid(row=0, column=2, rowspan=frow+1, sticky='ne')
|
||||
label = ttk.Label(info_frame, image=self.back_image,
|
||||
padding=(0, 5, 5, 5)) # left margin = 0
|
||||
l.grid(row=0, column=3, rowspan=frow+1, sticky='ne')
|
||||
label.grid(row=0, column=3, rowspan=frow+1, sticky='ne')
|
||||
|
||||
info_frame.columnconfigure(2, weight=1)
|
||||
info_frame.rowconfigure(frow, weight=1)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
if USE_PIL:
|
||||
padx = 4
|
||||
|
@ -529,7 +529,7 @@ class CardsetInfoDialog(MfxDialog):
|
|||
f = os.path.join(cardset.dir, "COPYRIGHT")
|
||||
try:
|
||||
text = open(f).read()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
if text:
|
||||
text_w.config(state="normal")
|
||||
|
|
|
@ -85,6 +85,6 @@ def create_solver_dialog(parent, game):
|
|||
try:
|
||||
solver_dialog.top.wm_deiconify()
|
||||
solver_dialog.top.tkraise()
|
||||
except:
|
||||
except Exception:
|
||||
# traceback.print_exc()
|
||||
solver_dialog = SolverDialog(parent, game)
|
||||
|
|
|
@ -161,24 +161,24 @@ class PysolStatusbar(MfxStatusbar):
|
|||
):
|
||||
self._createLabel(n, tooltip=t, width=w)
|
||||
#
|
||||
l = self._createLabel('info', expand=True)
|
||||
l.config(padding=(8, 0))
|
||||
label = self._createLabel('info', expand=True)
|
||||
label.config(padding=(8, 0))
|
||||
self._createSizegrip()
|
||||
|
||||
|
||||
class HelpStatusbar(MfxStatusbar):
|
||||
def __init__(self, top):
|
||||
MfxStatusbar.__init__(self, top, row=3, column=0, columnspan=3)
|
||||
l = self._createLabel('info', expand=True)
|
||||
l.config(justify='left', anchor='w', padding=(8, 0))
|
||||
label = self._createLabel('info', expand=True)
|
||||
label.config(justify='left', anchor='w', padding=(8, 0))
|
||||
|
||||
|
||||
class HtmlStatusbar(MfxStatusbar):
|
||||
def __init__(self, top, row, column, columnspan):
|
||||
MfxStatusbar.__init__(self, top, row=row, column=column,
|
||||
columnspan=columnspan)
|
||||
l = self._createLabel('url', expand=True)
|
||||
l.config(justify='left', anchor='w', padding=(8, 0))
|
||||
label = self._createLabel('url', expand=True)
|
||||
label.config(justify='left', anchor='w', padding=(8, 0))
|
||||
self._createSizegrip()
|
||||
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ class HTMLViewer(Base_HTMLViewer):
|
|||
def tkhtml_main(args):
|
||||
try:
|
||||
url = args[1]
|
||||
except:
|
||||
except Exception:
|
||||
url = os.path.join(os.pardir, os.pardir, "data", "html", "index.html")
|
||||
top = tkinter.Tk()
|
||||
top.tk.call("package", "require", "tile")
|
||||
|
|
|
@ -671,45 +671,45 @@ class _TopDialog(MfxDialog):
|
|||
frame.columnconfigure(0, weight=1)
|
||||
cnf['master'] = frame
|
||||
cnf['text'] = _('N')
|
||||
l = ttk.Label(**cnf)
|
||||
l.grid(row=0, column=0, sticky='ew')
|
||||
label = ttk.Label(**cnf)
|
||||
label.grid(row=0, column=0, sticky='ew')
|
||||
if gameid == 'all':
|
||||
cnf['text'] = _('Game')
|
||||
l = ttk.Label(**cnf)
|
||||
l.grid(row=0, column=1, sticky='ew')
|
||||
label = ttk.Label(**cnf)
|
||||
label.grid(row=0, column=1, sticky='ew')
|
||||
cnf['text'] = _('Game number')
|
||||
l = ttk.Label(**cnf)
|
||||
l.grid(row=0, column=2, sticky='ew')
|
||||
label = ttk.Label(**cnf)
|
||||
label.grid(row=0, column=2, sticky='ew')
|
||||
cnf['text'] = _('Started at')
|
||||
l = ttk.Label(**cnf)
|
||||
l.grid(row=0, column=3, sticky='ew')
|
||||
label = ttk.Label(**cnf)
|
||||
label.grid(row=0, column=3, sticky='ew')
|
||||
cnf['text'] = _('Result')
|
||||
l = ttk.Label(**cnf)
|
||||
l.grid(row=0, column=4, sticky='ew')
|
||||
label = ttk.Label(**cnf)
|
||||
label.grid(row=0, column=4, sticky='ew')
|
||||
|
||||
row = 1
|
||||
for i in top:
|
||||
# N
|
||||
cnf['text'] = str(row)
|
||||
l = ttk.Label(**cnf)
|
||||
l.grid(row=row, column=0, sticky='ew')
|
||||
label = ttk.Label(**cnf)
|
||||
label.grid(row=row, column=0, sticky='ew')
|
||||
if gameid == 'all':
|
||||
name = app.getGameTitleName(i.gameid)
|
||||
if name is None:
|
||||
name = _("** UNKNOWN %d **") % i.gameid
|
||||
cnf['text'] = name
|
||||
l = ttk.Label(**cnf)
|
||||
l.grid(row=row, column=1, sticky='ew')
|
||||
label = ttk.Label(**cnf)
|
||||
label.grid(row=row, column=1, sticky='ew')
|
||||
# Game number
|
||||
cnf['text'] = '#'+str(i.game_number)
|
||||
l = ttk.Label(**cnf)
|
||||
l.grid(row=row, column=2, sticky='ew')
|
||||
label = ttk.Label(**cnf)
|
||||
label.grid(row=row, column=2, sticky='ew')
|
||||
# Start time
|
||||
t = time.strftime(
|
||||
'%Y-%m-%d %H:%M', time.localtime(i.game_start_time))
|
||||
cnf['text'] = t
|
||||
l = ttk.Label(**cnf)
|
||||
l.grid(row=row, column=3, sticky='ew')
|
||||
label = ttk.Label(**cnf)
|
||||
label.grid(row=row, column=3, sticky='ew')
|
||||
# Result
|
||||
if isinstance(i.value, float):
|
||||
# time
|
||||
|
@ -718,8 +718,8 @@ class _TopDialog(MfxDialog):
|
|||
# moves
|
||||
s = str(i.value)
|
||||
cnf['text'] = s
|
||||
l = ttk.Label(**cnf)
|
||||
l.grid(row=row, column=4, sticky='ew')
|
||||
label = ttk.Label(**cnf)
|
||||
label.grid(row=row, column=4, sticky='ew')
|
||||
row += 1
|
||||
|
||||
focus = self.createButtons(bottom_frame, kw)
|
||||
|
@ -945,7 +945,7 @@ class ProgressionFrame(ttk.Frame):
|
|||
fn = self.app.dataloader.findImage('progression', dir)
|
||||
self.bg_image = loadImage(fn)
|
||||
canvas.create_image(0, 0, image=self.bg_image, anchor='nw')
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
#
|
||||
tw = max(measure(_('Games/day')),
|
||||
|
|
|
@ -50,9 +50,9 @@ class MfxTreeBaseNode:
|
|||
|
||||
def registerKey(self):
|
||||
if self.key is not None:
|
||||
l = self.tree.keys.get(self.key, [])
|
||||
l.append(self)
|
||||
self.tree.keys[self.key] = l
|
||||
lst = self.tree.keys.get(self.key, [])
|
||||
lst.append(self)
|
||||
self.tree.keys[self.key] = lst
|
||||
|
||||
def whoami(self):
|
||||
if self.parent_node is None:
|
||||
|
|
|
@ -127,7 +127,7 @@ class MfxDialog: # ex. _ToplevelDialog
|
|||
key = unicode(key, locale.getpreferredencoding())
|
||||
else:
|
||||
key = unicode(key, 'utf-8')
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
key = key.lower()
|
||||
|
@ -247,10 +247,10 @@ class MfxDialog: # ex. _ToplevelDialog
|
|||
widget.grid(
|
||||
column=column, row=0, sticky="nse", padx=padx, pady=pady)
|
||||
if focus is not None:
|
||||
def l(event=None, w=focus):
|
||||
def cb(event=None, w=focus):
|
||||
return w.event_generate('<<Invoke>>')
|
||||
bind(self.top, "<Return>", l)
|
||||
bind(self.top, "<KP_Enter>", l)
|
||||
bind(self.top, "<Return>", cb)
|
||||
bind(self.top, "<KP_Enter>", cb)
|
||||
# right justify
|
||||
frame.columnconfigure(sep_column, weight=1)
|
||||
return focus
|
||||
|
|
|
@ -178,7 +178,7 @@ class PysolToolbarTk:
|
|||
relief=TkSettings.toolbar_relief,
|
||||
borderwidth=TkSettings.toolbar_borderwidth)
|
||||
#
|
||||
for l, f, t in (
|
||||
for label, f, t in (
|
||||
(n_("New"), self.mNewGame, _("New game")),
|
||||
(n_("Restart"), self.mRestart, _("Restart the\ncurrent game")),
|
||||
(None, None, None),
|
||||
|
@ -196,13 +196,13 @@ class PysolToolbarTk:
|
|||
(None, None, None),
|
||||
(n_("Quit"), self.mQuit, _("Quit ")+TITLE),
|
||||
):
|
||||
if l is None:
|
||||
if label is None:
|
||||
sep = self._createSeparator()
|
||||
sep.bind("<3>", self.rightclickHandler)
|
||||
elif l == 'Pause':
|
||||
self._createButton(l, f, check=True, tooltip=t)
|
||||
elif label == 'Pause':
|
||||
self._createButton(label, f, check=True, tooltip=t)
|
||||
else:
|
||||
self._createButton(l, f, tooltip=t)
|
||||
self._createButton(label, f, tooltip=t)
|
||||
self.pause_button.config(variable=menubar.tkopt.pause)
|
||||
|
||||
self.popup = MfxMenu(master=None, label=n_('Toolbar'), tearoff=0)
|
||||
|
@ -424,9 +424,9 @@ class PysolToolbarTk:
|
|||
continue
|
||||
name = w.toolbar_name
|
||||
data.append((name, w))
|
||||
l = self.player_label
|
||||
label = self.player_label
|
||||
aspect = (400, 300)[size != 0]
|
||||
l.config(aspect=aspect)
|
||||
label.config(aspect=aspect)
|
||||
for name, w in data:
|
||||
self._setButtonImage(w, name)
|
||||
self.setCompound(self.compound, force=True)
|
||||
|
|
|
@ -185,11 +185,11 @@ class FontsDialog(MfxDialog):
|
|||
title = self._font2title(font)
|
||||
elif font is None:
|
||||
title = 'Default'
|
||||
l = tkinter.Label(frame, font=font, text=title)
|
||||
l.grid(row=row, column=1)
|
||||
label = tkinter.Label(frame, font=font, text=title)
|
||||
label.grid(row=row, column=1)
|
||||
b = tkinter.Button(frame, text=_('Change...'), width=10,
|
||||
command=lambda l=l,
|
||||
fn=fn: self.selectFont(l, fn))
|
||||
command=lambda label=label,
|
||||
fn=fn: self.selectFont(label, fn))
|
||||
b.grid(row=row, column=2)
|
||||
row += 1
|
||||
#
|
||||
|
|
|
@ -380,7 +380,7 @@ class SelectCardsetDialogWithPreview(MfxDialog):
|
|||
for n in names:
|
||||
f = os.path.join(cs.dir, n + cs.ext)
|
||||
self.preview_images.append(loadImage(file=f))
|
||||
except:
|
||||
except Exception:
|
||||
self.preview_key = -1
|
||||
self.preview_images = []
|
||||
return
|
||||
|
@ -452,12 +452,12 @@ class CardsetInfoDialog(MfxDialog):
|
|||
(_('Size:'), '%d x %d' % (cardset.CARDW, cardset.CARDH)),
|
||||
):
|
||||
if t is not None:
|
||||
l = tkinter.Label(info_frame, text=n,
|
||||
label = tkinter.Label(info_frame, text=n,
|
||||
anchor='w', justify='left')
|
||||
l.grid(row=row, column=0, sticky='nw')
|
||||
l = tkinter.Label(info_frame, text=t,
|
||||
label.grid(row=row, column=0, sticky='nw')
|
||||
label = tkinter.Label(info_frame, text=t,
|
||||
anchor='w', justify='left')
|
||||
l.grid(row=row, column=1, sticky='nw')
|
||||
label.grid(row=row, column=1, sticky='nw')
|
||||
row += 1
|
||||
if images:
|
||||
try:
|
||||
|
@ -474,7 +474,7 @@ class CardsetInfoDialog(MfxDialog):
|
|||
canvas.grid(row=0, column=2, rowspan=row+1, sticky='ne')
|
||||
info_frame.columnconfigure(2, weight=1)
|
||||
info_frame.rowconfigure(row, weight=1)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
# bg = top_frame["bg"]
|
||||
bg = 'white'
|
||||
|
@ -492,7 +492,7 @@ class CardsetInfoDialog(MfxDialog):
|
|||
f = os.path.join(cardset.dir, "COPYRIGHT")
|
||||
try:
|
||||
text = open(f).read()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
if text:
|
||||
text_w.config(state="normal")
|
||||
|
|
|
@ -94,6 +94,6 @@ def create_solver_dialog(parent, game):
|
|||
try:
|
||||
solver_dialog.top.wm_deiconify()
|
||||
solver_dialog.top.tkraise()
|
||||
except:
|
||||
except Exception:
|
||||
# traceback.print_exc()
|
||||
solver_dialog = SolverDialog(parent, game)
|
||||
|
|
|
@ -156,23 +156,23 @@ class PysolStatusbar(MfxStatusbar):
|
|||
):
|
||||
self._createLabel(n, tooltip=t, width=w)
|
||||
#
|
||||
l = self._createLabel('info', expand=True)
|
||||
l.config(padding=(8, 0))
|
||||
label = self._createLabel('info', expand=True)
|
||||
label.config(padding=(8, 0))
|
||||
|
||||
|
||||
class HelpStatusbar(MfxStatusbar):
|
||||
def __init__(self, top):
|
||||
MfxStatusbar.__init__(self, top, row=4, column=0, columnspan=3)
|
||||
l = self._createLabel('info', expand=True)
|
||||
l.config(justify='left', anchor='w', padx=8)
|
||||
label = self._createLabel('info', expand=True)
|
||||
label.config(justify='left', anchor='w', padx=8)
|
||||
|
||||
|
||||
class HtmlStatusbar(MfxStatusbar):
|
||||
def __init__(self, top, row, column, columnspan):
|
||||
MfxStatusbar.__init__(
|
||||
self, top, row=row, column=column, columnspan=columnspan)
|
||||
l = self._createLabel('url', expand=True)
|
||||
l.config(justify='left', anchor='w', padx=8)
|
||||
label = self._createLabel('url', expand=True)
|
||||
label.config(justify='left', anchor='w', padx=8)
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
|
|
@ -125,7 +125,7 @@ class HTMLViewer(Base_HTMLViewer):
|
|||
def tkhtml_main(args):
|
||||
try:
|
||||
url = args[1]
|
||||
except:
|
||||
except Exception:
|
||||
url = os.path.join(os.pardir, os.pardir, "data", "html", "index.html")
|
||||
top = tkinter.Tk()
|
||||
top.wm_minsize(400, 200)
|
||||
|
|
|
@ -131,10 +131,11 @@ class SingleGame_StatsDialog(MfxDialog):
|
|||
self.fg = c.option_get('foreground', '') or c.cget("insertbackground")
|
||||
#
|
||||
c.create_rectangle(2, 7, w, h, fill="", outline="#7f7f7f")
|
||||
l = tkinter.Label(c, text=text, font=self.font, bd=0, padx=3, pady=1)
|
||||
label = tkinter.Label(c, text=text, font=self.font, bd=0, padx=3,
|
||||
pady=1)
|
||||
dy = int(self.font_metrics['ascent']) - 10
|
||||
dy //= 2
|
||||
c.create_window(20, -dy, window=l, anchor="nw")
|
||||
c.create_window(20, -dy, window=label, anchor="nw")
|
||||
|
||||
def _createChartTexts(self, tx, ty, won, lost):
|
||||
c, tfont, fg = self.canvas, self.font, self.fg
|
||||
|
@ -678,34 +679,34 @@ class _TopDialog(MfxDialog):
|
|||
frame.columnconfigure(0, weight=1)
|
||||
cnf['master'] = frame
|
||||
cnf['text'] = _('N')
|
||||
l = tkinter.Label(**cnf)
|
||||
l.grid(row=0, column=0, sticky='ew')
|
||||
label = tkinter.Label(**cnf)
|
||||
label.grid(row=0, column=0, sticky='ew')
|
||||
cnf['text'] = _('Game number')
|
||||
l = tkinter.Label(**cnf)
|
||||
l.grid(row=0, column=1, sticky='ew')
|
||||
label = tkinter.Label(**cnf)
|
||||
label.grid(row=0, column=1, sticky='ew')
|
||||
cnf['text'] = _('Started at')
|
||||
l = tkinter.Label(**cnf)
|
||||
l.grid(row=0, column=2, sticky='ew')
|
||||
label = tkinter.Label(**cnf)
|
||||
label.grid(row=0, column=2, sticky='ew')
|
||||
cnf['text'] = _('Result')
|
||||
l = tkinter.Label(**cnf)
|
||||
l.grid(row=0, column=3, sticky='ew')
|
||||
label = tkinter.Label(**cnf)
|
||||
label.grid(row=0, column=3, sticky='ew')
|
||||
|
||||
row = 1
|
||||
for i in top:
|
||||
# N
|
||||
cnf['text'] = str(row)
|
||||
l = tkinter.Label(**cnf)
|
||||
l.grid(row=row, column=0, sticky='ew')
|
||||
label = tkinter.Label(**cnf)
|
||||
label.grid(row=row, column=0, sticky='ew')
|
||||
# Game number
|
||||
cnf['text'] = '#'+str(i.game_number)
|
||||
l = tkinter.Label(**cnf)
|
||||
l.grid(row=row, column=1, sticky='ew')
|
||||
label = tkinter.Label(**cnf)
|
||||
label.grid(row=row, column=1, sticky='ew')
|
||||
# Start time
|
||||
t = time.strftime(
|
||||
'%Y-%m-%d %H:%M', time.localtime(i.game_start_time))
|
||||
cnf['text'] = t
|
||||
l = tkinter.Label(**cnf)
|
||||
l.grid(row=row, column=2, sticky='ew')
|
||||
label = tkinter.Label(**cnf)
|
||||
label.grid(row=row, column=2, sticky='ew')
|
||||
# Result
|
||||
if isinstance(i.value, float):
|
||||
# time
|
||||
|
@ -714,8 +715,8 @@ class _TopDialog(MfxDialog):
|
|||
# moves
|
||||
s = str(i.value)
|
||||
cnf['text'] = s
|
||||
l = tkinter.Label(**cnf)
|
||||
l.grid(row=row, column=3, sticky='ew')
|
||||
label = tkinter.Label(**cnf)
|
||||
label.grid(row=row, column=3, sticky='ew')
|
||||
row += 1
|
||||
|
||||
focus = self.createButtons(bottom_frame, kw)
|
||||
|
@ -864,7 +865,7 @@ class ProgressionDialog(MfxDialog):
|
|||
fn = app.dataloader.findImage('progression', dir)
|
||||
self.bg_image = loadImage(fn)
|
||||
canvas.create_image(0, 0, image=self.bg_image, anchor='nw')
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
#
|
||||
tw = max(measure(_('Games/day')),
|
||||
|
|
|
@ -50,9 +50,9 @@ class MfxTreeBaseNode:
|
|||
|
||||
def registerKey(self):
|
||||
if self.key is not None:
|
||||
l = self.tree.keys.get(self.key, [])
|
||||
l.append(self)
|
||||
self.tree.keys[self.key] = l
|
||||
lst = self.tree.keys.get(self.key, [])
|
||||
lst.append(self)
|
||||
self.tree.keys[self.key] = lst
|
||||
|
||||
def whoami(self):
|
||||
if self.parent_node is None:
|
||||
|
|
|
@ -91,13 +91,13 @@ class MfxDialog: # ex. _ToplevelDialog
|
|||
unbind_destroy(self.top)
|
||||
try:
|
||||
self.top.wm_withdraw()
|
||||
except:
|
||||
except Exception:
|
||||
if traceback:
|
||||
traceback.print_exc()
|
||||
pass
|
||||
try:
|
||||
self.top.destroy()
|
||||
except:
|
||||
except Exception:
|
||||
if traceback:
|
||||
traceback.print_exc()
|
||||
pass
|
||||
|
@ -110,7 +110,7 @@ class MfxDialog: # ex. _ToplevelDialog
|
|||
self.parent.busyUpdate()
|
||||
else:
|
||||
self.parent.update()
|
||||
except:
|
||||
except Exception:
|
||||
if traceback:
|
||||
traceback.print_exc()
|
||||
pass
|
||||
|
@ -246,10 +246,10 @@ class MfxDialog: # ex. _ToplevelDialog
|
|||
column += 1
|
||||
b.grid(column=column, row=0, sticky="ns", padx=padx, pady=pady)
|
||||
if focus is not None:
|
||||
l = (lambda event=None, self=self, button=kw.default:
|
||||
cb = (lambda event=None, self=self, button=kw.default:
|
||||
self.mDone(button))
|
||||
bind(self.top, "<Return>", l)
|
||||
bind(self.top, "<KP_Enter>", l)
|
||||
bind(self.top, "<Return>", cb)
|
||||
bind(self.top, "<KP_Enter>", cb)
|
||||
frame.columnconfigure(0, weight=1)
|
||||
frame.columnconfigure(99, weight=1)
|
||||
return focus
|
||||
|
|
|
@ -179,7 +179,7 @@ class PysolToolbarTk:
|
|||
self.frame = tkinter.Frame(top, relief=TkSettings.toolbar_relief,
|
||||
bd=TkSettings.toolbar_borderwidth)
|
||||
#
|
||||
for l, f, t in (
|
||||
for label, f, t in (
|
||||
(n_("New"), self.mNewGame, _("New game")),
|
||||
(n_("Restart"), self.mRestart, _("Restart the\ncurrent game")),
|
||||
(None, None, None),
|
||||
|
@ -197,14 +197,14 @@ class PysolToolbarTk:
|
|||
(None, None, None),
|
||||
(n_("Quit"), self.mQuit, _("Quit ")+TITLE),
|
||||
):
|
||||
if l is None:
|
||||
if label is None:
|
||||
sep = self._createSeparator()
|
||||
sep.bind("<1>", self.clickHandler)
|
||||
sep.bind("<3>", self.rightclickHandler)
|
||||
elif l == 'Pause':
|
||||
self._createButton(l, f, check=True, tooltip=t)
|
||||
elif label == 'Pause':
|
||||
self._createButton(label, f, check=True, tooltip=t)
|
||||
else:
|
||||
self._createButton(l, f, tooltip=t)
|
||||
self._createButton(label, f, tooltip=t)
|
||||
self.pause_button.config(variable=menubar.tkopt.pause)
|
||||
|
||||
sep = self._createFlatSeparator()
|
||||
|
@ -437,12 +437,12 @@ class PysolToolbarTk:
|
|||
name = w.toolbar_name
|
||||
image = self._loadImage(name)
|
||||
data.append((name, w, image))
|
||||
except:
|
||||
except Exception:
|
||||
self.dir, self.size = old_dir, old_size
|
||||
return 0
|
||||
l = self.player_label
|
||||
label = self.player_label
|
||||
aspect = (400, 300)[size != 0]
|
||||
l.config(aspect=aspect)
|
||||
label.config(aspect=aspect)
|
||||
for name, w, image in data:
|
||||
w.config(image=image)
|
||||
setattr(self, name + "_image", image)
|
||||
|
|
|
@ -86,12 +86,12 @@ class BaseColorsDialog:
|
|||
self._calcLabel()(
|
||||
frame, text=title, anchor='w',).grid(
|
||||
row=row, column=0, sticky='we')
|
||||
l = tkinter.Label(frame, width=10, height=2,
|
||||
label = tkinter.Label(frame, width=10, height=2,
|
||||
bg=var.get(), textvariable=var)
|
||||
l.grid(row=row, column=1, padx=5)
|
||||
label.grid(row=row, column=1, padx=5)
|
||||
b = self._calcButton()(
|
||||
frame, text=_('Change...'), width=10,
|
||||
command=lambda l=l: self.selectColor(l))
|
||||
command=lambda label=label: self.selectColor(label))
|
||||
b.grid(row=row, column=2)
|
||||
row += 1
|
||||
#
|
||||
|
@ -111,7 +111,7 @@ class BaseColorsDialog:
|
|||
try:
|
||||
c = askcolor(parent=self.top, initialcolor=label.cget('bg'),
|
||||
title=_("Select color"))
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
if c and c[1]:
|
||||
|
|
|
@ -207,7 +207,7 @@ def create_find_card_dialog(parent, game, dir):
|
|||
try:
|
||||
find_card_dialog.wm_deiconify()
|
||||
find_card_dialog.tkraise()
|
||||
except:
|
||||
except Exception:
|
||||
# traceback.print_exc()
|
||||
find_card_dialog = FindCardDialog(parent, game, dir)
|
||||
|
||||
|
@ -215,7 +215,7 @@ def create_find_card_dialog(parent, game, dir):
|
|||
def connect_game_find_card_dialog(game):
|
||||
try:
|
||||
find_card_dialog.connectGame(game)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
|
@ -223,7 +223,7 @@ def destroy_find_card_dialog():
|
|||
global find_card_dialog
|
||||
try:
|
||||
find_card_dialog.destroy()
|
||||
except:
|
||||
except Exception:
|
||||
# traceback.print_exc()
|
||||
pass
|
||||
find_card_dialog = None
|
||||
|
|
|
@ -203,7 +203,7 @@ solver_dialog = None
|
|||
def connect_game_solver_dialog(game):
|
||||
try:
|
||||
solver_dialog.connectGame(game)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
|
@ -211,7 +211,7 @@ def destroy_solver_dialog():
|
|||
global solver_dialog
|
||||
try:
|
||||
solver_dialog.destroy()
|
||||
except:
|
||||
except Exception:
|
||||
# traceback.print_exc()
|
||||
pass
|
||||
solver_dialog = None
|
||||
|
@ -221,6 +221,6 @@ def reset_solver_dialog():
|
|||
if solver_dialog:
|
||||
try:
|
||||
solver_dialog.reset()
|
||||
except:
|
||||
except Exception:
|
||||
# traceback.print_exc()
|
||||
pass
|
||||
|
|
|
@ -313,12 +313,12 @@ class MfxCanvas(tkinter.Canvas):
|
|||
if Image:
|
||||
try:
|
||||
self._bg_img = Image.open(image)
|
||||
except:
|
||||
except Exception:
|
||||
return 0
|
||||
else:
|
||||
try:
|
||||
self._bg_img = loadImage(file=image, dither=1)
|
||||
except:
|
||||
except Exception:
|
||||
return 0
|
||||
self._stretch_bg_image = stretch
|
||||
self._save_aspect_bg_image = save_aspect
|
||||
|
|
|
@ -221,11 +221,11 @@ class Base_HTMLViewer:
|
|||
unbind_destroy(self.parent)
|
||||
try:
|
||||
self.parent.wm_withdraw()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
self.parent.destroy()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
self.parent = None
|
||||
|
||||
|
@ -341,7 +341,7 @@ to open the following URL:
|
|||
self.errorDialog(_("Unable to service request:\n") + url +
|
||||
"\n\n" + str(ex))
|
||||
return
|
||||
except:
|
||||
except Exception:
|
||||
if file:
|
||||
file.close()
|
||||
self.errorDialog(_("Unable to service request:\n") + url)
|
||||
|
@ -438,7 +438,7 @@ to open the following URL:
|
|||
return self.images[fn]
|
||||
try:
|
||||
img = tkinter.PhotoImage(master=self.parent, file=fn)
|
||||
except:
|
||||
except Exception:
|
||||
img = None
|
||||
self.images[fn] = img
|
||||
return img
|
||||
|
|
|
@ -59,11 +59,11 @@ def wm_get_geometry(window):
|
|||
m = __wm_get_geometry_re.search(g)
|
||||
if not m:
|
||||
raise tkinter.TclError("invalid geometry "+str(g))
|
||||
l = list(map(int, m.groups()))
|
||||
lst = list(map(int, m.groups()))
|
||||
if window.wm_state() == "zoomed":
|
||||
# workaround as Tk returns the "unzoomed" origin
|
||||
l[2] = l[3] = 0
|
||||
return l
|
||||
lst[2] = lst[3] = 0
|
||||
return lst
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
@ -135,7 +135,7 @@ def __getWidgetXY(widget, parent, relx=None, rely=None,
|
|||
if WIN_SYSTEM == "win32":
|
||||
try:
|
||||
m_width, m_height, m_x, m_y = wm_get_geometry(parent)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
if m_x is None:
|
||||
m_x = parent.winfo_x()
|
||||
|
@ -324,11 +324,11 @@ def fillImage(image, fill, outline=None):
|
|||
assert len(f) == height
|
||||
image.put(f)
|
||||
elif not fill:
|
||||
l = ((outline,) * width,)
|
||||
l1 = ((outline,) * width,)
|
||||
for y in range(0, ow):
|
||||
image.put(l, (0, y))
|
||||
image.put(l1, (0, y))
|
||||
for y in range(height-ow, height):
|
||||
image.put(l, (0, y))
|
||||
image.put(l1, (0, y))
|
||||
p = ((outline,) * ow,)
|
||||
for y in range(ow, height-ow):
|
||||
image.put(p, (0, y))
|
||||
|
|
|
@ -44,7 +44,7 @@ def init_tile(app, top):
|
|||
try:
|
||||
top.tk.eval('package require ttk::theme::'+t)
|
||||
# print 'load theme:', t
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
pass
|
||||
|
||||
|
@ -54,7 +54,7 @@ def set_theme(app, top, theme):
|
|||
style = ttk.Style(top)
|
||||
try:
|
||||
style.theme_use(theme)
|
||||
except:
|
||||
except Exception:
|
||||
print_err(_('invalid theme name: ') + theme)
|
||||
style.theme_use(app.opt.default_tile_theme)
|
||||
|
||||
|
@ -66,7 +66,7 @@ def get_font_name(font):
|
|||
font_name = None
|
||||
try:
|
||||
f = Font(font=font)
|
||||
except:
|
||||
except Exception:
|
||||
print_err(_('invalid font name: ') + font)
|
||||
if DEBUG:
|
||||
traceback.print_exc()
|
||||
|
|
|
@ -52,21 +52,21 @@ def init_root_window(root, app):
|
|||
if os.path.exists(f):
|
||||
try:
|
||||
root.tk.evalfile(f)
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
f = 'clrpick8.5.tcl'
|
||||
f = os.path.join(app.dataloader.dir, 'tcl', f)
|
||||
if os.path.exists(f):
|
||||
try:
|
||||
root.tk.evalfile(f)
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
f = 'fsdialog8.5.tcl'
|
||||
f = os.path.join(app.dataloader.dir, 'tcl', f)
|
||||
if os.path.exists(f):
|
||||
try:
|
||||
root.tk.evalfile(f)
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
else:
|
||||
from six.moves import tkinter_tkfiledialog
|
||||
|
|
|
@ -32,11 +32,11 @@ def encode_layout(layout):
|
|||
y_max = max([t[2] for t in layout])
|
||||
for x in range(x_max+1):
|
||||
for y in range(y_max+1):
|
||||
l = [t[0] for t in layout if t[1] == x and t[2] == y]
|
||||
if not l:
|
||||
mylist = [t[0] for t in layout if t[1] == x and t[2] == y]
|
||||
if not mylist:
|
||||
continue
|
||||
i_0 = i_n = l[0]
|
||||
for i in l[1:]:
|
||||
i_0 = i_n = mylist[0]
|
||||
for i in mylist[1:]:
|
||||
if i == i_n+1:
|
||||
i_n = i
|
||||
continue
|
||||
|
@ -81,17 +81,17 @@ def parse_kyodai(filename):
|
|||
|
||||
def parse_ace(filename):
|
||||
# Ace of Penguins (http://www.delorie.com/store/ace/)
|
||||
l = open(filename).read().replace('\n', '').split(',')
|
||||
l.reverse()
|
||||
mylist = open(filename).read().replace('\n', '').split(',')
|
||||
mylist.reverse()
|
||||
layout = []
|
||||
layer = 0
|
||||
while True:
|
||||
x = int(l.pop())
|
||||
x = int(mylist.pop())
|
||||
if x == 127:
|
||||
break
|
||||
if x <= 0:
|
||||
x = -x
|
||||
y, z = int(l.pop()), int(l.pop())
|
||||
y, z = int(mylist.pop()), int(mylist.pop())
|
||||
if layer < z:
|
||||
layer = z
|
||||
layout.append((z, x, y))
|
||||
|
@ -141,14 +141,14 @@ def parse_xmahjongg(filename):
|
|||
return normalize(layout)
|
||||
|
||||
|
||||
def normalize(l):
|
||||
minx = min([i[1] for i in l])
|
||||
def normalize(mylist):
|
||||
minx = min([i[1] for i in mylist])
|
||||
if minx:
|
||||
l = [(i[0], i[1]-minx, i[2]) for i in l]
|
||||
miny = min([i[2] for i in l])
|
||||
mylist = [(i[0], i[1]-minx, i[2]) for i in mylist]
|
||||
miny = min([i[2] for i in mylist])
|
||||
if miny:
|
||||
l = [(i[0], i[1], i[2]-miny) for i in l]
|
||||
return l
|
||||
mylist = [(i[0], i[1], i[2]-miny) for i in mylist]
|
||||
return mylist
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -32,7 +32,7 @@ root = tkinter.Tk()
|
|||
root.withdraw()
|
||||
try:
|
||||
root.tk.call('package', 'require', 'tile', '0.7.8')
|
||||
except:
|
||||
except Exception:
|
||||
TILE = None
|
||||
else:
|
||||
TILE = "tile0.7.8"
|
||||
|
|
Loading…
Add table
Reference in a new issue