[Tutor] How to make clickable listbox from database by Tkinter

Alan Gauld alan.gauld at btinternet.com
Mon Jun 15 10:03:09 CEST 2015


On 15/06/15 08:11, Ali Moradi wrote:

> how can i add a listbox under the entry and button widgets?

Can you clarify that sentence? What do you mean by "under"?
Do you want the list box to be located on the same form as
two widgets but underneath? Or do you want the listbox
to appear when you press the button?

If its the first then it will be down to using the
correct layout manager (pack, grid, place etc) in
conjunction with one or more Frame containers.

If its the second the jn you will need to say where
the listbox should appear: in a dialog or on the
existing form.

> i want to use database to fill the listbox, both fields in the database
> (English and Esperanto)

What kind of database? You can attach Python to most databases
but there are differences depending on the exact database
you use. Is it SQL or a flat file database?

> listbox should be like this (words are beside each other:
>
> *English*     *Esperanto*
> water        akvo
> father        patro
>
> and so on...

That's probably just a string formatting task.

> i want to make the items in the list searchable, and when the user types
> and clicks on the button, it shows the word.

You must be more specific. We can't read your mind.
If the user clicks on the button it should show which word?

I assume you mean if the user enters a word in the entry
widget and then presses the button then the list box should
arrange its contents such that the user word and its pair
are both visible? And maybe highlighted too?

I'm guessing that the word entered can be in either English
or Esperanto? So if the user enters 'water' it will show
and highlight the line:
"water   akvo"
And if the user enters the word 'patro' it will show
and highlight the line:
"father   patro"

Is that what you mean?

> files are attached.

This is a text based mailing list, your attachments have
disappeared in transit (at least for me). Please send the files
as text embedded in your mail. (Please be sure to use plain
text email for this as HTML will mess up the formatting).
If the files are long, say >100 lines put them on a pastebin
type site and send a link.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list