My apologies if this goes out twice. I posted to the nabble forum before
realizing I needed to subscribe to the mailing list.
## As Posted On Nabble ##
1st off, thanks to the developers of dabo. I'm a n00b to python, wxpython
and dabo. With the help of this forum and the step by step guide I have
managed to get everything in said guide working as expected. I've even
managed some simple modifications as I learn dabo et al. There's one
modification I just can't wrap my head around that I will want to use once I
start developing my own app.
Here's the problem. In the step by step the input field for stateprov is
currently set to a dTextBox. I would like to change this to a dDropdownList.
I don't want to set up another db table just to do this (I've got populating
a drop down from the db down no problem). I just want a static drop down
list that will add the selected state from the drop down list to the
stateprov field of the client table of the database (MySQL) on save. (one
mod I managed was an Add Client form)
I've looked at the test in the uiwx/dDropdownList.py file and have created
the following via the CD. The code is located in the ClientAddForm-code.py
file:
def afterInit(self):
#def initProperties(self): ## Commented out
locations = ({"state": "Ak", "iid": 1},
{"state": "Ga", "iid": 2},
{"state": "Tx", "iid": 3})
choices = []
keys = {}
for location in locations:
choices.append("%s" % (location['state']))
keys[location["iid"]] = len(choices) - 1
self.Choices = choices
self.Keys = keys
self.ValueMode = "key"
The drop list with choices displays in the form no problem, but when I save
to the database the selection is not added to the stateprov field.
H E L P ! ! !
Thanks in advance
Carey
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
Author: <lalong1@charter.net>
Posted: 2009-07-12 17:01:06 Link
Hello Carey,
When you instantiated the dropdown did you bind it to the bizobj?...ie
something like...
statesdropdown = your_dDropdownList(self, DataSource = bizobject,
DataField = "state_id_field")
Larry Long
> -----Original Message-----
> From: dabo-users-bounces@leafe.com
> [mailto:dabo-users-bounces@leafe.com] On Behalf Of Carey Gagnon
> Sent: Sunday, July 12, 2009 2:31 PM
> To: dabo-users@leafe.com
> Subject: [dabo-users] Very Simple dropdownlist
>
> My apologies if this goes out twice. I posted to the nabble
> forum before realizing I needed to subscribe to the mailing list.
>
> ## As Posted On Nabble ##
>
> 1st off, thanks to the developers of dabo. I'm a n00b to
> python, wxpython and dabo. With the help of this forum and
> the step by step guide I have managed to get everything in
> said guide working as expected. I've even managed some simple
> modifications as I learn dabo et al. There's one modification
> I just can't wrap my head around that I will want to use once
> I start developing my own app.
>
> Here's the problem. In the step by step the input field for
> stateprov is currently set to a dTextBox. I would like to
> change this to a dDropdownList.
> I don't want to set up another db table just to do this (I've
> got populating a drop down from the db down no problem). I
> just want a static drop down list that will add the selected
> state from the drop down list to the stateprov field of the
> client table of the database (MySQL) on save. (one mod I
> managed was an Add Client form)
>
> I've looked at the test in the uiwx/dDropdownList.py file and
> have created the following via the CD. The code is located in
> the ClientAddForm-code.py
> file:
>
> def afterInit(self):
> #def initProperties(self): ## Commented out
> locations = ({"state": "Ak", "iid": 1},
> {"state": "Ga", "iid": 2},
> {"state": "Tx", "iid": 3})
>
> choices = []
> keys = {}
> for location in locations:
> choices.append("%s" % (location['state']))
> keys[location["iid"]] = len(choices) - 1
> self.Choices = choices
> self.Keys = keys
> self.ValueMode = "key"
>
> The drop list with choices displays in the form no problem,
> but when I save to the database the selection is not added to
> the stateprov field.
>
>
> H E L P ! ! !
>
> Thanks in advance
> Carey
>
>
> --- StripMime Report -- processed MIME parts --- multipart/alternative
> text/plain (text body -- kept)
> text/html
> ---
>
[excessive quoting removed by server]
Larry;
I'm not sure I understand. In the Class Designer I set the
datatfield to stateprov for the drop down list. I assumed it passed what
ever was selected in the drop down to the database on save.
So even a static (for lack of a better phrase) drop down needs to be bound
to the bizobj in order to be wrtten to the database on save?
Thanks for your reply
Carey
On Sun, Jul 12, 2009 at 4:01 PM, <lalong1@charter.net> wrote:
> Hello Carey,
>
> When you instantiated the dropdown did you bind it to the bizobj?...ie
> something like...
> statesdropdown =3D your_dDropdownList(self, DataSource =3D bizobje=
ct,
> DataField =3D "state_id_field")
>
> Larry Long
>
> > -----Original Message-----
> > From: dabo-users-bounces@leafe.com
> > [mailto:dabo-users-bounces@leafe.com] On Behalf Of Carey Gagnon
> > Sent: Sunday, July 12, 2009 2:31 PM
> > To: dabo-users@leafe.com
> > Subject: [dabo-users] Very Simple dropdownlist
> >
> > My apologies if this goes out twice. I posted to the nabble
> > forum before realizing I needed to subscribe to the mailing list.
> >
> > ## As Posted On Nabble ##
> >
> > 1st off, thanks to the developers of dabo. I'm a n00b to
> > python, wxpython and dabo. With the help of this forum and
> > the step by step guide I have managed to get everything in
> > said guide working as expected. I've even managed some simple
> > modifications as I learn dabo et al. There's one modification
> > I just can't wrap my head around that I will want to use once
> > I start developing my own app.
> >
> > Here's the problem. In the step by step the input field for
> > stateprov is currently set to a dTextBox. I would like to
> > change this to a dDropdownList.
> > I don't want to set up another db table just to do this (I've
> > got populating a drop down from the db down no problem). I
> > just want a static drop down list that will add the selected
> > state from the drop down list to the stateprov field of the
> > client table of the database (MySQL) on save. (one mod I
> > managed was an Add Client form)
> >
> > I've looked at the test in the uiwx/dDropdownList.py file and
> > have created the following via the CD. The code is located in
> > the ClientAddForm-code.py
> > file:
> >
> > def afterInit(self):
> > #def initProperties(self): ## Commented out
> > locations =3D ({"state": "Ak", "iid": 1},
> > {"state": "Ga", "iid": 2},
> > {"state": "Tx", "iid": 3})
> >
> > choices =3D []
> > keys =3D {}
> > for location in locations:
> > choices.append("%s" % (location['state']))
> > keys[location["iid"]] =3D len(choices) - 1
> > self.Choices =3D choices
> > self.Keys =3D keys
> > self.ValueMode =3D "key"
> >
> > The drop list with choices displays in the form no problem,
> > but when I save to the database the selection is not added to
> > the stateprov field.
> >
> >
> > H E L P ! ! !
> >
> > Thanks in advance
> > Carey
> >
> >
> > --- StripMime Report -- processed MIME parts --- multipart/alternative
> > text/plain (text body -- kept)
> > text/html
> > ---
> >
[excessive quoting removed by server]
On Jul 12, 2009, at 4:19 PM, Carey Gagnon wrote:
> So even a static (for lack of a better phrase) drop down needs to be
> bound
> to the bizobj in order to be wrtten to the database on save?
Yes. A control is just a dumb UI object. However, you can enable data
binding by setting two properties: DataSource and DataField. These
determine the object and property, respectively, that the control is
bound to. In the most typical case, 'DataSource' is the same as the
bizobj's DataSource (the form will figure this out at run time), and
'DataField' is the column in the data that the control's Value should
be bound to. Just by setting those two properties you transform a dumb
UI control into a powerful data display/editing tool.
-- Ed Leafe
Still no luck. This is the code now:
def afterInit(self):
statesdropdown = SPLDropdown(self, DataSource = ClientBizobj, DataField
= "stateprov")
locations = ({"state": "Select", "iid": 0},
{"state": "Ak", "iid": 1},
{"state": "Ga", "iid": 2},
{"state": "Tx", "iid": 3})
choices = []
keys = {}
for location in locations:
choices.append("%s" % (location['state']))
keys[location["iid"]] = len(choices) - 1
self.Choices = choices
self.Keys = keys
self.ValueMode = "key"
#####################################
SPLDropdown is the RegID I gave to the drop down list.
Now I get the error:
NameError: global name 'SPLDropdown' is not defined
N00bs R Us
Carey
On Sun, Jul 12, 2009 at 4:31 PM, Ed Leafe <ed@leafe.com> wrote:
> On Jul 12, 2009, at 4:19 PM, Carey Gagnon wrote:
>
> > So even a static (for lack of a better phrase) drop down needs to be
> > bound
> > to the bizobj in order to be wrtten to the database on save?
>
> Yes. A control is just a dumb UI object. However, you can enable
> data
> binding by setting two properties: DataSource and DataField. These
> determine the object and property, respectively, that the control is
> bound to. In the most typical case, 'DataSource' is the same as the
> bizobj's DataSource (the form will figure this out at run time), and
> 'DataField' is the column in the data that the control's Value should
> be bound to. Just by setting those two properties you transform a dumb
> UI control into a powerful data display/editing tool.
>
>
> -- Ed Leafe
>
>
>
>
>
[excessive quoting removed by server]
On Jul 12, 2009, at 5:00 PM, Carey Gagnon wrote:
> statesdropdown = SPLDropdown(self, DataSource = ClientBizobj,
> DataField
> = "stateprov")
[snip]
> SPLDropdown is the RegID I gave to the drop down list.
You're confusing RegID, which is a sort of shortcut for making
referring to existing objects easily, with a class definition. The
first line above is attempting to create an instance of the class
'SPLDropdown', which obviously is not a class.
You said that you gave the dropdown a RegID; where exactly did you do
that?
To create the dropdown, the code would look something like:
statesdropdown = dabo.ui.dDropdownList(self, DataSource=ClientBizobj,
DataField="stateprov", RegID="SPLDropdown")
-- Ed Leafe
Author: <lalong1@charter.net>
Posted: 2009-07-12 20:29:01 Link
The afterinit is for what object?
> -----Original Message-----
> From: dabo-users-bounces@leafe.com
> [mailto:dabo-users-bounces@leafe.com] On Behalf Of Carey Gagnon
> Sent: Sunday, July 12, 2009 6:01 PM
> To: Dabo Users list
> Subject: Re: [dabo-users] Very Simple dropdownlist
>
> Still no luck. This is the code now:
>
> def afterInit(self):
> statesdropdown = SPLDropdown(self, DataSource =
> ClientBizobj, DataField = "stateprov")
> locations = ({"state": "Select", "iid": 0},
> {"state": "Ak", "iid": 1},
> {"state": "Ga", "iid": 2},
> {"state": "Tx", "iid": 3})
>
> choices = []
> keys = {}
> for location in locations:
> choices.append("%s" % (location['state']))
> keys[location["iid"]] = len(choices) - 1
> self.Choices = choices
> self.Keys = keys
> self.ValueMode = "key"
>
> #####################################
>
> SPLDropdown is the RegID I gave to the drop down list.
>
> Now I get the error:
> NameError: global name 'SPLDropdown' is not defined
>
>
> N00bs R Us
> Carey
>
>
>
> On Sun, Jul 12, 2009 at 4:31 PM, Ed Leafe <ed@leafe.com> wrote:
>
> > On Jul 12, 2009, at 4:19 PM, Carey Gagnon wrote:
> >
> > > So even a static (for lack of a better phrase) drop down
> needs to be
> > > bound to the bizobj in order to be wrtten to the database on save?
> >
> > Yes. A control is just a dumb UI object. However, you can
> > enable data binding by setting two properties: DataSource and
> > DataField. These determine the object and property,
> respectively, that
> > the control is bound to. In the most typical case,
> 'DataSource' is the
> > same as the bizobj's DataSource (the form will figure this
> out at run
> > time), and 'DataField' is the column in the data that the control's
> > Value should be bound to. Just by setting those two properties you
> > transform a dumb UI control into a powerful data
> display/editing tool.
> >
> >
> > -- Ed Leafe
> >
> >
> >
> >
> >
[excessive quoting removed by server]
Author: <lalong1@charter.net>
Posted: 2009-07-12 20:43:25 Link
Carey,
Try something like this...
statesdropdown = dabo.ui.dDropdownList(self,DataSource = ClientBizobj,
DataField = "stateprov")
choices = []
keys = {}
for location in locations:
choices.append("%s" % (location['state']))
keys[location["iid"]] = len(choices) - 1
statesdropdown.Choices = choices
statesdropdown.Keys = keys
statesdropdown.ValueMode = "key"
HTH,
Larry
Author: <lalong1@charter.net>
Posted: 2009-07-12 21:35:47 Link
Carey,
Sorry, my carriage returns didn't go thru....
statesdropdown = dabo.ui.dDropdownList(self,DataSource = ClientBizobj,
DataField = "stateprov")
choices = []
keys = {}
for location in locations:
choices.append("%s" % (location['state']))
keys[location["iid"]] = len(choices) - 1
statesdropdown.Choices = choices
statesdropdown.Keys = keys
statesdropdown.ValueMode = "key"
Larry
Ed / Larry;
Thanks for your assistance. I still haven't got it working.
I'm not sure what goes in the bizobj and what goes in the form, but I don't
want to be spoon fed either. can't learn anything that way.
I will play with what you guys have given me as time permits and see what
happen.
Thank again for your time, and I'll post back my results later.
Thanks
Carey
On Sun, Jul 12, 2009 at 8:35 PM, <lalong1@charter.net> wrote:
> Carey,
>
> Sorry, my carriage returns didn't go thru....
>
> statesdropdown =3D dabo.ui.dDropdownList(self,DataSource =3D ClientBizobj=
,
> DataField =3D "stateprov")
>
> choices =3D []
> keys =3D {}
> for location in locations:
> choices.append("%s" % (location['state']))
> keys[location["iid"]] =3D len(choices) - 1
>
> statesdropdown.Choices =3D choices
> statesdropdown.Keys =3D keys
> statesdropdown.ValueMode =3D "key"
>
> Larry
>
>
>
>
[excessive quoting removed by server]