diff --git a/pysollib/game.py b/pysollib/game.py index 52d47bd8..5368e64f 100644 --- a/pysollib/game.py +++ b/pysollib/game.py @@ -934,7 +934,9 @@ class Game: return if self.app.debug and not self.top.winfo_ismapped(): return - self.top.busyUpdate() + #self.top.busyUpdate() + self.canvas.after(200) + self.canvas.update_idletasks() old_a = self.app.opt.animations if old_a == 0: self.app.opt.animations = 1 # timer based diff --git a/pysollib/games/bisley.py b/pysollib/games/bisley.py index ebb22cca..4b06c13c 100644 --- a/pysollib/games/bisley.py +++ b/pysollib/games/bisley.py @@ -107,7 +107,7 @@ class DoubleBisley(Bisley): l, s = Layout(self), self.s # set window - w, h = l.XM+(8+4)*l.XS, l.YM+max(3*(l.YS+8*l.YOFFSET), 8*l.YS) + w, h = l.XM+(8+2)*l.XS, l.YM+max(3*(l.YS+8*l.YOFFSET), 8*l.YS) self.setSize(w, h) # create stacks diff --git a/pysollib/games/picturegallery.py b/pysollib/games/picturegallery.py index f2bf98c6..4cf31271 100644 --- a/pysollib/games/picturegallery.py +++ b/pysollib/games/picturegallery.py @@ -168,12 +168,12 @@ class PictureGallery_TableauStack(SS_RowStack): def getBottomImage(self): return self.game.app.images.getLetter(self.cap.base_rank) - def closeStackMove(self): - if len(self.cards) == self.cap.max_cards: - self.game.flipAllMove(self) - - def canFlipCard(self): - return False +## def closeStackMove(self): +## if len(self.cards) == self.cap.max_cards: +## self.game.closeStackMove(self) +## ##self.game.flipAllMove(self) +## def canFlipCard(self): +## return False class PictureGallery_RowStack(BasicRowStack): diff --git a/pysollib/games/ultra/larasgame.py b/pysollib/games/ultra/larasgame.py index ae2bbfb7..a421be49 100644 --- a/pysollib/games/ultra/larasgame.py +++ b/pysollib/games/ultra/larasgame.py @@ -281,9 +281,9 @@ class LarasGame(Game): s.talon = self.Talon_Class(x, y, self, max_rounds=self.MAX_ROUNDS) l.createText(s.talon, "s") if self.MAX_ROUNDS - 1: + tx, ty, ta, tf = l.getTextAttr(s.talon, "nn") s.talon.texts.rounds = MfxCanvasText(self.canvas, - x + l.XS / 2, y - l.YM, - anchor="center", + tx, ty, anchor=ta, font=self.app.getFont("canvas_default")) y = h - l.YS * 2 s.rows.append(LarasGame_RowStack(x, y, self, yoffset=0)) diff --git a/pysollib/move.py b/pysollib/move.py index c6323006..cc2e9ed7 100644 --- a/pysollib/move.py +++ b/pysollib/move.py @@ -142,19 +142,17 @@ class AFlipAllMove(AtomicMove): def __init__(self, stack): self.stack_id = stack.id - # do the actual move - def __doMove(self, game, stack): + def redo(self, game): + stack = game.allstacks[self.stack_id] for card in stack.cards: if card.face_up: card.showBack() - else: - card.showFace() - - def redo(self, game): - self.__doMove(game, game.allstacks[self.stack_id]) def undo(self, game): - self.__doMove(game, game.allstacks[self.stack_id]) + stack = game.allstacks[self.stack_id] + for card in stack.cards: + if not card.face_up: + card.showFace() def cmpForRedo(self, other): return cmp(self.stack_id, other.stack_id) diff --git a/pysollib/tk/menubar.py b/pysollib/tk/menubar.py index f2701299..74c1a2b5 100644 --- a/pysollib/tk/menubar.py +++ b/pysollib/tk/menubar.py @@ -828,6 +828,8 @@ class PysolMenubar(PysolMenubarActions): filename = self.app.getGameSaveName(self.game.id) if os.name == "posix": filename = filename + "-" + self.game.getGameNumber(format=0) + elif os.path.supports_unicode_filenames: # new in python 2.3 + filename = filename + "-" + self.game.getGameNumber(format=0) else: filename = filename + "-01" filename = filename + self.DEFAULTEXTENSION diff --git a/pysollib/tk/toolbar.py b/pysollib/tk/toolbar.py index 25a6f1be..77d2fbb9 100644 --- a/pysollib/tk/toolbar.py +++ b/pysollib/tk/toolbar.py @@ -63,18 +63,18 @@ n_ = lambda x: x # // # ************************************************************************/ -class ToolbarButton(Tkinter.Button): - def __init__(self, parent, toolbar, toolbar_name, position, **kwargs): - Tkinter.Button.__init__(self, parent, kwargs) +class AbstractToolbarButton: + def __init__(self, parent, toolbar, toolbar_name, position): self.toolbar = toolbar self.toolbar_name = toolbar_name self.position = position self.visible = False + def show(self, orient, force=False): if self.visible and not force: return self.visible = True - padx, pady= 2, 2 + padx, pady = 2, 2 if orient == Tkinter.HORIZONTAL: self.grid(row=0, column=self.position, @@ -85,11 +85,25 @@ class ToolbarButton(Tkinter.Button): column=0, ipadx=padx, ipady=pady, sticky='nsew') + def hide(self): if not self.visible: return self.visible = False self.grid_forget() + +class ToolbarCheckbutton(AbstractToolbarButton, Tkinter.Checkbutton): + def __init__(self, parent, toolbar, toolbar_name, position, **kwargs): + Tkinter.Checkbutton.__init__(self, parent, kwargs) + AbstractToolbarButton.__init__(self, parent, toolbar, toolbar_name, position) + + +class ToolbarButton(AbstractToolbarButton, Tkinter.Button): + def __init__(self, parent, toolbar, toolbar_name, position, **kwargs): + Tkinter.Button.__init__(self, parent, kwargs) + AbstractToolbarButton.__init__(self, parent, toolbar, toolbar_name, position) + + class ToolbarSeparator(Tkinter.Frame): def __init__(self, parent, toolbar, position, **kwargs): Tkinter.Frame.__init__(self, parent, kwargs) @@ -200,6 +214,8 @@ class PysolToolbar(PysolToolbarActions): sep = self._createSeparator() sep.bind("<1>", self.clickHandler) sep.bind("<3>", self.rightclickHandler) + elif l == 'Pause': + self._createButton(l, f, check=True, tooltip=t) else: self._createButton(l, f, tooltip=t) @@ -322,24 +338,33 @@ class PysolToolbar(PysolToolbarActions): self._widgets.append(sep) return sep - def _createButton(self, label, command, tooltip=None): + def _createButton(self, label, command, check=False, tooltip=None): name = label.lower() image = self._loadImage(name) position = len(self._widgets) bd = self.button_relief == 'flat' and 1 or 2 - button = ToolbarButton(self.frame, - position=position, - toolbar=self, - toolbar_name=name, - command=command, takefocus=0, - text=gettext(label), - bd=bd, - relief=self.button_relief, - overrelief='raised', - padx=self.button_pad, - pady=self.button_pad) + kw = { + 'position': position, + 'toolbar': self, + 'toolbar_name': name, + 'command': command, + 'takefocus': 0, + 'text': gettext(label), + 'bd': bd, + 'relief': self.button_relief, + 'overrelief': 'raised', + 'padx': self.button_pad, + 'pady': self.button_pad + } if image: - button.config(image=image) + kw['image'] = image + if check: + kw['offrelief'] = self.button_relief + kw['indicatoron'] = False + kw['selectcolor'] = '' + button = ToolbarCheckbutton(self.frame, **kw) + else: + button = ToolbarButton(self.frame, **kw) button.show(orient=self.orient) setattr(self, name + "_image", image) setattr(self, name + "_button", button) @@ -435,6 +460,7 @@ class PysolToolbar(PysolToolbarActions): self.popup = None if menubar: tkopt = menubar.tkopt + self.pause_button.config(variable=tkopt.pause) self.popup = MfxMenu(master=None, label=n_('Toolbar'), tearoff=0) createToolbarMenu(menubar, self.popup) @@ -453,7 +479,7 @@ class PysolToolbar(PysolToolbarActions): data = [] try: for w in self._widgets: - if not isinstance(w, ToolbarButton): + if not isinstance(w, (ToolbarButton, ToolbarCheckbutton)): continue name = w.toolbar_name image = self._loadImage(name) @@ -476,9 +502,12 @@ class PysolToolbar(PysolToolbarActions): self._setRelief(relief) self.frame.config(relief=self.frame_relief) for w in self._widgets: + bd = relief == 'flat' and 1 or 2 if isinstance(w, ToolbarButton): - bd = relief == 'flat' and 1 or 2 w.config(relief=self.button_relief, bd=bd) + elif isinstance(w, ToolbarCheckbutton): + w.config(relief=self.button_relief, + offrelief=self.button_relief, bd=bd) elif w.__class__ is ToolbarSeparator: # not ToolbarFlatSeparator w.config(relief=self.separator_relief) return True @@ -487,7 +516,7 @@ class PysolToolbar(PysolToolbarActions): if not force and self.compound == compound: return False for w in self._widgets: - if not isinstance(w, ToolbarButton): + if not isinstance(w, (ToolbarButton, ToolbarCheckbutton)): continue if compound == 'text': w.config(compound=Tkinter.NONE, image='')