Commit 847dc781 authored by Taylor Hanayik's avatar Taylor Hanayik
Browse files

better widget creation from factory functions

parent beb9e412
......@@ -117,6 +117,25 @@ def parseWidgetKey(key):
n = ""
return n, t
def parentIsGroup(parent):
if isinstance(parent.GetSizer(), wx.StaticBoxSizer):
return True
else:
return False
def addWidgetToGroup(parent, widget):
w = widget(parent.GetSizer().GetStaticBox())
return w
def widgetFromKey(key):
"""
returns the appropriate widget creation function,
but does not return the actual widget instance.
That comes later.
"""
widget = getattr(fslwidgets, key)
return widget
def makeWidget(parent, propObj, key, tag, value):
"""
......@@ -128,15 +147,15 @@ def makeWidget(parent, propObj, key, tag, value):
"""
if key in allowedWidgets:
wid = getattr(fslwidgets, key)
wid = widgetFromKey(key)
if isinstance(value, dict):
w = wid(parent, propObj, **value)
else:
if isGroup(key):
w = wid(parent, tag)
else:
if isinstance(parent.GetSizer(), wx.StaticBoxSizer):
w = wid(parent.GetSizer().GetStaticBox())
if parentIsGroup(parent):
w = addWidgetToGroup(parent, wid)
else:
w = wid(parent)
return w
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment