mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
+ improved tile support
git-svn-id: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@79 efabe8c0-fbe8-4139-b769-b5e6d273206e
This commit is contained in:
parent
9e682f4bfe
commit
d89f589b82
5 changed files with 51 additions and 19 deletions
|
@ -17,6 +17,7 @@ include scripts/all_games.py scripts/cardset_viewer.py
|
|||
include docs/*
|
||||
graft data/html
|
||||
graft data/html-src
|
||||
graft data/themes
|
||||
##
|
||||
## data - images
|
||||
##
|
||||
|
|
|
@ -213,9 +213,6 @@ def pysol_init(app, args):
|
|||
app.debug = int(opts['debug'])
|
||||
except:
|
||||
print >> sys.stderr, 'invalid argument for debug'
|
||||
if opts['tile-theme']:
|
||||
import settings
|
||||
settings.TILE_THEME = opts['tile-theme']
|
||||
|
||||
# init games database
|
||||
import games
|
||||
|
@ -245,8 +242,15 @@ def pysol_init(app, args):
|
|||
app.top_bg = top.cget("bg")
|
||||
app.top_palette = [None, None] # [fg, bg]
|
||||
app.top_cursor = top.cget("cursor")
|
||||
|
||||
# print some debug info
|
||||
if USE_TILE:
|
||||
import settings
|
||||
if opts['tile-theme']:
|
||||
settings.TILE_THEME = opts['tile-theme']
|
||||
from pysoltk import load_theme
|
||||
try:
|
||||
load_theme(app, top, settings.TILE_THEME)
|
||||
except Exception, err:
|
||||
print >> sys.stderr, 'ERROR: set theme:', err
|
||||
|
||||
# load options
|
||||
app.loadOptions()
|
||||
|
|
|
@ -52,6 +52,7 @@ __all__ = ['wm_withdraw',
|
|||
#'fillImage',
|
||||
'createImage',
|
||||
'get_text_width',
|
||||
'load_theme',
|
||||
]
|
||||
|
||||
# imports
|
||||
|
@ -174,14 +175,9 @@ def make_help_toplevel(app, title=None):
|
|||
# Create an independent Toplevel window.
|
||||
parent = app.top
|
||||
window = Tkinter.Tk(className=PACKAGE)
|
||||
window.tk.call('package', 'require', 'tile')
|
||||
from pysollib.settings import TILE_THEME
|
||||
if TILE_THEME:
|
||||
##window.tk.call('style', 'theme', 'use', TILE_THEME)
|
||||
style = Tkinter.Style(window)
|
||||
style.theme_use(TILE_THEME)
|
||||
bg = window.tk.call('style', 'lookup', TILE_THEME, '-background')
|
||||
window.tk_setPalette(bg)
|
||||
load_theme(app, window, TILE_THEME)
|
||||
font = parent.option_get('font', '')
|
||||
if font:
|
||||
window.option_add('*font', font)
|
||||
|
@ -195,7 +191,6 @@ def make_help_toplevel(app, title=None):
|
|||
if os.name == "posix":
|
||||
window.option_add('*Scrollbar.elementBorderWidth', '1', 60)
|
||||
window.option_add('*Scrollbar.borderWidth', '1', 60)
|
||||
|
||||
if title:
|
||||
window.wm_title(title)
|
||||
window.wm_iconname(title)
|
||||
|
@ -409,3 +404,31 @@ def createImage(width, height, fill, outline=None):
|
|||
def get_text_width(text, font, root=None):
|
||||
return Font(root=root, font=font).measure(text)
|
||||
|
||||
|
||||
# /***********************************************************************
|
||||
# //
|
||||
# ************************************************************************/
|
||||
|
||||
def load_theme(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):
|
||||
#top.tk.call('tile::setTheme', t)
|
||||
try:
|
||||
top.tk.call('package', 'require', 'tile::theme::'+t)
|
||||
##print 'load theme:', t
|
||||
except:
|
||||
traceback.print_exc()
|
||||
pass
|
||||
# set theme
|
||||
if theme:
|
||||
top.tk.call('style', 'theme', 'use', theme)
|
||||
bg = top.tk.call('style', 'lookup', '.', '-background')
|
||||
top.tk_setPalette(bg)
|
||||
bg = top.tk.call('style', 'lookup', '.', '-background', 'active')
|
||||
top.option_add('*Menu.activeBackground', bg)
|
||||
|
||||
|
||||
|
|
|
@ -85,12 +85,12 @@ StringVar = Tkinter.StringVar
|
|||
class MfxRoot(Tkinter.Tk):
|
||||
def __init__(self, **kw):
|
||||
apply(Tkinter.Tk.__init__, (self,), kw)
|
||||
self.tk.call("package", "require", "tile")
|
||||
from pysollib.settings import TILE_THEME
|
||||
if TILE_THEME:
|
||||
##self.tk.call('style', 'theme', 'use', TILE_THEME)
|
||||
style = Tkinter.Style(self)
|
||||
style.theme_use(TILE_THEME)
|
||||
## self.tk.call("package", "require", "tile")
|
||||
## from pysollib.settings import TILE_THEME
|
||||
## if TILE_THEME:
|
||||
## ##self.tk.call('style', 'theme', 'use', TILE_THEME)
|
||||
## style = Tkinter.Style(self)
|
||||
## style.theme_use(TILE_THEME)
|
||||
self.app = None
|
||||
# for interruptible sleep
|
||||
#self.sleep_var = Tkinter.IntVar(self)
|
||||
|
|
|
@ -38,6 +38,7 @@ __all__ = ['PysolToolbar'] #, 'TOOLBAR_BUTTONS']
|
|||
# imports
|
||||
import os, sys, types
|
||||
import traceback
|
||||
import Tkinter as Tk
|
||||
import Tile as Tkinter
|
||||
try:
|
||||
# PIL
|
||||
|
@ -223,7 +224,8 @@ class PysolToolbar(PysolToolbarActions):
|
|||
self.label_pady = 4
|
||||
self.button_pad = 2
|
||||
#
|
||||
self.frame = Tkinter.Frame(top, class_='Toolbar')
|
||||
#self.frame = Tkinter.Frame(top, class_='Toolbar')
|
||||
self.frame = Tk.Frame(top)
|
||||
#
|
||||
for l, f, t in (
|
||||
(n_("New"), self.mNewGame, _("New game")),
|
||||
|
@ -273,6 +275,7 @@ class PysolToolbar(PysolToolbarActions):
|
|||
if os.name == 'posix':
|
||||
#self.frame.config(bd=0, highlightthickness=1)
|
||||
#~self.frame.config(bd=1, relief=self.frame_relief, highlightthickness=0)
|
||||
self.frame.config(bd=1, relief='raised', highlightthickness=0)
|
||||
pass
|
||||
elif os.name == "nt":
|
||||
self.frame.config(bd=2, relief=self.frame_relief, padx=2, pady=2)
|
||||
|
@ -536,6 +539,7 @@ class PysolToolbar(PysolToolbarActions):
|
|||
return 1
|
||||
|
||||
def setRelief(self, relief):
|
||||
return True
|
||||
if self.button_relief == relief:
|
||||
return False
|
||||
self._setRelief(relief)
|
||||
|
|
Loading…
Add table
Reference in a new issue