Browse Source

Quick conf commits

pull/1/head
unknown 10 years ago
parent
commit
6becd008a4
9 changed files with 59 additions and 42 deletions
  1. 8
      src/app/dialogs/advanced_config.py
  2. BIN
      src/app/dialogs/advanced_config.pyc
  3. 5
      src/app/dialogs/argparse_test_data.py
  4. 38
      src/app/dialogs/basic_config_panel.py
  5. 28
      src/app/dialogs/components.py
  6. 5
      src/app/dialogs/controller.py
  7. 15
      src/app/dialogs/parse_validator.py
  8. 2
      src/app/dialogs/window.py
  9. BIN
      src/app/images/image_store.pyc

8
src/app/dialogs/advanced_config.py

@ -102,10 +102,10 @@ class AdvancedConfigPanel(ScrolledPanel, OptionReader):
'''
returns the collective values from all of the
widgets contained in the panel'''
values = [(c._action, c.GetValue())
for c in self.components]
for i in values:
print i[-1]
values = [c.GetValue()
for c in self.components
if c.GetValue() is not None]
return ' '.join(values)

BIN
src/app/dialogs/advanced_config.pyc

5
src/app/dialogs/argparse_test_data.py

@ -19,3 +19,8 @@ parser.add_argument('-c', '--constoption', action="store_const", const="myconsta
parser.add_argument('-t', '--truify', action="store_true", help='Ensure the store_true actions are sorted') # Flag
parser.add_argument('-f', '--falsificle', action="store_false", help='Ensure the store_false actions are sorted') # Flag
try:
parser.parse_args('fname -T yes'.split())
except Exception as e:
print 'asdfads'
print type(e)

38
src/app/dialogs/basic_config_panel.py

@ -14,37 +14,27 @@ class BasicDisplayPanel(wx.Panel, OptionReader):
def __init__(self, parent, **kwargs):
wx.Panel.__init__(self, parent, **kwargs)
self.SetBackgroundColour('#F0F0F0')
self._init_properties()
self._init_components()
self._do_layout()
def _init_components(self):
self.header_msg = self._bold_static_text("Enter Command Line Arguments")
self.cmd_textbox = wx.TextCtrl(self, -1, "")
def _do_layout(self):
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.AddSpacer(50)
sizer.Add(self.text, 0, wx.LEFT, 20)
sizer.AddSpacer(10)
# about_header = wx.StaticText(self, label="About")
# about_header = self._bold_static_text("About")
# about_body = wx.StaticText(self, label="This program does bla. Enter the command line args of your choice to control bla and bla.")
#
# sizer.Add(about_header, 0, wx.LEFT | wx.RIGHT, 20)
# sizer.AddSpacer(5)
# sizer.Add(about_body, 0, wx.LEFT | wx.RIGHT, 20)
sizer.AddSpacer(40)
text = self._bold_static_text("Enter Command Line Arguments")
#
sizer.Add(text, 0, wx.LEFT, 20)
sizer.AddSpacer(10)
h_sizer = wx.BoxSizer(wx.HORIZONTAL)
self.cmd_textbox = wx.TextCtrl(self, -1, "")
h_sizer.Add(self.cmd_textbox, 1, wx.ALL | wx.EXPAND)
sizer.Add(h_sizer, 0, wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, 20)
self.SetSizer(sizer)
def _init_properties(self):
self.SetBackgroundColour('#F0F0F0')
def get_contents(self):
return self.cmd_textbox.GetValue()
def _bold_static_text(self, text_label):
text = wx.StaticText(self, label=text_label)
@ -54,7 +44,7 @@ class BasicDisplayPanel(wx.Panel, OptionReader):
return text
def GetValues(self):
raise NotImplementedError
return self.cmd_textbox.GetValue()

28
src/app/dialogs/components.py

@ -12,6 +12,7 @@ import wx
from argparse import ArgumentParser
from abc import ABCMeta, abstractmethod
EMPTY = ''
class BuildException(RuntimeError):
pass
@ -153,6 +154,8 @@ class Positional(AbstractComponent):
"argument_value"
'''
self.AssertInitialization('Positional')
if str(self._widget.GetValue()) == EMPTY:
return None
return self._widget.GetValue()
@ -170,9 +173,9 @@ class Choice(AbstractComponent):
'''
self.AssertInitialization('Choice')
if self._widget.GetValue() == self._DEFAULT_VALUE:
return ''
return None
return ' '.join(
[self._action.option_strings[-1], # get the verbose copy if available
[self._action.option_strings[0], # get the verbose copy if available
self._widget.GetValue()])
def BuildWidget(self, parent, action):
@ -205,9 +208,11 @@ class Optional(AbstractComponent):
"--Option Value"
'''
self.AssertInitialization('Optional')
value = self._widget.GetValue()
if not value: return None
return ' '.join(
[self._action.option_strings[-1], # get the verbose copy if available
self._widget.GetValue()])
[self._action.option_strings[0], # get the verbose copy if available
value])
class Flag(AbstractComponent):
@ -258,7 +263,8 @@ class Flag(AbstractComponent):
returns
Options name for argument (-v)
'''
return self._action.option_strings[-1]
if self._widget.GetValue():
return self._action.option_strings[0]
def Update(self, size):
'''
@ -310,13 +316,11 @@ class Counter(AbstractComponent):
str(action.options_string[0]) * DropDown Value
'''
dropdown_value = self._widget.GetValue()
try:
return str(self._action.option_strings[0]) * int(dropdown_value)
except Exception as e:
print e
return ''
if not str(dropdown_value).isdigit():
return None
arg = str(self._action.option_strings[0]).replace('-','')
repeated_args = arg * int(dropdown_value)
return '-' + repeated_args
if __name__ == '__main__':

5
src/app/dialogs/controller.py

@ -30,8 +30,11 @@ class Controller(object):
def OnConfigCancel(self, event):
print 'OnCongigCancel pressed!'
def OnConfigNext(self, event):
self._body.GetOptions()
cmd_line_args = self._body.GetOptions()
def OnMainCancel(self, event):
print 'OnMaingCancel pressed!'
def OnMainNext(self, event):

15
src/app/dialogs/parse_validator.py

@ -0,0 +1,15 @@
'''
Created on Jan 22, 2014
@author: Chris
'''
def Validate(parser, argument_string):
try:
parser.parse_args(argument_string.split())
except:
raise ValueError
if __name__ == '__main__':
pass

2
src/app/dialogs/window.py

@ -36,7 +36,7 @@ def WithAdvancedOptions(parser):
app = wx.App(False)
frame = base_window.BaseWindow(advanced_config.AdvancedConfigPanel, parser)
frame.Show(True) # Show the frame.
app.MainLoop()
app.MainLoop()
if __name__ == '__main__':
parser = argparse_test_data.parser

BIN
src/app/images/image_store.pyc

Loading…
Cancel
Save