default values for option and flag (TODO: preferences dialog)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44847 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -48,6 +48,7 @@ class Globals:
|
|||||||
testWinPos = wx.DefaultPosition
|
testWinPos = wx.DefaultPosition
|
||||||
currentXXX = None
|
currentXXX = None
|
||||||
currentEncoding = defaultEncoding
|
currentEncoding = defaultEncoding
|
||||||
|
conf = None
|
||||||
|
|
||||||
def _makeFonts(self):
|
def _makeFonts(self):
|
||||||
self._sysFont = wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT)
|
self._sysFont = wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT)
|
||||||
|
@@ -1571,6 +1571,18 @@ class PythonOptions(wx.Dialog):
|
|||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
# Parse string in form var1=val1[,var2=val2]* as dictionary
|
||||||
|
def ReadDictFromString(s):
|
||||||
|
d = {}
|
||||||
|
for vv in s.split(','):
|
||||||
|
var,val = vv.split(':')
|
||||||
|
d[var.strip()] = val
|
||||||
|
return d
|
||||||
|
|
||||||
|
# Transform dictionary with strings into one string
|
||||||
|
def DictToString(d):
|
||||||
|
return ','.join(map(':'.join, d.items()))
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
print >> sys.stderr, 'usage: xrced [-dhiv] [file]'
|
print >> sys.stderr, 'usage: xrced [-dhiv] [file]'
|
||||||
|
|
||||||
@@ -1627,6 +1639,14 @@ Please upgrade wxWidgets to %d.%d.%d or higher.''' % MinWxVersion)
|
|||||||
conf.panelWidth = conf.ReadInt('panelWidth', 200)
|
conf.panelWidth = conf.ReadInt('panelWidth', 200)
|
||||||
conf.panelHeight = conf.ReadInt('panelHeight', 200)
|
conf.panelHeight = conf.ReadInt('panelHeight', 200)
|
||||||
conf.panic = not conf.HasEntry('nopanic')
|
conf.panic = not conf.HasEntry('nopanic')
|
||||||
|
# Preferences
|
||||||
|
p = 'Prefs/sizeritem_defaults_panel'
|
||||||
|
if conf.HasEntry(p):
|
||||||
|
sys.modules['xxx'].xxxSizerItem.defaults_panel = ReadDictFromString(conf.Read(p))
|
||||||
|
p = 'Prefs/sizeritem_defaults_control'
|
||||||
|
if conf.HasEntry(p):
|
||||||
|
sys.modules['xxx'].xxxSizerItem.defaults_control = ReadDictFromString(conf.Read(p))
|
||||||
|
|
||||||
# Add handlers
|
# Add handlers
|
||||||
wx.FileSystem.AddHandler(wx.MemoryFSHandler())
|
wx.FileSystem.AddHandler(wx.MemoryFSHandler())
|
||||||
# Create main frame
|
# Create main frame
|
||||||
@@ -1685,6 +1705,11 @@ Please upgrade wxWidgets to %d.%d.%d or higher.''' % MinWxVersion)
|
|||||||
wc.WriteInt('panelHeight', conf.panelHeight)
|
wc.WriteInt('panelHeight', conf.panelHeight)
|
||||||
wc.WriteInt('nopanic', True)
|
wc.WriteInt('nopanic', True)
|
||||||
wc.Write('recentFiles', '|'.join(conf.recentfiles.values()[-5:]))
|
wc.Write('recentFiles', '|'.join(conf.recentfiles.values()[-5:]))
|
||||||
|
# Preferences
|
||||||
|
v = sys.modules['xxx'].xxxSizerItem.defaults_panel
|
||||||
|
if v: wc.Write('Prefs/sizeritem_defaults_panel', DictToString(v))
|
||||||
|
v = sys.modules['xxx'].xxxSizerItem.defaults_control
|
||||||
|
if v: wc.Write('Prefs/sizeritem_defaults_control', DictToString(v))
|
||||||
wc.Flush()
|
wc.Flush()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@@ -315,6 +315,14 @@ class xxxObject:
|
|||||||
else: obj = self
|
else: obj = self
|
||||||
obj.name = name
|
obj.name = name
|
||||||
obj.node.setAttribute('name', name)
|
obj.node.setAttribute('name', name)
|
||||||
|
# Set normal (text) params
|
||||||
|
def set(self, param, value):
|
||||||
|
try:
|
||||||
|
self.params[param].update(value)
|
||||||
|
except KeyError:
|
||||||
|
p = xxxParam(g.tree.dom.createElement(param))
|
||||||
|
p.update(value)
|
||||||
|
self.params[param] = p
|
||||||
# Special processing for growablecols-like parameters
|
# Special processing for growablecols-like parameters
|
||||||
# represented by several nodes
|
# represented by several nodes
|
||||||
def special(self, tag, node):
|
def special(self, tag, node):
|
||||||
@@ -837,7 +845,8 @@ class xxxChildContainer(xxxObject):
|
|||||||
class xxxSizerItem(xxxChildContainer):
|
class xxxSizerItem(xxxChildContainer):
|
||||||
allParams = ['option', 'flag', 'border', 'minsize', 'ratio']
|
allParams = ['option', 'flag', 'border', 'minsize', 'ratio']
|
||||||
paramDict = {'option': ParamInt, 'minsize': ParamPosSize, 'ratio': ParamPosSize}
|
paramDict = {'option': ParamInt, 'minsize': ParamPosSize, 'ratio': ParamPosSize}
|
||||||
#default = {'cellspan': '1,1'}
|
defaults_panel = {}
|
||||||
|
defaults_control = {}
|
||||||
def __init__(self, parent, element, refElem=None):
|
def __init__(self, parent, element, refElem=None):
|
||||||
# For GridBag sizer items, extra parameters added
|
# For GridBag sizer items, extra parameters added
|
||||||
if isinstance(parent, xxxGridBagSizer):
|
if isinstance(parent, xxxGridBagSizer):
|
||||||
@@ -847,6 +856,14 @@ class xxxSizerItem(xxxChildContainer):
|
|||||||
if 'pos' in self.child.allParams:
|
if 'pos' in self.child.allParams:
|
||||||
self.child.allParams = self.child.allParams[:]
|
self.child.allParams = self.child.allParams[:]
|
||||||
self.child.allParams.remove('pos')
|
self.child.allParams.remove('pos')
|
||||||
|
# Set defaults for some children types
|
||||||
|
if isinstance(self.child, xxxContainer) and not self.child.isSizer:
|
||||||
|
for param,v in self.defaults_panel.items():
|
||||||
|
print param,v
|
||||||
|
self.set(param, v)
|
||||||
|
elif isinstance(self.child, xxxObject):
|
||||||
|
for param,v in self.defaults_control.items():
|
||||||
|
self.set(param, v)
|
||||||
def resetChild(self, xxx):
|
def resetChild(self, xxx):
|
||||||
xxxChildContainer.resetChild(self, xxx)
|
xxxChildContainer.resetChild(self, xxx)
|
||||||
# Remove pos parameter - not needed for sizeritems
|
# Remove pos parameter - not needed for sizeritems
|
||||||
|
Reference in New Issue
Block a user