Thread: [Boa Constr] Problem adding companion
Status: Beta
Brought to you by:
riaan
From: Torsten S. <mo...@ak...> - 2003-06-16 16:58:39
|
I have a problem adding wxIntCtrl. My UserCompanions.plug-in contains this: from wxPython.lib.intctrl import * class IntCtrlConstr: def constructor(self): return {'Value': 'value', 'Min': 'min', 'Max': 'max', 'Limited': 'limited', 'Allow_None': 'allow_none', 'Allow_Long': 'allow_long', 'Default_Color': 'default_color', 'OOB_Color': 'oob_color', 'Position': 'pos', 'Size': 'size', 'Style': 'style', 'Name': 'name'} class IntCtrlDTC(IntCtrlConstr,BasicCompanions.TextCtrlDTC): def __init__(self, name, designer, parent, ctrlClass): BasicCompanions.TextCtrlDTC.__init__(self, name, designer, parent, ctrlClass) self.editors['CaptionAlignment'] = PropertyEditors.EnumPropEdit self.options['CaptionAlignment'] = [wx.wxTOP, wx.wxLEFT] self.names['CaptionAlignment'] = {'wxTOP': wx.wxTOP, 'wxLEFT': wx.wxLEFT} def writeImports(self): return 'from wxPython.lib.intctrl import *' def designTimeSource(self, position = 'wxDefaultPosition', size = 'wxDefaultSize'): return {'value': 0, 'pos': position, 'size': size, 'name': `self.name`} # Add the component's class to this list PaletteStore.paletteLists['User'].extend([wxIntCtrl]) # Add an entry to this dict with the following structure: # <component class>: ['Palette tip name and bitmap file', <companion>] PaletteStore.compInfo.update({wxIntCtrl: ['IntCtrl', TextCtrlDTC]}) When I add an IntCtrl in the designer I get the following traceback: Traceback (most recent call last): File "/home/totty/boa/boa-constructor-0.2.3/Views/Designer.py", line 1291, in OnControlSelect File "/home/totty/boa/boa-constructor-0.2.3/Views/Designer.py", line 731, in selectControlByPos File "/home/totty/boa/boa-constructor-0.2.3/Views/Designer.py", line 449, in newControl File "/home/totty/boa/boa-constructor-0.2.3/Companions/BaseCompanions.py", line 579, in designTimeControl File "/usr/lib/python2.2/site-packages/wxPython/lib/intctrl.py", line 426, in __init__ self.SetValue(value) File "/usr/lib/python2.2/site-packages/wxPython/lib/intctrl.py", line 458, in SetValue wxTextCtrl.SetValue( self, self._toGUI(value) ) File "/usr/lib/python2.2/site-packages/wxPython/lib/intctrl.py", line 702, in _toGUI raise ValueError ( ValueError: wxIntCtrl requires integer value, passed 'intCtrl1' That means my 'value':0 is overwritten somewhere. Any help is appreciated. Torsten |
From: Riaan B. <riaan@e.co.za> - 2003-06-16 19:18:00
|
Hi Torsten, Nice to see people adding controls to Boa! Torsten Sadowski wrote: > I have a problem adding wxIntCtrl. My UserCompanions.plug-in contains > this: > > from wxPython.lib.intctrl import * > > class IntCtrlConstr: > def constructor(self): > return {'Value': 'value', 'Min': 'min', 'Max': 'max', > 'Limited': 'limited', 'Allow_None': 'allow_none', > 'Allow_Long': 'allow_long', > 'Default_Color': 'default_color', > 'OOB_Color': 'oob_color', I suggest 'AllowLong', 'DefaultColor', 'OOBColor'. > 'Position': 'pos', 'Size': 'size', > 'Style': 'style', 'Name': 'name'} > > > class IntCtrlDTC(IntCtrlConstr,BasicCompanions.TextCtrlDTC): > def __init__(self, name, designer, parent, ctrlClass): > BasicCompanions.TextCtrlDTC.__init__(self, name, designer, parent, > ctrlClass) > self.editors['CaptionAlignment'] = PropertyEditors.EnumPropEdit > self.options['CaptionAlignment'] = [wx.wxTOP, wx.wxLEFT] > self.names['CaptionAlignment'] = {'wxTOP': wx.wxTOP, 'wxLEFT': > wx.wxLEFT} > > def writeImports(self): > return 'from wxPython.lib.intctrl import *' > > def designTimeSource(self, position = 'wxDefaultPosition', size = > 'wxDefaultSize'): > return {'value': 0, Your error is probably here^ This dictionary contains source (string) values, so you should have: return {'value': '0', > 'pos': position, > 'size': size, > 'name': `self.name`} > <...> > ValueError: wxIntCtrl requires integer value, passed 'intCtrl1' Cheers, Riaan. |
From: Torsten S. <mo...@ak...> - 2003-06-17 15:14:45
|
Oh my stupidity. The big error was in the last line: # Add an entry to this dict with the following structure: # <component class>: ['Palette tip name and bitmap file', <companion>] PaletteStore.compInfo.update({wxIntCtrl: ['IntCtrl', TextCtrlDTC]}) which should read: PaletteStore.compInfo.update({wxIntCtrl: ['IntCtrl', IntCtrlDTC]}) because otherwise my DTC was never called. Torsten |
From: Torsten S. <mo...@ak...> - 2003-06-18 12:20:05
|
I wrapped up my homebuilt control. It appears in the designer, but then I get: Import statement invalid How do I define an Import statement? Torsten |
From: Riaan B. <riaan@e.co.za> - 2003-06-19 23:06:04
|
Hi Torsten, Torsten Sadowski wrote: > I wrapped up my homebuilt control. It appears in the designer, but then I > get: > > Import statement invalid This error is raised when the line returned by writeImports match neither the "import name" form nor the "from name import name" form. Please check that method in your source. The one you mailed in your first message looks correct. Also look at other calls to writeImports in the Companions directory if in doubt. Cheers, Riaan. |