Home | Trees | Indices | Help |
|
---|
|
object --+ | cGenericEditAreaMixin
Mixin for edit area panels providing generic functionality. **************** start of template **************** #==================================================================== # Class definition: from Gnumed.wxGladeWidgets import wxgXxxEAPnl class cXxxEAPnl(wxgXxxEAPnl.wxgXxxEAPnl, gmEditArea.cGenericEditAreaMixin): def __init__(self, *args, **kwargs): try: data = kwargs['xxx'] del kwargs['xxx'] except KeyError: data = None wxgXxxEAPnl.wxgXxxEAPnl.__init__(self, *args, **kwargs) gmEditArea.cGenericEditAreaMixin.__init__(self) # Code using this mixin should set mode and data # after instantiating the class: self.mode = 'new' self.data = data if data is not None: self.mode = 'edit' #self.__init_ui() #---------------------------------------------------------------- # def __init_ui(self): # # adjust phrasewheels etc #---------------------------------------------------------------- # generic Edit Area mixin API #---------------------------------------------------------------- def _valid_for_save(self): # its best to validate bottom -> top such that the # cursor ends up in the topmost failing field # remove when implemented: return False validity = True if self._TCTRL_xxx.GetValue().strip() == u'': validity = False self.display_tctrl_as_valid(tctrl = self._TCTRL_xxx, valid = False) gmDispatcher.send(signal = 'statustext', msg = _('No entry in field xxx.')) self._TCTRL_xxx.SetFocus() else: self.display_tctrl_as_valid(tctrl = self._TCTRL_xxx, valid = True) if self._PRW_xxx.GetData() is None: validity = False self._PRW_xxx.display_as_valid(False) gmDispatcher.send(signal = 'statustext', msg = _('No entry in field xxx.')) self._PRW_xxx.SetFocus() else: self._PRW_xxx.display_as_valid(True) return validity #---------------------------------------------------------------- def _save_as_new(self): # remove when implemented: return False # save the data as a new instance data = gmXXXX.create_xxxx() data[''] = self._ data[''] = self._ data.save() # must be done very late or else the property access # will refresh the display such that later field # access will return empty values self.data = data return False return True #---------------------------------------------------------------- def _save_as_update(self): # remove when implemented: return False # update self.data and save the changes self.data[''] = self._TCTRL_xxx.GetValue().strip() self.data[''] = self._PRW_xxx.GetData() self.data[''] = self._CHBOX_xxx.GetValue() self.data.save() return True #---------------------------------------------------------------- def _refresh_as_new(self): pass #---------------------------------------------------------------- def _refresh_as_new_from_existing(self): self._refresh_as_new() #---------------------------------------------------------------- def _refresh_from_existing(self): pass #---------------------------------------------------------------- **************** end of template ****************
Instance Methods | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from |
Properties | |
data | |
mode | |
status_message | |
Inherited from |
Method Details |
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
|
Invoked from the generic edit area dialog. Invokes _refresh_as_new() _refresh_from_existing() _refresh_as_new_from_existing() on the implementing edit area as needed. Then calls _valid_for_save(). |
Invoked from the generic edit area dialog. Invokes _valid_for_save, _save_as_new, _save_as_update on the implementing edit area as needed. _save_as_* must set self.__data and return True/False |
Property Details |
status_message
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sat Aug 3 03:56:05 2013 | http://epydoc.sourceforge.net |