|
|
@ -4,33 +4,35 @@ Managed the internal layout for configuration options |
|
|
|
@author: Chris |
|
|
|
""" |
|
|
|
|
|
|
|
import itertools |
|
|
|
from itertools import chain |
|
|
|
|
|
|
|
import wx |
|
|
|
|
|
|
|
from wx.lib.scrolledpanel import ScrolledPanel |
|
|
|
from itertools import chain, izip_longest |
|
|
|
|
|
|
|
from gooey.gui.util import wx_util |
|
|
|
from gooey.gui.lang import i18n |
|
|
|
from gooey.gui import component_builder |
|
|
|
from gooey.gui.option_reader import OptionReader |
|
|
|
|
|
|
|
|
|
|
|
PADDING = 10 |
|
|
|
|
|
|
|
|
|
|
|
class AdvancedConfigPanel(ScrolledPanel, OptionReader): |
|
|
|
class ConfigPanel(ScrolledPanel, OptionReader): |
|
|
|
|
|
|
|
def __init__(self, parent, build_spec=None, **kwargs): |
|
|
|
def __init__(self, parent, widgets=None, req_cols=1, opt_cols=3, title=None, **kwargs): |
|
|
|
ScrolledPanel.__init__(self, parent, **kwargs) |
|
|
|
self.SetupScrolling(scroll_x=False, scrollToTop=False) |
|
|
|
|
|
|
|
self.SetDoubleBuffered(True) |
|
|
|
|
|
|
|
self._build_spec = build_spec |
|
|
|
self.widgets = component_builder.build_components(build_spec['widgets']) |
|
|
|
self.title = title |
|
|
|
|
|
|
|
self.widgets = component_builder.build_components(widgets) |
|
|
|
|
|
|
|
self._msg_req_args = None |
|
|
|
self._msg_opt_args = None |
|
|
|
self._num_req_cols = req_cols |
|
|
|
self._num_opt_cols = opt_cols |
|
|
|
|
|
|
|
self._controller = None |
|
|
|
|
|
|
@ -45,25 +47,28 @@ class AdvancedConfigPanel(ScrolledPanel, OptionReader): |
|
|
|
container = wx.BoxSizer(wx.VERTICAL) |
|
|
|
container.AddSpacer(15) |
|
|
|
|
|
|
|
if self.title: |
|
|
|
container.Add(wx_util.h0(self, self.title), 0, wx.LEFT | wx.RIGHT, PADDING) |
|
|
|
container.AddSpacer(30) |
|
|
|
|
|
|
|
if self.widgets.required_args: |
|
|
|
container.Add(wx_util.h1(self, i18n._("required_args_msg")), 0, wx.LEFT | wx.RIGHT, PADDING) |
|
|
|
container.AddSpacer(5) |
|
|
|
container.Add(wx_util.horizontal_rule(self), *STD_LAYOUT) |
|
|
|
container.AddSpacer(20) |
|
|
|
|
|
|
|
self.CreateComponentGrid(container, self.widgets.required_args, cols=self._build_spec['requireds_cols']) |
|
|
|
self.CreateComponentGrid(container, self.widgets.required_args, cols=self._num_req_cols) |
|
|
|
|
|
|
|
container.AddSpacer(10) |
|
|
|
|
|
|
|
|
|
|
|
if self.widgets.optional_args: |
|
|
|
container.AddSpacer(10) |
|
|
|
# container.AddSpacer(10) |
|
|
|
container.Add(wx_util.h1(self, i18n._("optional_args_msg")), 0, wx.LEFT | wx.RIGHT, PADDING) |
|
|
|
container.AddSpacer(5) |
|
|
|
container.Add(wx_util.horizontal_rule(self), *STD_LAYOUT) |
|
|
|
container.AddSpacer(20) |
|
|
|
|
|
|
|
self.CreateComponentGrid(container, self.widgets.optional_args, cols=self._build_spec['optionals_cols']) |
|
|
|
self.CreateComponentGrid(container, self.widgets.optional_args, cols=self._num_opt_cols) |
|
|
|
|
|
|
|
self.SetSizer(container) |
|
|
|
|
|
|
@ -100,7 +105,7 @@ class AdvancedConfigPanel(ScrolledPanel, OptionReader): |
|
|
|
"itertools recipe: Collect data into fixed-length chunks or blocks" |
|
|
|
# grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx |
|
|
|
args = [iter(iterable)] * n |
|
|
|
return itertools.izip_longest(fillvalue=fillvalue, *args) |
|
|
|
return izip_longest(fillvalue=fillvalue, *args) |
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
pass |