FAQ

Daniel P. Engel wrote:
Wouldn't that be sels[0]?
The value in sels[0] is the string I wish to display in a label, not the
row number. Actually I've abandoned the attempt to find the row number.
I'm now creating a dictionary at the same time the listbox is being
populated:

while 1:
lRec = curs.fetchone()
if not lRec: break

itm = str(lRec[3]) + ", " + str(lRec[1]) + " " + str(lRec[2])
self.box.insert('end', itm)
self.pnmbrs[itm] = str(lRec[0])

The select statement fetches the unique people_nmbr and the person's
first middle and last name. The listbox displays the name value,
thusly: last_name, first_name middle_name.
When a row is selected from the listbox, the selected value is used as a
key:

def selectionCommand(self):
sels = self.box.getcurselection()
if len(sels) == 0:
print 'No selection'
else:
print 'Selection:', sels[0]
print 'People Number:', self.pnmbrs[sels[0]]



If there is a prefered or more efficient way of doing this, I would be
grateful to hear of it.

--
---------------------------------------------------------------------
Scott Holmes http://sholmes.ws
http://pages.sbcglobal.net/scottholmes
scottholmes at sbcglobal.net

Independent Programmer/Analyst Passport 4GL
PHP HTML Composer PostgreSQL Informix 4GL, SQL
---------------------------------------------------------------------
There are more things in heaven and earth, Horatio,
than are dreamt of in your philosophy
---------------------------------------------------------------------

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 3 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedAug 5, '03 at 12:13a
activeAug 5, '03 at 5:45p
posts3
users2
websitepython.org

2 users in discussion

Scott Holmes: 2 posts Daniel P. Engel: 1 post

People

Translate

site design / logo © 2022 Grokbase