mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
* improved toolbar (Tile)
* bugfixes git-svn-id: https://pysolfc.svn.sourceforge.net/svnroot/pysolfc/PySolFC/trunk@187 39dd0a4e-7c14-0410-91b3-c4f2d318f732
This commit is contained in:
parent
f8b08538c8
commit
13358ce72d
6 changed files with 81 additions and 65 deletions
|
@ -235,18 +235,19 @@ gAIJGkSokKFDiFwkIlAQgqJFjBo5osBDxSMWkBYmRJI0yeAYSgMrWbqEiU2mHJo2leBksJNB
|
|||
T59AhRI1ipTj/wD6FRAAOw==}
|
||||
|
||||
image create photo ::ttk::dialog::image::folder_new -data {
|
||||
R0lGODlhEAAQAMYAAG1va2dpZc7OzsrEuW1pXvyxPsDAv5aXlZuYkOOrVb6cZODCkfvSkNyy
|
||||
bMuYSfywPsnJyaamptm5hv3nw/765/740f3urPzJZvuyQGF6mjRlpDtnoFJwlNvFnv766P77
|
||||
5P32u/3xkfzkddSsW2R4jMbY677S6MjMy+64Y/zTk/740/32vP3zo/zue/zoYPq+SNCgVK7H
|
||||
44yx2I+w05yxwebFif3vrv3xkvzufPzrYfzfUe2+YV9hXdCyfvzLavzld/zoYfzgUfvDRNu6
|
||||
gVVXU5OwzeGwYs2yf+a7Zvq9SeW6YNCxeem1ZT5onpWwy5Gw0J2xwOOxX7PF2ERrm4+x0p6x
|
||||
vomu1qbC4Dlnoq3H44uw14qv14iu1oWr1YCo03qk0nOgz26dzpi53Fh2m5u73XCeznCdz26c
|
||||
zm2czmybzmubzWqazmmZzWiZzZS226mrqYmv12uazWqazWiYzWaYzGWYzWWXzGSWzGOVzJq6
|
||||
3lNxlkVdeT5giT9ghv///////yH5BAEKAH8ALAAAAAAQABAAAAfNgH8Ag4MBAX+IiYgAAo2O
|
||||
AwSIBYoABgeXlwgJCgsMDQ4PghARpKUSExQVFhcYfwEGGRqyGxwdHh8gISIjJAEQGiUmJico
|
||||
KSorLC0uLzCvGjEyMjM0NTY3ODk6Oxw8v9D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aKEVRIlSLTIUuGGxDBdRowQISKE2bNnU3igMEMQjAgRIYbJnftCxyA0Z8r8
|
||||
8OGDRw++PHbw8PEDiJkzaDYpXpwoEAA7}
|
||||
|
||||
image create photo ::ttk::dialog::image::configure -data {
|
||||
R0lGODlhFgAWAMYAAH9/f+rp6Pn5+NjY1/j39vPy8YKXsjRlpOzq6P///050pHx8fLu7u+3r
|
||||
|
|
|
@ -235,18 +235,19 @@ gAIJGkSokKFDiFwkIlAQgqJFjBo5osBDxSMWkBYmRJI0yeAYSgMrWbqEiU2mHJo2leBksJNB
|
|||
T59AhRI1ipTj/wD6FRAAOw==}
|
||||
|
||||
image create photo ::ttk::dialog::image::folder_new -data {
|
||||
R0lGODlhEAAQAMYAAG1va2dpZc7OzsrEuW1pXvyxPsDAv5aXlZuYkOOrVb6cZODCkfvSkNyy
|
||||
bMuYSfywPsnJyaamptm5hv3nw/765/740f3urPzJZvuyQGF6mjRlpDtnoFJwlNvFnv766P77
|
||||
5P32u/3xkfzkddSsW2R4jMbY677S6MjMy+64Y/zTk/740/32vP3zo/zue/zoYPq+SNCgVK7H
|
||||
44yx2I+w05yxwebFif3vrv3xkvzufPzrYfzfUe2+YV9hXdCyfvzLavzld/zoYfzgUfvDRNu6
|
||||
gVVXU5OwzeGwYs2yf+a7Zvq9SeW6YNCxeem1ZT5onpWwy5Gw0J2xwOOxX7PF2ERrm4+x0p6x
|
||||
vomu1qbC4Dlnoq3H44uw14qv14iu1oWr1YCo03qk0nOgz26dzpi53Fh2m5u73XCeznCdz26c
|
||||
zm2czmybzmubzWqazmmZzWiZzZS226mrqYmv12uazWqazWiYzWaYzGWYzWWXzGSWzGOVzJq6
|
||||
3lNxlkVdeT5giT9ghv///////yH5BAEKAH8ALAAAAAAQABAAAAfNgH8Ag4MBAX+IiYgAAo2O
|
||||
AwSIBYoABgeXlwgJCgsMDQ4PghARpKUSExQVFhcYfwEGGRqyGxwdHh8gISIjJAEQGiUmJico
|
||||
KSorLC0uLzCvGjEyM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||||
tmDIIbHGhy0nop4wYaKEVRIlSLTIUuGGxDBdRowQISKE2bNnU3igMEMQjAgRIYbJnftCxyA0Z8r8
|
||||
8OGDRw++PHbw8PEDiJkzaDYpXpwoEAA7}
|
||||
|
||||
image create photo ::ttk::dialog::image::configure -data {
|
||||
R0lGODlhFgAWAMYAAH9/f+rp6Pn5+NjY1/j39vPy8YKXsjRlpOzq6P///050pHx8fLu7u+3r
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- mode: python; coding: koi8-r; -*-
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
#outdir = '../html'
|
||||
pysollib_dir = '../'
|
||||
|
@ -23,6 +19,9 @@ pysollib_path = os.path.join(sys.path[0], pysollib_dir)
|
|||
sys.path[0] = os.path.normpath(pysollib_path)
|
||||
#print sys.path
|
||||
|
||||
from pysollib.init import fix_gettext
|
||||
fix_gettext()
|
||||
|
||||
import pysollib.games
|
||||
import pysollib.games.special
|
||||
import pysollib.games.ultra
|
||||
|
|
|
@ -410,23 +410,21 @@ class GameInfo(Struct):
|
|||
suits=range(4), ranks=range(13), trumps=(),
|
||||
rules_filename=None,
|
||||
):
|
||||
def gettext_name(s):
|
||||
if not isinstance(s, unicode):
|
||||
return _(unicode(s, 'utf-8'))
|
||||
return _(s)
|
||||
#
|
||||
ncards = decks * (len(suits) * len(ranks) + len(trumps))
|
||||
game_flags = game_type & ~1023
|
||||
game_type = game_type & 1023
|
||||
en_name = name # for Application.getGameRulesFilename
|
||||
name = gettext_name(name)
|
||||
en_name = name # for app.getGameRulesFilename
|
||||
if not isinstance(name, unicode):
|
||||
en_name = unicode(name, 'utf-8')
|
||||
name = _(name)
|
||||
if not short_name:
|
||||
short_name = name
|
||||
else:
|
||||
short_name = gettext_name(short_name)
|
||||
short_name = _(short_name)
|
||||
if isinstance(altnames, basestring):
|
||||
altnames = (altnames,)
|
||||
altnames = [gettext_name(n) for n in altnames]
|
||||
altnames = [_(n) for n in altnames]
|
||||
#
|
||||
if not (1 <= category <= 9):
|
||||
if game_type == GI.GT_HANAFUDA:
|
||||
|
|
|
@ -32,6 +32,8 @@ import settings
|
|||
def fix_gettext():
|
||||
def ugettext(message):
|
||||
# unicoded gettext
|
||||
if not isinstance(message, unicode):
|
||||
message = unicode(message, 'utf-8')
|
||||
domain = gettext._current_domain
|
||||
try:
|
||||
t = gettext.translation(domain,
|
||||
|
@ -42,6 +44,10 @@ def fix_gettext():
|
|||
gettext.ugettext = ugettext
|
||||
def ungettext(msgid1, msgid2, n):
|
||||
# unicoded ngettext
|
||||
if not isinstance(msgid1, unicode):
|
||||
msgid1 = unicode(msgid1, 'utf-8')
|
||||
if not isinstance(msgid2, unicode):
|
||||
msgid2 = unicode(msgid2, 'utf-8')
|
||||
domain = gettext._current_domain
|
||||
try:
|
||||
t = gettext.translation(domain,
|
||||
|
|
|
@ -42,9 +42,9 @@ import Tile
|
|||
|
||||
# PySol imports
|
||||
from pysollib.mfxutil import destruct
|
||||
from pysollib.mfxutil import Image, ImageTk
|
||||
from pysollib.mfxutil import Image, ImageTk, ImageOps
|
||||
from pysollib.util import IMAGE_EXTENSIONS
|
||||
from pysollib.settings import TITLE
|
||||
from pysollib.settings import TITLE, WIN_SYSTEM
|
||||
from pysollib.actions import PysolToolbarActions
|
||||
from pysollib.winsystems import TkSettings
|
||||
|
||||
|
@ -52,6 +52,7 @@ from pysollib.winsystems import TkSettings
|
|||
from tkconst import EVENT_HANDLED
|
||||
from tkwidget import MfxTooltip
|
||||
from menubar import createToolbarMenu, MfxMenu
|
||||
from tkutil import loadImage
|
||||
|
||||
|
||||
# /***********************************************************************
|
||||
|
@ -261,10 +262,7 @@ class PysolToolbar(PysolToolbarActions):
|
|||
for ext in IMAGE_EXTENSIONS:
|
||||
file = os.path.join(self.dir, name+ext)
|
||||
if os.path.isfile(file):
|
||||
if Image:
|
||||
image = ImageTk.PhotoImage(Image.open(file))
|
||||
else:
|
||||
image = Tkinter.PhotoImage(file=file)
|
||||
image = loadImage(file=file)
|
||||
break
|
||||
return image
|
||||
|
||||
|
@ -278,9 +276,34 @@ class PysolToolbar(PysolToolbarActions):
|
|||
self._widgets.append(sep)
|
||||
return sep
|
||||
|
||||
def _createDisabledButtonImage(self, tkim):
|
||||
# grayscale and light-up image
|
||||
im = tkim._pil_image
|
||||
dis_im = ImageOps.grayscale(im)
|
||||
##color = '#ffffff'
|
||||
##factor = 0.6
|
||||
color = '#dedede'
|
||||
factor = 0.75
|
||||
sh = Image.new(dis_im.mode, dis_im.size, color)
|
||||
tmp = Image.blend(dis_im, sh, factor)
|
||||
dis_im = Image.composite(tmp, im, im)
|
||||
dis_tkim = ImageTk.PhotoImage(image=dis_im)
|
||||
return dis_tkim
|
||||
|
||||
def _setButtonImage(self, button, name):
|
||||
image = self._loadImage(name)
|
||||
if Image: # ??? and WIN_SYSTEM != 'aqua':
|
||||
dis_image = self._createDisabledButtonImage(image)
|
||||
setattr(self, name + "_disabled_image", dis_image)
|
||||
setattr(self, name + "_image", image)
|
||||
button.config(image=(image, 'disabled', dis_image))
|
||||
else:
|
||||
image = self._loadImage(name)
|
||||
setattr(self, name + "_image", image)
|
||||
button.config(image=image)
|
||||
|
||||
def _createButton(self, label, command, check=False, tooltip=None):
|
||||
name = label.lower()
|
||||
image = self._loadImage(name)
|
||||
position = len(self._widgets)
|
||||
kw = {
|
||||
'position' : position,
|
||||
|
@ -290,14 +313,13 @@ class PysolToolbar(PysolToolbarActions):
|
|||
'takefocus' : 0,
|
||||
'text' : _(label),
|
||||
}
|
||||
if image:
|
||||
kw['image'] = image
|
||||
|
||||
if check:
|
||||
button = ToolbarCheckbutton(self.frame, **kw)
|
||||
else:
|
||||
button = ToolbarButton(self.frame, **kw)
|
||||
self._setButtonImage(button, name)
|
||||
button.show(orient=self.orient)
|
||||
setattr(self, name + "_image", image)
|
||||
setattr(self, name + "_button", button)
|
||||
self._widgets.append(button)
|
||||
if tooltip:
|
||||
|
@ -409,25 +431,18 @@ class PysolToolbar(PysolToolbarActions):
|
|||
return 0
|
||||
if not os.path.isdir(dir):
|
||||
return 0
|
||||
old_dir, old_size = self.dir, self.size
|
||||
self.dir, self.size = dir, size
|
||||
data = []
|
||||
try:
|
||||
for w in self._widgets:
|
||||
if not isinstance(w, (ToolbarButton, ToolbarCheckbutton)):
|
||||
continue
|
||||
name = w.toolbar_name
|
||||
image = self._loadImage(name)
|
||||
data.append((name, w, image))
|
||||
except:
|
||||
self.dir, self.size = old_dir, old_size
|
||||
return 0
|
||||
for w in self._widgets:
|
||||
if not isinstance(w, (ToolbarButton, ToolbarCheckbutton)):
|
||||
continue
|
||||
name = w.toolbar_name
|
||||
data.append((name, w))
|
||||
l = self.player_label
|
||||
aspect = (400, 300) [size != 0]
|
||||
l.config(aspect=aspect)
|
||||
for name, w, image in data:
|
||||
w.config(image=image)
|
||||
setattr(self, name + "_image", image)
|
||||
for name, w in data:
|
||||
self._setButtonImage(w, name)
|
||||
self.setCompound(self.compound, force=True)
|
||||
return 1
|
||||
|
||||
|
@ -437,11 +452,7 @@ class PysolToolbar(PysolToolbarActions):
|
|||
for w in self._widgets:
|
||||
if not isinstance(w, (ToolbarButton, ToolbarCheckbutton)):
|
||||
continue
|
||||
if compound == 'text':
|
||||
w.config(compound='none', image='')
|
||||
else:
|
||||
image = getattr(self, w.toolbar_name+'_image')
|
||||
w.config(compound=compound, image=image)
|
||||
w.config(compound=compound)
|
||||
self.compound = compound
|
||||
return True
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue