[dabo-users] Very Simple dropdownlist

Author: Carey Gagnon

Posted: 2009-07-12 at 14:31:29

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

---

©2009 Carey Gagnon