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: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@26 efabe8c0-fbe8-4139-b769-b5e6d273206e
This commit is contained in:
skomoroh 2006-07-24 21:04:31 +00:00
parent 7d832033b2
commit d91ba30ac8
6 changed files with 31 additions and 15 deletions

View file

@ -272,7 +272,6 @@ class PysolMenubarActions:
ms.autodeal = 1
if autostacks[2]:
ms.quickplay = 1
ms.highlight_piles = 0
if opt.highlight_piles and game.getHighlightPilesStacks():
ms.highlight_piles = 1
if game.app.getGameRulesFilename(game.id): # note: this may return ""
@ -321,7 +320,7 @@ class PysolMenubarActions:
self.setToolbarState(ms.rules, "rules")
#
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
def updateMenus(self):

View file

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

View file

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

View file

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

View file

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

View file

@ -214,7 +214,7 @@ class PysolToolbar(PysolToolbarActions):
sep = self._createSeparator()
sep.bind("<1>", self.clickHandler)
sep.bind("<3>", self.rightclickHandler)
elif l == 'Pause':
elif l == 'Pause' and Tkinter.TkVersion >= 8.4:
self._createButton(l, f, check=True, tooltip=t)
else:
self._createButton(l, f, tooltip=t)