From: Alex T. <al...@tw...> - 2005-07-14 17:17:01
|
Schollnick, Benjamin wrote: >Folks, > >I'm working on a custom dialog, that I need to revise depending on the >type of data being edited. > >The following code works fine, except for the Choice Dialog. > > > What is there about it that doesn't work ? The following shows a traceback for the error that there is no component named "Software_Classificationfield" - which is what I'd expect, because all 3 variants of defining that component are commented out. If one of those were put back in (I think any of them), then you'd also want to change the source line that says result.Software_Classification = dlg.components.Software_Classificationfield.text to result.Software_Classification = dlg.components.Software_Classificationfield.stringSelection and I think it might then work. I created a quick dialog that (I think) was equivalent (using the first variant from the comment block), and that one-line change made it work - so give it a try, and if that doesn't do it for you, let me know. If it's still not working, you can send me the code/rsrc directly and then I'll be sure I'm fixing the right problem :-) -- Alex >class Edit_Window(model.CustomDialog): > def static_and_area (self, x, y, label, default): > #self.static_and_area (10, 20, "xyz", "testing") > #self.static_and_area (10, 20, "xyz", "testing") > self.components[label+'text'] = {'type':'StaticText', > 'name':label+'text', > 'position':(x, y), > 'text':label.replace("_", " "),} > > self.components[label+'field'] = {'type':'TextArea', > 'name':label+'field', > 'position':(x+110, y-10), > 'size':(280, 40), > 'text':default.replace("_", " "),} > > > def static_and_pulldown ( self, x, y, label, data=[]): > self.components[label+'text'] = {'type':'StaticText', > 'name':label+'text', > 'position':(x, y), > 'text':label.replace("_", " "),} >## self.components[label+'field'] = {'type':'Choice', >## 'name':'Choice1', >## 'position':(10, 10), >## 'items':[], >## 'labelSpecified':0, >## 'nameSpecified':0, >## } >## self.components[label+'field'] = {'type':'Choice', >## 'name':'popChoice', >## 'position':(100, 360), >## 'items':{'one':1, 'two':2, >'three':3}, >## 'stringSelection':'two', >## }, >## self.components[label+'field'] = {'type':'Choice', >## 'name':label+'field', >## 'position':(x+125, y), >## 'items':['abc', >'def','ghi'], >## 'stringSelection': 'def',}, > > >Any ideas? > >C:\develope\security>software_licensing_report2.py > >Traceback (most recent call last): > File "C:\develope\Python24\lib\site-packages\PythonCard\widget.py", >line 439,in _dispatch > handler(background, aWxEvent) > File "C:\develope\security\browser.py", line 62, in >on_btnEdit_mouseClick > results = self.edit (self, data) > File "C:\develope\security\editting_dialog.py", line 109, in >edit_software_catalog > result.Software_Classification = >dlg.components.Software_Classificationfield.text > File "C:\develope\Python24\lib\site-packages\PythonCard\model.py", >line 77, in __getattr__ > return self.data[key] >KeyError: 'Software_Classificationfield' >{'returnedString': 'Close', 'accepted': True, 'returned': 5100} > > - Ben > > -- Alex Tweedly http://www.tweedly.net -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.323 / Virus Database: 267.8.14/48 - Release Date: 13/07/2005 |