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==}
|
T59AhRI1ipTj/wD6FRAAOw==}
|
||||||
|
|
||||||
image create photo ::ttk::dialog::image::folder_new -data {
|
image create photo ::ttk::dialog::image::folder_new -data {
|
||||||
R0lGODlhEAAQAMYAAG1va2dpZc7OzsrEuW1pXvyxPsDAv5aXlZuYkOOrVb6cZODCkfvSkNyy
|
R0lGODlhFgAWAPZxAFVXU1ZYVFdZVVhZUlhaVl1fW19hXWdpZW1va7O5baexc8a6V8nJbdvVeNrY
|
||||||
bMuYSfywPsnJyaamptm5hv3nw/765/740f3urPzJZvuyQGF6mjRlpDtnoFJwlNvFnv766P77
|
feDcfOLdfDRlozRlpDtqoERljkdqlFh8lE54rlp5oFh7pV+BkWSApHOOr3ySrW2KsHWOsnycvmqa
|
||||||
5P32u/3xkfzkddSsW2R4jMbY677S6MjMy+64Y/zTk/740/32vP3zo/zue/zoYPq+SNCgVK7H
|
zmuczmyczm2cznGfz3Kf0HOg0Hei0Xej0Xij0Xqk0n6n03+o1I6OjYuQlpucm7u4m564vaampaur
|
||||||
44yx2I+w05yxwebFif3vrv3xkvzufPzrYfzfUe2+YV9hXdCyfvzLavzld/zoYfzgUfvDRNu6
|
p6WoqqioqKqrqqW8tKixvLS0tLe3t7i4uLm5ubq6uby8vL6+vsG8lLvImr3MucjOi9PWjuXgiO/p
|
||||||
gVVXU5OwzeGwYs2yf+a7Zvq9SeW6YNCxeem1ZT5onpW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nH0VAgyIKBAA7}
|
tmDIIbHGhy0nop4wYaKEVRIlSLTIUuGGxDBdRowQISKE2bNnU3igMEMQjAgRIYbJnftCxyA0Z8r8
|
||||||
|
8OGDRw++PHbw8PEDiJkzaDYpXpwoEAA7}
|
||||||
|
|
||||||
image create photo ::ttk::dialog::image::configure -data {
|
image create photo ::ttk::dialog::image::configure -data {
|
||||||
R0lGODlhFgAWAMYAAH9/f+rp6Pn5+NjY1/j39vPy8YKXsjRlpOzq6P///050pHx8fLu7u+3r
|
R0lGODlhFgAWAMYAAH9/f+rp6Pn5+NjY1/j39vPy8YKXsjRlpOzq6P///050pHx8fLu7u+3r
|
||||||
|
|
|
@ -235,18 +235,19 @@ gAIJGkSokKFDiFwkIlAQgqJFjBo5osBDxSMWkBYmRJI0yeAYSgMrWbqEiU2mHJo2leBksJNB
|
||||||
T59AhRI1ipTj/wD6FRAAOw==}
|
T59AhRI1ipTj/wD6FRAAOw==}
|
||||||
|
|
||||||
image create photo ::ttk::dialog::image::folder_new -data {
|
image create photo ::ttk::dialog::image::folder_new -data {
|
||||||
R0lGODlhEAAQAMYAAG1va2dpZc7OzsrEuW1pXvyxPsDAv5aXlZuYkOOrVb6cZODCkfvSkNyy
|
R0lGODlhFgAWAPZxAFVXU1ZYVFdZVVhZUlhaVl1fW19hXWdpZW1va7O5baexc8a6V8nJbdvVeNrY
|
||||||
bMuYSfywPsnJyaamptm5hv3nw/765/740f3urPzJZvuyQGF6mjRlpDtnoFJwlNvFnv766P77
|
feDcfOLdfDRlozRlpDtqoERljkdqlFh8lE54rlp5oFh7pV+BkWSApHOOr3ySrW2KsHWOsnycvmqa
|
||||||
5P32u/3xkfzkddSsW2R4jMbY677S6MjMy+64Y/zTk/740/32vP3zo/zue/zoYPq+SNCgVK7H
|
zmuczmyczm2cznGfz3Kf0HOg0Hei0Xej0Xij0Xqk0n6n03+o1I6OjYuQlpucm7u4m564vaampaur
|
||||||
44yx2I+w05yxwebFif3vrv3xkvzufPzrYfzfUe2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FxJBwFLFi0ytGzh0sXLFzBhxKQzMIZMGTNhzqBJo2YNmzZu0r2B
|
FXJSMkiENuZilotXrlgZaSXkFRAcJIb7UqUllZZVqLRgIZNFFg4dBA1Is2EMixVAVahYIVQFihQq
|
||||||
oyaOHDZz6NSxcwdPHj17+MjayZNnH0VAgyIKBAA7}
|
tmDIIbHGhy0nop4wYaKEVRIlSLTIUuGGxDBdRowQISKE2bNnU3igMEMQjAgRIYbJnftCxyA0Z8r8
|
||||||
|
8OGDRw++PHbw8PEDiJkzaDYpXpwoEAA7}
|
||||||
|
|
||||||
image create photo ::ttk::dialog::image::configure -data {
|
image create photo ::ttk::dialog::image::configure -data {
|
||||||
R0lGODlhFgAWAMYAAH9/f+rp6Pn5+NjY1/j39vPy8YKXsjRlpOzq6P///050pHx8fLu7u+3r
|
R0lGODlhFgAWAMYAAH9/f+rp6Pn5+NjY1/j39vPy8YKXsjRlpOzq6P///050pHx8fLu7u+3r
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- mode: python; coding: koi8-r; -*-
|
|
||||||
#
|
|
||||||
# $Id$
|
|
||||||
#
|
|
||||||
|
|
||||||
#outdir = '../html'
|
#outdir = '../html'
|
||||||
pysollib_dir = '../'
|
pysollib_dir = '../'
|
||||||
|
@ -23,6 +19,9 @@ pysollib_path = os.path.join(sys.path[0], pysollib_dir)
|
||||||
sys.path[0] = os.path.normpath(pysollib_path)
|
sys.path[0] = os.path.normpath(pysollib_path)
|
||||||
#print sys.path
|
#print sys.path
|
||||||
|
|
||||||
|
from pysollib.init import fix_gettext
|
||||||
|
fix_gettext()
|
||||||
|
|
||||||
import pysollib.games
|
import pysollib.games
|
||||||
import pysollib.games.special
|
import pysollib.games.special
|
||||||
import pysollib.games.ultra
|
import pysollib.games.ultra
|
||||||
|
|
|
@ -410,23 +410,21 @@ class GameInfo(Struct):
|
||||||
suits=range(4), ranks=range(13), trumps=(),
|
suits=range(4), ranks=range(13), trumps=(),
|
||||||
rules_filename=None,
|
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))
|
ncards = decks * (len(suits) * len(ranks) + len(trumps))
|
||||||
game_flags = game_type & ~1023
|
game_flags = game_type & ~1023
|
||||||
game_type = game_type & 1023
|
game_type = game_type & 1023
|
||||||
en_name = name # for Application.getGameRulesFilename
|
en_name = name # for app.getGameRulesFilename
|
||||||
name = gettext_name(name)
|
if not isinstance(name, unicode):
|
||||||
|
en_name = unicode(name, 'utf-8')
|
||||||
|
name = _(name)
|
||||||
if not short_name:
|
if not short_name:
|
||||||
short_name = name
|
short_name = name
|
||||||
else:
|
else:
|
||||||
short_name = gettext_name(short_name)
|
short_name = _(short_name)
|
||||||
if isinstance(altnames, basestring):
|
if isinstance(altnames, basestring):
|
||||||
altnames = (altnames,)
|
altnames = (altnames,)
|
||||||
altnames = [gettext_name(n) for n in altnames]
|
altnames = [_(n) for n in altnames]
|
||||||
#
|
#
|
||||||
if not (1 <= category <= 9):
|
if not (1 <= category <= 9):
|
||||||
if game_type == GI.GT_HANAFUDA:
|
if game_type == GI.GT_HANAFUDA:
|
||||||
|
|
|
@ -32,6 +32,8 @@ import settings
|
||||||
def fix_gettext():
|
def fix_gettext():
|
||||||
def ugettext(message):
|
def ugettext(message):
|
||||||
# unicoded gettext
|
# unicoded gettext
|
||||||
|
if not isinstance(message, unicode):
|
||||||
|
message = unicode(message, 'utf-8')
|
||||||
domain = gettext._current_domain
|
domain = gettext._current_domain
|
||||||
try:
|
try:
|
||||||
t = gettext.translation(domain,
|
t = gettext.translation(domain,
|
||||||
|
@ -42,6 +44,10 @@ def fix_gettext():
|
||||||
gettext.ugettext = ugettext
|
gettext.ugettext = ugettext
|
||||||
def ungettext(msgid1, msgid2, n):
|
def ungettext(msgid1, msgid2, n):
|
||||||
# unicoded ngettext
|
# 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
|
domain = gettext._current_domain
|
||||||
try:
|
try:
|
||||||
t = gettext.translation(domain,
|
t = gettext.translation(domain,
|
||||||
|
|
|
@ -42,9 +42,9 @@ import Tile
|
||||||
|
|
||||||
# PySol imports
|
# PySol imports
|
||||||
from pysollib.mfxutil import destruct
|
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.util import IMAGE_EXTENSIONS
|
||||||
from pysollib.settings import TITLE
|
from pysollib.settings import TITLE, WIN_SYSTEM
|
||||||
from pysollib.actions import PysolToolbarActions
|
from pysollib.actions import PysolToolbarActions
|
||||||
from pysollib.winsystems import TkSettings
|
from pysollib.winsystems import TkSettings
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ from pysollib.winsystems import TkSettings
|
||||||
from tkconst import EVENT_HANDLED
|
from tkconst import EVENT_HANDLED
|
||||||
from tkwidget import MfxTooltip
|
from tkwidget import MfxTooltip
|
||||||
from menubar import createToolbarMenu, MfxMenu
|
from menubar import createToolbarMenu, MfxMenu
|
||||||
|
from tkutil import loadImage
|
||||||
|
|
||||||
|
|
||||||
# /***********************************************************************
|
# /***********************************************************************
|
||||||
|
@ -261,10 +262,7 @@ class PysolToolbar(PysolToolbarActions):
|
||||||
for ext in IMAGE_EXTENSIONS:
|
for ext in IMAGE_EXTENSIONS:
|
||||||
file = os.path.join(self.dir, name+ext)
|
file = os.path.join(self.dir, name+ext)
|
||||||
if os.path.isfile(file):
|
if os.path.isfile(file):
|
||||||
if Image:
|
image = loadImage(file=file)
|
||||||
image = ImageTk.PhotoImage(Image.open(file))
|
|
||||||
else:
|
|
||||||
image = Tkinter.PhotoImage(file=file)
|
|
||||||
break
|
break
|
||||||
return image
|
return image
|
||||||
|
|
||||||
|
@ -278,9 +276,34 @@ class PysolToolbar(PysolToolbarActions):
|
||||||
self._widgets.append(sep)
|
self._widgets.append(sep)
|
||||||
return 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):
|
def _createButton(self, label, command, check=False, tooltip=None):
|
||||||
name = label.lower()
|
name = label.lower()
|
||||||
image = self._loadImage(name)
|
|
||||||
position = len(self._widgets)
|
position = len(self._widgets)
|
||||||
kw = {
|
kw = {
|
||||||
'position' : position,
|
'position' : position,
|
||||||
|
@ -290,14 +313,13 @@ class PysolToolbar(PysolToolbarActions):
|
||||||
'takefocus' : 0,
|
'takefocus' : 0,
|
||||||
'text' : _(label),
|
'text' : _(label),
|
||||||
}
|
}
|
||||||
if image:
|
|
||||||
kw['image'] = image
|
|
||||||
if check:
|
if check:
|
||||||
button = ToolbarCheckbutton(self.frame, **kw)
|
button = ToolbarCheckbutton(self.frame, **kw)
|
||||||
else:
|
else:
|
||||||
button = ToolbarButton(self.frame, **kw)
|
button = ToolbarButton(self.frame, **kw)
|
||||||
|
self._setButtonImage(button, name)
|
||||||
button.show(orient=self.orient)
|
button.show(orient=self.orient)
|
||||||
setattr(self, name + "_image", image)
|
|
||||||
setattr(self, name + "_button", button)
|
setattr(self, name + "_button", button)
|
||||||
self._widgets.append(button)
|
self._widgets.append(button)
|
||||||
if tooltip:
|
if tooltip:
|
||||||
|
@ -409,25 +431,18 @@ class PysolToolbar(PysolToolbarActions):
|
||||||
return 0
|
return 0
|
||||||
if not os.path.isdir(dir):
|
if not os.path.isdir(dir):
|
||||||
return 0
|
return 0
|
||||||
old_dir, old_size = self.dir, self.size
|
|
||||||
self.dir, self.size = dir, size
|
self.dir, self.size = dir, size
|
||||||
data = []
|
data = []
|
||||||
try:
|
for w in self._widgets:
|
||||||
for w in self._widgets:
|
if not isinstance(w, (ToolbarButton, ToolbarCheckbutton)):
|
||||||
if not isinstance(w, (ToolbarButton, ToolbarCheckbutton)):
|
continue
|
||||||
continue
|
name = w.toolbar_name
|
||||||
name = w.toolbar_name
|
data.append((name, w))
|
||||||
image = self._loadImage(name)
|
|
||||||
data.append((name, w, image))
|
|
||||||
except:
|
|
||||||
self.dir, self.size = old_dir, old_size
|
|
||||||
return 0
|
|
||||||
l = self.player_label
|
l = self.player_label
|
||||||
aspect = (400, 300) [size != 0]
|
aspect = (400, 300) [size != 0]
|
||||||
l.config(aspect=aspect)
|
l.config(aspect=aspect)
|
||||||
for name, w, image in data:
|
for name, w in data:
|
||||||
w.config(image=image)
|
self._setButtonImage(w, name)
|
||||||
setattr(self, name + "_image", image)
|
|
||||||
self.setCompound(self.compound, force=True)
|
self.setCompound(self.compound, force=True)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
@ -437,11 +452,7 @@ class PysolToolbar(PysolToolbarActions):
|
||||||
for w in self._widgets:
|
for w in self._widgets:
|
||||||
if not isinstance(w, (ToolbarButton, ToolbarCheckbutton)):
|
if not isinstance(w, (ToolbarButton, ToolbarCheckbutton)):
|
||||||
continue
|
continue
|
||||||
if compound == 'text':
|
w.config(compound=compound)
|
||||||
w.config(compound='none', image='')
|
|
||||||
else:
|
|
||||||
image = getattr(self, w.toolbar_name+'_image')
|
|
||||||
w.config(compound=compound, image=image)
|
|
||||||
self.compound = compound
|
self.compound = compound
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue