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

new module: pysollib.tksettings

files:
  common.py - base classes for all platforms
  win32.py, x11.py, aqua.py - platform-specific settings
classes:
  initRootWindow - init window (main and html_help)
  TkSettings - contain gui-options


git-svn-id: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@120 efabe8c0-fbe8-4139-b769-b5e6d273206e
This commit is contained in:
skomoroh 2006-12-14 23:35:12 +00:00
parent 24849a81ab
commit 76eea5a5a5
15 changed files with 339 additions and 152 deletions

View file

@ -3,7 +3,7 @@
## ##
## code ## code
## ##
include pysol setup.py setup.cfg MANIFEST.in Makefile COPYING README include pysol.py setup.py setup.cfg MANIFEST.in Makefile COPYING README
#recursive-include pysollib *.py #recursive-include pysollib *.py
include pysollib/*.py pysollib/macosx/*.py include pysollib/*.py pysollib/macosx/*.py
include pysollib/tk/*.py pysollib/tile/*.py pysollib/pysolgtk/*.py include pysollib/tk/*.py pysollib/tile/*.py pysollib/pysolgtk/*.py
@ -19,7 +19,7 @@ include scripts/all_games.py scripts/cardset_viewer.py
## ##
include docs/* include docs/*
graft data/html graft data/html
graft data/html-src graft html-src
## ##
## data - images ## data - images
## ##

View file

@ -49,6 +49,7 @@ from pysolaudio import thread, pysolsoundserver
from pysolaudio import AbstractAudioClient, PysolSoundServerModuleClient from pysolaudio import AbstractAudioClient, PysolSoundServerModuleClient
from pysolaudio import Win32AudioClient, OSSAudioClient, PyGameAudioClient from pysolaudio import Win32AudioClient, OSSAudioClient, PyGameAudioClient
from settings import PACKAGE, SOUND_MOD from settings import PACKAGE, SOUND_MOD
from tksettings import initRootWindow
# Toolkit imports # Toolkit imports
from pysoltk import wm_withdraw, loadImage from pysoltk import wm_withdraw, loadImage
@ -84,9 +85,6 @@ def parse_option(argv):
try: try:
optlist, args = getopt.getopt(argv[1:], "g:i:hD:", optlist, args = getopt.getopt(argv[1:], "g:i:hD:",
["game=", "gameid=", ["game=", "gameid=",
"fg=", "foreground=",
"bg=", "background=",
"fn=", "font=",
"french-only", "french-only",
"noplugins", "noplugins",
"nosound", "nosound",
@ -99,9 +97,6 @@ def parse_option(argv):
opts = {"help" : False, opts = {"help" : False,
"game" : None, "game" : None,
"gameid" : None, "gameid" : None,
"fg" : None,
"bg" : None,
"fn" : None,
"french-only" : False, "french-only" : False,
"noplugins" : False, "noplugins" : False,
"nosound" : False, "nosound" : False,
@ -114,12 +109,6 @@ def parse_option(argv):
opts["game"] = i[1] opts["game"] = i[1]
elif i[0] in ("-i", "--gameid"): elif i[0] in ("-i", "--gameid"):
opts["gameid"] = i[1] opts["gameid"] = i[1]
elif i[0] in ("--fg", "--foreground"):
opts["fg"] = i[1]
elif i[0] in ("--bg", "--background"):
opts["bg"] = i[1]
elif i[0] in ("--fn", "--font"):
opts["fn"] = i[1]
elif i[0] == "--french-only": elif i[0] == "--french-only":
opts["french-only"] = True opts["french-only"] = True
elif i[0] == "--noplugins": elif i[0] == "--noplugins":
@ -261,7 +250,7 @@ def pysol_init(app, args):
app.opt.sound_mode = 0 app.opt.sound_mode = 0
# init toolkit 2) # init toolkit 2)
top.initToolkit(app, opts['fg'], opts['bg'], opts['fn']) initRootWindow(top, app)
# check games # check games
if len(app.gdb.getGamesIdSortedByName()) == 0: if len(app.gdb.getGamesIdSortedByName()) == 0:

View file

@ -340,11 +340,6 @@ class PysolMenubar(PysolMenubarActions):
def _createMenubar(self): def _createMenubar(self):
MfxMenubar.addPath = self._addPath MfxMenubar.addPath = self._addPath
kw = { "name": "menubar" } kw = { "name": "menubar" }
if WIN_SYSTEM == "x11":
pass
##kw["relief"] = "groove"
kw["activeborderwidth"] = 1
kw['bd'] = 1
self.__menubar = apply(MfxMenubar, (self.top,), kw) self.__menubar = apply(MfxMenubar, (self.top,), kw)
# init keybindings # init keybindings

View file

@ -158,26 +158,9 @@ def makeToplevel(parent, title=None):
def make_help_toplevel(app, title=None): def make_help_toplevel(app, title=None):
# Create an independent Toplevel window. # Create an independent Toplevel window.
parent = app.top from pysollib.tksettings import initRootWindow
window = Tkinter.Tk(className=PACKAGE) window = Tkinter.Tk(className=PACKAGE)
theme = app.opt.tile_theme initRootWindow(window, app)
init_tile(app, window, theme)
font = parent.option_get('font', '')
if font:
window.option_add('*font', font)
fg, bg = app.top_palette
if bg:
window.tk_setPalette(bg)
if fg:
window.option_add('*foreground', fg)
window.option_add('*selectBackground', '#00008b', 50)
window.option_add('*selectForeground', 'white', 50)
if WIN_SYSTEM == "x11":
window.option_add('*Scrollbar.elementBorderWidth', '1', 60)
window.option_add('*Scrollbar.borderWidth', '1', 60)
if title:
window.wm_title(title)
window.wm_iconname(title)
return window return window

View file

@ -49,8 +49,9 @@ except ImportError:
# PySol imports # PySol imports
from pysollib.mfxutil import destruct from pysollib.mfxutil import destruct
from pysollib.util import IMAGE_EXTENSIONS from pysollib.util import IMAGE_EXTENSIONS
from pysollib.settings import PACKAGE, WIN_SYSTEM from pysollib.settings import PACKAGE
from pysollib.actions import PysolToolbarActions from pysollib.actions import PysolToolbarActions
from pysollib.tksettings import TkSettings
# Toolkit imports # Toolkit imports
from tkconst import EVENT_HANDLED, EVENT_PROPAGATE from tkconst import EVENT_HANDLED, EVENT_PROPAGATE
@ -77,17 +78,13 @@ class AbstractToolbarButton:
return return
self.visible = True self.visible = True
if orient == 'horizontal': if orient == 'horizontal':
padx, pady = 0, 2 padx, pady = TkSettings.toolbar_button_padding
if WIN_SYSTEM == 'win32':
padx, pady = 2, 2
self.grid(row=0, self.grid(row=0,
column=self.position, column=self.position,
padx=padx, pady=pady, padx=padx, pady=pady,
sticky='nsew') sticky='nsew')
else: else:
padx, pady = 2, 0 pady, padx = TkSettings.toolbar_button_padding
if WIN_SYSTEM == 'win32':
padx, pady = 2, 2
self.grid(row=self.position, self.grid(row=self.position,
column=0, column=0,
padx=padx, pady=pady, padx=padx, pady=pady,
@ -153,9 +150,7 @@ class ToolbarLabel(Tkinter.Message):
if self.visible and not force: if self.visible and not force:
return return
self.visible = True self.visible = True
padx, pady = 4, 4 padx, pady = TkSettings.toolbar_label_padding
if WIN_SYSTEM == 'win32':
padx, pady = 6, 6
if orient == 'horizontal': if orient == 'horizontal':
self.grid(row=0, self.grid(row=0,
column=self.position, column=self.position,
@ -192,7 +187,9 @@ class PysolToolbar(PysolToolbarActions):
self.compound = compound self.compound = compound
self.orient='horizontal' self.orient='horizontal'
# #
self.frame = Tkinter.Frame(top, class_='Toolbar') self.frame = Tkinter.Frame(top, class_='Toolbar',
relief=TkSettings.toolbar_relief,
borderwidth=TkSettings.toolbar_borderwidth)
# #
for l, f, t in ( for l, f, t in (
(n_("New"), self.mNewGame, _("New game")), (n_("New"), self.mNewGame, _("New game")),
@ -231,13 +228,6 @@ class PysolToolbar(PysolToolbarActions):
self.frame.bind("<3>", self.rightclickHandler) self.frame.bind("<3>", self.rightclickHandler)
# #
self.setCompound(compound, force=True) self.setCompound(compound, force=True)
# Change the look of the frame to match the platform look
if WIN_SYSTEM == 'x11':
pass
elif WIN_SYSTEM == "win32":
self.frame.config(relief='groove')
else:
pass
def config(self, w, v): def config(self, w, v):
if w == 'player': if w == 'player':

View file

@ -80,16 +80,6 @@ def createToolbarMenu(menubar, menu):
submenu.add_radiobutton(label=name, submenu.add_radiobutton(label=name,
variable=menubar.tkopt.toolbar_style, variable=menubar.tkopt.toolbar_style,
value=f, command=menubar.mOptToolbarStyle) value=f, command=menubar.mOptToolbarStyle)
submenu = MfxMenu(menu, label=n_('Relief'), tearoff=tearoff)
submenu.add_radiobutton(label=n_('Flat'),
variable=menubar.tkopt.toolbar_relief,
value=Tkinter.FLAT,
command=menubar.mOptToolbarRelief)
submenu.add_radiobutton(label=n_('Raised'),
variable=menubar.tkopt.toolbar_relief,
value=Tkinter.RAISED,
command=menubar.mOptToolbarRelief)
if Tkinter.TkVersion >= 8.4: if Tkinter.TkVersion >= 8.4:
submenu = MfxMenu(menu, label=n_('Compound'), tearoff=tearoff) submenu = MfxMenu(menu, label=n_('Compound'), tearoff=tearoff)
for comp, label in COMPOUNDS: for comp, label in COMPOUNDS:
@ -347,11 +337,6 @@ class PysolMenubar(PysolMenubarActions):
def _createMenubar(self): def _createMenubar(self):
MfxMenubar.addPath = self._addPath MfxMenubar.addPath = self._addPath
kw = { "name": "menubar" } kw = { "name": "menubar" }
if WIN_SYSTEM == "x11":
pass
##kw["relief"] = "groove"
kw["activeborderwidth"] = 1
kw['bd'] = 1
self.__menubar = apply(MfxMenubar, (self.top,), kw) self.__menubar = apply(MfxMenubar, (self.top,), kw)
# init keybindings # init keybindings

View file

@ -156,25 +156,9 @@ def makeToplevel(parent, title=None):
def make_help_toplevel(app, title=None): def make_help_toplevel(app, title=None):
# Create an independent Toplevel window. # Create an independent Toplevel window.
parent = app.top from pysollib.tksettings import initRootWindow
window = Tkinter.Tk(className=PACKAGE) window = Tkinter.Tk(className=PACKAGE)
font = parent.option_get('font', '') initRootWindow(window, app)
if font:
window.option_add('*font', font)
fg, bg = app.top_palette
if bg:
window.tk_setPalette(bg)
if fg:
window.option_add('*foreground', fg)
window.option_add('*selectBackground', '#00008b', 50)
window.option_add('*selectForeground', 'white', 50)
if WIN_SYSTEM == "x11":
window.option_add('*Scrollbar.elementBorderWidth', '1', 60)
window.option_add('*Scrollbar.borderWidth', '1', 60)
if title:
window.wm_title(title)
window.wm_iconname(title)
return window return window

View file

@ -52,6 +52,7 @@ from pysollib.macosx.appSupport import setupApp
from tkutil import after_idle, wm_set_icon from tkutil import after_idle, wm_set_icon
from tkconst import EVENT_HANDLED, EVENT_PROPAGATE from tkconst import EVENT_HANDLED, EVENT_PROPAGATE
# /*********************************************************************** # /***********************************************************************
# // menubar # // menubar
# ************************************************************************/ # ************************************************************************/

View file

@ -49,6 +49,7 @@ from pysollib.mfxutil import destruct
from pysollib.util import IMAGE_EXTENSIONS from pysollib.util import IMAGE_EXTENSIONS
from pysollib.settings import PACKAGE, WIN_SYSTEM from pysollib.settings import PACKAGE, WIN_SYSTEM
from pysollib.actions import PysolToolbarActions from pysollib.actions import PysolToolbarActions
from pysollib.tksettings import TkSettings
# Toolkit imports # Toolkit imports
from tkconst import EVENT_HANDLED, EVENT_PROPAGATE from tkconst import EVENT_HANDLED, EVENT_PROPAGATE
@ -149,8 +150,7 @@ class ToolbarLabel(Tkinter.Message):
if self.visible and not force: if self.visible and not force:
return return
self.visible = True self.visible = True
padx = 4 padx, pady = TkSettings.toolbar_label_padding
pady = 4
if orient == Tkinter.HORIZONTAL: if orient == Tkinter.HORIZONTAL:
self.grid(row=0, self.grid(row=0,
column=self.position, column=self.position,
@ -179,7 +179,7 @@ class PysolToolbar(PysolToolbarActions):
PysolToolbarActions.__init__(self) PysolToolbarActions.__init__(self)
self.top = top self.top = top
self._setRelief(relief) #self._setRelief(relief)
self.side = -1 self.side = -1
self._tooltips = [] self._tooltips = []
self._widgets = [] self._widgets = []
@ -187,11 +187,10 @@ class PysolToolbar(PysolToolbarActions):
self.size = size self.size = size
self.compound = compound self.compound = compound
self.orient=Tkinter.HORIZONTAL self.orient=Tkinter.HORIZONTAL
self.label_padx = 4
self.label_pady = 4
self.button_pad = 2 self.button_pad = 2
# #
self.frame = Tkinter.Frame(top) self.frame = Tkinter.Frame(top, relief=TkSettings.toolbar_relief,
bd=TkSettings.toolbar_borderwidth)
# #
for l, f, t in ( for l, f, t in (
(n_("New"), self.mNewGame, _("New game")), (n_("New"), self.mNewGame, _("New game")),
@ -232,17 +231,6 @@ class PysolToolbar(PysolToolbarActions):
self.frame.bind("<3>", self.rightclickHandler) self.frame.bind("<3>", self.rightclickHandler)
# #
self.setCompound(compound, force=True) self.setCompound(compound, force=True)
# Change the look of the frame to match the platform look
# (see also setRelief)
if WIN_SYSTEM == 'x11':
#self.frame.config(bd=0, highlightthickness=1)
self.frame.config(bd=1, relief=self.frame_relief, highlightthickness=0)
elif WIN_SYSTEM == "win32":
self.frame.config(bd=2, relief=self.frame_relief, padx=2, pady=2)
#self._createSeparator(width=4, side=Tkinter.LEFT, relief=Tkinter.FLAT)
#self._createSeparator(width=4, side=Tkinter.RIGHT, relief=Tkinter.FLAT)
else:
self.frame.config(bd=0, highlightthickness=1)
def config(self, w, v): def config(self, w, v):
if w == 'player': if w == 'player':
@ -273,27 +261,6 @@ class PysolToolbar(PysolToolbarActions):
if w.visible: if w.visible:
prev_visible = w prev_visible = w
def _setRelief(self, relief):
if type(relief) is types.IntType:
relief = ('raised', 'flat')[relief]
elif relief in ('raised', 'flat'):
pass
else:
relief = 'flat'
self.button_relief = relief
if relief == 'raised':
self.frame_relief = 'flat'
self.separator_relief = 'flat'
if WIN_SYSTEM == 'win32':
self.frame_relief = 'groove'
else:
self.frame_relief = 'raised'
self.separator_relief = 'sunken' #'raised'
if WIN_SYSTEM == 'win32':
self.frame_relief = 'groove'
self.separator_relief = 'groove'
return relief
# util # util
def _loadImage(self, name): def _loadImage(self, name):
file = os.path.join(self.dir, name) file = os.path.join(self.dir, name)
@ -317,7 +284,7 @@ class PysolToolbar(PysolToolbarActions):
highlightthickness=1, highlightthickness=1,
width=4, width=4,
takefocus=0, takefocus=0,
relief=self.separator_relief) relief=TkSettings.toolbar_separator_relief)
sep.show(orient=self.orient) sep.show(orient=self.orient)
self._widgets.append(sep) self._widgets.append(sep)
return sep return sep
@ -342,7 +309,9 @@ class PysolToolbar(PysolToolbarActions):
name = label.lower() name = label.lower()
image = self._loadImage(name) image = self._loadImage(name)
position = len(self._widgets) position = len(self._widgets)
bd = self.button_relief == 'flat' and 1 or 2 button_relief = TkSettings.toolbar_button_relief
bd = TkSettings.toolbar_button_borderwidth
padx, pady = TkSettings.toolbar_button_padding
kw = { kw = {
'position' : position, 'position' : position,
'toolbar' : self, 'toolbar' : self,
@ -351,9 +320,9 @@ class PysolToolbar(PysolToolbarActions):
'takefocus' : 0, 'takefocus' : 0,
'text' : gettext(label), 'text' : gettext(label),
'bd' : bd, 'bd' : bd,
'relief' : self.button_relief, 'relief' : button_relief,
'padx' : self.button_pad, 'padx' : padx,
'pady' : self.button_pad 'pady' : pady,
} }
if Tkinter.TkVersion >= 8.4: if Tkinter.TkVersion >= 8.4:
kw['overrelief'] = 'raised' kw['overrelief'] = 'raised'
@ -361,7 +330,7 @@ class PysolToolbar(PysolToolbarActions):
kw['image'] = image kw['image'] = image
if check: if check:
if Tkinter.TkVersion >= 8.4: if Tkinter.TkVersion >= 8.4:
kw['offrelief'] = self.button_relief kw['offrelief'] = button_relief
kw['indicatoron'] = False kw['indicatoron'] = False
kw['selectcolor'] = '' kw['selectcolor'] = ''
button = ToolbarCheckbutton(self.frame, **kw) button = ToolbarCheckbutton(self.frame, **kw)
@ -498,23 +467,6 @@ class PysolToolbar(PysolToolbarActions):
self.setCompound(self.compound, force=True) self.setCompound(self.compound, force=True)
return 1 return 1
def setRelief(self, relief):
if self.button_relief == relief:
return False
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):
w.config(relief=self.button_relief, bd=bd)
elif isinstance(w, ToolbarCheckbutton):
w.config(relief=self.button_relief, bd=bd)
if Tkinter.TkVersion >= 8.4:
w.config(offrelief=self.button_relief)
elif w.__class__ is ToolbarSeparator: # not ToolbarFlatSeparator
w.config(relief=self.separator_relief)
return True
def setCompound(self, compound, force=False): def setCompound(self, compound, force=False):
if Tkinter.TkVersion < 8.4: if Tkinter.TkVersion < 8.4:
return False return False

View file

@ -0,0 +1,32 @@
##---------------------------------------------------------------------------##
##
## PySol -- a Python Solitaire game
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; see the file COPYING.
## If not, write to the Free Software Foundation, Inc.,
## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
##
##---------------------------------------------------------------------------##
from pysollib.settings import WIN_SYSTEM
if WIN_SYSTEM == 'win32':
import win32 as gui
elif WIN_SYSTEM == 'aqua':
import aqua as gui
else: # 'x11'
import x11 as gui
initRootWindow = gui.initRootWindow
TkSettings = gui.TkSettings

View file

@ -0,0 +1,47 @@
##---------------------------------------------------------------------------##
##
## PySol -- a Python Solitaire game
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; see the file COPYING.
## If not, write to the Free Software Foundation, Inc.,
## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
##
##---------------------------------------------------------------------------##
import sys, os
from pysollib.settings import TOOLKIT, USE_TILE
from pysollib.tile import Tile
from pysollib.macosx.appSupport import setupApp, hideTkConsole
from common import baseInitRootWindow, BaseTkSettings
class initRootWindow(baseInitRootWindow):
def __init__(self, root, app):
baseInitRootWindow.__init__(self, root, app)
#setupApp(app)
hideTkConsole(root)
if TOOLKIT == 'gtk':
pass
elif USE_TILE:
pass
else:
#root.option_add(...)
pass
class TkSettings(BaseTkSettings):
pass

View file

@ -0,0 +1,94 @@
##---------------------------------------------------------------------------##
##
## PySol -- a Python Solitaire game
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; see the file COPYING.
## If not, write to the Free Software Foundation, Inc.,
## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
##
##---------------------------------------------------------------------------##
import sys, os, traceback
from pysollib.settings import PACKAGE, VERSION
from pysollib.settings import TOOLKIT, USE_TILE
from pysollib.tile import Tile
from pysollib.pysoltk import wm_set_icon
def init_tile(app, top, theme):
top.tk.call("package", "require", "tile")
# load available themes
d = os.path.join(app.dataloader.dir, 'themes')
if os.path.isdir(d):
top.tk.call('lappend', 'auto_path', d)
for t in os.listdir(d):
if os.path.exists(os.path.join(d, t, 'pkgIndex.tcl')):
try:
top.tk.call('package', 'require', 'tile::theme::'+t)
#print 'load theme:', t
except:
traceback.print_exc()
pass
def set_theme(top, theme):
# set theme
style = Tile.Style(top)
all_themes = style.theme_names()
if theme not in all_themes:
print >> sys.stderr, 'WARNING: invalid theme name:', theme
theme = 'default'
style.theme_use(theme)
class baseInitRootWindow:
def __init__(self, root, app):
#root.wm_group(root)
root.wm_title(PACKAGE + ' ' + VERSION)
root.wm_iconname(PACKAGE + ' ' + VERSION)
try:
wm_set_icon(root, app.dataloader.findIcon())
except: pass
# set minsize
sw, sh, sd = (root.winfo_screenwidth(),
root.winfo_screenheight(),
root.winfo_screendepth())
if sw < 640 or sh < 480:
root.wm_minsize(400, 300)
else:
root.wm_minsize(520, 360)
if TOOLKIT == 'gtk':
pass
elif USE_TILE:
theme = app.opt.tile_theme
init_tile(app, root, theme)
set_theme(root, theme)
else:
pass
class BaseTkSettings:
toolbar_button_padding = (2, 2)
toolbar_label_padding = (4, 4)
if USE_TILE:
toolbar_relief = 'flat'
toolbar_borderwidth = 0
else:
toolbar_relief = 'raised'
toolbar_button_relief = 'flat'
toolbar_separator_relief = 'sunken'
toolbar_borderwidth = 1
toolbar_button_borderwidth = 1

View file

@ -0,0 +1,57 @@
##---------------------------------------------------------------------------##
##
## PySol -- a Python Solitaire game
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; see the file COPYING.
## If not, write to the Free Software Foundation, Inc.,
## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
##
##---------------------------------------------------------------------------##
import sys, os
from pysollib.settings import TOOLKIT, USE_TILE
from pysollib.tile import Tile
from common import baseInitRootWindow
class initRootWindow(baseInitRootWindow):
def __init__(self, root, app):
baseInitRootWindow.__init__(self, root, app)
if TOOLKIT == 'gtk':
pass
elif USE_TILE:
theme = app.opt.tile_theme
if theme not in ('winnative', 'xpnative'):
color = style.lookup('.', 'background')
if color:
top.tk_setPalette(color)
##top.option_add('*Menu.foreground', 'black')
top.option_add('*Menu.activeBackground', '#08246b')
top.option_add('*Menu.activeForeground', 'white')
if theme == 'winnative':
style.configure('Toolbutton', padding=2)
else:
#root.option_add(...)
pass
class TkSettings(BaseTkSettings):
toolbar_relief = 'groove'
toolbar_borderwidth = 2
if USE_TILE:
toolbar_button_padding = (2, 0)
toolbar_label_padding = (6, 6)

View file

@ -0,0 +1,78 @@
##---------------------------------------------------------------------------##
##
## PySol -- a Python Solitaire game
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; see the file COPYING.
## If not, write to the Free Software Foundation, Inc.,
## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
##
##---------------------------------------------------------------------------##
import sys, os
from pysollib.settings import TOOLKIT, USE_TILE
from pysollib.tile import Tile
from common import baseInitRootWindow, BaseTkSettings
# /***********************************************************************
# // Init root window
# ************************************************************************/
class initRootWindow(baseInitRootWindow):
def __init__(self, root, app):
baseInitRootWindow.__init__(self, root, app)
##root.self.wm_maxsize(9999, 9999) # unlimited
if TOOLKIT == 'gtk':
pass
elif USE_TILE:
f = os.path.join(app.dataloader.dir, 'tcl', 'menu8.4.tcl')
if os.path.exists(f):
root.tk.call('source', f)
style = Tile.Style(root)
color = style.lookup('.', 'background')
if color:
root.tk_setPalette(color)
color = style.lookup('.', 'background', 'active')
if color:
root.option_add('*Menu.activeBackground', color)
font = style.lookup('.', 'font')
if font:
root.option_add('*font', font)
root.option_add('*Menu.borderWidth', 1, 60)
root.option_add('*Menu.activeBorderWidth', 1, 60)
#
else:
root.option_add('*Entry.background', 'white', 60)
root.option_add('*Entry.foreground', 'black', 60)
root.option_add('*Listbox.background', 'white', 60)
root.option_add('*Listbox.foreground', 'black', 60)
##root.option_add('*borderWidth', '1', 50)
##root.option_add('*Button.borderWidth', '1', 50)
root.option_add('*Scrollbar.elementBorderWidth', 1, 60)
root.option_add('*Scrollbar.borderWidth', 1, 60)
root.option_add('*Menu.borderWidth', 1, 60)
root.option_add('*Menu.activeBorderWidth', 1, 60)
#root.option_add('*Button.HighlightBackground', '#595d59')
#root.option_add('*Button.HighlightThickness', '1')
root.option_add('*font', 'helvetica 12', 60)
class TkSettings(BaseTkSettings):
pass

View file

@ -77,7 +77,7 @@ kw = {
} }
if os.name == 'nt': if os.name == 'nt':
kw['windows'] = [{'script': 'pysol', kw['windows'] = [{'script': 'pysol.py',
'icon_resources': [(1, 'data/pysol.ico')], }] 'icon_resources': [(1, 'data/pysol.ico')], }]
kw['packages'].remove('pysollib.pysolgtk') kw['packages'].remove('pysollib.pysolgtk')