From: Schollnick, B. <Ben...@xe...> - 2005-07-14 17:27:10
|
I'm such a fool today... Thanks... Silly Programmer Error, I guess... (D'oh) - Ben > -----Original Message----- > From: Alex Tweedly [mailto:al...@tw...]=20 > Sent: Thursday, July 14, 2005 1:17 PM > To: Schollnick, Benjamin > Cc: pyt...@li... > Subject: Re: [Pythoncard-users] Programatically adding Choice field... >=20 >=20 > Schollnick, Benjamin wrote: >=20 > >Folks, > > > >I'm working on a custom dialog, that I need to revise=20 > depending on the=20 > >type of data being edited. > > > >The following code works fine, except for the Choice Dialog. > > > > =20 > > > What is there about it that doesn't work ? >=20 > The following shows a traceback for the error that there is=20 > no component=20 > named "Software_Classificationfield" - which is what I'd=20 > expect, because=20 > all 3 variants of defining that component are commented out. >=20 > If one of those were put back in (I think any of them), then=20 > you'd also=20 > want to change the source line that says >=20 > result.Software_Classification =3D=20 > dlg.components.Software_Classificationfield.text > to > result.Software_Classification =3D=20 > dlg.components.Software_Classificationfield.stringSelection >=20 > and I think it might then work. >=20 > I created a quick dialog that (I think) was equivalent (using=20 > the first variant from the comment block), and that one-line=20 > change made it work - so give it a try, and if that doesn't=20 > do it for you, let me know. >=20 > If it's still not working, you can send me the code/rsrc=20 > directly and then I'll be sure I'm fixing the right problem :-) >=20 > -- Alex >=20 >=20 > >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'] =3D {'type':'StaticText', > > 'name':label+'text', > > 'position':(x, y), > > 'text':label.replace("_", " "),} > > > > self.components[label+'field'] =3D {'type':'TextArea', > > 'name':label+'field', > > 'position':(x+110, y-10), > > 'size':(280, 40), > > =20 > 'text':default.replace("_", " "),} > > > > > > def static_and_pulldown ( self, x, y, label, data=3D[]): > > self.components[label+'text'] =3D {'type':'StaticText', > > 'name':label+'text', > > 'position':(x, y), > > 'text':label.replace("_", " "),} > >## self.components[label+'field'] =3D {'type':'Choice',=20 > >## 'name':'Choice1',=20 > >## 'position':(10, 10),=20 > >## 'items':[],=20 > >## 'labelSpecified':0,=20 > >## 'nameSpecified':0,=20 > >## } > >## self.components[label+'field'] =3D {'type':'Choice',=20 > >## 'name':'popChoice',=20 > >## 'position':(100, 360),=20 > >## =20 > 'items':{'one':1, 'two':2, > >'three':3},=20 > >## =20 > 'stringSelection':'two',=20 > >## }, > >## self.components[label+'field'] =3D {'type':'Choice', > >## 'name':label+'field', > >## 'position':(x+125, y), > >## 'items':['abc', > >'def','ghi'], > >## =20 > '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=20 > >on_btnEdit_mouseClick > > results =3D self.edit (self, data) > > File "C:\develope\security\editting_dialog.py", line 109, in=20 > >edit_software_catalog > > result.Software_Classification =3D=20 > >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 > > =20 > > > --=20 > Alex Tweedly http://www.tweedly.net >=20 >=20 >=20 > --=20 > No virus found in this outgoing message. > Checked by AVG Anti-Virus. > Version: 7.0.323 / Virus Database: 267.8.14/48 - Release=20 > Date: 13/07/2005 >=20 >=20 |