Discussion:
[Tutor] clickable listbox from sqlite database.
Ali Moradi
2015-06-16 12:47:36 UTC
Permalink
Hi, you got what i mean thanks, your code (http://pastebin.com/VbaVKJgj)
was so good. now i want to do two more things.

i want to fill the listbox from my database which contains of one table
(Words) and two fields (English) and (Esperanto), how can i do that? i want
the program to be the same just the words loaded from my sqlite database.

and second thing: i want to search the word when user hits "Enter" on
keyboard, so user doesn't have to click on search button all the time!

thanks a bunch.

code: http://pastebin.com/VbaVKJgj
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Alan Gauld
2015-06-16 18:36:20 UTC
Permalink
Post by Ali Moradi
i want to fill the listbox from my database which contains of one table
(Words) and two fields (English) and (Esperanto), how can i do that? i want
the program to be the same just the words loaded from my sqlite database.
Do you know SQL?
And if so do you know how to call SQL from Python?

If the answer to either is no then can I suggest you read
my database topic in my tutorial, then come back here and ask again if
it still doesn't make sense.
Post by Ali Moradi
and second thing: i want to search the word when user hits "Enter" on
keyboard, so user doesn't have to click on search button all the time!
You need the Tkinter bind() function. It connects events to functions.
Using my code it will look something like:

eSearch = tk.Entry(top)
eSearch.pack()
eSearch.bind('<Return>', lambda e: search())

If you don't understand the lambda bit you could do it
this way instead...

modify search to be:

def search(event=None):
target = eSearch.get()
if target in words:
tList.delete(0.0,tk.END)
tList.insert(0.0,target)

And change the bind above to be:

eSearch.bind('<Return>', search)

Or just go and research lambda :-)
--
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


_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Loading...