mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
* some bugs fixes
* cleanup code git-svn-id: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@121 efabe8c0-fbe8-4139-b769-b5e6d273206e
This commit is contained in:
parent
76eea5a5a5
commit
2c570e5a92
20 changed files with 54 additions and 285 deletions
|
@ -5,7 +5,7 @@
|
||||||
##
|
##
|
||||||
include pysol.py 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 pysollib/tksettings/*.py
|
||||||
include pysollib/tk/*.py pysollib/tile/*.py pysollib/pysolgtk/*.py
|
include pysollib/tk/*.py pysollib/tile/*.py pysollib/pysolgtk/*.py
|
||||||
include pysollib/games/*.py pysollib/games/special/*.py
|
include pysollib/games/*.py pysollib/games/special/*.py
|
||||||
include pysollib/games/ultra/*.py pysollib/games/mahjongg/*.py
|
include pysollib/games/ultra/*.py pysollib/games/mahjongg/*.py
|
||||||
|
|
|
@ -56,6 +56,7 @@ from game import Game
|
||||||
from gamedb import GI, GAME_DB, loadGame
|
from gamedb import GI, GAME_DB, loadGame
|
||||||
from settings import TOP_SIZE, TOP_TITLE, TOOLKIT
|
from settings import TOP_SIZE, TOP_TITLE, TOOLKIT
|
||||||
from settings import DEBUG
|
from settings import DEBUG
|
||||||
|
from tksettings import TkSettings
|
||||||
|
|
||||||
# Toolkit imports
|
# Toolkit imports
|
||||||
from pysoltk import wm_withdraw, loadImage
|
from pysoltk import wm_withdraw, loadImage
|
||||||
|
@ -671,11 +672,9 @@ class Application:
|
||||||
# create the canvas
|
# create the canvas
|
||||||
self.scrolled_canvas = MfxScrolledCanvas(self.top)
|
self.scrolled_canvas = MfxScrolledCanvas(self.top)
|
||||||
self.canvas = self.scrolled_canvas.canvas
|
self.canvas = self.scrolled_canvas.canvas
|
||||||
if WIN_SYSTEM == 'win32':
|
padx, pady = TkSettings.canvas_padding
|
||||||
self.scrolled_canvas.grid(row=1, column=1, sticky='nsew',
|
self.scrolled_canvas.grid(row=1, column=1, sticky='nsew',
|
||||||
padx=1, pady=1)
|
padx=padx, pady=pady)
|
||||||
else:
|
|
||||||
self.scrolled_canvas.grid(row=1, column=1, sticky='nsew')
|
|
||||||
self.top.grid_columnconfigure(1, weight=1)
|
self.top.grid_columnconfigure(1, weight=1)
|
||||||
self.top.grid_rowconfigure(1, weight=1)
|
self.top.grid_rowconfigure(1, weight=1)
|
||||||
self.setTile(self.tabletile_index, force=True)
|
self.setTile(self.tabletile_index, force=True)
|
||||||
|
|
|
@ -42,7 +42,7 @@ import Tkinter
|
||||||
# PySol imports
|
# PySol imports
|
||||||
from mfxutil import EnvError
|
from mfxutil import EnvError
|
||||||
from settings import PACKAGE, PACKAGE_URL, TOOLKIT, VERSION, FC_VERSION
|
from settings import PACKAGE, PACKAGE_URL, TOOLKIT, VERSION, FC_VERSION
|
||||||
from pysoltk import make_help_toplevel, wm_map, wm_set_icon
|
from pysoltk import make_help_toplevel, wm_map
|
||||||
from pysoltk import MfxMessageDialog
|
from pysoltk import MfxMessageDialog
|
||||||
from pysoltk import HTMLViewer
|
from pysoltk import HTMLViewer
|
||||||
from gamedb import GAME_DB
|
from gamedb import GAME_DB
|
||||||
|
@ -155,10 +155,6 @@ def help_html(app, document, dir_, top=None):
|
||||||
else:
|
else:
|
||||||
#maximized = 0
|
#maximized = 0
|
||||||
top.wm_minsize(400, 200)
|
top.wm_minsize(400, 200)
|
||||||
try:
|
|
||||||
wm_set_icon(top, app.dataloader.findIcon())
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
viewer = HTMLViewer(top, app, help_html_index)
|
viewer = HTMLViewer(top, app, help_html_index)
|
||||||
viewer.display(doc)
|
viewer.display(doc)
|
||||||
#wm_map(top, maximized=maximized)
|
#wm_map(top, maximized=maximized)
|
||||||
|
|
|
@ -73,26 +73,28 @@ def init():
|
||||||
settings.TOOLKIT = 'tk'
|
settings.TOOLKIT = 'tk'
|
||||||
settings.USE_TILE = True
|
settings.USE_TILE = True
|
||||||
sys.argv.remove('--tile')
|
sys.argv.remove('--tile')
|
||||||
elif settings.TOOLKIT == 'tk' and settings.USE_TILE == 'auto':
|
if settings.TOOLKIT == 'tk':
|
||||||
# check tile
|
|
||||||
import Tkinter
|
import Tkinter
|
||||||
from Tkinter import TclError
|
from Tkinter import TclError
|
||||||
root = Tkinter.Tk()
|
root = Tkinter.Tk()
|
||||||
#
|
|
||||||
# TkAqua displays the console automatically in application
|
|
||||||
# bundles, so we hide it here.
|
|
||||||
from macosx.appSupport import hideTkConsole
|
|
||||||
#
|
|
||||||
hideTkConsole(root)
|
|
||||||
root.withdraw()
|
|
||||||
settings.USE_TILE = False
|
|
||||||
try:
|
|
||||||
root.tk.call('package', 'require', 'tile', '0.7.8')
|
|
||||||
except TclError:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
settings.USE_TILE = True
|
|
||||||
settings.WIN_SYSTEM = root.tk.call('tk', 'windowingsystem')
|
settings.WIN_SYSTEM = root.tk.call('tk', 'windowingsystem')
|
||||||
|
if settings.WIN_SYSTEM == 'aqua':
|
||||||
|
# TkAqua displays the console automatically in application
|
||||||
|
# bundles, so we hide it here.
|
||||||
|
from macosx.appSupport import hideTkConsole
|
||||||
|
hideTkConsole(root)
|
||||||
|
#
|
||||||
|
root.withdraw()
|
||||||
|
if settings.USE_TILE == 'auto':
|
||||||
|
# check tile
|
||||||
|
settings.USE_TILE = False
|
||||||
|
try:
|
||||||
|
root.tk.call('package', 'require', 'tile', '0.7.8')
|
||||||
|
except TclError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
settings.USE_TILE = True
|
||||||
|
# "can't invoke event <<ThemeChanged>>: application has been destroyed"
|
||||||
#root.destroy()
|
#root.destroy()
|
||||||
Tkinter._default_root = None
|
Tkinter._default_root = None
|
||||||
|
|
||||||
|
|
|
@ -51,9 +51,6 @@ def wm_deiconify(window):
|
||||||
def wm_map(window, maximized=None):
|
def wm_map(window, maximized=None):
|
||||||
window.show()
|
window.show()
|
||||||
|
|
||||||
def wm_set_icon(window, icon):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def makeToplevel(parent, title=None, class_=None, gtkclass=gtk.Window):
|
def makeToplevel(parent, title=None, class_=None, gtkclass=gtk.Window):
|
||||||
window = gtkclass()
|
window = gtkclass()
|
||||||
if not hasattr(window, 'table'):
|
if not hasattr(window, 'table'):
|
||||||
|
|
|
@ -51,7 +51,7 @@ from pysollib.actions import PysolMenubarActions
|
||||||
|
|
||||||
# toolkit imports
|
# toolkit imports
|
||||||
from tkconst import EVENT_HANDLED, EVENT_PROPAGATE, CURSOR_WATCH, COMPOUNDS
|
from tkconst import EVENT_HANDLED, EVENT_PROPAGATE, CURSOR_WATCH, COMPOUNDS
|
||||||
from tkutil import bind, after_idle, load_theme
|
from tkutil import bind, after_idle
|
||||||
from selectgame import SelectGameDialog, SelectGameDialogWithPreview
|
from selectgame import SelectGameDialog, SelectGameDialogWithPreview
|
||||||
from soundoptionsdialog import SoundOptionsDialog
|
from soundoptionsdialog import SoundOptionsDialog
|
||||||
from selectcardset import SelectCardsetDialogWithPreview
|
from selectcardset import SelectCardsetDialogWithPreview
|
||||||
|
|
|
@ -41,7 +41,7 @@ import Tile as Tkinter
|
||||||
|
|
||||||
# Toolkit imports
|
# Toolkit imports
|
||||||
from tkconst import EVENT_HANDLED, EVENT_PROPAGATE
|
from tkconst import EVENT_HANDLED, EVENT_PROPAGATE
|
||||||
from tkutil import makeToplevel, setTransient, wm_set_icon
|
from tkutil import makeToplevel, setTransient
|
||||||
|
|
||||||
|
|
||||||
# /***********************************************************************
|
# /***********************************************************************
|
||||||
|
@ -72,10 +72,6 @@ class PysolProgressBar:
|
||||||
else:
|
else:
|
||||||
self.progress.pack(expand='yes', fill='x')
|
self.progress.pack(expand='yes', fill='x')
|
||||||
self.frame.pack(expand='yes', fill='both')
|
self.frame.pack(expand='yes', fill='both')
|
||||||
if app:
|
|
||||||
try:
|
|
||||||
wm_set_icon(self.top, app.dataloader.findIcon())
|
|
||||||
except: pass
|
|
||||||
if 1:
|
if 1:
|
||||||
setTransient(self.top, None, relx=0.5, rely=0.5)
|
setTransient(self.top, None, relx=0.5, rely=0.5)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -239,9 +239,6 @@ class MfxTreeInCanvas(MfxScrolledCanvas):
|
||||||
self.font = None
|
self.font = None
|
||||||
self.linestyle = "gray50"
|
self.linestyle = "gray50"
|
||||||
self.linecolor = "black"
|
self.linecolor = "black"
|
||||||
if WIN_SYSTEM == "win32":
|
|
||||||
self.linestyle = "" # Tk bug ?
|
|
||||||
self.linecolor = "gray50"
|
|
||||||
|
|
||||||
def __init__(self, parent, rootnodes, **kw):
|
def __init__(self, parent, rootnodes, **kw):
|
||||||
kw['bd'] = 0
|
kw['bd'] = 0
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
__all__ = ['wm_withdraw',
|
__all__ = ['wm_withdraw',
|
||||||
'wm_deiconify',
|
'wm_deiconify',
|
||||||
'wm_map',
|
'wm_map',
|
||||||
'wm_set_icon',
|
|
||||||
'wm_get_geometry',
|
'wm_get_geometry',
|
||||||
#'setTransient',
|
#'setTransient',
|
||||||
#'makeToplevel',
|
#'makeToplevel',
|
||||||
|
@ -53,8 +52,6 @@ __all__ = ['wm_withdraw',
|
||||||
'createImage',
|
'createImage',
|
||||||
'shadowImage',
|
'shadowImage',
|
||||||
'get_text_width',
|
'get_text_width',
|
||||||
#'init_tile',
|
|
||||||
#'load_theme',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# imports
|
# imports
|
||||||
|
@ -91,17 +88,6 @@ def wm_map(window, maximized=0):
|
||||||
else:
|
else:
|
||||||
wm_deiconify(window)
|
wm_deiconify(window)
|
||||||
|
|
||||||
def wm_set_icon(window, filename):
|
|
||||||
if not filename:
|
|
||||||
return
|
|
||||||
if WIN_SYSTEM == 'win32':
|
|
||||||
##window.tk.call('wm', 'iconbitmap', root._w, '-default', '@'+filename)
|
|
||||||
pass
|
|
||||||
elif WIN_SYSTEM == 'x11':
|
|
||||||
##window.wm_iconbitmap("@"+filename)
|
|
||||||
##window.wm_iconmask("@"+filename)
|
|
||||||
pass
|
|
||||||
|
|
||||||
__wm_get_geometry_re = re.compile(r"^(\d+)x(\d+)\+([\-]?\d+)\+([\-]?\d+)$")
|
__wm_get_geometry_re = re.compile(r"^(\d+)x(\d+)\+([\-]?\d+)\+([\-]?\d+)$")
|
||||||
|
|
||||||
def wm_get_geometry(window):
|
def wm_get_geometry(window):
|
||||||
|
@ -383,64 +369,4 @@ def get_text_width(text, font, root=None):
|
||||||
return Font(root=root, font=font).measure(text)
|
return Font(root=root, font=font).measure(text)
|
||||||
|
|
||||||
|
|
||||||
# /***********************************************************************
|
|
||||||
# //
|
|
||||||
# ************************************************************************/
|
|
||||||
|
|
||||||
def init_tile(app, top, theme):
|
|
||||||
if WIN_SYSTEM == 'x11':
|
|
||||||
f = os.path.join(app.dataloader.dir, 'tcl', 'menu8.4.tcl')
|
|
||||||
if os.path.exists(f):
|
|
||||||
top.tk.call('source', f)
|
|
||||||
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
|
|
||||||
#
|
|
||||||
load_theme(app, top, theme)
|
|
||||||
|
|
||||||
def load_theme(app, top, theme):
|
|
||||||
# set theme
|
|
||||||
style = Tkinter.Style(top)
|
|
||||||
all_themes = style.theme_names()
|
|
||||||
if theme not in all_themes:
|
|
||||||
print >> sys.stderr, 'WARNING: invalid theme name:', theme
|
|
||||||
theme = 'default'
|
|
||||||
if theme:
|
|
||||||
style.theme_use(theme)
|
|
||||||
if WIN_SYSTEM == 'x11':
|
|
||||||
color = style.lookup('.', 'background')
|
|
||||||
if color:
|
|
||||||
top.tk_setPalette(color)
|
|
||||||
color = style.lookup('.', 'background', 'active')
|
|
||||||
if color:
|
|
||||||
top.option_add('*Menu.activeBackground', color)
|
|
||||||
elif WIN_SYSTEM == 'win32':
|
|
||||||
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)
|
|
||||||
font = app.opt.fonts['default']
|
|
||||||
if font:
|
|
||||||
style.configure('.', font=font)
|
|
||||||
else:
|
|
||||||
font = style.lookup('.', 'font')
|
|
||||||
if font:
|
|
||||||
top.option_add('*font', font)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -47,9 +47,9 @@ from tkFont import Font
|
||||||
|
|
||||||
# PySol imports
|
# PySol imports
|
||||||
from pysollib.mfxutil import destruct, Struct
|
from pysollib.mfxutil import destruct, Struct
|
||||||
from pysollib.settings import PACKAGE, VERSION, WIN_SYSTEM
|
from pysollib.settings import PACKAGE, VERSION
|
||||||
from pysollib.macosx.appSupport import setupApp
|
from pysollib.macosx.appSupport import setupApp
|
||||||
from tkutil import after_idle, init_tile, wm_set_icon
|
from tkutil import after_idle
|
||||||
from tkconst import EVENT_HANDLED, EVENT_PROPAGATE
|
from tkconst import EVENT_HANDLED, EVENT_PROPAGATE
|
||||||
|
|
||||||
# /***********************************************************************
|
# /***********************************************************************
|
||||||
|
@ -99,68 +99,6 @@ class MfxRoot(Tkinter.Tk):
|
||||||
def connectApp(self, app):
|
def connectApp(self, app):
|
||||||
self.app = app
|
self.app = app
|
||||||
|
|
||||||
def initToolkit(self, app, fg=None, bg=None, font=None):
|
|
||||||
setupApp(app)
|
|
||||||
sw, sh, sd = self.winfo_screenwidth(), self.winfo_screenheight(), self.winfo_screendepth()
|
|
||||||
self.wm_group(self)
|
|
||||||
self.wm_title(PACKAGE + ' ' + VERSION)
|
|
||||||
self.wm_iconname(PACKAGE + ' ' + VERSION)
|
|
||||||
if sw < 640 or sh < 480:
|
|
||||||
self.wm_minsize(400, 300)
|
|
||||||
else:
|
|
||||||
self.wm_minsize(540, 380)
|
|
||||||
##self.self.wm_maxsize(9999, 9999) # unlimited
|
|
||||||
self.wm_protocol('WM_DELETE_WINDOW', self.wmDeleteWindow)
|
|
||||||
prog = sys.executable
|
|
||||||
if prog and os.path.isfile(prog):
|
|
||||||
argv0 = os.path.normpath(sys.argv[0])
|
|
||||||
prog = os.path.abspath(prog)
|
|
||||||
if os.path.isfile(argv0):
|
|
||||||
wm_command = prog + " " + os.path.abspath(argv0)
|
|
||||||
self.wm_command(wm_command)
|
|
||||||
if 1:
|
|
||||||
# set expected window size to assist the layout of the window manager
|
|
||||||
self.config(width=min(800,sw-64), height=min(600,sh-64))
|
|
||||||
try:
|
|
||||||
wm_set_icon(self, app.dataloader.findIcon())
|
|
||||||
except: pass
|
|
||||||
|
|
||||||
# font
|
|
||||||
if font:
|
|
||||||
self.option_add('*font', font)
|
|
||||||
elif WIN_SYSTEM == 'x11':
|
|
||||||
self.option_add('*font', 'Helvetica 12', 50)
|
|
||||||
font = self.option_get('font', '')
|
|
||||||
try:
|
|
||||||
f = Font(self, font)
|
|
||||||
except:
|
|
||||||
print >> sys.stderr, 'invalid font name:', font
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
if font:
|
|
||||||
fa = f.actual()
|
|
||||||
app.opt.fonts['default'] = (fa['family'],
|
|
||||||
fa['size'],
|
|
||||||
fa['slant'],
|
|
||||||
fa['weight'])
|
|
||||||
else:
|
|
||||||
app.opt.fonts['default'] = None
|
|
||||||
|
|
||||||
# theme
|
|
||||||
try:
|
|
||||||
init_tile(app, self, app.opt.tile_theme)
|
|
||||||
except TclError:
|
|
||||||
raise
|
|
||||||
except Exception, err:
|
|
||||||
print >> sys.stderr, 'ERROR: set theme:', err
|
|
||||||
##self.option_add('*Toolbar.relief', 'groove')
|
|
||||||
##self.option_add('*Toolbar.relief', 'raised')
|
|
||||||
##self.option_add('*Toolbar.borderWidth', 1)
|
|
||||||
##self.option_add('*Toolbar.Button.Pad', 2)
|
|
||||||
##self.option_add('*Toolbar.Button.default', 'disabled')
|
|
||||||
##self.option_add('*Toolbar*takeFocus', 0)
|
|
||||||
|
|
||||||
|
|
||||||
# sometimes an update() is needed under Windows, whereas
|
# sometimes an update() is needed under Windows, whereas
|
||||||
# under Unix an update_idletasks() would be enough...
|
# under Unix an update_idletasks() would be enough...
|
||||||
def busyUpdate(self):
|
def busyUpdate(self):
|
||||||
|
|
|
@ -40,7 +40,7 @@ import os, sys, Tkinter
|
||||||
|
|
||||||
# Toolkit imports
|
# Toolkit imports
|
||||||
from tkconst import EVENT_HANDLED, EVENT_PROPAGATE
|
from tkconst import EVENT_HANDLED, EVENT_PROPAGATE
|
||||||
from tkutil import makeToplevel, setTransient, wm_set_icon
|
from tkutil import makeToplevel, setTransient
|
||||||
|
|
||||||
|
|
||||||
# /***********************************************************************
|
# /***********************************************************************
|
||||||
|
@ -75,10 +75,6 @@ class PysolProgressBar:
|
||||||
self.f2 = Tkinter.Label(self.frame, image=images[1])
|
self.f2 = Tkinter.Label(self.frame, image=images[1])
|
||||||
self.f2.grid_configure(column=2, row=0, sticky="ew", ipadx=8, ipady=4)
|
self.f2.grid_configure(column=2, row=0, sticky="ew", ipadx=8, ipady=4)
|
||||||
self.top.config(cursor="watch")
|
self.top.config(cursor="watch")
|
||||||
if app:
|
|
||||||
try:
|
|
||||||
wm_set_icon(self.top, app.dataloader.findIcon())
|
|
||||||
except: pass
|
|
||||||
self.pack()
|
self.pack()
|
||||||
if 1:
|
if 1:
|
||||||
setTransient(self.top, None, relx=0.5, rely=0.5)
|
setTransient(self.top, None, relx=0.5, rely=0.5)
|
||||||
|
|
|
@ -331,7 +331,7 @@ class CanvasFormatter(PysolStatsFormatter):
|
||||||
def pstats(self, y, args, gameid=None):
|
def pstats(self, y, args, gameid=None):
|
||||||
x = 1
|
x = 1
|
||||||
t1, t2, t3, t4, t5, t6, t7 = args
|
t1, t2, t3, t4, t5, t6, t7 = args
|
||||||
self.gamenumber = None
|
self.gameid = gameid
|
||||||
if gameid is None: # header
|
if gameid is None: # header
|
||||||
self.gameid = 'header'
|
self.gameid = 'header'
|
||||||
for var, text, anchor, tab in (
|
for var, text, anchor, tab in (
|
||||||
|
@ -342,6 +342,7 @@ class CanvasFormatter(PysolStatsFormatter):
|
||||||
('time', t5, 'ne', self._tabs[5]),
|
('time', t5, 'ne', self._tabs[5]),
|
||||||
('moves', t6, 'ne', self._tabs[6]),
|
('moves', t6, 'ne', self._tabs[6]),
|
||||||
('percent', t7, 'ne', self._tabs[7]), ):
|
('percent', t7, 'ne', self._tabs[7]), ):
|
||||||
|
self.gamenumber = None
|
||||||
if gameid is None: # header
|
if gameid is None: # header
|
||||||
self.gamenumber=var
|
self.gamenumber=var
|
||||||
id = self.canvas.create_text(x, y, text=text, anchor=anchor,
|
id = self.canvas.create_text(x, y, text=text, anchor=anchor,
|
||||||
|
@ -477,6 +478,7 @@ class AllGames_StatsDialog(MfxDialog):
|
||||||
self.player = player
|
self.player = player
|
||||||
self.title = title
|
self.title = title
|
||||||
self.sort_by = 'name'
|
self.sort_by = 'name'
|
||||||
|
self.selected_game = None
|
||||||
#
|
#
|
||||||
kwdefault(kw, width=self.CHAR_W*64, height=lines*self.CHAR_H)
|
kwdefault(kw, width=self.CHAR_W*64, height=lines*self.CHAR_H)
|
||||||
kw = self.initKw(kw)
|
kw = self.initKw(kw)
|
||||||
|
@ -535,7 +537,7 @@ class AllGames_StatsDialog(MfxDialog):
|
||||||
id = self.canvas.find_withtag(Tkinter.CURRENT)
|
id = self.canvas.find_withtag(Tkinter.CURRENT)
|
||||||
if not id:
|
if not id:
|
||||||
return
|
return
|
||||||
##print id, self.nodes.get(id[0])
|
##print 'singleClick:', id, self.nodes.get(id[0])
|
||||||
gameid, gamenumber = self.nodes.get(id[0], (None, None))
|
gameid, gamenumber = self.nodes.get(id[0], (None, None))
|
||||||
if gameid == 'header':
|
if gameid == 'header':
|
||||||
if self.sort_by == gamenumber: return
|
if self.sort_by == gamenumber: return
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
__all__ = ['wm_withdraw',
|
__all__ = ['wm_withdraw',
|
||||||
'wm_deiconify',
|
'wm_deiconify',
|
||||||
'wm_map',
|
'wm_map',
|
||||||
'wm_set_icon',
|
|
||||||
'wm_get_geometry',
|
'wm_get_geometry',
|
||||||
#'setTransient',
|
#'setTransient',
|
||||||
#'makeToplevel',
|
#'makeToplevel',
|
||||||
|
@ -89,17 +88,6 @@ def wm_map(window, maximized=0):
|
||||||
else:
|
else:
|
||||||
wm_deiconify(window)
|
wm_deiconify(window)
|
||||||
|
|
||||||
def wm_set_icon(window, filename):
|
|
||||||
if not filename:
|
|
||||||
return
|
|
||||||
if WIN_SYSTEM == 'win32':
|
|
||||||
pass
|
|
||||||
##window.wm_iconbitmap(default="@"+filename)
|
|
||||||
elif WIN_SYSTEM == "x11":
|
|
||||||
pass
|
|
||||||
##window.wm_iconbitmap("@" + filename)
|
|
||||||
##window.wm_iconmask("@" + filename)
|
|
||||||
|
|
||||||
__wm_get_geometry_re = re.compile(r"^(\d+)x(\d+)\+([\-]?\d+)\+([\-]?\d+)$")
|
__wm_get_geometry_re = re.compile(r"^(\d+)x(\d+)\+([\-]?\d+)\+([\-]?\d+)$")
|
||||||
|
|
||||||
def wm_get_geometry(window):
|
def wm_get_geometry(window):
|
||||||
|
|
|
@ -49,7 +49,7 @@ from tkFont import Font
|
||||||
from pysollib.mfxutil import destruct, Struct
|
from pysollib.mfxutil import destruct, Struct
|
||||||
from pysollib.settings import PACKAGE, VERSION, WIN_SYSTEM
|
from pysollib.settings import PACKAGE, VERSION, WIN_SYSTEM
|
||||||
from pysollib.macosx.appSupport import setupApp
|
from pysollib.macosx.appSupport import setupApp
|
||||||
from tkutil import after_idle, wm_set_icon
|
from tkutil import after_idle
|
||||||
from tkconst import EVENT_HANDLED, EVENT_PROPAGATE
|
from tkconst import EVENT_HANDLED, EVENT_PROPAGATE
|
||||||
|
|
||||||
|
|
||||||
|
@ -100,81 +100,6 @@ class MfxRoot(Tkinter.Tk):
|
||||||
def connectApp(self, app):
|
def connectApp(self, app):
|
||||||
self.app = app
|
self.app = app
|
||||||
|
|
||||||
def initToolkit(self, app, fg=None, bg=None, font=None, theme=None):
|
|
||||||
setupApp(app)
|
|
||||||
sw, sh, sd = self.winfo_screenwidth(), self.winfo_screenheight(), self.winfo_screendepth()
|
|
||||||
self.wm_group(self)
|
|
||||||
self.wm_title(PACKAGE + ' ' + VERSION)
|
|
||||||
self.wm_iconname(PACKAGE + ' ' + VERSION)
|
|
||||||
if sw < 640 or sh < 480:
|
|
||||||
self.wm_minsize(400, 300)
|
|
||||||
else:
|
|
||||||
self.wm_minsize(520, 360)
|
|
||||||
##self.self.wm_maxsize(9999, 9999) # unlimited
|
|
||||||
self.wm_protocol('WM_DELETE_WINDOW', self.wmDeleteWindow)
|
|
||||||
prog = sys.executable
|
|
||||||
if prog and os.path.isfile(prog):
|
|
||||||
argv0 = os.path.normpath(sys.argv[0])
|
|
||||||
prog = os.path.abspath(prog)
|
|
||||||
if os.path.isfile(argv0):
|
|
||||||
wm_command = prog + " " + os.path.abspath(argv0)
|
|
||||||
self.wm_command(wm_command)
|
|
||||||
if 1:
|
|
||||||
# set expected window size to assist the layout of the window manager
|
|
||||||
self.config(width=min(800,sw-64), height=min(600,sh-64))
|
|
||||||
try:
|
|
||||||
wm_set_icon(self, app.dataloader.findIcon())
|
|
||||||
except: pass
|
|
||||||
|
|
||||||
# set global color scheme
|
|
||||||
if not fg and not bg:
|
|
||||||
if WIN_SYSTEM == 'x11': # Unix/X11
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
if bg:
|
|
||||||
self.tk_setPalette(bg)
|
|
||||||
app.top_palette[1] = bg
|
|
||||||
app.top_bg = bg
|
|
||||||
if fg:
|
|
||||||
self.option_add('*foreground', fg)
|
|
||||||
app.top_palette[0] = fg
|
|
||||||
|
|
||||||
#
|
|
||||||
if WIN_SYSTEM == 'x11': # Unix/X11
|
|
||||||
self.option_add('*Entry.background', 'white', 60)
|
|
||||||
self.option_add('*Entry.foreground', 'black', 60)
|
|
||||||
self.option_add('*Listbox.background', 'white', 60)
|
|
||||||
self.option_add('*Listbox.foreground', 'black', 60)
|
|
||||||
##self.option_add('*borderWidth', '1', 50)
|
|
||||||
##self.option_add('*Button.borderWidth', '1', 50)
|
|
||||||
self.option_add('*Scrollbar.elementBorderWidth', '1', 60)
|
|
||||||
self.option_add('*Scrollbar.borderWidth', '1', 60)
|
|
||||||
self.option_add('*Menu.borderWidth', '1', 60)
|
|
||||||
#self.option_add('*Button.HighlightBackground', '#595d59')
|
|
||||||
#self.option_add('*Button.HighlightThickness', '1')
|
|
||||||
|
|
||||||
# font
|
|
||||||
if font:
|
|
||||||
self.option_add('*font', font)
|
|
||||||
elif WIN_SYSTEM == 'x11':
|
|
||||||
self.option_add('*font', 'Helvetica 12', 50)
|
|
||||||
font = self.option_get('font', '')
|
|
||||||
try:
|
|
||||||
f = Font(self, font)
|
|
||||||
except:
|
|
||||||
print >> sys.stderr, 'invalid font name:', font
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
if font:
|
|
||||||
fa = f.actual()
|
|
||||||
app.opt.fonts['default'] = (fa['family'],
|
|
||||||
fa['size'],
|
|
||||||
fa['slant'],
|
|
||||||
fa['weight'])
|
|
||||||
else:
|
|
||||||
app.opt.fonts['default'] = None
|
|
||||||
|
|
||||||
|
|
||||||
# sometimes an update() is needed under Windows, whereas
|
# sometimes an update() is needed under Windows, whereas
|
||||||
# under Unix an update_idletasks() would be enough...
|
# under Unix an update_idletasks() would be enough...
|
||||||
def busyUpdate(self):
|
def busyUpdate(self):
|
||||||
|
|
|
@ -47,7 +47,7 @@ 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
|
from pysollib.tksettings import TkSettings
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,9 @@ from common import baseInitRootWindow, BaseTkSettings
|
||||||
class initRootWindow(baseInitRootWindow):
|
class initRootWindow(baseInitRootWindow):
|
||||||
def __init__(self, root, app):
|
def __init__(self, root, app):
|
||||||
baseInitRootWindow.__init__(self, root, app)
|
baseInitRootWindow.__init__(self, root, app)
|
||||||
#setupApp(app)
|
if TOOLKIT == 'tk':
|
||||||
hideTkConsole(root)
|
#setupApp(app)
|
||||||
|
hideTkConsole(root)
|
||||||
if TOOLKIT == 'gtk':
|
if TOOLKIT == 'gtk':
|
||||||
pass
|
pass
|
||||||
elif USE_TILE:
|
elif USE_TILE:
|
||||||
|
|
|
@ -24,7 +24,6 @@ import sys, os, traceback
|
||||||
from pysollib.settings import PACKAGE, VERSION
|
from pysollib.settings import PACKAGE, VERSION
|
||||||
from pysollib.settings import TOOLKIT, USE_TILE
|
from pysollib.settings import TOOLKIT, USE_TILE
|
||||||
from pysollib.tile import Tile
|
from pysollib.tile import Tile
|
||||||
from pysollib.pysoltk import wm_set_icon
|
|
||||||
|
|
||||||
|
|
||||||
def init_tile(app, top, theme):
|
def init_tile(app, top, theme):
|
||||||
|
@ -57,9 +56,9 @@ class baseInitRootWindow:
|
||||||
#root.wm_group(root)
|
#root.wm_group(root)
|
||||||
root.wm_title(PACKAGE + ' ' + VERSION)
|
root.wm_title(PACKAGE + ' ' + VERSION)
|
||||||
root.wm_iconname(PACKAGE + ' ' + VERSION)
|
root.wm_iconname(PACKAGE + ' ' + VERSION)
|
||||||
try:
|
|
||||||
wm_set_icon(root, app.dataloader.findIcon())
|
root.wm_protocol('WM_DELETE_WINDOW', root.wmDeleteWindow)
|
||||||
except: pass
|
|
||||||
# set minsize
|
# set minsize
|
||||||
sw, sh, sd = (root.winfo_screenwidth(),
|
sw, sh, sd = (root.winfo_screenwidth(),
|
||||||
root.winfo_screenheight(),
|
root.winfo_screenheight(),
|
||||||
|
@ -79,6 +78,7 @@ class baseInitRootWindow:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class BaseTkSettings:
|
class BaseTkSettings:
|
||||||
|
canvas_padding = (0, 0)
|
||||||
toolbar_button_padding = (2, 2)
|
toolbar_button_padding = (2, 2)
|
||||||
toolbar_label_padding = (4, 4)
|
toolbar_label_padding = (4, 4)
|
||||||
if USE_TILE:
|
if USE_TILE:
|
||||||
|
|
|
@ -24,7 +24,7 @@ import sys, os
|
||||||
from pysollib.settings import TOOLKIT, USE_TILE
|
from pysollib.settings import TOOLKIT, USE_TILE
|
||||||
from pysollib.tile import Tile
|
from pysollib.tile import Tile
|
||||||
|
|
||||||
from common import baseInitRootWindow
|
from common import baseInitRootWindow, BaseTkSettings
|
||||||
|
|
||||||
|
|
||||||
class initRootWindow(baseInitRootWindow):
|
class initRootWindow(baseInitRootWindow):
|
||||||
|
@ -34,13 +34,14 @@ class initRootWindow(baseInitRootWindow):
|
||||||
pass
|
pass
|
||||||
elif USE_TILE:
|
elif USE_TILE:
|
||||||
theme = app.opt.tile_theme
|
theme = app.opt.tile_theme
|
||||||
|
style = Tile.Style(root)
|
||||||
if theme not in ('winnative', 'xpnative'):
|
if theme not in ('winnative', 'xpnative'):
|
||||||
color = style.lookup('.', 'background')
|
color = style.lookup('.', 'background')
|
||||||
if color:
|
if color:
|
||||||
top.tk_setPalette(color)
|
root.tk_setPalette(color)
|
||||||
##top.option_add('*Menu.foreground', 'black')
|
##root.option_add('*Menu.foreground', 'black')
|
||||||
top.option_add('*Menu.activeBackground', '#08246b')
|
root.option_add('*Menu.activeBackground', '#08246b')
|
||||||
top.option_add('*Menu.activeForeground', 'white')
|
root.option_add('*Menu.activeForeground', 'white')
|
||||||
if theme == 'winnative':
|
if theme == 'winnative':
|
||||||
style.configure('Toolbutton', padding=2)
|
style.configure('Toolbutton', padding=2)
|
||||||
else:
|
else:
|
||||||
|
@ -49,9 +50,9 @@ class initRootWindow(baseInitRootWindow):
|
||||||
|
|
||||||
|
|
||||||
class TkSettings(BaseTkSettings):
|
class TkSettings(BaseTkSettings):
|
||||||
|
canvas_padding = (1, 1)
|
||||||
toolbar_relief = 'groove'
|
toolbar_relief = 'groove'
|
||||||
toolbar_borderwidth = 2
|
toolbar_borderwidth = 2
|
||||||
if USE_TILE:
|
if USE_TILE:
|
||||||
toolbar_button_padding = (2, 0)
|
toolbar_button_padding = (2, 0)
|
||||||
toolbar_label_padding = (6, 6)
|
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,10 @@ class initRootWindow(baseInitRootWindow):
|
||||||
def __init__(self, root, app):
|
def __init__(self, root, app):
|
||||||
baseInitRootWindow.__init__(self, root, app)
|
baseInitRootWindow.__init__(self, root, app)
|
||||||
|
|
||||||
|
## if TOOLKIT == 'tk':
|
||||||
|
## window.wm_iconbitmap("@"+filename)
|
||||||
|
## window.wm_iconmask("@"+filename)
|
||||||
|
|
||||||
##root.self.wm_maxsize(9999, 9999) # unlimited
|
##root.self.wm_maxsize(9999, 9999) # unlimited
|
||||||
if TOOLKIT == 'gtk':
|
if TOOLKIT == 'gtk':
|
||||||
pass
|
pass
|
||||||
|
|
1
setup.py
1
setup.py
|
@ -66,6 +66,7 @@ kw = {
|
||||||
'scripts' : ['pysol.py'],
|
'scripts' : ['pysol.py'],
|
||||||
'packages' : ['pysollib',
|
'packages' : ['pysollib',
|
||||||
'pysollib.macosx',
|
'pysollib.macosx',
|
||||||
|
'pysollib.tksettings',
|
||||||
'pysollib.tk',
|
'pysollib.tk',
|
||||||
'pysollib.tile',
|
'pysollib.tile',
|
||||||
'pysollib.pysolgtk',
|
'pysollib.pysolgtk',
|
||||||
|
|
Loading…
Add table
Reference in a new issue