[Tutor] How do I.......(another Tk, list question)

Magnus Lycka magnus@thinkware.se
Sun, 20 Oct 2002 01:50:02 +0200


At 20:04 2002-10-19 -0400, andy surany wrote:
>Now I would like to reflect the results of those change functions in the=20
>displayed list. Seems to me I have 2 choices: 1 is to re-execute the query=
=20
>and re-populate the box; the other is to handle the individual elements of=
=20
>the list (I have the location and value of each selected list element). If=
=20
>I do not re-execute the query, are there extensions to Listbox which would=
=20
>allow me to add/delete elements?

I'd go for the refill from the database if performance is
ok. And maybe not only when I changed... Perhaps someone else
can change it? Or maybe I can open a second instance of the
program (or an SQL monitor) and change it outside the scope
of this app. This might need to be reflected in the list...

I use the GoF Observer (publish/subscribe) pattern for these
sorts of things. But I just have one thread/process/user to
worry about in my app. (So far.)

>I tried just "re-calling" the routine that did the query and built the=20
>box. It worked - but gave me a whole new ScrolledList (so there are 2 on=20
>the display.....). Am I on the right track with this?

You should have one routine that builds the box.
Then you should have a second routine to fill it.
In general, try to make your functions do just one thing.

In this case, you just call the second routine a second
time. (The refill routine will empty the list before
adding elements of course.)

Save a handle to the control as an attribute of the
surrounding class.


--=20
Magnus Lyck=E5, Thinkware AB
=C4lvans v=E4g 99, SE-907 50 UME=C5
tel: 070-582 80 65, fax: 070-612 80 65
http://www.thinkware.se/  mailto:magnus@thinkware.se