1
0
Fork 0
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:
Shlomi Fish 2017-11-04 20:15:52 +02:00
parent 5c85816641
commit 38bfb88971
55 changed files with 565 additions and 553 deletions

View file

@ -23,12 +23,12 @@ eval('import pysollib.games.special')
try: try:
os.mkdir('html') os.mkdir('html')
except: except Exception:
pass pass
try: try:
os.mkdir('html/rules') os.mkdir('html/rules')
except: except Exception:
pass pass
pysollib_path = os.path.join(sys.path[0], pysollib_dir) pysollib_path = os.path.join(sys.path[0], pysollib_dir)

View file

@ -425,13 +425,13 @@ class Application:
# try to load statistics # try to load statistics
try: try:
self.loadStatistics() self.loadStatistics()
except: except Exception:
traceback.print_exc() traceback.print_exc()
pass pass
# try to load comments # try to load comments
try: try:
self.loadComments() self.loadComments()
except: except Exception:
traceback.print_exc() traceback.print_exc()
pass pass
# startup information # startup information
@ -444,7 +444,7 @@ class Application:
game = None game = None
try: try:
game = tmpgame._loadGame(self.fn.holdgame, self) game = tmpgame._loadGame(self.fn.holdgame, self)
except: except Exception:
traceback.print_exc() traceback.print_exc()
game = None game = None
if game: if game:
@ -463,7 +463,7 @@ class Application:
self.nextgame.loadedgame = tmpgame._loadGame( self.nextgame.loadedgame = tmpgame._loadGame(
self.commandline.loadgame, self) self.commandline.loadgame, self)
self.nextgame.loadedgame.gstats.holded = 0 self.nextgame.loadedgame.gstats.holded = 0
except: except Exception:
traceback.print_exc() traceback.print_exc()
self.nextgame.loadedgame = None self.nextgame.loadedgame = None
elif self.commandline.game is not None: elif self.commandline.game is not None:
@ -541,7 +541,7 @@ class Application:
self.game.gstats.holded = 1 self.game.gstats.holded = 1
self.game._saveGame(self.fn.holdgame) self.game._saveGame(self.fn.holdgame)
self.opt.game_holded = self.game.id self.opt.game_holded = self.game.id
except: except Exception:
traceback.print_exc() traceback.print_exc()
pass pass
self.wm_save_state() self.wm_save_state()
@ -573,25 +573,25 @@ class Application:
# save options # save options
try: try:
self.saveOptions() self.saveOptions()
except: except Exception:
traceback.print_exc() traceback.print_exc()
pass pass
# save statistics # save statistics
try: try:
self.saveStatistics() self.saveStatistics()
except: except Exception:
traceback.print_exc() traceback.print_exc()
pass pass
# save comments # save comments
try: try:
self.saveComments() self.saveComments()
except: except Exception:
traceback.print_exc() traceback.print_exc()
pass pass
# shut down audio # shut down audio
try: try:
self.audio.destroy() self.audio.destroy()
except: except Exception:
traceback.print_exc() traceback.print_exc()
pass pass
@ -1074,7 +1074,7 @@ Please select a %s type %s.
self.opt.__dict__.update(opt.__dict__) self.opt.__dict__.update(opt.__dict__)
try: try:
os.remove(self.fn.opt) os.remove(self.fn.opt)
except: except Exception:
pass pass
self.opt.load(self.fn.opt_cfg) self.opt.load(self.fn.opt_cfg)
self.opt.setConstants() self.opt.setConstants()

View file

@ -2904,9 +2904,9 @@ Congratulations, you did it !
# try to detect a redo move in order to keep our history # try to detect a redo move in order to keep our history
redo = 0 redo = 0
if moves.index + 1 < len(moves.history): if moves.index + 1 < len(moves.history):
l, m = len(current), moves.history[moves.index] mylen, m = len(current), moves.history[moves.index]
if l == len(m): if mylen == len(m):
for i in range(l): for i in range(mylen):
a1 = current[i] a1 = current[i]
a2 = m[i] a2 = m[i]
if a1.__class__ is not a2.__class__ or \ if a1.__class__ is not a2.__class__ or \
@ -3022,7 +3022,7 @@ Congratulations, you did it !
try: try:
self._dumpGame(p, bookmark=2) self._dumpGame(p, bookmark=2)
bm = (file.getvalue(), self.moves.index) bm = (file.getvalue(), self.moves.index)
except: except Exception:
pass pass
else: else:
self.gsaveinfo.bookmarks[n] = bm self.gsaveinfo.bookmarks[n] = bm
@ -3049,7 +3049,7 @@ Congratulations, you did it !
assert game.id == self.id assert game.id == self.id
# save state for undoGotoBookmark # save state for undoGotoBookmark
self.setBookmark(-1, confirm=0) self.setBookmark(-1, confirm=0)
except: except Exception:
del self.gsaveinfo.bookmarks[n] del self.gsaveinfo.bookmarks[n]
self.setCursor(cursor=self.app.top_cursor) self.setCursor(cursor=self.app.top_cursor)
else: else:
@ -3093,7 +3093,7 @@ but this could also be a bug you might want to report."""))
self.setCursor(cursor=self.app.top_cursor) self.setCursor(cursor=self.app.top_cursor)
MfxExceptionDialog(self.top, ex, title=_("Load game error"), MfxExceptionDialog(self.top, ex, title=_("Load game error"),
text=_("Error while loading game")) text=_("Error while loading game"))
except: except Exception:
self.updateMenus() self.updateMenus()
self.setCursor(cursor=self.app.top_cursor) self.setCursor(cursor=self.app.top_cursor)
MfxMessageDialog(self.top, title=_("Load game error"), MfxMessageDialog(self.top, title=_("Load game error"),

View file

@ -640,9 +640,9 @@ class GameManager:
def getGamesIdSortedById(self): def getGamesIdSortedById(self):
if self.__games_by_id is None: if self.__games_by_id is None:
l = list(self.__games.keys()) lst = list(self.__games.keys())
l.sort() lst.sort()
self.__games_by_id = tuple(l) self.__games_by_id = tuple(lst)
return self.__games_by_id return self.__games_by_id
def getGamesIdSortedByName(self): def getGamesIdSortedByName(self):

View file

@ -283,8 +283,8 @@ class RoyalFamily(Cruel):
RowStack_Class = UD_AC_RowStack RowStack_Class = UD_AC_RowStack
def createGame(self): def createGame(self):
l = Cruel.createGame(self) lay = Cruel.createGame(self)
l.createRoundText(self.s.talon, 'sw') lay.createRoundText(self.s.talon, 'sw')
def _shuffleHook(self, cards): def _shuffleHook(self, cards):
# move Kings to bottom of the Talon (i.e. last cards to be dealt) # 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 RowStack_Class = UD_SS_RowStack
def createGame(self): def createGame(self):
l = Cruel.createGame(self) lay = Cruel.createGame(self)
l.createRoundText(self.s.talon, 'sw') lay.createRoundText(self.s.talon, 'sw')
def _shuffleHook(self, cards): def _shuffleHook(self, cards):
# move Aces to bottom of the Talon (i.e. last cards to be dealt) # 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 Solver_Class = None
def createGame(self): def createGame(self):
l = Cruel.createGame(self) lay = Cruel.createGame(self)
l.createRoundText(self.s.talon, 'sw') lay.createRoundText(self.s.talon, 'sw')
def _shuffleHook(self, cards): def _shuffleHook(self, cards):
# move Kings to bottom of each stack (???) # move Kings to bottom of each stack (???)

View file

@ -346,9 +346,9 @@ class CastlesEnd(Bastion):
ReserveStack_Class = CastlesEnd_Reserve ReserveStack_Class = CastlesEnd_Reserve
def createGame(self): def createGame(self):
l = Bastion.createGame(self) lay = Bastion.createGame(self)
self.base_rank = None 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') font = self.app.getFont('canvas_default')
self.texts.info = MfxCanvasText(self.canvas, tx, ty, self.texts.info = MfxCanvasText(self.canvas, tx, ty,
anchor=ta, font=font) anchor=ta, font=font)
@ -423,11 +423,11 @@ class Chessboard(Fortress):
RowStack_Class = StackWrapper(Chessboard_RowStack, mod=13) RowStack_Class = StackWrapper(Chessboard_RowStack, mod=13)
def createGame(self): def createGame(self):
l = Fortress.createGame(self) lay = Fortress.createGame(self)
tx, ty, ta, tf = l.getTextAttr(self.s.foundations[-1], "e") tx, ty, ta, tf = lay.getTextAttr(self.s.foundations[-1], "e")
font = self.app.getFont("canvas_default") font = self.app.getFont("canvas_default")
self.texts.info = MfxCanvasText( 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): def updateText(self):
if self.preview > 1: if self.preview > 1:

View file

@ -85,68 +85,68 @@ class Canfield(Game):
def createGame(self, rows=4, max_rounds=-1, num_deal=3, def createGame(self, rows=4, max_rounds=-1, num_deal=3,
text=True, round_text=False): text=True, round_text=False):
# create layout # create layout
l, s = Layout(self), self.s lay, s = Layout(self), self.s
decks = self.gameinfo.decks decks = self.gameinfo.decks
# set window # set window
if self.INITIAL_RESERVE_FACEUP == 1: if self.INITIAL_RESERVE_FACEUP == 1:
yoffset = l.YOFFSET # min(l.YOFFSET, 14) yoffset = lay.YOFFSET # min(lay.YOFFSET, 14)
else: else:
yoffset = 10 yoffset = 10
if self.INITIAL_RESERVE_CARDS > 30: if self.INITIAL_RESERVE_CARDS > 30:
yoffset = 5 yoffset = 5
# (piles up to 20 cards are playable in default window size) # (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: if round_text:
h += l.TEXT_HEIGHT h += lay.TEXT_HEIGHT
self.setSize( self.setSize(
l.XM + (2+max(rows, 4*decks))*l.XS + l.XM, lay.XM + (2+max(rows, 4*decks))*lay.XS + lay.XM,
l.YM + l.YS + l.TEXT_HEIGHT + h) lay.YM + lay.YS + lay.TEXT_HEIGHT + h)
# extra settings # extra settings
self.base_card = None self.base_card = None
# create stacks # create stacks
x, y = l.XM, l.YM x, y = lay.XM, lay.YM
s.talon = self.Talon_Class(x, y, self, s.talon = self.Talon_Class(x, y, self,
max_rounds=max_rounds, num_deal=num_deal) max_rounds=max_rounds, num_deal=num_deal)
l.createText(s.talon, "s") lay.createText(s.talon, "s")
if round_text: if round_text:
l.createRoundText(s.talon, 'sss') lay.createRoundText(s.talon, 'sss')
x += l.XS x += lay.XS
s.waste = WasteStack(x, y, self) s.waste = WasteStack(x, y, self)
l.createText(s.waste, "s") lay.createText(s.waste, "s")
x += l.XM x += lay.XM
y = l.YM y = lay.YM
for i in range(4): for i in range(4):
for j in range(decks): for j in range(decks):
x += l.XS x += lay.XS
s.foundations.append(self.Foundation_Class(x, y, self, i, s.foundations.append(self.Foundation_Class(x, y, self, i,
mod=13, max_move=0)) mod=13, max_move=0))
if text: if text:
if rows > 4 * decks: if rows > 4 * decks:
tx, ty, ta, tf = l.getTextAttr(None, "se") tx, ty, ta, tf = lay.getTextAttr(None, "se")
tx, ty = x + tx + l.XM, y + ty tx, ty = x + tx + lay.XM, y + ty
else: else:
tx, ty, ta, tf = l.getTextAttr(None, "ss") tx, ty, ta, tf = lay.getTextAttr(None, "ss")
tx, ty = x + tx, y + ty tx, ty = x + tx, y + ty
font = self.app.getFont("canvas_default") font = self.app.getFont("canvas_default")
self.texts.info = MfxCanvasText(self.canvas, tx, ty, self.texts.info = MfxCanvasText(self.canvas, tx, ty,
anchor=ta, font=font) 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: if round_text:
y += l.TEXT_HEIGHT y += lay.TEXT_HEIGHT
s.reserves.append(self.ReserveStack_Class(x, y, self)) s.reserves.append(self.ReserveStack_Class(x, y, self))
s.reserves[0].CARD_YOFFSET = yoffset 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: if text:
y += l.TEXT_HEIGHT y += lay.TEXT_HEIGHT
for i in range(rows): for i in range(rows):
s.rows.append(self.RowStack_Class(x, y, self)) s.rows.append(self.RowStack_Class(x, y, self))
x += l.XS x += lay.XS
# define stack-groups # define stack-groups
l.defaultStackGroups() lay.defaultStackGroups()
# #
# game extras # game extras
@ -359,43 +359,43 @@ class EagleWing(Canfield):
def createGame(self): def createGame(self):
# Canfield.createGame(self, rows=8, max_rounds=3, num_deal=1) # Canfield.createGame(self, rows=8, max_rounds=3, num_deal=1)
# create layout # create layout
l, s = Layout(self), self.s lay, s = Layout(self), self.s
# set window # 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 # extra settings
self.base_card = None self.base_card = None
# create stacks # 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) s.talon = WasteTalonStack(x, y, self, max_rounds=3, num_deal=1)
l.createText(s.talon, "s") lay.createText(s.talon, "s")
l.createRoundText(s.talon, 'ne', dx=l.XS) lay.createRoundText(s.talon, 'ne', dx=lay.XS)
x += l.XS x += lay.XS
s.waste = WasteStack(x, y, self) s.waste = WasteStack(x, y, self)
l.createText(s.waste, "s") lay.createText(s.waste, "s")
for i in range(4): for i in range(4):
x = l.XM + (i+3)*l.XS x = lay.XM + (i+3)*lay.XS
s.foundations.append( s.foundations.append(
self.Foundation_Class(x, y, self, i, mod=13, max_move=0)) self.Foundation_Class(x, y, self, i, mod=13, max_move=0))
tx, ty, ta, tf = l.getTextAttr(None, "se") tx, ty, ta, tf = lay.getTextAttr(None, "se")
tx, ty = x + tx + l.XM, y + ty tx, ty = x + tx + lay.XM, y + ty
font = self.app.getFont("canvas_default") font = self.app.getFont("canvas_default")
self.texts.info = MfxCanvasText( self.texts.info = MfxCanvasText(
self.canvas, tx, ty, anchor=ta, font=font) 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): for i in range(8):
x = l.XM + (i + (i >= 4))*l.XS 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]*l.CH 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)) 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.append(self.ReserveStack_Class(x, y, self))
# s.reserves[0].CARD_YOFFSET = 0 # s.reserves[0].CARD_YOFFSET = 0
l.createText(s.reserves[0], "s") lay.createText(s.reserves[0], "s")
# define stack-groups # define stack-groups
l.defaultStackGroups() lay.defaultStackGroups()
shallHighlightMatch = Game._shallHighlightMatch_SSW shallHighlightMatch = Game._shallHighlightMatch_SSW
@ -414,33 +414,34 @@ class Gate(Game):
def createGame(self): def createGame(self):
# create layout # create layout
l, s = Layout(self), self.s lay, s = Layout(self), self.s
# set window # set window
w, h = max(8*l.XS, 6*l.XS+8*l.XOFFSET), l.YM+3*l.YS+12*l.YOFFSET w = max(8*lay.XS, 6*lay.XS+8*lay.XOFFSET)
self.setSize(w+l.XM, h) h = lay.YM+3*lay.YS+12*lay.YOFFSET
self.setSize(w+lay.XM, h)
# create stacks # create stacks
y = l.YM y = lay.YM
for x in (l.XM, l.XM+w-l.XS-4*l.XOFFSET): for x in (lay.XM, lay.XM+w-lay.XS-4*lay.XOFFSET):
stack = OpenStack(x, y, self, max_accept=0) 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) 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): for i in range(4):
s.foundations.append(SS_FoundationStack(x, y, self, suit=i)) s.foundations.append(SS_FoundationStack(x, y, self, suit=i))
x += l.XS x += lay.XS
x, y = l.XM+(w-8*l.XS)//2, l.YM+l.YS x, y = lay.XM+(w-8*lay.XS)//2, lay.YM+lay.YS
for i in range(8): for i in range(8):
s.rows.append(AC_RowStack(x, y, self)) s.rows.append(AC_RowStack(x, y, self))
x += l.XS x += lay.XS
s.talon = WasteTalonStack(l.XM, h-l.YS, self, max_rounds=1) s.talon = WasteTalonStack(lay.XM, h-lay.YS, self, max_rounds=1)
l.createText(s.talon, "n") lay.createText(s.talon, "n")
s.waste = WasteStack(l.XM+l.XS, h-l.YS, self) s.waste = WasteStack(lay.XM+lay.XS, h-lay.YS, self)
l.createText(s.waste, "n") lay.createText(s.waste, "n")
# define stack-groups # define stack-groups
l.defaultStackGroups() lay.defaultStackGroups()
# #
# game overrides # game overrides
@ -480,36 +481,36 @@ class LittleGate(Gate):
def createGame(self, rows=4): def createGame(self, rows=4):
# create layout # create layout
l, s = Layout(self), self.s lay, s = Layout(self), self.s
# set window # set window
max_rows = max(7, rows+3) 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) self.setSize(w, h)
# create stacks # create stacks
y = l.YM+l.YS+l.TEXT_HEIGHT y = lay.YM+lay.YS+lay.TEXT_HEIGHT
for x in (l.XM, w-l.XS): for x in (lay.XM, w-lay.XS):
stack = self.ReserveStack_Class(x, y, self) 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) 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): for i in range(4):
s.foundations.append(SS_FoundationStack(x, y, self, suit=i)) s.foundations.append(SS_FoundationStack(x, y, self, suit=i))
x += l.XS x += lay.XS
x, y = l.XM+(max_rows-rows)*l.XS//2, l.YM+l.YS+l.TEXT_HEIGHT x, y = lay.XM+(max_rows-rows)*lay.XS//2, lay.YM+lay.YS+lay.TEXT_HEIGHT
for i in range(rows): for i in range(rows):
s.rows.append(self.RowStack_Class(x, y, self)) s.rows.append(self.RowStack_Class(x, y, self))
x += l.XS x += lay.XS
s.talon = WasteTalonStack(l.XM, l.YM, self, max_rounds=1) s.talon = WasteTalonStack(lay.XM, lay.YM, self, max_rounds=1)
l.createText(s.talon, "s") lay.createText(s.talon, "s")
s.waste = WasteStack(l.XM+l.XS, l.YM, self) s.waste = WasteStack(lay.XM+lay.XS, lay.YM, self)
l.createText(s.waste, "s") lay.createText(s.waste, "s")
# define stack-groups # define stack-groups
l.defaultStackGroups() lay.defaultStackGroups()
return l return lay
class Doorway(LittleGate): class Doorway(LittleGate):
@ -519,14 +520,14 @@ class Doorway(LittleGate):
ReserveStack_Class = ReserveStack ReserveStack_Class = ReserveStack
def createGame(self): def createGame(self):
l = LittleGate.createGame(self, rows=5) lay = LittleGate.createGame(self, rows=5)
king_stack, queen_stack = self.s.reserves 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") font = self.app.getFont("canvas_default")
king_stack.texts.misc = MfxCanvasText(self.canvas, tx, ty, king_stack.texts.misc = MfxCanvasText(self.canvas, tx, ty,
anchor=ta, font=font, anchor=ta, font=font,
text=_('King')) 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") font = self.app.getFont("canvas_default")
queen_stack.texts.misc = MfxCanvasText(self.canvas, tx, ty, queen_stack.texts.misc = MfxCanvasText(self.canvas, tx, ty,
anchor=ta, font=font, anchor=ta, font=font,
@ -660,36 +661,37 @@ class Duke(Game):
RowStack_Class = AC_RowStack RowStack_Class = AC_RowStack
def createGame(self): 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, \ w, h = lay.XM + 6*lay.XS + 4*lay.XOFFSET, \
l.YM + l.TEXT_HEIGHT + 2*l.YS + 12*l.YOFFSET lay.YM + lay.TEXT_HEIGHT + 2*lay.YS + 12*lay.YOFFSET
self.setSize(w, h) 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) s.talon = WasteTalonStack(x, y, self, max_rounds=3)
l.createText(s.talon, 's') lay.createText(s.talon, 's')
l.createRoundText(s.talon, 'ne', dx=l.XS) lay.createRoundText(s.talon, 'ne', dx=lay.XS)
x += l.XS x += lay.XS
s.waste = WasteStack(x, y, self) s.waste = WasteStack(x, y, self)
l.createText(s.waste, 's') lay.createText(s.waste, 's')
x += l.XS+4*l.XOFFSET x += lay.XS+4*lay.XOFFSET
y = l.YM y = lay.YM
for i in range(4): for i in range(4):
s.foundations.append(self.Foundation_Class(x, y, self, suit=i)) s.foundations.append(self.Foundation_Class(x, y, self, suit=i))
x += l.XS x += lay.XS
x0, y0, w = l.XM, l.YM+l.YS+2*l.TEXT_HEIGHT, l.XS+2*l.XOFFSET 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)): 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 = 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) 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): for i in range(4):
s.rows.append(self.RowStack_Class(x, y, self)) s.rows.append(self.RowStack_Class(x, y, self))
x += l.XS x += lay.XS
l.defaultStackGroups() lay.defaultStackGroups()
def startGame(self): def startGame(self):
for i in range(3): for i in range(3):
@ -741,51 +743,51 @@ class Skippy(Canfield):
def createGame(self): def createGame(self):
# create layout # create layout
l, s = Layout(self), self.s lay, s = Layout(self), self.s
# set window # set window
playcards = 8 playcards = 8
w0 = l.XS+playcards*l.XOFFSET w0 = lay.XS+playcards*lay.XOFFSET
w = l.XM+l.XS//2+max(10*l.XS, l.XS+4*w0) w = lay.XM+lay.XS//2+max(10*lay.XS, lay.XS+4*w0)
h = l.YM+5*l.YS+l.TEXT_HEIGHT h = lay.YM+5*lay.YS+lay.TEXT_HEIGHT
self.setSize(w, h) self.setSize(w, h)
# extra settings # extra settings
self.base_card = None self.base_card = None
# create stacks # create stacks
x, y = l.XM, l.YM x, y = lay.XM, lay.YM
s.talon = WasteTalonStack(x, y, self, max_rounds=1) s.talon = WasteTalonStack(x, y, self, max_rounds=1)
l.createText(s.talon, 's') lay.createText(s.talon, 's')
x += l.XS x += lay.XS
s.waste = WasteStack(x, y, self) s.waste = WasteStack(x, y, self)
l.createText(s.waste, 's') lay.createText(s.waste, 's')
x = self.width - 8*l.XS x = self.width - 8*lay.XS
for i in range(8): for i in range(8):
s.foundations.append(SS_FoundationStack(x, y, self, s.foundations.append(SS_FoundationStack(x, y, self,
suit=i % 4, mod=13)) suit=i % 4, mod=13))
x += l.XS x += lay.XS
tx, ty, ta, tf = l.getTextAttr(None, "ss") tx, ty, ta, tf = lay.getTextAttr(None, "ss")
tx, ty = x-l.XS+tx, y+ty tx, ty = x-lay.XS+tx, y+ty
font = self.app.getFont("canvas_default") font = self.app.getFont("canvas_default")
self.texts.info = MfxCanvasText(self.canvas, tx, ty, self.texts.info = MfxCanvasText(self.canvas, tx, ty,
anchor=ta, font=font) 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): for i in range(4):
s.reserves.append(ReserveStack(x, y, self)) s.reserves.append(ReserveStack(x, y, self))
y += l.YS y += lay.YS
y = l.YM+l.YS+l.TEXT_HEIGHT y = lay.YM+lay.YS+lay.TEXT_HEIGHT
for i in range(4): 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): for j in range(4):
stack = RK_RowStack(x, y, self, max_move=1, mod=13) stack = RK_RowStack(x, y, self, max_move=1, mod=13)
s.rows.append(stack) s.rows.append(stack)
stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0 stack.CARD_XOFFSET, stack.CARD_YOFFSET = lay.XOFFSET, 0
x += w0 x += w0
y += l.YS y += lay.YS
# define stack-groups # define stack-groups
l.defaultStackGroups() lay.defaultStackGroups()
def startGame(self): def startGame(self):
self.base_card = None self.base_card = None
@ -818,32 +820,33 @@ class Skippy(Canfield):
class Lafayette(Game): class Lafayette(Game):
def createGame(self): def createGame(self):
l, s = Layout(self), self.s lay, s = Layout(self), self.s
self.setSize(l.XM+8*l.XS, l.YM+2*l.YS+12*l.YOFFSET) 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): for i in range(4):
s.foundations.append(SS_FoundationStack(x, y, self, suit=i)) 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)) base_rank=KING, dir=-1))
x += l.XS x += lay.XS
x, y = l.XM, l.YM+l.YS x, y = lay.XM, lay.YM+lay.YS
s.talon = WasteTalonStack(x, y, self, max_rounds=UNLIMITED_REDEALS, s.talon = WasteTalonStack(x, y, self, max_rounds=UNLIMITED_REDEALS,
num_deal=3) num_deal=3)
l.createText(s.talon, 'ne') lay.createText(s.talon, 'ne')
y += l.YS y += lay.YS
s.waste = WasteStack(x, y, self) s.waste = WasteStack(x, y, self)
l.createText(s.waste, 'ne') lay.createText(s.waste, 'ne')
x, y = l.XM+2*l.XS, l.YM+l.YS x, y = lay.XM+2*lay.XS, lay.YM+lay.YS
for i in range(4): for i in range(4):
s.rows.append(AC_RowStack(x, y, self, base_rank=6)) s.rows.append(AC_RowStack(x, y, self, base_rank=6))
x += l.XS x += lay.XS
x += l.XS x += lay.XS
stack = OpenStack(x, y, self) stack = OpenStack(x, y, self)
s.reserves.append(stack) s.reserves.append(stack)
stack.CARD_YOFFSET = l.YOFFSET stack.CARD_YOFFSET = lay.YOFFSET
l.defaultStackGroups() lay.defaultStackGroups()
def startGame(self): def startGame(self):
for i in range(13): for i in range(13):

View file

@ -342,13 +342,13 @@ class ThreeShufflesAndADraw(LaBelleLucie):
ThreeShufflesAndADraw_RowStack, base_rank=NO_RANK) ThreeShufflesAndADraw_RowStack, base_rank=NO_RANK)
def createGame(self): def createGame(self):
l = LaBelleLucie.createGame(self) lay = LaBelleLucie.createGame(self)
s = self.s s = self.s
# add a reserve stack # add a reserve stack
x, y = s.rows[3].x, s.rows[-1].y x, y = s.rows[3].x, s.rows[-1].y
s.reserves.append(ThreeShufflesAndADraw_ReserveStack(x, y, self)) s.reserves.append(ThreeShufflesAndADraw_ReserveStack(x, y, self))
# redefine the stack-groups # redefine the stack-groups
l.defaultStackGroups() lay.defaultStackGroups()
# extra settings # extra settings
self.draw_done = 0 self.draw_done = 0
@ -450,18 +450,18 @@ class Intelligence(Fan):
RowStack_Class = StackWrapper(Intelligence_RowStack, base_rank=NO_RANK) RowStack_Class = StackWrapper(Intelligence_RowStack, base_rank=NO_RANK)
def createGame(self, rows=(5, 5, 5, 3)): def createGame(self, rows=(5, 5, 5, 3)):
l = Fan.createGame(self, rows) lay = Fan.createGame(self, rows)
s = self.s s = self.s
# add a reserve stack # 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( s.reserves.append(
Intelligence_ReserveStack( Intelligence_ReserveStack(
x, y, self, max_move=0, max_accept=0, x, y, self, max_move=0, max_accept=0,
max_cards=UNLIMITED_CARDS)) max_cards=UNLIMITED_CARDS))
l.createText(s.reserves[0], "sw") lay.createText(s.reserves[0], "sw")
l.createRoundText(s.talon, 'nn') lay.createRoundText(s.talon, 'nn')
# redefine the stack-groups # redefine the stack-groups
l.defaultStackGroups() lay.defaultStackGroups()
def startGame(self): def startGame(self):
talon = self.s.talon talon = self.s.talon

View file

@ -235,8 +235,8 @@ class Elevator_RowStack(Golf_RowStack):
def basicIsBlocked(self): def basicIsBlocked(self):
r, step = self.game.s.rows, self.STEP r, step = self.game.s.rows, self.STEP
i, n, l = self.id, 1, len(step) i, n, mylen = self.id, 1, len(step)
while i < l: while i < mylen:
i = i + step[i] i = i + step[i]
n = n + 1 n = n + 1
for j in range(i, i+n): for j in range(i, i+n):

View file

@ -75,24 +75,24 @@ class Klondike(Game):
def createGame(self, max_rounds=-1, num_deal=1, **layout): def createGame(self, max_rounds=-1, num_deal=1, **layout):
# create 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) kwdefault(layout, rows=7, waste=1, texts=1, playcards=16)
self.Layout_Method.__get__(l, l.__class__)(**layout) self.Layout_Method.__get__(lay, lay.__class__)(**layout)
# self.__class__.Layout_Method(l, **layout) # self.__class__.Layout_Method(lay, **layout)
self.setSize(l.size[0], l.size[1]) self.setSize(lay.size[0], lay.size[1])
# create stacks # 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) max_rounds=max_rounds, num_deal=num_deal)
if l.s.waste: if lay.s.waste:
s.waste = WasteStack(l.s.waste.x, l.s.waste.y, self) s.waste = WasteStack(lay.s.waste.x, lay.s.waste.y, self)
for r in l.s.foundations: for r in lay.s.foundations:
s.foundations.append( s.foundations.append(
self.Foundation_Class(r.x, r.y, self, suit=r.suit)) 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)) s.rows.append(self.RowStack_Class(r.x, r.y, self))
# default # default
l.defaultAll() lay.defaultAll()
return l return lay
def startGame(self, flip=0, reverse=1): def startGame(self, flip=0, reverse=1):
for i in range(1, len(self.s.rows)): for i in range(1, len(self.s.rows)):
@ -115,11 +115,11 @@ class VegasKlondike(Klondike):
getGameBalance = Game.getGameScoreCasino getGameBalance = Game.getGameScoreCasino
def createGame(self, max_rounds=1): 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, self.texts.score = MfxCanvasText(self.canvas,
8, self.height - 8, anchor="sw", 8, self.height - 8, anchor="sw",
font=self.app.getFont("canvas_large")) font=self.app.getFont("canvas_large"))
return l return lay
def updateText(self): def updateText(self):
if self.preview > 1: if self.preview > 1:
@ -140,8 +140,8 @@ class VegasKlondike(Klondike):
class CasinoKlondike(VegasKlondike): class CasinoKlondike(VegasKlondike):
def createGame(self): def createGame(self):
l = VegasKlondike.createGame(self, max_rounds=3) lay = VegasKlondike.createGame(self, max_rounds=3)
l.createRoundText(self.s.talon, 'ne', dx=l.XS) lay.createRoundText(self.s.talon, 'ne', dx=lay.XS)
# ************************************************************************ # ************************************************************************
@ -174,9 +174,9 @@ class Chinaman(ThumbAndPouch):
RowStack_Class = StackWrapper(BO_RowStack, base_rank=KING) RowStack_Class = StackWrapper(BO_RowStack, base_rank=KING)
def createGame(self): def createGame(self):
l = Klondike.createGame(self, num_deal=3, lay = Klondike.createGame(self, num_deal=3,
max_rounds=2, round_text=True) 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): class BlindAlleys(Eastcliff):
def createGame(self): def createGame(self):
l = Klondike.createGame(self, max_rounds=2, rows=6, round_text=True) lay = Klondike.createGame(self, max_rounds=2, rows=6, round_text=True)
l.createRoundText(self.s.talon, 'ne', dx=l.XS) lay.createRoundText(self.s.talon, 'ne', dx=lay.XS)
def _shuffleHook(self, cards): def _shuffleHook(self, cards):
# move Aces to top of the Talon (i.e. first cards to be dealt) # move Aces to top of the Talon (i.e. first cards to be dealt)
@ -345,9 +345,9 @@ class Usk(Somerset):
Solver_Class = None Solver_Class = None
def createGame(self): 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) waste=False, texts=False, round_text=True)
l.createRoundText(self.s.talon, 'ne') lay.createRoundText(self.s.talon, 'ne')
def redealCards(self): def redealCards(self):
n = 0 n = 0
@ -435,8 +435,8 @@ class EightTimesEight(Klondike):
class AchtmalAcht(EightTimesEight): class AchtmalAcht(EightTimesEight):
def createGame(self): def createGame(self):
l = Klondike.createGame(self, rows=8, max_rounds=3, round_text=True) lay = Klondike.createGame(self, rows=8, max_rounds=3, round_text=True)
l.createRoundText(self.s.talon, 'sw', dx=-l.XS) lay.createRoundText(self.s.talon, 'sw', dx=-lay.XS)
class EightByEight_RowStack(RK_RowStack): class EightByEight_RowStack(RK_RowStack):
@ -454,9 +454,9 @@ class EightByEight(EightTimesEight):
RowStack_Class = EightByEight_RowStack RowStack_Class = EightByEight_RowStack
def createGame(self): 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) 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 shallHighlightMatch = Game._shallHighlightMatch_RK
@ -482,17 +482,18 @@ class Batsford(Klondike):
kwdefault(layout, rows=10, max_rounds=1, playcards=22) kwdefault(layout, rows=10, max_rounds=1, playcards=22)
round_text = (layout['max_rounds'] > 1) round_text = (layout['max_rounds'] > 1)
layout['round_text'] = round_text layout['round_text'] = round_text
l = Klondike.createGame(self, **layout) lay = Klondike.createGame(self, **layout)
s = self.s 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)) s.reserves.append(Batsford_ReserveStack(x, y, self, max_cards=3))
self.setRegion( 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) priority=1)
l.createText(s.reserves[0], "se") lay.createText(s.reserves[0], "se")
if round_text: if round_text:
l.createRoundText(self.s.talon, 'ne', dx=l.XS) lay.createRoundText(self.s.talon, 'ne', dx=lay.XS)
l.defaultStackGroups() lay.defaultStackGroups()
class BatsfordAgain(Batsford): class BatsfordAgain(Batsford):
@ -506,8 +507,8 @@ class BatsfordAgain(Batsford):
class Jumbo(Klondike): class Jumbo(Klondike):
def createGame(self): def createGame(self):
l = Klondike.createGame(self, rows=9, max_rounds=2, round_text=True) lay = Klondike.createGame(self, rows=9, max_rounds=2, round_text=True)
l.createRoundText(self.s.talon, 'ne', dx=l.XS) lay.createRoundText(self.s.talon, 'ne', dx=lay.XS)
def startGame(self, flip=0): def startGame(self, flip=0):
for i in range(9): for i in range(9):
@ -534,15 +535,15 @@ class Stonewall(Klondike):
DEAL = (0, 1, 0, 1, -1, 0, 1) DEAL = (0, 1, 0, 1, -1, 0, 1)
def createGame(self): 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 s = self.s
h = max(self.height, l.YM+4*l.YS) h = max(self.height, lay.YM+4*lay.YS)
self.setSize(self.width + l.XM+4*l.XS, h) self.setSize(self.width + lay.XM+4*lay.XS, h)
for i in range(4): for i in range(4):
for j 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)) s.reserves.append(OpenStack(x, y, self, max_accept=0))
l.defaultStackGroups() lay.defaultStackGroups()
def startGame(self): def startGame(self):
frames = 0 frames = 0
@ -580,17 +581,17 @@ class KingAlbert(Klondike):
RESERVES = (2, 2, 2, 1) RESERVES = (2, 2, 2, 1)
def createGame(self): def createGame(self):
l = Klondike.createGame( lay = Klondike.createGame(
self, max_rounds=1, rows=self.ROWS, waste=0, texts=0) self, max_rounds=1, rows=self.ROWS, waste=0, texts=0)
s = self.s s = self.s
rw, rh = max(self.RESERVES), len(self.RESERVES) rw, rh = max(self.RESERVES), len(self.RESERVES)
h = max(self.height, l.YM+rh*l.YS) h = max(self.height, lay.YM+rh*lay.YS)
self.setSize(self.width + 2*l.XM+rw*l.XS, h) self.setSize(self.width + 2*lay.XM+rw*lay.XS, h)
for i in range(rh): for i in range(rh):
for j in range(self.RESERVES[i]): 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)) s.reserves.append(OpenStack(x, y, self, max_accept=0))
l.defaultStackGroups() lay.defaultStackGroups()
def startGame(self): def startGame(self):
Klondike.startGame(self, flip=1, reverse=0) 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) RowStack_Class = StackWrapper(AC_RowStack, mod=13, base_rank=NO_RANK)
def createGame(self, max_rounds=1, rows=7, reserves=7, playcards=16): 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) maxrows = max(rows, 7)
w = l.XM+maxrows*l.XS+l.XM+2*l.XS w = lay.XM+maxrows*lay.XS+lay.XM+2*lay.XS
h = max(l.YM+2*l.YS+playcards*l.YOFFSET+l.TEXT_HEIGHT, l.YM+4*l.YS) h = max(lay.YM+2*lay.YS+playcards*lay.YOFFSET+lay.TEXT_HEIGHT,
lay.YM+4*lay.YS)
self.setSize(w, h) 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) s.talon = self.Talon_Class(x, y, self, max_rounds=max_rounds)
l.createText(s.talon, 's') lay.createText(s.talon, 's')
x += l.XS x += lay.XS
s.waste = WasteStack(x, y, self) s.waste = WasteStack(x, y, self)
x += 2*l.XS x += 2*lay.XS
for i in range(4): for i in range(4):
s.foundations.append(self.Foundation_Class(x, y, self, suit=i)) 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): for i in range(rows):
s.rows.append(self.RowStack_Class(x, y, self)) 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): 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 = OpenStack(x, y, self, max_accept=0)
stack.CARD_YOFFSET = l.YM // 3 stack.CARD_YOFFSET = lay.YM // 3
s.reserves.append(stack) 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 # 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) # priority=1)
l.defaultStackGroups() lay.defaultStackGroups()
self.sg.dropstacks.append(s.talon) self.sg.dropstacks.append(s.talon)
def startGame(self, flip=0, reverse=1): def startGame(self, flip=0, reverse=1):
@ -748,33 +750,34 @@ class Senate(Jane):
playcards = 10 playcards = 10
l, s = Layout(self), self.s lay, s = Layout(self), self.s
self.setSize(l.XM+(rows+7)*l.XS, l.YM+2*(l.YS+playcards*l.YOFFSET)) 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): for i in range(rows):
s.rows.append(SS_RowStack(x, y, self)) 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: for y in lay.YM, lay.YM+lay.YS+playcards*lay.YOFFSET:
x = l.XM+rows*l.XS+l.XS//2 x = lay.XM+rows*lay.XS+lay.XS//2
for i in range(4): for i in range(4):
stack = OpenStack(x, y, self, max_accept=0) 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) s.reserves.append(stack)
x += l.XS x += lay.XS
x = l.XM+(rows+5)*l.XS x = lay.XM+(rows+5)*lay.XS
for i in range(2): for i in range(2):
y = l.YM+l.YS y = lay.YM+lay.YS
for j in range(4): for j in range(4):
s.foundations.append(SS_FoundationStack(x, y, self, suit=j)) s.foundations.append(SS_FoundationStack(x, y, self, suit=j))
y += l.YS y += lay.YS
x += l.XS x += lay.XS
x, y = self.width-l.XS, l.YM x, y = self.width-lay.XS, lay.YM
s.talon = AgnesBernauer_Talon(x, y, self) s.talon = AgnesBernauer_Talon(x, y, self)
l.createText(s.talon, 'nw') lay.createText(s.talon, 'nw')
l.defaultStackGroups() lay.defaultStackGroups()
def startGame(self): def startGame(self):
self.s.talon.dealRow(rows=self.s.foundations, frames=0) self.s.talon.dealRow(rows=self.s.foundations, frames=0)
@ -808,29 +811,29 @@ class Phoenix(Klondike):
def createGame(self): def createGame(self):
l, s = Layout(self), self.s lay, s = Layout(self), self.s
self.setSize(l.XM + 10*l.XS, l.YM + 4*(l.YS+l.YM)) self.setSize(lay.XM + 10*lay.XS, lay.YM + 4*(lay.YS+lay.YM))
for i in range(2): for i in range(2):
x = l.XM + i*l.XS x = lay.XM + i*lay.XS
for j in range(4): 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)) s.reserves.append(OpenStack(x, y, self, max_accept=0))
for i in range(2): for i in range(2):
x = l.XM + (8+i)*l.XS x = lay.XM + (8+i)*lay.XS
for j in range(4): 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)) s.reserves.append(OpenStack(x, y, self, max_accept=0))
for i in range(4): for i in range(4):
s.foundations.append( 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): for i in range(6):
s.rows.append( 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( 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): def startGame(self):
for i in range(6): for i in range(6):
@ -856,8 +859,8 @@ class Lanes(Klondike):
RowStack_Class = StackWrapper(AC_RowStack, base_rank=ANY_RANK, max_move=1) RowStack_Class = StackWrapper(AC_RowStack, base_rank=ANY_RANK, max_move=1)
def createGame(self): def createGame(self):
l = Klondike.createGame(self, rows=6, max_rounds=2, round_text=True) lay = Klondike.createGame(self, rows=6, max_rounds=2, round_text=True)
l.createRoundText(self.s.talon, 'ne', dx=l.XS) lay.createRoundText(self.s.talon, 'ne', dx=lay.XS)
def _shuffleHook(self, cards): def _shuffleHook(self, cards):
# move Aces to top of the Talon (i.e. first cards to be dealt) # 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) RowStack_Class = StackWrapper(SS_RowStack, base_rank=ANY_RANK, max_move=1)
def createGame(self): def createGame(self):
l = Klondike.createGame(self, rows=6, max_rounds=2) lay = Klondike.createGame(self, rows=6, max_rounds=2)
l.createRoundText(self.s.talon, 'sss') lay.createRoundText(self.s.talon, 'sss')
def startGame(self): def startGame(self):
for i in range(3): for i in range(3):
@ -1044,30 +1047,30 @@ class SevenDevils(Klondike):
def createGame(self): def createGame(self):
l, s = Layout(self), self.s lay, s = Layout(self), self.s
self.setSize(l.XM + 10*l.XS, l.YM+3*l.YS+12*l.YOFFSET) 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): for i in range(8):
s.foundations.append(SS_FoundationStack(x, y, self, suit=i//2)) s.foundations.append(SS_FoundationStack(x, y, self, suit=i//2))
x += l.XS x += lay.XS
x, y = l.XM+l.XS//2, l.YM+l.YS x, y = lay.XM+lay.XS//2, lay.YM+lay.YS
for i in range(7): for i in range(7):
s.rows.append(self.RowStack_Class(x, y, self)) 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(7): 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)) s.reserves.append(OpenStack(x, y, self, max_accept=0))
y += l.YS // 2 y += lay.YS // 2
x, y = l.XM, self.height-l.YS x, y = lay.XM, self.height-lay.YS
s.talon = WasteTalonStack(x, y, self, max_rounds=1) s.talon = WasteTalonStack(x, y, self, max_rounds=1)
l.createText(s.talon, 'n') lay.createText(s.talon, 'n')
x += l.XS x += lay.XS
s.waste = WasteStack(x, y, self) 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): def startGame(self, flip=0, reverse=1):
Klondike.startGame(self) Klondike.startGame(self)
@ -1099,9 +1102,9 @@ class MovingLeft(Klondike):
class Souter(MovingLeft): class Souter(MovingLeft):
def createGame(self): 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) 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): class Boost(Klondike):
def createGame(self): def createGame(self):
l = Klondike.createGame(self, rows=4, max_rounds=3, round_text=True) lay = Klondike.createGame(self, rows=4, max_rounds=3, round_text=True)
l.createRoundText(self.s.talon, 'ne', dx=l.XS) lay.createRoundText(self.s.talon, 'ne', dx=lay.XS)
# ************************************************************************ # ************************************************************************
@ -1198,8 +1201,8 @@ class GoldRush(Klondike):
Talon_Class = CanfieldRush_Talon Talon_Class = CanfieldRush_Talon
def createGame(self): def createGame(self):
l = Klondike.createGame(self, max_rounds=3, round_text=True) lay = Klondike.createGame(self, max_rounds=3, round_text=True)
l.createRoundText(self.s.talon, 'ne', dx=l.XS) 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) RowStack_Class = StackWrapper(RK_RowStack, base_rank=NO_RANK)
def createGame(self, xoffset=0, playcards=0): def createGame(self, xoffset=0, playcards=0):
l, s = Layout(self), self.s lay, s = Layout(self), self.s
if xoffset: if xoffset:
xoffset = l.XOFFSET xoffset = lay.XOFFSET
w0 = l.XS+playcards*l.XOFFSET w0 = lay.XS+playcards*lay.XOFFSET
self.setSize(l.XM + 5*w0, l.YM+4*l.YS) 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): for i in range(5):
stack = self.RowStack_Class(x, y, self, max_move=1) stack = self.RowStack_Class(x, y, self, max_move=1)
s.rows.append(stack) s.rows.append(stack)
stack.CARD_XOFFSET = xoffset stack.CARD_XOFFSET = xoffset
stack.CARD_YOFFSET = 0 stack.CARD_YOFFSET = 0
x += w0 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): for i in range(3):
stack = self.RowStack_Class(x, y, self, max_move=1) stack = self.RowStack_Class(x, y, self, max_move=1)
s.rows.append(stack) s.rows.append(stack)
stack.CARD_XOFFSET = xoffset stack.CARD_XOFFSET = xoffset
stack.CARD_YOFFSET = 0 stack.CARD_YOFFSET = 0
x += w0 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): for i in range(5):
stack = self.RowStack_Class(x, y, self, max_move=1) stack = self.RowStack_Class(x, y, self, max_move=1)
s.rows.append(stack) s.rows.append(stack)
stack.CARD_XOFFSET = xoffset stack.CARD_XOFFSET = xoffset
stack.CARD_YOFFSET = 0 stack.CARD_YOFFSET = 0
x += w0 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): for i in range(4):
s.foundations.append(SS_FoundationStack(x, y, self, suit=i)) s.foundations.append(SS_FoundationStack(x, y, self, suit=i))
x += l.XS x += lay.XS
x, y = l.XM, self.height-l.YS x, y = lay.XM, self.height-lay.YS
s.talon = InitialDealTalonStack(x, y, self, max_rounds=1) s.talon = InitialDealTalonStack(x, y, self, max_rounds=1)
l.defaultStackGroups() lay.defaultStackGroups()
def startGame(self): def startGame(self):
self.s.talon.dealRow(frames=0) self.s.talon.dealRow(frames=0)
@ -1311,32 +1314,32 @@ class Legion(Klondike):
class BigBertha(Game): class BigBertha(Game):
def createGame(self): def createGame(self):
l, s = Layout(self), self.s lay, s = Layout(self), self.s
self.setSize(l.XM+15*l.XS, l.YM+3*l.YS+15*l.YOFFSET) 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) 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): for i in range(8):
s.foundations.append(SS_FoundationStack(x, y, self, s.foundations.append(SS_FoundationStack(x, y, self,
suit=i % 4, max_cards=12)) 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): for i in range(15):
s.rows.append(AC_RowStack(x, y, self)) 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): for i in range(14):
s.reserves.append(OpenStack(x, y, self, max_accept=0)) 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, s.foundations.append(RK_FoundationStack(x, y, self, suit=ANY_SUIT,
base_rank=KING, dir=0, max_cards=8)) base_rank=KING, dir=0, max_cards=8))
l.defaultStackGroups() lay.defaultStackGroups()
def startGame(self): def startGame(self):
for i in range(5): for i in range(5):
@ -1406,9 +1409,9 @@ class EightSages(Klondike):
RowStack_Class = EightSages_Row RowStack_Class = EightSages_Row
def createGame(self): 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) 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): def startGame(self):
self.startDealSample() self.startDealSample()

View file

@ -759,7 +759,7 @@ class AnnoDomini(Numerica):
RowStack_Class = StackWrapper(AC_RowStack, mod=13) RowStack_Class = StackWrapper(AC_RowStack, mod=13)
def createGame(self): def createGame(self):
l = Numerica.createGame( lay = Numerica.createGame(
self, max_rounds=3, waste_max_cards=UNLIMITED_CARDS) self, max_rounds=3, waste_max_cards=UNLIMITED_CARDS)
year = str(time.localtime()[0]) year = str(time.localtime()[0])
i = 0 i = 0
@ -772,7 +772,7 @@ class AnnoDomini(Numerica):
d = JACK d = JACK
s.cap.base_rank = d s.cap.base_rank = d
i += 1 i += 1
l.createRoundText(self.s.talon, 'nn') lay.createRoundText(self.s.talon, 'nn')
def startGame(self): def startGame(self):
self.startDealSample() self.startDealSample()

View file

@ -528,13 +528,14 @@ class GreatWall(AbstractFlowerGame):
return return
for i in range(4): for i in range(4):
stack = self.s.foundations[i] stack = self.s.foundations[i]
l = len(stack.cards) // 12 mylen = len(stack.cards) // 12
if l == 0: if mylen == 0:
text = "" text = ""
elif l == 4: elif mylen == 4:
text = _("Filled") text = _("Filled")
else: else:
text = str(l) + (_("st"), _("nd"), _("rd"), _("th"))[l - 1] \ text = str(mylen) + \
(_("st"), _("nd"), _("rd"), _("th"))[mylen - 1] \
+ _(" Deck") + _(" Deck")
stack.texts.misc.config(text=text) stack.texts.misc.config(text=text)

View file

@ -189,11 +189,11 @@ class Matrix3(Game):
if self.busy: if self.busy:
return 0 return 0
s = self.s.rows s = self.s.rows
l = len(s) - 1 mylen = len(s) - 1
for r in s[:l]: for r in s[:mylen]:
if not r.cards or not r.cards[0].rank == r.id: if not r.cards or not r.cards[0].rank == r.id:
return 0 return 0
self.s.talon.dealRow(rows=s[l:], frames=0) self.s.talon.dealRow(rows=s[mylen:], frames=0)
return 1 return 1
def shallHighlightMatch(self, stack1, card1, stack2, card2): def shallHighlightMatch(self, stack1, card1, stack2, card2):

View file

@ -153,8 +153,8 @@ class Grandfather(RussianSolitaire):
Talon_Class = StackWrapper(Grandfather_Talon, max_rounds=3) Talon_Class = StackWrapper(Grandfather_Talon, max_rounds=3)
def createGame(self): def createGame(self):
l = Yukon.createGame(self) layout = Yukon.createGame(self)
l.createRoundText(self.s.talon, 'nn') layout.createRoundText(self.s.talon, 'nn')
def startGame(self): def startGame(self):
frames = 0 frames = 0
@ -309,14 +309,15 @@ class Abacus(Rushdike):
RowStack_Class = Abacus_RowStack RowStack_Class = Abacus_RowStack
def createGame(self): def createGame(self):
l = Rushdike.createGame(self) layout = Rushdike.createGame(self)
help = (_('''\ help = (_('''\
Club: A 2 3 4 5 6 7 8 9 T J Q K 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 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 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''')) Diamond: 4 8 Q 3 7 J 2 6 T A 5 9 K'''))
self.texts.help = MfxCanvasText(self.canvas, self.texts.help = MfxCanvasText(self.canvas,
l.XM, self.height - l.YM, text=help, layout.XM, self.height - layout.YM,
text=help,
anchor="sw", anchor="sw",
font=self.app.getFont("canvas_fixed")) font=self.app.getFont("canvas_fixed"))
@ -405,21 +406,21 @@ class TenAcross(Yukon):
def createGame(self, **layout): def createGame(self, **layout):
# create layout # create layout
l, s = Layout(self), self.s lay, s = Layout(self), self.s
kwdefault(layout, rows=10, reserves=2, texts=0) kwdefault(layout, rows=10, reserves=2, texts=0)
self.Layout_Method(l, **layout) self.Layout_Method(lay, **layout)
self.setSize(l.size[0], l.size[1]) self.setSize(lay.size[0], lay.size[1])
# create stacks # create stacks
s.talon = InitialDealTalonStack(l.s.talon.x, l.s.talon.y, self) s.talon = InitialDealTalonStack(lay.s.talon.x, lay.s.talon.y, self)
for r in l.s.foundations: for r in lay.s.foundations:
self.s.foundations.append( self.s.foundations.append(
self.Foundation_Class(r.x, r.y, self, suit=r.suit)) 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)) 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)) self.s.reserves.append(ReserveStack(r.x, r.y, self))
# default # default
l.defaultAll() lay.defaultAll()
# #
# game overrides # game overrides

View file

@ -132,7 +132,7 @@ def help_html(app, document, dir_, top=None):
# viewer = None # viewer = None
viewer.updateHistoryXYView() viewer.updateHistoryXYView()
viewer.display(doc, relpath=0) viewer.display(doc, relpath=0)
except: except Exception:
# traceback.print_exc() # traceback.print_exc()
top = make_help_toplevel(app, title=TITLE+_(" Help")) top = make_help_toplevel(app, title=TITLE+_(" Help"))
if top.winfo_screenwidth() < 800 or top.winfo_screenheight() < 600: 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(): def destroy_help_html():
try: try:
help_html_viewer.destroy() help_html_viewer.destroy()
except: except Exception:
pass pass

View file

@ -86,7 +86,7 @@ class Images:
return None return None
try: try:
img = loadImage(file=f) img = loadImage(file=f)
except: except Exception:
return None return None
w, h = img.width(), img.height() w, h = img.width(), img.height()
if self.CARDW < 0: if self.CARDW < 0:
@ -103,7 +103,7 @@ class Images:
d = os.path.join('images', 'cards', 'bottoms') d = os.path.join('images', 'cards', 'bottoms')
try: try:
imagedir = self.d.findDir(cs_type, d) imagedir = self.d.findDir(cs_type, d)
except: except Exception:
pass pass
if not USE_PIL or imagedir is None: if not USE_PIL or imagedir is None:
# load image # load image
@ -117,7 +117,7 @@ class Images:
d = os.path.join('images', 'cards', 'bottoms', cs_type) d = os.path.join('images', 'cards', 'bottoms', cs_type)
try: try:
fn = self.d.findImage(filename, d) fn = self.d.findImage(filename, d)
except: except Exception:
fn = None fn = None
img = createBottom(self._card[0], color, fn) img = createBottom(self._card[0], color, fn)
return img return img

View file

@ -38,9 +38,9 @@ def init():
if os.name == 'nt' and 'LANG' not in os.environ: if os.name == 'nt' and 'LANG' not in os.environ:
try: try:
l = locale.getdefaultlocale() loc = locale.getdefaultlocale()
os.environ['LANG'] = l[0] os.environ['LANG'] = loc[0]
except: except Exception:
pass pass
# locale.setlocale(locale.LC_ALL, '') # locale.setlocale(locale.LC_ALL, '')
@ -66,7 +66,7 @@ def init():
if 'PYSOL_DEBUG' in os.environ: if 'PYSOL_DEBUG' in os.environ:
try: try:
pysollib.settings.DEBUG = int(os.environ['PYSOL_DEBUG']) pysollib.settings.DEBUG = int(os.environ['PYSOL_DEBUG'])
except: except Exception:
pysollib.settings.DEBUG = 1 pysollib.settings.DEBUG = 1
print(('PySol debugging: set DEBUG to', pysollib.settings.DEBUG)) print(('PySol debugging: set DEBUG to', pysollib.settings.DEBUG))
@ -135,7 +135,7 @@ def init():
pysollib.settings.USE_FREECELL_SOLVER = True pysollib.settings.USE_FREECELL_SOLVER = True
if os.name == 'posix': if os.name == 'posix':
os.wait() # kill zombi os.wait() # kill zombi
except: except Exception:
# traceback.print_exc() # traceback.print_exc()
pass pass
os.environ['FREECELL_SOLVER_QUIET'] = '1' os.environ['FREECELL_SOLVER_QUIET'] = '1'

View file

@ -174,7 +174,7 @@ def pysol_init(app, args):
if not os.path.exists(d): if not os.path.exists(d):
try: try:
os.makedirs(d) os.makedirs(d)
except: except Exception:
traceback.print_exc() traceback.print_exc()
pass pass
@ -191,7 +191,7 @@ def pysol_init(app, args):
# load options # load options
try: try:
app.loadOptions() app.loadOptions()
except: except Exception:
traceback.print_exc() traceback.print_exc()
pass pass
@ -232,7 +232,7 @@ def pysol_init(app, args):
app.dn.plugins): app.dn.plugins):
try: try:
app.loadPlugins(dir) app.loadPlugins(dir)
except: except Exception:
pass pass
GAME_DB.setCallback(None) GAME_DB.setCallback(None)
@ -257,7 +257,7 @@ def pysol_init(app, args):
app.audio = c() app.audio = c()
app.audio.startServer() app.audio.startServer()
app.audio.connectServer(app) app.audio.connectServer(app)
except: except Exception:
pass pass
else: else:
# success # success

View file

@ -145,7 +145,7 @@ def win32_getusername():
user = os.environ.get('USERNAME', '').strip() user = os.environ.get('USERNAME', '').strip()
try: try:
user = unicode(user, locale.getpreferredencoding()) user = unicode(user, locale.getpreferredencoding())
except: except Exception:
user = '' user = ''
return user return user
@ -304,6 +304,6 @@ def openURL(url):
webbrowser.open(url) webbrowser.open(url)
except OSError: # raised on windows if link is unreadable except OSError: # raised on windows if link is unreadable
pass pass
except: except Exception:
return 0 return 0
return 1 return 1

View file

@ -235,9 +235,9 @@ class ATurnStackMove(AtomicMove):
to_stack = game.allstacks[self.to_stack_id] to_stack = game.allstacks[self.to_stack_id]
assert len(from_stack.cards) > 0 assert len(from_stack.cards) > 0
assert len(to_stack.cards) == 0 assert len(to_stack.cards) == 0
l = len(from_stack.cards) mylen = len(from_stack.cards)
for i in range(l): for i in range(mylen):
# unhide = (i >= l - 2) # unhide = (i >= mylen - 2)
unhide = 1 unhide = 1
# print 1, unhide, from_stack.getCard().__dict__ # print 1, unhide, from_stack.getCard().__dict__
card = from_stack.removeCard(unhide=unhide, update=0) card = from_stack.removeCard(unhide=unhide, update=0)
@ -254,9 +254,9 @@ class ATurnStackMove(AtomicMove):
to_stack = game.allstacks[self.from_stack_id] to_stack = game.allstacks[self.from_stack_id]
assert len(from_stack.cards) > 0 assert len(from_stack.cards) > 0
assert len(to_stack.cards) == 0 assert len(to_stack.cards) == 0
l = len(from_stack.cards) mylen = len(from_stack.cards)
for i in range(l): for i in range(mylen):
# unhide = (i >= l - 2) # unhide = (i >= mylen - 2)
unhide = 1 unhide = 1
card = from_stack.removeCard(unhide=unhide, update=0) card = from_stack.removeCard(unhide=unhide, update=0)
assert not card.face_up assert not card.face_up

View file

@ -560,7 +560,7 @@ class Options:
val = config[section][key] val = config[section][key]
except KeyError: except KeyError:
val = None val = None
except: except Exception:
print_err('load option error: %s: %s' % (section, key)) print_err('load option error: %s: %s' % (section, key))
traceback.print_exc() traceback.print_exc()
val = None val = None
@ -627,14 +627,14 @@ class Options:
if recent_gameid is not None: if recent_gameid is not None:
try: try:
self.recent_gameid = [int(i) for i in recent_gameid] self.recent_gameid = [int(i) for i in recent_gameid]
except: except Exception:
traceback.print_exc() traceback.print_exc()
favorite_gameid = self._getOption('general', 'favorite_gameid', 'list') favorite_gameid = self._getOption('general', 'favorite_gameid', 'list')
if favorite_gameid is not None: if favorite_gameid is not None:
try: try:
self.favorite_gameid = [int(i) for i in favorite_gameid] self.favorite_gameid = [int(i) for i in favorite_gameid]
except: except Exception:
traceback.print_exc() traceback.print_exc()
visible_buttons = self._getOption('general', 'visible_buttons', 'list') visible_buttons = self._getOption('general', 'visible_buttons', 'list')
@ -663,7 +663,7 @@ class Options:
if val is not None: if val is not None:
try: try:
val[1] = int(val[1]) val[1] = int(val[1])
except: except Exception:
traceback.print_exc() traceback.print_exc()
else: else:
val = tuple(val) val = tuple(val)
@ -687,7 +687,7 @@ class Options:
if val is not None: if val is not None:
try: try:
self.cardset[int(key)] = val self.cardset[int(key)] = val
except: except Exception:
traceback.print_exc() traceback.print_exc()
for key, t in (('scale_cards', 'bool'), for key, t in (('scale_cards', 'bool'),
('scale_x', 'float'), ('scale_x', 'float'),
@ -704,13 +704,13 @@ class Options:
val = [int(i) for i in val] val = [int(i) for i in val]
assert len(val) == 2 assert len(val) == 2
self.games_geometry[int(key)] = val self.games_geometry[int(key)] = val
except: except Exception:
traceback.print_exc() traceback.print_exc()
game_geometry = self._getOption('general', 'game_geometry', 'list') game_geometry = self._getOption('general', 'game_geometry', 'list')
if game_geometry is not None: if game_geometry is not None:
try: try:
self.game_geometry = tuple(int(i) for i in game_geometry) self.game_geometry = tuple(int(i) for i in game_geometry)
except: except Exception:
traceback.print_exc() traceback.print_exc()
# cards offsets # cards offsets
@ -719,5 +719,5 @@ class Options:
val = [int(i) for i in val] val = [int(i) for i in val]
assert len(val) == 2 assert len(val) == 2
self.offsets[key] = val self.offsets[key] = val
except: except Exception:
traceback.print_exc() traceback.print_exc()

View file

@ -70,7 +70,7 @@ class AbstractAudioClient:
try: try:
if self._connectServer(): if self._connectServer():
self.connected = 1 self.connected = 1
except: except Exception:
if traceback: if traceback:
traceback.print_exc() traceback.print_exc()
self.destroy() self.destroy()
@ -102,7 +102,7 @@ class AbstractAudioClient:
self.sample_priority = priority self.sample_priority = priority
self.sample_loop = loop self.sample_loop = loop
return 1 return 1
except: except Exception:
if traceback: if traceback:
traceback.print_exc() traceback.print_exc()
return 0 return 0
@ -112,7 +112,7 @@ class AbstractAudioClient:
return return
try: try:
self._stopSamples() self._stopSamples()
except: except Exception:
if traceback: if traceback:
traceback.print_exc() traceback.print_exc()
self.sample_priority = -1 self.sample_priority = -1
@ -123,7 +123,7 @@ class AbstractAudioClient:
return return
try: try:
self._stopSamplesLoop() self._stopSamplesLoop()
except: except Exception:
if traceback: if traceback:
traceback.print_exc() traceback.print_exc()
self.sample_priority = -1 self.sample_priority = -1
@ -184,7 +184,7 @@ class PysolSoundServerModuleClient(AbstractAudioClient):
self.audiodev = pysolsoundserver self.audiodev = pysolsoundserver
self.audiodev.init() self.audiodev.init()
self.server = 1 self.server = 1
except: except Exception:
if traceback: if traceback:
traceback.print_exc() traceback.print_exc()
self.server = None self.server = None
@ -236,7 +236,7 @@ class PysolSoundServerModuleClient(AbstractAudioClient):
% (music.absname, music.index, 0, loop, % (music.absname, music.index, 0, loop,
music.volume)) music.volume))
self.cmd("startqueue") self.cmd("startqueue")
except: except Exception:
if traceback: if traceback:
traceback.print_exc() traceback.print_exc()
@ -253,7 +253,7 @@ class PysolSoundServerModuleClient(AbstractAudioClient):
try: try:
self.cmd("setwavvol %d" % s) self.cmd("setwavvol %d" % s)
self.cmd("setmusvol %d" % m) self.cmd("setmusvol %d" % m)
except: except Exception:
if traceback: if traceback:
traceback.print_exc() traceback.print_exc()
@ -286,7 +286,7 @@ class Win32AudioClient(AbstractAudioClient):
try: try:
a.PlaySound(filename, flags) a.PlaySound(filename, flags)
return 1 return 1
except: except Exception:
pass pass
return 0 return 0
@ -352,7 +352,7 @@ class OSSAudioServer:
# audiodev.close() # audiodev.close()
# self.audiodev = ossaudiodev.open('w') # self.audiodev = ossaudiodev.open('w')
return 1 return 1
except: except Exception:
if traceback: if traceback:
traceback.print_exc() traceback.print_exc()
return 0 return 0
@ -373,7 +373,7 @@ class OSSAudioServer:
self.sound_priority = priority self.sound_priority = priority
self._busy = False self._busy = False
return 1 return 1
except: except Exception:
if traceback: if traceback:
traceback.print_exc() traceback.print_exc()
self._busy = False self._busy = False
@ -469,7 +469,7 @@ class PyGameAudioClient(AbstractAudioClient):
self.sound = self.mixer.Sound(filename) self.sound = self.mixer.Sound(filename)
self.sound.set_volume(vol) self.sound.set_volume(vol)
self.sound_channel = self.sound.play(loop) self.sound_channel = self.sound.play(loop)
except: except Exception:
if traceback: if traceback:
traceback.print_exc() traceback.print_exc()
pass pass
@ -501,7 +501,7 @@ class PyGameAudioClient(AbstractAudioClient):
while self.music and self.music.get_busy(): while self.music and self.music.get_busy():
self._wait(200) self._wait(200)
self._wait(300) self._wait(300)
except: except Exception:
# if traceback: traceback.print_exc() # if traceback: traceback.print_exc()
self._wait(1000) self._wait(1000)

View file

@ -206,7 +206,7 @@ class SelectCardsetDialogWithPreview(MfxDialog):
for n in names: for n in names:
f = os.path.join(cs.dir, n + cs.ext) f = os.path.join(cs.dir, n + cs.ext)
self.preview_images.append(loadImage(file=f)) self.preview_images.append(loadImage(file=f))
except: except Exception:
self.preview_key = -1 self.preview_key = -1
self.preview_images = [] self.preview_images = []
return return

View file

@ -331,7 +331,7 @@ class HTMLViewer:
try: # if app try: # if app
default_font = self.app.getFont('sans') default_font = self.app.getFont('sans')
fixed_font = self.app.getFont('fixed') fixed_font = self.app.getFont('fixed')
except: except Exception:
traceback.print_exc() traceback.print_exc()
default_font = ('times new roman', 12) default_font = ('times new roman', 12)
fixed_font = ('courier', 12) fixed_font = ('courier', 12)
@ -428,7 +428,7 @@ class HTMLViewer:
# self.app.game.stopDemo() # self.app.game.stopDemo()
# self.app.game._cancelDrag() # self.app.game._cancelDrag()
pass pass
except: except Exception:
pass pass
# ftp: and http: would work if we use urllib, but this widget is # ftp: and http: would work if we use urllib, but this widget is
@ -465,7 +465,7 @@ to open the following URL:
self.errorDialog( self.errorDialog(
_('Unable to service request:\n') + url + '\n\n' + str(ex)) _('Unable to service request:\n') + url + '\n\n' + str(ex))
return return
except: except Exception:
if file: if file:
file.close() file.close()
self.errorDialog(_('Unable to service request:\n') + url) self.errorDialog(_('Unable to service request:\n') + url)
@ -548,7 +548,7 @@ to open the following URL:
return self.images[fn] return self.images[fn]
try: try:
img = gdk.pixbuf_new_from_file(fn) img = gdk.pixbuf_new_from_file(fn)
except: except Exception:
img = None img = None
self.images[fn] = img self.images[fn] = img
return img return img
@ -569,7 +569,7 @@ to open the following URL:
def tkhtml_main(args): def tkhtml_main(args):
try: try:
url = args[1] url = args[1]
except: except Exception:
url = os.path.join(os.pardir, os.pardir, 'data', 'html', 'index.html') url = os.path.join(os.pardir, os.pardir, 'data', 'html', 'index.html')
top = gtk.Window() top = gtk.Window()
table = gtk.Table() table = gtk.Table()

View file

@ -276,9 +276,9 @@ def bind(widget, sequence, func, add=None):
if k in __bindings: if k in __bindings:
__bindings[k].append((wrap, func)) __bindings[k].append((wrap, func))
else: else:
l = [(wrap, func)] lst = [(wrap, func)]
widget.connect(signal, _wrap_event, l) widget.connect(signal, _wrap_event, lst)
__bindings[k] = l __bindings[k] = lst
def unbind_destroy(widget): def unbind_destroy(widget):

View file

@ -111,9 +111,9 @@ class ResourceManager:
def getAllSortedByName(self): def getAllSortedByName(self):
if self._objects_by_name is None: if self._objects_by_name is None:
l = [(obj.getSortKey(), obj) for obj in self._objects] lst = [(obj.getSortKey(), obj) for obj in self._objects]
l.sort() lst.sort()
self._objects_by_name = tuple([item[1] for item in l]) self._objects_by_name = tuple([item[1] for item in lst])
return self._objects_by_name return self._objects_by_name
# #

View file

@ -523,11 +523,12 @@ class Stack:
if from_stack is self or self.basicIsBlocked(): if from_stack is self or self.basicIsBlocked():
return False return False
cap = self.cap cap = self.cap
l = len(cards) mylen = len(cards)
if l < cap.min_accept or l > cap.max_accept: if mylen < cap.min_accept or mylen > cap.max_accept:
return False return False
l = l + len(self.cards) mylen = mylen + len(self.cards)
if l > cap.max_cards: # note: we don't check cap.min_cards here # note: we don't check cap.min_cards here
if mylen > cap.max_cards:
return False return False
for c in cards: for c in cards:
if not c.face_up: if not c.face_up:
@ -557,11 +558,12 @@ class Stack:
if self.basicIsBlocked(): if self.basicIsBlocked():
return False return False
cap = self.cap cap = self.cap
l = len(cards) mylen = len(cards)
if l < cap.min_move or l > cap.max_move: if mylen < cap.min_move or mylen > cap.max_move:
return False return False
l = len(self.cards) - l mylen = len(self.cards) - mylen
if l < cap.min_cards: # note: we don't check cap.max_cards here # note: we don't check cap.max_cards here
if mylen < cap.min_cards:
return False return False
return cardsFaceUp(cards) return cardsFaceUp(cards)
@ -1325,8 +1327,8 @@ class Stack:
def createShadows(self, cards, dx=0, dy=0): def createShadows(self, cards, dx=0, dy=0):
if not self.game.app.opt.shadow or self.canvas.preview > 1: if not self.game.app.opt.shadow or self.canvas.preview > 1:
return () return ()
l = len(cards) mylen = len(cards)
if l == 0 or l > self.max_shadow_cards: if mylen == 0 or mylen > self.max_shadow_cards:
return () return ()
images = self.game.app.images images = self.game.app.images
cx, cy = cards[0].x, cards[0].y 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: if c.x != cx or abs(c.y - cy) != images.CARD_YOFFSET:
return () return ()
cy = c.y cy = c.y
img0, img1 = images.getShadow(0), images.getShadow(l) img0, img1 = images.getShadow(0), images.getShadow(mylen)
c0 = cards[-1] c0 = cards[-1]
if self.CARD_YOFFSET[0] < 0: if self.CARD_YOFFSET[0] < 0:
c0 = cards[0] c0 = cards[0]
@ -1359,7 +1361,7 @@ class Stack:
if c.y != cy or abs(c.x - cx) != images.CARD_XOFFSET: if c.y != cy or abs(c.x - cx) != images.CARD_XOFFSET:
return () return ()
cx = c.x cx = c.x
img0, img1 = images.getShadow(-l), images.getShadow(1) img0, img1 = images.getShadow(-mylen), images.getShadow(1)
c0 = cards[-1] c0 = cards[-1]
if self.CARD_XOFFSET[0] < 0: if self.CARD_XOFFSET[0] < 0:
c0 = cards[0] c0 = cards[0]
@ -1496,12 +1498,12 @@ class Stack:
fill="", outline=color, width=4, fill="", outline=color, width=4,
group=self.group) group=self.group)
drag.shadows.append(r) 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) # fill=color, width=4)
# drag.shadows.append(l) # drag.shadows.append(mylen)
# l = MfxCanvasLine(self.canvas, xx0, yy0+h, xx0+w, yy0, # mylen = MfxCanvasLine(self.canvas, xx0, yy0+h, xx0+w, yy0,
# fill=color, width=4) # fill=color, width=4)
# drag.shadows.append(l) # drag.shadows.append(mylen)
return return
# #
shade = Image.new('RGBA', (w, h)) shade = Image.new('RGBA', (w, h))

View file

@ -181,10 +181,11 @@ class FontsDialog(MfxDialog):
[str(i) for i in font if i not in ('roman', 'normal')]) [str(i) for i in font if i not in ('roman', 'normal')])
elif font is None: elif font is None:
title = 'Default' title = 'Default'
l = ttk.Label(frame, font=font, text=title) label = ttk.Label(frame, font=font, text=title)
l.grid(row=row, column=1, padx=8) label.grid(row=row, column=1, padx=8)
b = ttk.Button(frame, text=_('Change...'), width=10, 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) b.grid(row=row, column=2)
row += 1 row += 1
# #

View file

@ -387,7 +387,7 @@ class SelectCardsetDialogWithPreview(MfxDialog):
for n in names: for n in names:
f = os.path.join(cs.dir, n + cs.ext) f = os.path.join(cs.dir, n + cs.ext)
self.preview_images.append(loadImage(file=f)) self.preview_images.append(loadImage(file=f))
except: except Exception:
self.preview_key = -1 self.preview_key = -1
self.preview_images = [] self.preview_images = []
return return
@ -461,12 +461,12 @@ class CardsetInfoDialog(MfxDialog):
(_('Size:'), '%d x %d' % (cardset.CARDW, cardset.CARDH)), (_('Size:'), '%d x %d' % (cardset.CARDW, cardset.CARDH)),
): ):
if t is not None: if t is not None:
l = ttk.Label(info_frame, text=n, label = ttk.Label(info_frame, text=n,
anchor='w', justify='left') anchor='w', justify='left')
l.grid(row=frow, column=0, sticky='nw', padx=4) label.grid(row=frow, column=0, sticky='nw', padx=4)
l = ttk.Label(info_frame, text=t, label = ttk.Label(info_frame, text=t,
anchor='w', justify='left') 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 frow += 1
if images: if images:
try: try:
@ -474,15 +474,15 @@ class CardsetInfoDialog(MfxDialog):
im = choice(images) im = choice(images)
f = os.path.join(cardset.dir, cardset.backname) f = os.path.join(cardset.dir, cardset.backname)
self.back_image = loadImage(file=f) # store the image self.back_image = loadImage(file=f) # store the image
l = ttk.Label(info_frame, image=im, padding=5) label = ttk.Label(info_frame, image=im, padding=5)
l.grid(row=0, column=2, rowspan=frow+1, sticky='ne') label.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=self.back_image,
padding=(0, 5, 5, 5)) # left margin = 0 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.columnconfigure(2, weight=1)
info_frame.rowconfigure(frow, weight=1) info_frame.rowconfigure(frow, weight=1)
except: except Exception:
pass pass
if USE_PIL: if USE_PIL:
padx = 4 padx = 4
@ -529,7 +529,7 @@ class CardsetInfoDialog(MfxDialog):
f = os.path.join(cardset.dir, "COPYRIGHT") f = os.path.join(cardset.dir, "COPYRIGHT")
try: try:
text = open(f).read() text = open(f).read()
except: except Exception:
pass pass
if text: if text:
text_w.config(state="normal") text_w.config(state="normal")

View file

@ -85,6 +85,6 @@ def create_solver_dialog(parent, game):
try: try:
solver_dialog.top.wm_deiconify() solver_dialog.top.wm_deiconify()
solver_dialog.top.tkraise() solver_dialog.top.tkraise()
except: except Exception:
# traceback.print_exc() # traceback.print_exc()
solver_dialog = SolverDialog(parent, game) solver_dialog = SolverDialog(parent, game)

View file

@ -161,24 +161,24 @@ class PysolStatusbar(MfxStatusbar):
): ):
self._createLabel(n, tooltip=t, width=w) self._createLabel(n, tooltip=t, width=w)
# #
l = self._createLabel('info', expand=True) label = self._createLabel('info', expand=True)
l.config(padding=(8, 0)) label.config(padding=(8, 0))
self._createSizegrip() self._createSizegrip()
class HelpStatusbar(MfxStatusbar): class HelpStatusbar(MfxStatusbar):
def __init__(self, top): def __init__(self, top):
MfxStatusbar.__init__(self, top, row=3, column=0, columnspan=3) MfxStatusbar.__init__(self, top, row=3, column=0, columnspan=3)
l = self._createLabel('info', expand=True) label = self._createLabel('info', expand=True)
l.config(justify='left', anchor='w', padding=(8, 0)) label.config(justify='left', anchor='w', padding=(8, 0))
class HtmlStatusbar(MfxStatusbar): class HtmlStatusbar(MfxStatusbar):
def __init__(self, top, row, column, columnspan): def __init__(self, top, row, column, columnspan):
MfxStatusbar.__init__(self, top, row=row, column=column, MfxStatusbar.__init__(self, top, row=row, column=column,
columnspan=columnspan) columnspan=columnspan)
l = self._createLabel('url', expand=True) label = self._createLabel('url', expand=True)
l.config(justify='left', anchor='w', padding=(8, 0)) label.config(justify='left', anchor='w', padding=(8, 0))
self._createSizegrip() self._createSizegrip()

View file

@ -130,7 +130,7 @@ class HTMLViewer(Base_HTMLViewer):
def tkhtml_main(args): def tkhtml_main(args):
try: try:
url = args[1] url = args[1]
except: except Exception:
url = os.path.join(os.pardir, os.pardir, "data", "html", "index.html") url = os.path.join(os.pardir, os.pardir, "data", "html", "index.html")
top = tkinter.Tk() top = tkinter.Tk()
top.tk.call("package", "require", "tile") top.tk.call("package", "require", "tile")

View file

@ -671,45 +671,45 @@ class _TopDialog(MfxDialog):
frame.columnconfigure(0, weight=1) frame.columnconfigure(0, weight=1)
cnf['master'] = frame cnf['master'] = frame
cnf['text'] = _('N') cnf['text'] = _('N')
l = ttk.Label(**cnf) label = ttk.Label(**cnf)
l.grid(row=0, column=0, sticky='ew') label.grid(row=0, column=0, sticky='ew')
if gameid == 'all': if gameid == 'all':
cnf['text'] = _('Game') cnf['text'] = _('Game')
l = ttk.Label(**cnf) label = ttk.Label(**cnf)
l.grid(row=0, column=1, sticky='ew') label.grid(row=0, column=1, sticky='ew')
cnf['text'] = _('Game number') cnf['text'] = _('Game number')
l = ttk.Label(**cnf) label = ttk.Label(**cnf)
l.grid(row=0, column=2, sticky='ew') label.grid(row=0, column=2, sticky='ew')
cnf['text'] = _('Started at') cnf['text'] = _('Started at')
l = ttk.Label(**cnf) label = ttk.Label(**cnf)
l.grid(row=0, column=3, sticky='ew') label.grid(row=0, column=3, sticky='ew')
cnf['text'] = _('Result') cnf['text'] = _('Result')
l = ttk.Label(**cnf) label = ttk.Label(**cnf)
l.grid(row=0, column=4, sticky='ew') label.grid(row=0, column=4, sticky='ew')
row = 1 row = 1
for i in top: for i in top:
# N # N
cnf['text'] = str(row) cnf['text'] = str(row)
l = ttk.Label(**cnf) label = ttk.Label(**cnf)
l.grid(row=row, column=0, sticky='ew') label.grid(row=row, column=0, sticky='ew')
if gameid == 'all': if gameid == 'all':
name = app.getGameTitleName(i.gameid) name = app.getGameTitleName(i.gameid)
if name is None: if name is None:
name = _("** UNKNOWN %d **") % i.gameid name = _("** UNKNOWN %d **") % i.gameid
cnf['text'] = name cnf['text'] = name
l = ttk.Label(**cnf) label = ttk.Label(**cnf)
l.grid(row=row, column=1, sticky='ew') label.grid(row=row, column=1, sticky='ew')
# Game number # Game number
cnf['text'] = '#'+str(i.game_number) cnf['text'] = '#'+str(i.game_number)
l = ttk.Label(**cnf) label = ttk.Label(**cnf)
l.grid(row=row, column=2, sticky='ew') label.grid(row=row, column=2, sticky='ew')
# Start time # Start time
t = time.strftime( t = time.strftime(
'%Y-%m-%d %H:%M', time.localtime(i.game_start_time)) '%Y-%m-%d %H:%M', time.localtime(i.game_start_time))
cnf['text'] = t cnf['text'] = t
l = ttk.Label(**cnf) label = ttk.Label(**cnf)
l.grid(row=row, column=3, sticky='ew') label.grid(row=row, column=3, sticky='ew')
# Result # Result
if isinstance(i.value, float): if isinstance(i.value, float):
# time # time
@ -718,8 +718,8 @@ class _TopDialog(MfxDialog):
# moves # moves
s = str(i.value) s = str(i.value)
cnf['text'] = s cnf['text'] = s
l = ttk.Label(**cnf) label = ttk.Label(**cnf)
l.grid(row=row, column=4, sticky='ew') label.grid(row=row, column=4, sticky='ew')
row += 1 row += 1
focus = self.createButtons(bottom_frame, kw) focus = self.createButtons(bottom_frame, kw)
@ -945,7 +945,7 @@ class ProgressionFrame(ttk.Frame):
fn = self.app.dataloader.findImage('progression', dir) fn = self.app.dataloader.findImage('progression', dir)
self.bg_image = loadImage(fn) self.bg_image = loadImage(fn)
canvas.create_image(0, 0, image=self.bg_image, anchor='nw') canvas.create_image(0, 0, image=self.bg_image, anchor='nw')
except: except Exception:
pass pass
# #
tw = max(measure(_('Games/day')), tw = max(measure(_('Games/day')),

View file

@ -50,9 +50,9 @@ class MfxTreeBaseNode:
def registerKey(self): def registerKey(self):
if self.key is not None: if self.key is not None:
l = self.tree.keys.get(self.key, []) lst = self.tree.keys.get(self.key, [])
l.append(self) lst.append(self)
self.tree.keys[self.key] = l self.tree.keys[self.key] = lst
def whoami(self): def whoami(self):
if self.parent_node is None: if self.parent_node is None:

View file

@ -127,7 +127,7 @@ class MfxDialog: # ex. _ToplevelDialog
key = unicode(key, locale.getpreferredencoding()) key = unicode(key, locale.getpreferredencoding())
else: else:
key = unicode(key, 'utf-8') key = unicode(key, 'utf-8')
except: except Exception:
pass pass
else: else:
key = key.lower() key = key.lower()
@ -247,10 +247,10 @@ class MfxDialog: # ex. _ToplevelDialog
widget.grid( widget.grid(
column=column, row=0, sticky="nse", padx=padx, pady=pady) column=column, row=0, sticky="nse", padx=padx, pady=pady)
if focus is not None: if focus is not None:
def l(event=None, w=focus): def cb(event=None, w=focus):
return w.event_generate('<<Invoke>>') return w.event_generate('<<Invoke>>')
bind(self.top, "<Return>", l) bind(self.top, "<Return>", cb)
bind(self.top, "<KP_Enter>", l) bind(self.top, "<KP_Enter>", cb)
# right justify # right justify
frame.columnconfigure(sep_column, weight=1) frame.columnconfigure(sep_column, weight=1)
return focus return focus

View file

@ -178,7 +178,7 @@ class PysolToolbarTk:
relief=TkSettings.toolbar_relief, relief=TkSettings.toolbar_relief,
borderwidth=TkSettings.toolbar_borderwidth) borderwidth=TkSettings.toolbar_borderwidth)
# #
for l, f, t in ( for label, f, t in (
(n_("New"), self.mNewGame, _("New game")), (n_("New"), self.mNewGame, _("New game")),
(n_("Restart"), self.mRestart, _("Restart the\ncurrent game")), (n_("Restart"), self.mRestart, _("Restart the\ncurrent game")),
(None, None, None), (None, None, None),
@ -196,13 +196,13 @@ class PysolToolbarTk:
(None, None, None), (None, None, None),
(n_("Quit"), self.mQuit, _("Quit ")+TITLE), (n_("Quit"), self.mQuit, _("Quit ")+TITLE),
): ):
if l is None: if label is None:
sep = self._createSeparator() sep = self._createSeparator()
sep.bind("<3>", self.rightclickHandler) sep.bind("<3>", self.rightclickHandler)
elif l == 'Pause': elif label == 'Pause':
self._createButton(l, f, check=True, tooltip=t) self._createButton(label, f, check=True, tooltip=t)
else: else:
self._createButton(l, f, tooltip=t) self._createButton(label, f, tooltip=t)
self.pause_button.config(variable=menubar.tkopt.pause) self.pause_button.config(variable=menubar.tkopt.pause)
self.popup = MfxMenu(master=None, label=n_('Toolbar'), tearoff=0) self.popup = MfxMenu(master=None, label=n_('Toolbar'), tearoff=0)
@ -424,9 +424,9 @@ class PysolToolbarTk:
continue continue
name = w.toolbar_name name = w.toolbar_name
data.append((name, w)) data.append((name, w))
l = self.player_label label = self.player_label
aspect = (400, 300)[size != 0] aspect = (400, 300)[size != 0]
l.config(aspect=aspect) label.config(aspect=aspect)
for name, w in data: for name, w in data:
self._setButtonImage(w, name) self._setButtonImage(w, name)
self.setCompound(self.compound, force=True) self.setCompound(self.compound, force=True)

View file

@ -185,11 +185,11 @@ class FontsDialog(MfxDialog):
title = self._font2title(font) title = self._font2title(font)
elif font is None: elif font is None:
title = 'Default' title = 'Default'
l = tkinter.Label(frame, font=font, text=title) label = tkinter.Label(frame, font=font, text=title)
l.grid(row=row, column=1) label.grid(row=row, column=1)
b = tkinter.Button(frame, text=_('Change...'), width=10, b = tkinter.Button(frame, text=_('Change...'), width=10,
command=lambda l=l, command=lambda label=label,
fn=fn: self.selectFont(l, fn)) fn=fn: self.selectFont(label, fn))
b.grid(row=row, column=2) b.grid(row=row, column=2)
row += 1 row += 1
# #

View file

@ -380,7 +380,7 @@ class SelectCardsetDialogWithPreview(MfxDialog):
for n in names: for n in names:
f = os.path.join(cs.dir, n + cs.ext) f = os.path.join(cs.dir, n + cs.ext)
self.preview_images.append(loadImage(file=f)) self.preview_images.append(loadImage(file=f))
except: except Exception:
self.preview_key = -1 self.preview_key = -1
self.preview_images = [] self.preview_images = []
return return
@ -452,12 +452,12 @@ class CardsetInfoDialog(MfxDialog):
(_('Size:'), '%d x %d' % (cardset.CARDW, cardset.CARDH)), (_('Size:'), '%d x %d' % (cardset.CARDW, cardset.CARDH)),
): ):
if t is not None: if t is not None:
l = tkinter.Label(info_frame, text=n, label = tkinter.Label(info_frame, text=n,
anchor='w', justify='left') anchor='w', justify='left')
l.grid(row=row, column=0, sticky='nw') label.grid(row=row, column=0, sticky='nw')
l = tkinter.Label(info_frame, text=t, label = tkinter.Label(info_frame, text=t,
anchor='w', justify='left') anchor='w', justify='left')
l.grid(row=row, column=1, sticky='nw') label.grid(row=row, column=1, sticky='nw')
row += 1 row += 1
if images: if images:
try: try:
@ -474,7 +474,7 @@ class CardsetInfoDialog(MfxDialog):
canvas.grid(row=0, column=2, rowspan=row+1, sticky='ne') canvas.grid(row=0, column=2, rowspan=row+1, sticky='ne')
info_frame.columnconfigure(2, weight=1) info_frame.columnconfigure(2, weight=1)
info_frame.rowconfigure(row, weight=1) info_frame.rowconfigure(row, weight=1)
except: except Exception:
pass pass
# bg = top_frame["bg"] # bg = top_frame["bg"]
bg = 'white' bg = 'white'
@ -492,7 +492,7 @@ class CardsetInfoDialog(MfxDialog):
f = os.path.join(cardset.dir, "COPYRIGHT") f = os.path.join(cardset.dir, "COPYRIGHT")
try: try:
text = open(f).read() text = open(f).read()
except: except Exception:
pass pass
if text: if text:
text_w.config(state="normal") text_w.config(state="normal")

View file

@ -94,6 +94,6 @@ def create_solver_dialog(parent, game):
try: try:
solver_dialog.top.wm_deiconify() solver_dialog.top.wm_deiconify()
solver_dialog.top.tkraise() solver_dialog.top.tkraise()
except: except Exception:
# traceback.print_exc() # traceback.print_exc()
solver_dialog = SolverDialog(parent, game) solver_dialog = SolverDialog(parent, game)

View file

@ -156,23 +156,23 @@ class PysolStatusbar(MfxStatusbar):
): ):
self._createLabel(n, tooltip=t, width=w) self._createLabel(n, tooltip=t, width=w)
# #
l = self._createLabel('info', expand=True) label = self._createLabel('info', expand=True)
l.config(padding=(8, 0)) label.config(padding=(8, 0))
class HelpStatusbar(MfxStatusbar): class HelpStatusbar(MfxStatusbar):
def __init__(self, top): def __init__(self, top):
MfxStatusbar.__init__(self, top, row=4, column=0, columnspan=3) MfxStatusbar.__init__(self, top, row=4, column=0, columnspan=3)
l = self._createLabel('info', expand=True) label = self._createLabel('info', expand=True)
l.config(justify='left', anchor='w', padx=8) label.config(justify='left', anchor='w', padx=8)
class HtmlStatusbar(MfxStatusbar): class HtmlStatusbar(MfxStatusbar):
def __init__(self, top, row, column, columnspan): def __init__(self, top, row, column, columnspan):
MfxStatusbar.__init__( MfxStatusbar.__init__(
self, top, row=row, column=column, columnspan=columnspan) self, top, row=row, column=column, columnspan=columnspan)
l = self._createLabel('url', expand=True) label = self._createLabel('url', expand=True)
l.config(justify='left', anchor='w', padx=8) label.config(justify='left', anchor='w', padx=8)
# ************************************************************************ # ************************************************************************

View file

@ -125,7 +125,7 @@ class HTMLViewer(Base_HTMLViewer):
def tkhtml_main(args): def tkhtml_main(args):
try: try:
url = args[1] url = args[1]
except: except Exception:
url = os.path.join(os.pardir, os.pardir, "data", "html", "index.html") url = os.path.join(os.pardir, os.pardir, "data", "html", "index.html")
top = tkinter.Tk() top = tkinter.Tk()
top.wm_minsize(400, 200) top.wm_minsize(400, 200)

View file

@ -131,10 +131,11 @@ class SingleGame_StatsDialog(MfxDialog):
self.fg = c.option_get('foreground', '') or c.cget("insertbackground") self.fg = c.option_get('foreground', '') or c.cget("insertbackground")
# #
c.create_rectangle(2, 7, w, h, fill="", outline="#7f7f7f") 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 = int(self.font_metrics['ascent']) - 10
dy //= 2 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): def _createChartTexts(self, tx, ty, won, lost):
c, tfont, fg = self.canvas, self.font, self.fg c, tfont, fg = self.canvas, self.font, self.fg
@ -678,34 +679,34 @@ class _TopDialog(MfxDialog):
frame.columnconfigure(0, weight=1) frame.columnconfigure(0, weight=1)
cnf['master'] = frame cnf['master'] = frame
cnf['text'] = _('N') cnf['text'] = _('N')
l = tkinter.Label(**cnf) label = tkinter.Label(**cnf)
l.grid(row=0, column=0, sticky='ew') label.grid(row=0, column=0, sticky='ew')
cnf['text'] = _('Game number') cnf['text'] = _('Game number')
l = tkinter.Label(**cnf) label = tkinter.Label(**cnf)
l.grid(row=0, column=1, sticky='ew') label.grid(row=0, column=1, sticky='ew')
cnf['text'] = _('Started at') cnf['text'] = _('Started at')
l = tkinter.Label(**cnf) label = tkinter.Label(**cnf)
l.grid(row=0, column=2, sticky='ew') label.grid(row=0, column=2, sticky='ew')
cnf['text'] = _('Result') cnf['text'] = _('Result')
l = tkinter.Label(**cnf) label = tkinter.Label(**cnf)
l.grid(row=0, column=3, sticky='ew') label.grid(row=0, column=3, sticky='ew')
row = 1 row = 1
for i in top: for i in top:
# N # N
cnf['text'] = str(row) cnf['text'] = str(row)
l = tkinter.Label(**cnf) label = tkinter.Label(**cnf)
l.grid(row=row, column=0, sticky='ew') label.grid(row=row, column=0, sticky='ew')
# Game number # Game number
cnf['text'] = '#'+str(i.game_number) cnf['text'] = '#'+str(i.game_number)
l = tkinter.Label(**cnf) label = tkinter.Label(**cnf)
l.grid(row=row, column=1, sticky='ew') label.grid(row=row, column=1, sticky='ew')
# Start time # Start time
t = time.strftime( t = time.strftime(
'%Y-%m-%d %H:%M', time.localtime(i.game_start_time)) '%Y-%m-%d %H:%M', time.localtime(i.game_start_time))
cnf['text'] = t cnf['text'] = t
l = tkinter.Label(**cnf) label = tkinter.Label(**cnf)
l.grid(row=row, column=2, sticky='ew') label.grid(row=row, column=2, sticky='ew')
# Result # Result
if isinstance(i.value, float): if isinstance(i.value, float):
# time # time
@ -714,8 +715,8 @@ class _TopDialog(MfxDialog):
# moves # moves
s = str(i.value) s = str(i.value)
cnf['text'] = s cnf['text'] = s
l = tkinter.Label(**cnf) label = tkinter.Label(**cnf)
l.grid(row=row, column=3, sticky='ew') label.grid(row=row, column=3, sticky='ew')
row += 1 row += 1
focus = self.createButtons(bottom_frame, kw) focus = self.createButtons(bottom_frame, kw)
@ -864,7 +865,7 @@ class ProgressionDialog(MfxDialog):
fn = app.dataloader.findImage('progression', dir) fn = app.dataloader.findImage('progression', dir)
self.bg_image = loadImage(fn) self.bg_image = loadImage(fn)
canvas.create_image(0, 0, image=self.bg_image, anchor='nw') canvas.create_image(0, 0, image=self.bg_image, anchor='nw')
except: except Exception:
pass pass
# #
tw = max(measure(_('Games/day')), tw = max(measure(_('Games/day')),

View file

@ -50,9 +50,9 @@ class MfxTreeBaseNode:
def registerKey(self): def registerKey(self):
if self.key is not None: if self.key is not None:
l = self.tree.keys.get(self.key, []) lst = self.tree.keys.get(self.key, [])
l.append(self) lst.append(self)
self.tree.keys[self.key] = l self.tree.keys[self.key] = lst
def whoami(self): def whoami(self):
if self.parent_node is None: if self.parent_node is None:

View file

@ -91,13 +91,13 @@ class MfxDialog: # ex. _ToplevelDialog
unbind_destroy(self.top) unbind_destroy(self.top)
try: try:
self.top.wm_withdraw() self.top.wm_withdraw()
except: except Exception:
if traceback: if traceback:
traceback.print_exc() traceback.print_exc()
pass pass
try: try:
self.top.destroy() self.top.destroy()
except: except Exception:
if traceback: if traceback:
traceback.print_exc() traceback.print_exc()
pass pass
@ -110,7 +110,7 @@ class MfxDialog: # ex. _ToplevelDialog
self.parent.busyUpdate() self.parent.busyUpdate()
else: else:
self.parent.update() self.parent.update()
except: except Exception:
if traceback: if traceback:
traceback.print_exc() traceback.print_exc()
pass pass
@ -246,10 +246,10 @@ class MfxDialog: # ex. _ToplevelDialog
column += 1 column += 1
b.grid(column=column, row=0, sticky="ns", padx=padx, pady=pady) b.grid(column=column, row=0, sticky="ns", padx=padx, pady=pady)
if focus is not None: 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)) self.mDone(button))
bind(self.top, "<Return>", l) bind(self.top, "<Return>", cb)
bind(self.top, "<KP_Enter>", l) bind(self.top, "<KP_Enter>", cb)
frame.columnconfigure(0, weight=1) frame.columnconfigure(0, weight=1)
frame.columnconfigure(99, weight=1) frame.columnconfigure(99, weight=1)
return focus return focus

View file

@ -179,7 +179,7 @@ class PysolToolbarTk:
self.frame = tkinter.Frame(top, relief=TkSettings.toolbar_relief, self.frame = tkinter.Frame(top, relief=TkSettings.toolbar_relief,
bd=TkSettings.toolbar_borderwidth) bd=TkSettings.toolbar_borderwidth)
# #
for l, f, t in ( for label, f, t in (
(n_("New"), self.mNewGame, _("New game")), (n_("New"), self.mNewGame, _("New game")),
(n_("Restart"), self.mRestart, _("Restart the\ncurrent game")), (n_("Restart"), self.mRestart, _("Restart the\ncurrent game")),
(None, None, None), (None, None, None),
@ -197,14 +197,14 @@ class PysolToolbarTk:
(None, None, None), (None, None, None),
(n_("Quit"), self.mQuit, _("Quit ")+TITLE), (n_("Quit"), self.mQuit, _("Quit ")+TITLE),
): ):
if l is None: if label is None:
sep = self._createSeparator() sep = self._createSeparator()
sep.bind("<1>", self.clickHandler) sep.bind("<1>", self.clickHandler)
sep.bind("<3>", self.rightclickHandler) sep.bind("<3>", self.rightclickHandler)
elif l == 'Pause': elif label == 'Pause':
self._createButton(l, f, check=True, tooltip=t) self._createButton(label, f, check=True, tooltip=t)
else: else:
self._createButton(l, f, tooltip=t) self._createButton(label, f, tooltip=t)
self.pause_button.config(variable=menubar.tkopt.pause) self.pause_button.config(variable=menubar.tkopt.pause)
sep = self._createFlatSeparator() sep = self._createFlatSeparator()
@ -437,12 +437,12 @@ class PysolToolbarTk:
name = w.toolbar_name name = w.toolbar_name
image = self._loadImage(name) image = self._loadImage(name)
data.append((name, w, image)) data.append((name, w, image))
except: except Exception:
self.dir, self.size = old_dir, old_size self.dir, self.size = old_dir, old_size
return 0 return 0
l = self.player_label label = self.player_label
aspect = (400, 300)[size != 0] aspect = (400, 300)[size != 0]
l.config(aspect=aspect) label.config(aspect=aspect)
for name, w, image in data: for name, w, image in data:
w.config(image=image) w.config(image=image)
setattr(self, name + "_image", image) setattr(self, name + "_image", image)

View file

@ -86,12 +86,12 @@ class BaseColorsDialog:
self._calcLabel()( self._calcLabel()(
frame, text=title, anchor='w',).grid( frame, text=title, anchor='w',).grid(
row=row, column=0, sticky='we') 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) bg=var.get(), textvariable=var)
l.grid(row=row, column=1, padx=5) label.grid(row=row, column=1, padx=5)
b = self._calcButton()( b = self._calcButton()(
frame, text=_('Change...'), width=10, 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) b.grid(row=row, column=2)
row += 1 row += 1
# #
@ -111,7 +111,7 @@ class BaseColorsDialog:
try: try:
c = askcolor(parent=self.top, initialcolor=label.cget('bg'), c = askcolor(parent=self.top, initialcolor=label.cget('bg'),
title=_("Select color")) title=_("Select color"))
except: except Exception:
pass pass
else: else:
if c and c[1]: if c and c[1]:

View file

@ -207,7 +207,7 @@ def create_find_card_dialog(parent, game, dir):
try: try:
find_card_dialog.wm_deiconify() find_card_dialog.wm_deiconify()
find_card_dialog.tkraise() find_card_dialog.tkraise()
except: except Exception:
# traceback.print_exc() # traceback.print_exc()
find_card_dialog = FindCardDialog(parent, game, dir) 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): def connect_game_find_card_dialog(game):
try: try:
find_card_dialog.connectGame(game) find_card_dialog.connectGame(game)
except: except Exception:
pass pass
@ -223,7 +223,7 @@ def destroy_find_card_dialog():
global find_card_dialog global find_card_dialog
try: try:
find_card_dialog.destroy() find_card_dialog.destroy()
except: except Exception:
# traceback.print_exc() # traceback.print_exc()
pass pass
find_card_dialog = None find_card_dialog = None

View file

@ -203,7 +203,7 @@ solver_dialog = None
def connect_game_solver_dialog(game): def connect_game_solver_dialog(game):
try: try:
solver_dialog.connectGame(game) solver_dialog.connectGame(game)
except: except Exception:
pass pass
@ -211,7 +211,7 @@ def destroy_solver_dialog():
global solver_dialog global solver_dialog
try: try:
solver_dialog.destroy() solver_dialog.destroy()
except: except Exception:
# traceback.print_exc() # traceback.print_exc()
pass pass
solver_dialog = None solver_dialog = None
@ -221,6 +221,6 @@ def reset_solver_dialog():
if solver_dialog: if solver_dialog:
try: try:
solver_dialog.reset() solver_dialog.reset()
except: except Exception:
# traceback.print_exc() # traceback.print_exc()
pass pass

View file

@ -313,12 +313,12 @@ class MfxCanvas(tkinter.Canvas):
if Image: if Image:
try: try:
self._bg_img = Image.open(image) self._bg_img = Image.open(image)
except: except Exception:
return 0 return 0
else: else:
try: try:
self._bg_img = loadImage(file=image, dither=1) self._bg_img = loadImage(file=image, dither=1)
except: except Exception:
return 0 return 0
self._stretch_bg_image = stretch self._stretch_bg_image = stretch
self._save_aspect_bg_image = save_aspect self._save_aspect_bg_image = save_aspect

View file

@ -221,11 +221,11 @@ class Base_HTMLViewer:
unbind_destroy(self.parent) unbind_destroy(self.parent)
try: try:
self.parent.wm_withdraw() self.parent.wm_withdraw()
except: except Exception:
pass pass
try: try:
self.parent.destroy() self.parent.destroy()
except: except Exception:
pass pass
self.parent = None self.parent = None
@ -341,7 +341,7 @@ to open the following URL:
self.errorDialog(_("Unable to service request:\n") + url + self.errorDialog(_("Unable to service request:\n") + url +
"\n\n" + str(ex)) "\n\n" + str(ex))
return return
except: except Exception:
if file: if file:
file.close() file.close()
self.errorDialog(_("Unable to service request:\n") + url) self.errorDialog(_("Unable to service request:\n") + url)
@ -438,7 +438,7 @@ to open the following URL:
return self.images[fn] return self.images[fn]
try: try:
img = tkinter.PhotoImage(master=self.parent, file=fn) img = tkinter.PhotoImage(master=self.parent, file=fn)
except: except Exception:
img = None img = None
self.images[fn] = img self.images[fn] = img
return img return img

View file

@ -59,11 +59,11 @@ def wm_get_geometry(window):
m = __wm_get_geometry_re.search(g) m = __wm_get_geometry_re.search(g)
if not m: if not m:
raise tkinter.TclError("invalid geometry "+str(g)) raise tkinter.TclError("invalid geometry "+str(g))
l = list(map(int, m.groups())) lst = list(map(int, m.groups()))
if window.wm_state() == "zoomed": if window.wm_state() == "zoomed":
# workaround as Tk returns the "unzoomed" origin # workaround as Tk returns the "unzoomed" origin
l[2] = l[3] = 0 lst[2] = lst[3] = 0
return l return lst
# ************************************************************************ # ************************************************************************
@ -135,7 +135,7 @@ def __getWidgetXY(widget, parent, relx=None, rely=None,
if WIN_SYSTEM == "win32": if WIN_SYSTEM == "win32":
try: try:
m_width, m_height, m_x, m_y = wm_get_geometry(parent) m_width, m_height, m_x, m_y = wm_get_geometry(parent)
except: except Exception:
pass pass
if m_x is None: if m_x is None:
m_x = parent.winfo_x() m_x = parent.winfo_x()
@ -324,11 +324,11 @@ def fillImage(image, fill, outline=None):
assert len(f) == height assert len(f) == height
image.put(f) image.put(f)
elif not fill: elif not fill:
l = ((outline,) * width,) l1 = ((outline,) * width,)
for y in range(0, ow): for y in range(0, ow):
image.put(l, (0, y)) image.put(l1, (0, y))
for y in range(height-ow, height): for y in range(height-ow, height):
image.put(l, (0, y)) image.put(l1, (0, y))
p = ((outline,) * ow,) p = ((outline,) * ow,)
for y in range(ow, height-ow): for y in range(ow, height-ow):
image.put(p, (0, y)) image.put(p, (0, y))

View file

@ -44,7 +44,7 @@ def init_tile(app, top):
try: try:
top.tk.eval('package require ttk::theme::'+t) top.tk.eval('package require ttk::theme::'+t)
# print 'load theme:', t # print 'load theme:', t
except: except Exception:
traceback.print_exc() traceback.print_exc()
pass pass
@ -54,7 +54,7 @@ def set_theme(app, top, theme):
style = ttk.Style(top) style = ttk.Style(top)
try: try:
style.theme_use(theme) style.theme_use(theme)
except: except Exception:
print_err(_('invalid theme name: ') + theme) print_err(_('invalid theme name: ') + theme)
style.theme_use(app.opt.default_tile_theme) style.theme_use(app.opt.default_tile_theme)
@ -66,7 +66,7 @@ def get_font_name(font):
font_name = None font_name = None
try: try:
f = Font(font=font) f = Font(font=font)
except: except Exception:
print_err(_('invalid font name: ') + font) print_err(_('invalid font name: ') + font)
if DEBUG: if DEBUG:
traceback.print_exc() traceback.print_exc()

View file

@ -52,21 +52,21 @@ def init_root_window(root, app):
if os.path.exists(f): if os.path.exists(f):
try: try:
root.tk.evalfile(f) root.tk.evalfile(f)
except: except Exception:
traceback.print_exc() traceback.print_exc()
f = 'clrpick8.5.tcl' f = 'clrpick8.5.tcl'
f = os.path.join(app.dataloader.dir, 'tcl', f) f = os.path.join(app.dataloader.dir, 'tcl', f)
if os.path.exists(f): if os.path.exists(f):
try: try:
root.tk.evalfile(f) root.tk.evalfile(f)
except: except Exception:
traceback.print_exc() traceback.print_exc()
f = 'fsdialog8.5.tcl' f = 'fsdialog8.5.tcl'
f = os.path.join(app.dataloader.dir, 'tcl', f) f = os.path.join(app.dataloader.dir, 'tcl', f)
if os.path.exists(f): if os.path.exists(f):
try: try:
root.tk.evalfile(f) root.tk.evalfile(f)
except: except Exception:
traceback.print_exc() traceback.print_exc()
else: else:
from six.moves import tkinter_tkfiledialog from six.moves import tkinter_tkfiledialog

View file

@ -32,11 +32,11 @@ def encode_layout(layout):
y_max = max([t[2] for t in layout]) y_max = max([t[2] for t in layout])
for x in range(x_max+1): for x in range(x_max+1):
for y in range(y_max+1): for y in range(y_max+1):
l = [t[0] for t in layout if t[1] == x and t[2] == y] mylist = [t[0] for t in layout if t[1] == x and t[2] == y]
if not l: if not mylist:
continue continue
i_0 = i_n = l[0] i_0 = i_n = mylist[0]
for i in l[1:]: for i in mylist[1:]:
if i == i_n+1: if i == i_n+1:
i_n = i i_n = i
continue continue
@ -81,17 +81,17 @@ def parse_kyodai(filename):
def parse_ace(filename): def parse_ace(filename):
# Ace of Penguins (http://www.delorie.com/store/ace/) # Ace of Penguins (http://www.delorie.com/store/ace/)
l = open(filename).read().replace('\n', '').split(',') mylist = open(filename).read().replace('\n', '').split(',')
l.reverse() mylist.reverse()
layout = [] layout = []
layer = 0 layer = 0
while True: while True:
x = int(l.pop()) x = int(mylist.pop())
if x == 127: if x == 127:
break break
if x <= 0: if x <= 0:
x = -x x = -x
y, z = int(l.pop()), int(l.pop()) y, z = int(mylist.pop()), int(mylist.pop())
if layer < z: if layer < z:
layer = z layer = z
layout.append((z, x, y)) layout.append((z, x, y))
@ -141,14 +141,14 @@ def parse_xmahjongg(filename):
return normalize(layout) return normalize(layout)
def normalize(l): def normalize(mylist):
minx = min([i[1] for i in l]) minx = min([i[1] for i in mylist])
if minx: if minx:
l = [(i[0], i[1]-minx, 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 l]) miny = min([i[2] for i in mylist])
if miny: if miny:
l = [(i[0], i[1], i[2]-miny) for i in l] mylist = [(i[0], i[1], i[2]-miny) for i in mylist]
return l return mylist
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -32,7 +32,7 @@ root = tkinter.Tk()
root.withdraw() root.withdraw()
try: try:
root.tk.call('package', 'require', 'tile', '0.7.8') root.tk.call('package', 'require', 'tile', '0.7.8')
except: except Exception:
TILE = None TILE = None
else: else:
TILE = "tile0.7.8" TILE = "tile0.7.8"