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

* improved keybindings in dialogs

* added usage xrdb font (x11)


git-svn-id: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@127 efabe8c0-fbe8-4139-b769-b5e6d273206e
This commit is contained in:
skomoroh 2006-12-20 22:22:56 +00:00
parent 3e649f70eb
commit 6d63b6cf54
5 changed files with 62 additions and 19 deletions

View file

@ -1196,7 +1196,11 @@ Please select a %s type %s.
return
opt = unpickle(self.fn.opt)
if opt:
##import pprint; pprint.pprint(opt.__dict__)
if DEBUG >= 6:
import pprint
print '======== options ========'
pprint.pprint(opt.__dict__)
print '========================='
self.opt.__dict__.update(opt.__dict__)
self.opt.setConstants()

View file

@ -161,7 +161,7 @@ class ResourceManager:
self._addDir(result, os.path.join(dir, s))
except EnvError, ex:
pass
if DEBUG >= 5:
if DEBUG >= 6:
print "getSearchDirs", env, search, "->", result
return result

View file

@ -129,19 +129,23 @@ class MfxDialog: # ex. _ToplevelDialog
raise SystemExit
def altKeyEvent(self, event):
key = event.char
try:
if os.name == 'nt':
key = unicode(key, locale.getpreferredencoding())
else:
key = unicode(key, 'utf-8')
except:
pass
widget = None
if self.accel_keys.has_key(event.keysym):
widget = self.accel_keys[event.keysym]
else:
key = key.lower()
widget = self.accel_keys.get(key)
if not widget is None:
widget.event_generate('<<Invoke>>')
key = event.char
try:
if os.name == 'nt':
key = unicode(key, locale.getpreferredencoding())
else:
key = unicode(key, 'utf-8')
except:
pass
else:
key = key.lower()
widget = self.accel_keys.get(key)
if not widget is None:
widget.event_generate('<<Invoke>>')
def initKw(self, kw):
kw = KwStruct(kw,
@ -181,8 +185,8 @@ class MfxDialog: # ex. _ToplevelDialog
b.pack(side=kw.image_side, padx=kw.image_padx, pady=kw.image_pady)
def createButtons(self, frame, kw):
xbutton = column = -1
padx, pady = 4, 4
xbutton = column = -1
focus = None
max_len = 0
if 'sep' in kw.strings:
@ -247,7 +251,7 @@ class MfxDialog: # ex. _ToplevelDialog
widget.config(compound='left', image=button_img)
widget.grid(column=column, row=0, sticky="nse", padx=padx, pady=pady)
if focus is not None:
l = (lambda event=None, self=self, button=kw.default: self.mDone(button))
l = lambda event=None, w=focus: w.event_generate('<<Invoke>>')
bind(self.top, "<Return>", l)
bind(self.top, "<KP_Enter>", l)
# right justify

View file

@ -23,6 +23,7 @@ import sys, os, traceback
from pysollib.settings import PACKAGE, VERSION
from pysollib.settings import TOOLKIT, USE_TILE
from pysollib.settings import DEBUG
from pysollib.tile import Tile
@ -51,6 +52,26 @@ def set_theme(top, theme):
style.theme_use(theme)
def get_font_name(font):
# create font name
# i.e. "helvetica 12" -> ("helvetica", 12, "roman", "normal")
from tkFont import Font
font_name = None
try:
f = Font(font=font)
except:
print >> sys.stderr, 'invalid font name:', font
if DEBUG:
traceback.print_exc()
else:
fa = f.actual()
font_name = (fa['family'],
fa['size'],
fa['slant'],
fa['weight'])
return font_name
class baseInitRootWindow:
def __init__(self, root, app):
#root.wm_group(root)

View file

@ -21,10 +21,11 @@
import sys, os
from pysollib.settings import PACKAGE
from pysollib.settings import TOOLKIT, USE_TILE
from pysollib.tile import Tile
from common import baseInitRootWindow, BaseTkSettings
from common import baseInitRootWindow, BaseTkSettings, get_font_name
# /***********************************************************************
@ -53,9 +54,22 @@ class initRootWindow(baseInitRootWindow):
color = style.lookup('.', 'background', 'active')
if color:
root.option_add('*Menu.activeBackground', color)
font = style.lookup('.', 'font')
font = root.option_get('font', PACKAGE)
if font:
root.option_add('*font', font)
# use font from xrdb
fn = get_font_name(font)
if fn:
root.option_add('*font', font)
style.configure('.', font=font)
app.opt.fonts['default'] = fn
else:
# use font from Tile settings
font = style.lookup('.', 'font')
if font:
fn = get_font_name(font)
if fn:
root.option_add('*font', font)
app.opt.fonts['default'] = fn
root.option_add('*Menu.borderWidth', 1, 60)
root.option_add('*Menu.activeBorderWidth', 1, 60)
#