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
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)
if isGroup(key):
w = wid(parent, tag)
if isinstance(parent.GetSizer(), wx.StaticBoxSizer):
w = wid(parent.GetSizer().GetStaticBox())
if parentIsGroup(parent):
w = addWidgetToGroup(parent, wid)
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