Browse Source

refactored Components to support nargs. Fixed output unittest

pull/1/head
unknown 10 years ago
parent
commit
8e34ddd5dc
3 changed files with 15 additions and 15 deletions
  1. 20
      src/app/dialogs/components.py
  2. 10
      src/app/dialogs/controller.py
  3. BIN
      src/app/images/image_store.pyc

20
src/app/dialogs/components.py

@ -46,9 +46,6 @@ class AbstractComponent(object):
else:
sizer.AddStretchSpacer(1)
if self.HasNargs(self._action):
sizer.Add(self.AddNargsMsg(parent, self._action))
sizer.AddStretchSpacer(1)
sizer.Add(self._widget, 0, wx.EXPAND)
return sizer
@ -57,16 +54,17 @@ class AbstractComponent(object):
return action.help is not None
def HasNargs(self, action):
return action.nargs == '+'
return action.nargs == '+' or action.nargs == '?'
def CreateHelpMsgWidget(self, parent, action):
text = wx.StaticText(parent, label=action.help)
self.MakeDarkGrey(text)
return text
base_text = wx.StaticText(parent, label=action.help)
if self.HasNargs(action):
base_text += self.CreateNargsMsg(action)
self.MakeDarkGrey(base_text)
return base_text
def AddNargsMsg(self, parent, action):
msg = 'Note: at least 1 or more arguments are required'
return wx.StaticText(parent, label=msg)
def CreateNargsMsg(self, action):
return ' (Note: at least 1 or more arguments are required'
def CreateDestNameWidget(self, parent, action):
label = str(action.dest).title()
@ -232,7 +230,7 @@ class Flag(AbstractComponent):
sizer.AddSpacer(6)
if self.HasNargs(self._action):
sizer.Add(self.AddNargsMsg(parent, self._action))
sizer.Add(self.CreateNargsMsg(parent, self._action))
if self._msg:
hsizer = self.buildHorizonalMsgSizer(parent)

10
src/app/dialogs/controller.py

@ -4,6 +4,7 @@ Created on Dec 22, 2013
@author: Chris
'''
import wx
import msg_dialog
from app.dialogs.model import Model
@ -40,7 +41,8 @@ class Controller(object):
cmd_line_args = self._body.GetOptions()
if not self._model.IsValidArgString(cmd_line_args):
error_msg = self._model.GetErrorMsg(cmd_line_args)
print error_msg
print error_msg
self.ShowArgumentErrorDlg(error_msg)
else:
print 'All args passed.'
print cmd_line_args
@ -52,7 +54,7 @@ class Controller(object):
print 'OnCongigNext pressed!'
def ShowArgumentErrorDlg(self, error):
msg_dialog.ShowError(error)
a = wx.MessageDialog(None, error, 'Argument Error')
a.ShowModal()
a.Destroy()

BIN
src/app/images/image_store.pyc

Loading…
Cancel
Save