Discussion:
[Tutor] Clickable listbox in Tkinter python 2
Ali Moradi
2015-06-15 13:41:50 UTC
Permalink
let me put it this way:

the listbox should be on the same frame under the entry widget and the
whole list should be visible, when the user types the word in Entry widger
and clicks on search button, the listbox narrows down to that word only and
now just (for example: water akvo) are visible. do you know what i mean?
i'm not native english speaker so maybe i can't explain it :(

the code and my database is in the file uploaded (the database is sqlite3
[i made it in ubuntu linux with SQLiteBrowser program]):

http://qfs.mobi/f2361208

https://drive.google.com/file/d/0Bwe9iYyAhRzgT3hudnAxUkVzTTA/view?usp=sharing
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Alan Gauld
2015-06-15 15:57:05 UTC
Permalink
Post by Ali Moradi
the listbox should be on the same frame under the entry widget and the
whole list should be visible, when the user types the word in Entry widger
and clicks on search button, the listbox narrows down to that word only and
now just (for example: water akvo) are visible. do you know what i mean?
i'm not native english speaker so maybe i can't explain it :(
OK I think I've got it. You might want to make the list scrollable since
there will probably be more entries than can fit in a single widget at
one time.

As to making the list shrink down to a single entry, that will be
your job, it is not a standard feature. Essentially you will need to
select all the pairs initially from SQLite and then select only the
matching pair after a search. If you don't know how to do database
searches from Python ask about that in a separate thread.

As to the layout something like(for Python 3):

import tkinter as tk

words = ['a','list','of','strings']

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

top = tk.Tk()

eSearch = tk.Entry(top)
eSearch.pack()
tList = tk.Text()
tList.insert(0.0, '\n'.join(words))
tList.pack()
bSearch = tk.Button(top, text='Search', command=search)
bSearch.pack()

top.mainloop()


is as simple as it gets. You can modify the sizes by using the
width/height widget options of course. You can be much more
sophisticated but that should get you started.
Post by Ali Moradi
http://qfs.mobi/f2361208
https://drive.google.com/file/d/0Bwe9iYyAhRzgT3hudnAxUkVzTTA/view?usp=sharing
Neither of those show me code, they seem to want me to download
something. Since I never download from untrusted sources I can't
see the code. Try pasting it somewhere like

http://www.pastebin.com
--
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...