1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

* improved tooltip

* fixed any bugs


git-svn-id: https://pysolfc.svn.sourceforge.net/svnroot/pysolfc/PySolFC/trunk@26 39dd0a4e-7c14-0410-91b3-c4f2d318f732
This commit is contained in:
skomoroh 2006-07-24 21:04:31 +00:00
parent 8238b1cb0b
commit 28ed1285d3
6 changed files with 31 additions and 15 deletions

View file

@ -272,7 +272,6 @@ class PysolMenubarActions:
ms.autodeal = 1 ms.autodeal = 1
if autostacks[2]: if autostacks[2]:
ms.quickplay = 1 ms.quickplay = 1
ms.highlight_piles = 0
if opt.highlight_piles and game.getHighlightPilesStacks(): if opt.highlight_piles and game.getHighlightPilesStacks():
ms.highlight_piles = 1 ms.highlight_piles = 1
if game.app.getGameRulesFilename(game.id): # note: this may return "" if game.app.getGameRulesFilename(game.id): # note: this may return ""
@ -321,7 +320,7 @@ class PysolMenubarActions:
self.setToolbarState(ms.rules, "rules") self.setToolbarState(ms.rules, "rules")
# #
self.tkopt.comment.set(bool(self.game.gsaveinfo.comment)) self.tkopt.comment.set(bool(self.game.gsaveinfo.comment))
#self.setToolbarState(ms.pause, "pause") self.tkopt.pause.set(self.game.pause)
# update menu items and toolbar # update menu items and toolbar
def updateMenus(self): def updateMenus(self):

View file

@ -147,11 +147,15 @@ class AFlipAllMove(AtomicMove):
for card in stack.cards: for card in stack.cards:
if card.face_up: if card.face_up:
card.showBack() card.showBack()
else:
card.showFace()
def undo(self, game): def undo(self, game):
stack = game.allstacks[self.stack_id] stack = game.allstacks[self.stack_id]
for card in stack.cards: for card in stack.cards:
if not card.face_up: if card.face_up:
card.showBack()
else:
card.showFace() card.showFace()
def cmpForRedo(self, other): def cmpForRedo(self, other):

View file

@ -429,7 +429,8 @@ class Stack:
view._position(card) view._position(card)
if update: if update:
view.updateText() view.updateText()
self.closeStackMove() if not self.game.moves.state == self.game.S_REDO:
self.closeStackMove()
return card return card
def insertCard(self, card, positon, unhide=1, update=1): def insertCard(self, card, positon, unhide=1, update=1):
@ -445,7 +446,8 @@ class Stack:
view._position(c) view._position(c)
if update: if update:
view.updateText() view.updateText()
self.closeStackMove() if not self.game.moves.state == self.game.S_REDO:
self.closeStackMove()
return card return card
# Remove a card from the stack. Also update display. {model -> view} # Remove a card from the stack. Also update display. {model -> view}

View file

@ -85,6 +85,10 @@ class GameInfoDialog(MfxDialog):
5: 'SL_SKILL', 5: 'SL_SKILL',
} }
skill_level = sl.get(gi.skill_level) skill_level = sl.get(gi.skill_level)
if game.Hint_Class is None:
hint = None
else:
hint = game.Hint_Class.__name__
row = 0 row = 0
for n, t in (('Name:', gi.name), for n, t in (('Name:', gi.name),
('Short name:', gi.short_name), ('Short name:', gi.short_name),
@ -101,7 +105,7 @@ class GameInfoDialog(MfxDialog):
('Rules filename:', gi.rules_filename), ('Rules filename:', gi.rules_filename),
('Module:', game.__module__), ('Module:', game.__module__),
('Class:', game.__class__.__name__), ('Class:', game.__class__.__name__),
('Hint:', game.Hint_Class.__name__), ('Hint:', hint),
): ):
if t: if t:
Label(frame, text=n, anchor=W).grid(row=row, column=0, sticky=N+W) Label(frame, text=n, anchor=W).grid(row=row, column=0, sticky=N+W)

View file

@ -41,7 +41,7 @@ __all__ = ['MfxMessageDialog',
] ]
# imports # imports
import os, sys, types, Tkinter import os, sys, time, types, Tkinter
import traceback import traceback
# PySol imports # PySol imports
@ -333,6 +333,8 @@ class MfxSimpleEntry(MfxDialog):
# ************************************************************************/ # ************************************************************************/
class MfxTooltip: class MfxTooltip:
last_leave_time = 0
def __init__(self, widget): def __init__(self, widget):
# private vars # private vars
self.widget = widget self.widget = widget
@ -346,8 +348,9 @@ class MfxTooltip:
self.bindings.append(self.widget.bind("<Leave>", self._leave)) self.bindings.append(self.widget.bind("<Leave>", self._leave))
self.bindings.append(self.widget.bind("<ButtonPress>", self._leave)) self.bindings.append(self.widget.bind("<ButtonPress>", self._leave))
# user overrideable settings # user overrideable settings
self.time = 600 # milliseconds self.timeout = 800 # milliseconds
self.cancel_time = 5000 self.cancel_timeout = 5000
self.leave_timeout = 400
self.relief = Tkinter.SOLID self.relief = Tkinter.SOLID
self.justify = Tkinter.LEFT self.justify = Tkinter.LEFT
self.fg = "#000000" self.fg = "#000000"
@ -373,7 +376,10 @@ class MfxTooltip:
after_cancel(self.timer) after_cancel(self.timer)
after_cancel(self.cancel_timer) after_cancel(self.cancel_timer)
self.cancel_timer = None self.cancel_timer = None
self.timer = after(self.widget, self.time, self._showTip) if time.time() - MfxTooltip.last_leave_time < self.leave_timeout/1000.:
self._showTip()
else:
self.timer = after(self.widget, self.timeout, self._showTip)
def _leave(self, *event): def _leave(self, *event):
after_cancel(self.timer) after_cancel(self.timer)
@ -386,14 +392,15 @@ class MfxTooltip:
self.tooltip.destroy() self.tooltip.destroy()
destruct(self.tooltip) destruct(self.tooltip)
self.tooltip = None self.tooltip = None
MfxTooltip.last_leave_time = time.time()
def _showTip(self): def _showTip(self):
self.timer = None self.timer = None
if self.tooltip or not self.text: if self.tooltip or not self.text:
return return
if isinstance(self.widget, Tkinter.Button): ## if isinstance(self.widget, (Tkinter.Button, Tkinter.Checkbutton)):
if self.widget["state"] == Tkinter.DISABLED: ## if self.widget["state"] == Tkinter.DISABLED:
return ## return
##x = self.widget.winfo_rootx() ##x = self.widget.winfo_rootx()
x = self.widget.winfo_pointerx() x = self.widget.winfo_pointerx()
y = self.widget.winfo_rooty() + self.widget.winfo_height() y = self.widget.winfo_rooty() + self.widget.winfo_height()
@ -409,7 +416,7 @@ class MfxTooltip:
self.label.pack(ipadx=1, ipady=1) self.label.pack(ipadx=1, ipady=1)
self.tooltip.wm_geometry("%+d%+d" % (x, y)) self.tooltip.wm_geometry("%+d%+d" % (x, y))
self.tooltip.wm_deiconify() self.tooltip.wm_deiconify()
self.cancel_timer = after(self.widget, self.cancel_time, self._leave) self.cancel_timer = after(self.widget, self.cancel_timeout, self._leave)
##self.tooltip.tkraise() ##self.tooltip.tkraise()

View file

@ -214,7 +214,7 @@ class PysolToolbar(PysolToolbarActions):
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 l == 'Pause' and Tkinter.TkVersion >= 8.4:
self._createButton(l, f, check=True, tooltip=t) self._createButton(l, f, check=True, tooltip=t)
else: else:
self._createButton(l, f, tooltip=t) self._createButton(l, f, tooltip=t)