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:
parent
3e649f70eb
commit
6d63b6cf54
5 changed files with 62 additions and 19 deletions
|
@ -1196,7 +1196,11 @@ Please select a %s type %s.
|
||||||
return
|
return
|
||||||
opt = unpickle(self.fn.opt)
|
opt = unpickle(self.fn.opt)
|
||||||
if 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.__dict__.update(opt.__dict__)
|
||||||
self.opt.setConstants()
|
self.opt.setConstants()
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,7 @@ class ResourceManager:
|
||||||
self._addDir(result, os.path.join(dir, s))
|
self._addDir(result, os.path.join(dir, s))
|
||||||
except EnvError, ex:
|
except EnvError, ex:
|
||||||
pass
|
pass
|
||||||
if DEBUG >= 5:
|
if DEBUG >= 6:
|
||||||
print "getSearchDirs", env, search, "->", result
|
print "getSearchDirs", env, search, "->", result
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
|
@ -129,19 +129,23 @@ class MfxDialog: # ex. _ToplevelDialog
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
def altKeyEvent(self, event):
|
def altKeyEvent(self, event):
|
||||||
key = event.char
|
widget = None
|
||||||
try:
|
if self.accel_keys.has_key(event.keysym):
|
||||||
if os.name == 'nt':
|
widget = self.accel_keys[event.keysym]
|
||||||
key = unicode(key, locale.getpreferredencoding())
|
|
||||||
else:
|
|
||||||
key = unicode(key, 'utf-8')
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
key = key.lower()
|
key = event.char
|
||||||
widget = self.accel_keys.get(key)
|
try:
|
||||||
if not widget is None:
|
if os.name == 'nt':
|
||||||
widget.event_generate('<<Invoke>>')
|
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):
|
def initKw(self, kw):
|
||||||
kw = KwStruct(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)
|
b.pack(side=kw.image_side, padx=kw.image_padx, pady=kw.image_pady)
|
||||||
|
|
||||||
def createButtons(self, frame, kw):
|
def createButtons(self, frame, kw):
|
||||||
xbutton = column = -1
|
|
||||||
padx, pady = 4, 4
|
padx, pady = 4, 4
|
||||||
|
xbutton = column = -1
|
||||||
focus = None
|
focus = None
|
||||||
max_len = 0
|
max_len = 0
|
||||||
if 'sep' in kw.strings:
|
if 'sep' in kw.strings:
|
||||||
|
@ -247,7 +251,7 @@ class MfxDialog: # ex. _ToplevelDialog
|
||||||
widget.config(compound='left', image=button_img)
|
widget.config(compound='left', image=button_img)
|
||||||
widget.grid(column=column, row=0, sticky="nse", padx=padx, pady=pady)
|
widget.grid(column=column, row=0, sticky="nse", padx=padx, pady=pady)
|
||||||
if focus is not None:
|
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, "<Return>", l)
|
||||||
bind(self.top, "<KP_Enter>", l)
|
bind(self.top, "<KP_Enter>", l)
|
||||||
# right justify
|
# right justify
|
||||||
|
|
|
@ -23,6 +23,7 @@ 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.settings import DEBUG
|
||||||
from pysollib.tile import Tile
|
from pysollib.tile import Tile
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,6 +52,26 @@ def set_theme(top, theme):
|
||||||
style.theme_use(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:
|
class baseInitRootWindow:
|
||||||
def __init__(self, root, app):
|
def __init__(self, root, app):
|
||||||
#root.wm_group(root)
|
#root.wm_group(root)
|
||||||
|
|
|
@ -21,10 +21,11 @@
|
||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
|
from pysollib.settings import PACKAGE
|
||||||
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, BaseTkSettings
|
from common import baseInitRootWindow, BaseTkSettings, get_font_name
|
||||||
|
|
||||||
|
|
||||||
# /***********************************************************************
|
# /***********************************************************************
|
||||||
|
@ -53,9 +54,22 @@ class initRootWindow(baseInitRootWindow):
|
||||||
color = style.lookup('.', 'background', 'active')
|
color = style.lookup('.', 'background', 'active')
|
||||||
if color:
|
if color:
|
||||||
root.option_add('*Menu.activeBackground', color)
|
root.option_add('*Menu.activeBackground', color)
|
||||||
font = style.lookup('.', 'font')
|
font = root.option_get('font', PACKAGE)
|
||||||
if font:
|
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.borderWidth', 1, 60)
|
||||||
root.option_add('*Menu.activeBorderWidth', 1, 60)
|
root.option_add('*Menu.activeBorderWidth', 1, 60)
|
||||||
#
|
#
|
||||||
|
|
Loading…
Add table
Reference in a new issue