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

+ new variable: settings.WIN_SYSTEM - tk windowing system (set up in init.py)

* replaced os.name on WIN_SYSTEM for gui-specific code


git-svn-id: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@112 efabe8c0-fbe8-4139-b769-b5e6d273206e
This commit is contained in:
skomoroh 2006-12-13 01:51:41 +00:00
parent 85a29c5622
commit 05dac1faf5
19 changed files with 96 additions and 157 deletions

View file

@ -45,7 +45,7 @@ from mfxutil import getusername, gethomedir, getprefdir, EnvError
from mfxutil import latin1_to_ascii
from util import Timer
from util import CARDSET, IMAGE_EXTENSIONS
from settings import PACKAGE, PACKAGE_URL, VERSION, VERSION_TUPLE
from settings import PACKAGE, PACKAGE_URL, VERSION, VERSION_TUPLE, WIN_SYSTEM
from resource import CSI, CardsetConfig, Cardset, CardsetManager
from resource import Tile, TileManager
from resource import Sample, SampleManager
@ -108,13 +108,17 @@ class Options:
self.shade_filled_stacks = True
self.demo_logo = True
self.tile_theme = 'default'
if os.name == 'nt':
if WIN_SYSTEM == 'win32':
self.tile_theme = 'winnative'
elif WIN_SYSTEM == 'x11':
self.tile_theme = 'step'
else: # aqua
self.tile_theme = 'aqua'
self.toolbar = 1 # 0 == hide, 1,2,3,4 == top, bottom, lef, right
##self.toolbar_style = 'default'
self.toolbar_style = 'crystal'
if os.name == 'posix':
self.toolbar_style = 'bluecurve'
self.toolbar_style = 'bluecurve'
if WIN_SYSTEM == 'win32':
self.toolbar_style = 'crystal'
self.toolbar_relief = 'flat'
self.toolbar_compound = 'none' # icons only
self.toolbar_size = 0
@ -164,11 +168,11 @@ class Options:
"canvas_large" : ("helvetica", 16),
"canvas_small" : ("helvetica", 10),
}
if os.name == 'posix':
self.fonts["sans"] = ("helvetica", 12)
if os.name == 'nt':
if WIN_SYSTEM == 'win32':
self.fonts["sans"] = ("times new roman", 12)
self.fonts["fixed"] = ("courier new", 10)
elif WIN_SYSTEM == 'x11':
self.fonts["sans"] = ("helvetica", 12)
# colors
self.colors = {
'table': '#008200',
@ -665,7 +669,7 @@ class Application:
# create the canvas
self.scrolled_canvas = MfxScrolledCanvas(self.top)
self.canvas = self.scrolled_canvas.canvas
if os.name == 'nt':
if WIN_SYSTEM == 'win32':
self.scrolled_canvas.grid(row=1, column=1, sticky='nsew',
padx=1, pady=1)
else:
@ -865,10 +869,10 @@ class Application:
"joker11_100_774",
"joker10_100",):
self.gimages.logos.append(self.dataloader.findImage(f, dir))
if os.name == 'posix':
dir = os.path.join('images', 'dialog', 'bluecurve')
else:
if WIN_SYSTEM == 'win32':
dir = os.path.join('images', 'dialog', 'default')
else:
dir = os.path.join('images', 'dialog', 'bluecurve')
for f in ('error', 'info', 'question', 'warning'):
fn = self.dataloader.findImage(f, dir)
im = loadImage(fn)

View file

@ -399,8 +399,8 @@ class GameInfo(Struct):
ncards = decks * (len(suits) * len(ranks) + len(trumps))
game_flags = game_type & ~1023
game_type = game_type & 1023
if os.name == "mac":
name = latin1_to_ascii(name)
#if os.name == "mac":
# name = latin1_to_ascii(name)
name = to_unicode(name)
if not short_name:
short_name = name

View file

@ -61,7 +61,6 @@ def init():
except:
settings.DEBUG = 1
print 'PySol debugging: set DEBUG to', settings.DEBUG
## init toolkit
if '--gtk' in sys.argv:
settings.TOOLKIT = 'gtk'
@ -93,6 +92,7 @@ def init():
pass
else:
settings.USE_TILE = True
settings.WIN_SYSTEM = root.tk.call('tk', 'windowingsystem')
#root.destroy()
Tkinter._default_root = None

View file

@ -32,6 +32,9 @@ VERSION = '4.82'
FC_VERSION = '0.9.5'
VERSION_TUPLE = (4, 82)
# Tk windowing system (auto determine in init.py)
WIN_SYSTEM = 'x11' # win32, x11, aqua, classic
# toolkit
TOOLKIT = 'tk' # or 'gtk'
USE_TILE = 'auto' # or True or False

View file

@ -1,5 +1,5 @@
import sys
from pysollib.settings import WIN_SYSTEM
import Tkinter
from Tkconstants import *
@ -325,7 +325,7 @@ class Scrollbar(Widget, Tkinter.Scrollbar):
# from http://tkinter.unpythonic.net/wiki/PyLocateTile :
# standard Tk scrollbars work on OS X, but Tile ones look weird
if sys.platform == "darwin":
if WIN_SYSTEM == "aqua":
Scrollbar = Tkinter.Scrollbar

View file

@ -44,7 +44,7 @@ import tkFileDialog
# PySol imports
from pysollib.mfxutil import destruct, Struct, kwdefault
from pysollib.util import CARDSET
from pysollib.settings import PACKAGE
from pysollib.settings import PACKAGE, WIN_SYSTEM
from pysollib.settings import TOP_TITLE
from pysollib.gamedb import GI
from pysollib.actions import PysolMenubarActions
@ -340,7 +340,7 @@ class PysolMenubar(PysolMenubarActions):
def _createMenubar(self):
MfxMenubar.addPath = self._addPath
kw = { "name": "menubar" }
if 1 and os.name == "posix":
if WIN_SYSTEM == "x11":
pass
##kw["relief"] = "groove"
kw["activeborderwidth"] = 1
@ -353,7 +353,7 @@ class PysolMenubar(PysolMenubarActions):
m = "Ctrl-"
if sys.platform == "darwin": m = "Cmd-"
if self.top.tk.call("tk", "windowingsystem") == "aqua":
if WIN_SYSTEM == "aqua":
applemenu=MfxMenu(self.__menubar, n_("apple"))
applemenu.add_command(label=_("&About ")+PACKAGE, command=self.mHelpAbout)
@ -377,7 +377,7 @@ class PysolMenubar(PysolMenubarActions):
menu.add_command(label=n_("Save &as..."), command=self.mSaveAs)
menu.add_separator()
menu.add_command(label=n_("&Hold and quit"), command=self.mHoldAndQuit)
if not self.top.tk.call("tk", "windowingsystem") == "aqua":
if WIN_SYSTEM != "aqua":
menu.add_command(label=n_("&Quit"), command=self.mQuit, accelerator=m+"Q")
if self.progress: self.progress.update(step=1)
@ -517,7 +517,7 @@ class PysolMenubar(PysolMenubarActions):
menu.add_command(label=n_("&Rules for this game"), command=self.mHelpRules, accelerator="F1")
menu.add_command(label=n_("&License terms"), command=self.mHelpLicense)
##menu.add_command(label=n_("What's &new ?"), command=self.mHelpNews)
if not self.top.tk.call("tk", "windowingsystem") == "aqua":
if WIN_SYSTEM != "aqua":
menu.add_separator()
menu.add_command(label=n_("&About ")+PACKAGE+"...", command=self.mHelpAbout)
@ -1335,7 +1335,6 @@ the next time you restart """)+PACKAGE,
'xpnative': 'XP Native',
'aqua': 'Aqua',
}
for t in all_themes:
try:
n = tn[t]

View file

@ -73,16 +73,6 @@ class MfxStatusbar:
columnspan=self._columnspan, sticky='ew')
self.frame = Tkinter.Frame(self.top_frame)
self.frame.pack(side='left', expand=True, fill='both', padx=0, pady=1)
## if os.name == "mac":
## Tkinter.Label(self.frame, width=2).pack(side='right')
## if os.name == 'nt':
## #self.frame.config(relief='raised')
## #self.padx = 1
## pass
## if 0:
## self.frame.config(bd=0)
## self.label_relief = 'flat'
## self.padx = 0
# util
def _createLabel(self, name, side='left',

View file

@ -40,6 +40,7 @@ import Tile as Tkinter
# Toolkit imports
from tkutil import bind
from tkwidget import MfxScrolledCanvas
from pysollib.settings import WIN_SYSTEM
# /***********************************************************************
@ -238,7 +239,7 @@ class MfxTreeInCanvas(MfxScrolledCanvas):
self.font = None
self.linestyle = "gray50"
self.linecolor = "black"
if os.name == "nt":
if WIN_SYSTEM == "win32":
self.linestyle = "" # Tk bug ?
self.linecolor = "gray50"

View file

@ -71,7 +71,7 @@ except ImportError:
# Toolkit imports
from tkconst import tkversion
from pysollib.settings import PACKAGE
from pysollib.settings import PACKAGE, WIN_SYSTEM
# /***********************************************************************
@ -82,20 +82,11 @@ def wm_withdraw(window):
window.wm_withdraw()
def wm_deiconify(window):
need_fix = os.name == "nt" and tkversion < (8, 3, 0, 0)
if need_fix:
# FIXME: This is needed so the window pops up on top on Windows.
try:
window.wm_iconify()
window.update_idletasks()
except Tkinter.TclError:
# wm_iconify() may fail if the window is transient
pass
window.wm_deiconify()
def wm_map(window, maximized=0):
if window.wm_state() != "iconic":
if maximized and os.name == "nt":
if maximized and WIN_SYSTEM == "win32":
window.wm_state("zoomed")
else:
wm_deiconify(window)
@ -103,10 +94,10 @@ def wm_map(window, maximized=0):
def wm_set_icon(window, filename):
if not filename:
return
if os.name == 'nt':
if WIN_SYSTEM == 'win32':
##window.tk.call('wm', 'iconbitmap', root._w, '-default', '@'+filename)
pass
elif os.name == "posix":
elif WIN_SYSTEM == 'x11':
##window.wm_iconbitmap("@"+filename)
##window.wm_iconmask("@"+filename)
pass
@ -139,27 +130,15 @@ def setTransient(window, parent, relx=None, rely=None, expose=1):
# remain invisible while we figure out the geometry
window.wm_withdraw()
window.wm_group(parent)
need_fix = os.name == "nt" and tkversion < (8, 3, 0, 0)
if need_fix:
# FIXME: This is needed to avoid ugly frames on Windows.
window.wm_geometry("+%d+%d" % (-10000, -10000))
if expose and parent is not None:
# FIXME: This is needed so the window pops up on top on Windows.
window.wm_iconify()
if parent and parent.wm_state() != "withdrawn":
window.wm_transient(parent)
# actualize geometry information
window.update_idletasks()
# show
x, y = __getWidgetXY(window, parent, relx=relx, rely=rely)
if need_fix:
if expose:
wm_deiconify(window)
window.wm_geometry("+%d+%d" % (x, y))
else:
window.wm_geometry("+%d+%d" % (x, y))
if expose:
window.wm_deiconify()
window.wm_geometry("+%d+%d" % (x, y))
if expose:
window.wm_deiconify()
def makeToplevel(parent, title=None):
# Create a Toplevel window.
@ -193,7 +172,7 @@ def make_help_toplevel(app, title=None):
window.option_add('*foreground', fg)
window.option_add('*selectBackground', '#00008b', 50)
window.option_add('*selectForeground', 'white', 50)
if os.name == "posix":
if WIN_SYSTEM == "x11":
window.option_add('*Scrollbar.elementBorderWidth', '1', 60)
window.option_add('*Scrollbar.borderWidth', '1', 60)
if title:
@ -216,7 +195,7 @@ def __getWidgetXY(widget, parent, relx=None, rely=None,
##print parent.wm_geometry()
##print parent.winfo_geometry(), parent.winfo_x(), parent.winfo_y(), parent.winfo_rootx(), parent.winfo_rooty(), parent.winfo_vrootx(), parent.winfo_vrooty()
m_x = m_y = None
if os.name == "nt":
if WIN_SYSTEM == "win32":
try:
m_width, m_height, m_x, m_y = wm_get_geometry(parent)
except:
@ -426,7 +405,7 @@ def get_text_width(text, font, root=None):
# ************************************************************************/
def init_tile(app, top, theme):
if os.name == 'posix':
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)
@ -455,28 +434,23 @@ def load_theme(app, top, theme):
theme = 'default'
if theme:
style.theme_use(theme)
if theme not in ('winnative', 'xpnative'):
if WIN_SYSTEM == 'x11':
color = style.lookup('.', 'background')
if color:
try:
top.tk_setPalette(color)
##top.option_add('*background', color)
pass
except:
traceback.print_exc()
pass
if os.name == 'posix':
color = style.lookup('.', 'background', 'active')
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.option_add('*Menu.activeBackground', color)
elif os.name == 'nt':
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)
#if 'xpnative' in all_themes:
# theme = 'xpnative'
if theme == 'winnative':
style.configure('Toolbutton', padding=2)
font = app.opt.fonts['default']
if font:
style.configure('.', font=font)

View file

@ -50,6 +50,7 @@ import traceback
# PySol imports
from pysollib.mfxutil import destruct, kwdefault, KwStruct
from pysollib.settings import WIN_SYSTEM
# Toolkit imports
from tkconst import EVENT_HANDLED, EVENT_PROPAGATE
@ -194,7 +195,7 @@ class MfxDialog: # ex. _ToplevelDialog
s = s.replace('&', '')
max_len = max(max_len, len(s))
##print s, len(s)
if max_len > 12 and os.name == 'posix': button_width = max_len
if max_len > 12 and WIN_SYSTEM == 'x11': button_width = max_len
elif max_len > 9 : button_width = max_len+1
elif max_len > 6 : button_width = max_len+2
else : button_width = 8
@ -560,7 +561,7 @@ class MfxScrolledCanvas:
bind(w, "<KeyPress-Home>", self.scroll_top)
bind(w, "<KeyPress-End>", self.scroll_bottom)
# mousewheel support
if os.name == 'posix':
if WIN_SYSTEM == 'x11':
bind(w, '<4>', self.mouse_wheel_up)
bind(w, '<5>', self.mouse_wheel_down)
# don't work on Linux

View file

@ -47,7 +47,7 @@ from tkFont import Font
# PySol imports
from pysollib.mfxutil import destruct, Struct
from pysollib.settings import PACKAGE, VERSION
from pysollib.settings import PACKAGE, VERSION, WIN_SYSTEM
from pysollib.macosx.appSupport import setupApp
from tkutil import after_idle, init_tile, wm_set_icon
from tkconst import EVENT_HANDLED, EVENT_PROPAGATE
@ -128,7 +128,7 @@ class MfxRoot(Tkinter.Tk):
# font
if font:
self.option_add('*font', font)
elif os.name == 'posix':
elif WIN_SYSTEM == 'x11':
self.option_add('*font', 'Helvetica 12', 50)
font = self.option_get('font', '')
try:
@ -148,13 +148,6 @@ class MfxRoot(Tkinter.Tk):
# theme
try:
windowingsystem = app.top.tk.call("tk", "windowingsystem")
if windowingsystem == "x11":
app.opt.tile_theme = "clam"
elif windowingsystem == "aqua":
app.opt.tile_theme = "aqua"
elif windowingsystem == "win32":
app.opt.tile_theme = "xpnative"
init_tile(app, self, app.opt.tile_theme)
except TclError:
raise

View file

@ -49,7 +49,7 @@ except ImportError:
# PySol imports
from pysollib.mfxutil import destruct
from pysollib.util import IMAGE_EXTENSIONS
from pysollib.settings import PACKAGE
from pysollib.settings import PACKAGE, WIN_SYSTEM
from pysollib.actions import PysolToolbarActions
# Toolkit imports
@ -78,7 +78,7 @@ class AbstractToolbarButton:
self.visible = True
if orient == 'horizontal':
padx, pady = 0, 2
if os.name == 'nt':
if WIN_SYSTEM == 'win32':
padx, pady = 2, 2
self.grid(row=0,
column=self.position,
@ -86,7 +86,7 @@ class AbstractToolbarButton:
sticky='nsew')
else:
padx, pady = 2, 0
if os.name == 'nt':
if WIN_SYSTEM == 'win32':
padx, pady = 2, 2
self.grid(row=self.position,
column=0,
@ -154,7 +154,7 @@ class ToolbarLabel(Tkinter.Message):
return
self.visible = True
padx, pady = 4, 4
if os.name == 'nt':
if WIN_SYSTEM == 'win32':
padx, pady = 6, 6
if orient == 'horizontal':
self.grid(row=0,
@ -232,9 +232,9 @@ class PysolToolbar(PysolToolbarActions):
#
self.setCompound(compound, force=True)
# Change the look of the frame to match the platform look
if os.name == 'posix':
if WIN_SYSTEM == 'x11':
pass
elif os.name == "nt":
elif WIN_SYSTEM == "win32":
self.frame.config(relief='groove')
else:
pass

View file

@ -43,7 +43,7 @@ import Tkinter, tkColorChooser, tkFileDialog
# PySol imports
from pysollib.mfxutil import destruct, Struct, kwdefault
from pysollib.util import CARDSET
from pysollib.settings import PACKAGE
from pysollib.settings import PACKAGE, WIN_SYSTEM
from pysollib.settings import TOP_TITLE
from pysollib.gamedb import GI
from pysollib.actions import PysolMenubarActions
@ -347,7 +347,7 @@ class PysolMenubar(PysolMenubarActions):
def _createMenubar(self):
MfxMenubar.addPath = self._addPath
kw = { "name": "menubar" }
if 1 and os.name == "posix":
if WIN_SYSTEM == "x11":
pass
##kw["relief"] = "groove"
kw["activeborderwidth"] = 1
@ -360,7 +360,7 @@ class PysolMenubar(PysolMenubarActions):
m = "Ctrl-"
if sys.platform == "darwin": m = "Cmd-"
if self.top.tk.call("tk", "windowingsystem") == "aqua":
if WIN_SYSTEM == "aqua":
applemenu=MfxMenu(self.__menubar, n_("apple"))
applemenu.add_command(label=_("&About ")+PACKAGE, command=self.mHelpAbout)
@ -384,7 +384,7 @@ class PysolMenubar(PysolMenubarActions):
menu.add_command(label=n_("Save &as..."), command=self.mSaveAs)
menu.add_separator()
menu.add_command(label=n_("&Hold and quit"), command=self.mHoldAndQuit)
if not self.top.tk.call("tk", "windowingsystem") == "aqua":
if WIN_SYSTEM != "aqua":
menu.add_command(label=n_("&Quit"), command=self.mQuit, accelerator=m+"Q")
if self.progress: self.progress.update(step=1)
@ -522,7 +522,7 @@ class PysolMenubar(PysolMenubarActions):
menu.add_command(label=n_("&Rules for this game"), command=self.mHelpRules, accelerator="F1")
menu.add_command(label=n_("&License terms"), command=self.mHelpLicense)
##menu.add_command(label=n_("What's &new ?"), command=self.mHelpNews)
if not self.top.tk.call("tk", "windowingsystem") == "aqua":
if WIN_SYSTEM != "aqua":
menu.add_separator()
menu.add_command(label=n_("&About ")+PACKAGE+"...", command=self.mHelpAbout)

View file

@ -49,6 +49,8 @@ if __name__ == '__main__':
# Toolkit imports
from tkwidget import MfxTooltip
from pysollib.settings import WIN_SYSTEM
# /***********************************************************************
# //
@ -73,7 +75,7 @@ class MfxStatusbar:
padx=1, pady=1)
#if os.name == "mac":
# Tkinter.Label(self.frame, width=2).pack(side='right')
if os.name == 'nt':
if WIN_SYSTEM == 'win32':
self.frame.config(relief='raised')
self.padx = 0
if 0:

View file

@ -40,6 +40,7 @@ import Tkinter
# Toolkit imports
from tkutil import bind
from tkwidget import MfxScrolledCanvas
from pysollib.settings import WIN_SYSTEM
# /***********************************************************************
@ -238,7 +239,7 @@ class MfxTreeInCanvas(MfxScrolledCanvas):
self.font = None
self.linestyle = "gray50"
self.linecolor = "black"
if os.name == "nt":
if WIN_SYSTEM == "win32":
self.linestyle = "" # Tk bug ?
self.linecolor = "gray50"

View file

@ -69,7 +69,7 @@ except ImportError:
# Toolkit imports
from tkconst import tkversion
from pysollib.settings import PACKAGE
from pysollib.settings import PACKAGE, WIN_SYSTEM
# /***********************************************************************
@ -80,20 +80,11 @@ def wm_withdraw(window):
window.wm_withdraw()
def wm_deiconify(window):
need_fix = os.name == "nt" and tkversion < (8, 3, 0, 0)
if need_fix:
# FIXME: This is needed so the window pops up on top on Windows.
try:
window.wm_iconify()
window.update_idletasks()
except Tkinter.TclError:
# wm_iconify() may fail if the window is transient
pass
window.wm_deiconify()
def wm_map(window, maximized=0):
if window.wm_state() != "iconic":
if maximized and os.name == "nt":
if maximized and WIN_SYSTEM == "win32":
window.wm_state("zoomed")
else:
wm_deiconify(window)
@ -101,12 +92,13 @@ def wm_map(window, maximized=0):
def wm_set_icon(window, filename):
if not filename:
return
if os.name == 'nt':
window.wm_iconbitmap(default="@"+filename)
elif os.name == "posix":
if WIN_SYSTEM == 'win32':
pass
##window.wm_iconbitmap(default="@"+filename)
elif WIN_SYSTEM == "x11":
pass
##window.wm_iconbitmap("@" + filename)
##window.wm_iconmask("@" + filename)
pass
__wm_get_geometry_re = re.compile(r"^(\d+)x(\d+)\+([\-]?\d+)\+([\-]?\d+)$")
@ -136,27 +128,15 @@ def setTransient(window, parent, relx=None, rely=None, expose=1):
# remain invisible while we figure out the geometry
window.wm_withdraw()
window.wm_group(parent)
need_fix = os.name == "nt" and tkversion < (8, 3, 0, 0)
if need_fix:
# FIXME: This is needed to avoid ugly frames on Windows.
window.wm_geometry("+%d+%d" % (-10000, -10000))
if expose and parent is not None:
# FIXME: This is needed so the window pops up on top on Windows.
window.wm_iconify()
if parent and parent.wm_state() != "withdrawn":
window.wm_transient(parent)
# actualize geometry information
window.update_idletasks()
# show
x, y = __getWidgetXY(window, parent, relx=relx, rely=rely)
if need_fix:
if expose:
wm_deiconify(window)
window.wm_geometry("+%d+%d" % (x, y))
else:
window.wm_geometry("+%d+%d" % (x, y))
if expose:
window.wm_deiconify()
window.wm_geometry("+%d+%d" % (x, y))
if expose:
window.wm_deiconify()
def makeToplevel(parent, title=None):
# Create a Toplevel window.
@ -188,7 +168,7 @@ def make_help_toplevel(app, title=None):
window.option_add('*foreground', fg)
window.option_add('*selectBackground', '#00008b', 50)
window.option_add('*selectForeground', 'white', 50)
if os.name == "posix":
if WIN_SYSTEM == "x11":
window.option_add('*Scrollbar.elementBorderWidth', '1', 60)
window.option_add('*Scrollbar.borderWidth', '1', 60)
@ -212,7 +192,7 @@ def __getWidgetXY(widget, parent, relx=None, rely=None,
##print parent.wm_geometry()
##print parent.winfo_geometry(), parent.winfo_x(), parent.winfo_y(), parent.winfo_rootx(), parent.winfo_rooty(), parent.winfo_vrootx(), parent.winfo_vrooty()
m_x = m_y = None
if os.name == "nt":
if WIN_SYSTEM == "win32":
try:
m_width, m_height, m_x, m_y = wm_get_geometry(parent)
except:

View file

@ -49,6 +49,7 @@ import traceback
# PySol imports
from pysollib.mfxutil import destruct, kwdefault, KwStruct
from pysollib.settings import WIN_SYSTEM
# Toolkit imports
from tkconst import EVENT_HANDLED, EVENT_PROPAGATE
@ -206,7 +207,7 @@ class MfxDialog: # ex. _ToplevelDialog
s = s.replace('&', '')
max_len = max(max_len, len(s))
##print s, len(s)
if max_len > 12 and os.name == 'posix': button_width = max_len
if max_len > 12 and WIN_SYSTEM == 'x11': button_width = max_len
elif max_len > 9 : button_width = max_len+1
elif max_len > 6 : button_width = max_len+2
else : button_width = 8
@ -564,7 +565,7 @@ class MfxScrolledCanvas:
bind(w, "<KeyPress-Home>", self.scroll_top)
bind(w, "<KeyPress-End>", self.scroll_bottom)
# mousewheel support
if os.name == 'posix':
if WIN_SYSTEM == 'x11':
bind(w, '<4>', self.mouse_wheel_up)
bind(w, '<5>', self.mouse_wheel_down)
# don't work on Linux

View file

@ -127,18 +127,8 @@ class MfxRoot(Tkinter.Tk):
# set global color scheme
if not fg and not bg:
if os.name == 'posix': # Unix/X11
if WIN_SYSTEM == 'x11': # Unix/X11
pass
if os.name == 'mac':
color, priority = '#d9d9d9', '60'
classes = (
'Button', 'Canvas', 'Checkbutton', 'Entry',
'Frame', 'Label', 'Listbox', 'Menubutton', ### 'Menu',
'Message', 'Radiobutton', 'Scale', 'Scrollbar', 'Text',
)
for c in classes:
self.option_add('*' + c + '*background', color, priority)
self.option_add('*' + c + '*activeBackground', color, priority)
else:
if bg:
self.tk_setPalette(bg)
@ -149,7 +139,7 @@ class MfxRoot(Tkinter.Tk):
app.top_palette[0] = fg
#
if os.name == 'posix': # Unix/X11
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)
@ -165,7 +155,7 @@ class MfxRoot(Tkinter.Tk):
# font
if font:
self.option_add('*font', font)
elif os.name == 'posix':
elif WIN_SYSTEM == 'x11':
self.option_add('*font', 'Helvetica 12', 50)
font = self.option_get('font', '')
try:

View file

@ -47,7 +47,7 @@ except ImportError:
# PySol imports
from pysollib.mfxutil import destruct
from pysollib.util import IMAGE_EXTENSIONS
from pysollib.settings import PACKAGE
from pysollib.settings import PACKAGE, WIN_SYSTEM
from pysollib.actions import PysolToolbarActions
# Toolkit imports
@ -234,10 +234,10 @@ class PysolToolbar(PysolToolbarActions):
self.setCompound(compound, force=True)
# Change the look of the frame to match the platform look
# (see also setRelief)
if os.name == 'posix':
if WIN_SYSTEM == 'x11':
#self.frame.config(bd=0, highlightthickness=1)
self.frame.config(bd=1, relief=self.frame_relief, highlightthickness=0)
elif os.name == "nt":
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)
@ -284,12 +284,12 @@ class PysolToolbar(PysolToolbarActions):
if relief == 'raised':
self.frame_relief = 'flat'
self.separator_relief = 'flat'
if os.name == 'nt':
if WIN_SYSTEM == 'win32':
self.frame_relief = 'groove'
else:
self.frame_relief = 'raised'
self.separator_relief = 'sunken' #'raised'
if os.name == 'nt':
if WIN_SYSTEM == 'win32':
self.frame_relief = 'groove'
self.separator_relief = 'groove'
return relief