Discussion:
[Tutor] How to show the listbox from sqlite and make it searchable?
Ali Moradi
2015-08-03 12:22:09 UTC
Permalink
hi, this is my code (
http://paste.pound-python.org/show/3DZoev97e1UkWFcATKYF/)

how can i show the two fields name "esperanto" and "english" in a listbox
positioned under the entry widget? i want the two fields to be beside
eachother like (abak/o abacus)

and i want to make them searchable via the entry widget like a dictionary
app :)

thanks, i'm beginner so please modify my code.

and is there any good tutorial on using SQLite with tkinter and how to
desplay records on GUIs ?
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Mark Lawrence
2015-08-03 20:38:24 UTC
Permalink
Post by Ali Moradi
hi, this is my code (
http://paste.pound-python.org/show/3DZoev97e1UkWFcATKYF/)
Please post your code inline so we can see it and it is retained for
posterity.
Post by Ali Moradi
how can i show the two fields name "esperanto" and "english" in a listbox
positioned under the entry widget? i want the two fields to be beside
eachother like (abak/o abacus)
and i want to make them searchable via the entry widget like a dictionary
app :)
thanks, i'm beginner so please modify my code.
and is there any good tutorial on using SQLite with tkinter and how to
desplay records on GUIs ?
Combine these two.

http://zetcode.com/gui/tkinter/
http://zetcode.com/db/sqlitepythontutorial/
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Alan Gauld
2015-08-03 20:47:21 UTC
Permalink
Post by Ali Moradi
how can i show the two fields name "esperanto" and "english" in a listbox
positioned under the entry widget? i want the two fields to be beside
eachother like (abak/o abacus)
You need to do two things:
1) set the font of the listbox to be monospaced so that
everything lines up
2) format a string with fixed length fields

Then you just insert the strings into the list box as usual.

There are no grid type components in standard Tkinter.
There is one in Tix but it's fiendishly hard to work with
and I don't recommend it. What is worth doing is using
the Tix ScrolledListbox or ScrolledText widgets to hold
the text because you get scroolling almost for nothing.
Post by Ali Moradi
and i want to make them searchable via the entry widget like a dictionary
app :)
Then you will need to write the search code yourself.
extract the lines from the list box or text widget and
check if your search matches. Keep track of the current
line and when found highlight the line or field within
the line as required. Its non trivial but not especially
hard.
Post by Ali Moradi
and is there any good tutorial on using SQLite with tkinter and how to
desplay records on GUIs ?
No. There is no magic, Tkinter has no knowledge of SQLite (or
any other database) and vice versa so there is nothing special
to do. You just create strings using the SQL data and insert
them into the GUI.

Tkinter is a very basic, bare bones GUYI tool. That makes
it easy to learn but you have to do a lot of the backend
logic yourself. Other toolkits provide more smarts but
it takes longer to learn them.
--
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
Alan Gauld
2015-08-03 21:11:06 UTC
Permalink
Post by Ali Moradi
hi, this is my code (
http://paste.pound-python.org/show/3DZoev97e1UkWFcATKYF/)
OK I had a look at the code this time. Several points:

You never set your listbox in the GUI - there is no call to grid().

Your button has no command attached to it so it does nothing
when pressed.

Your SQL function has a self parameter but is not a
method of an object. You try to insert self into the
list widget. What do you think self will contain?
In fact it never gets called so its irrelevant, but
if it did get called what would it contain?

It looks like you are just cutting and pasting code from
somewhere without really thinking about what it does or
how it all fits together? You need to slow down and
build it piece by piece. (I seem to recall having a
similar discussion with you a couple of months ago?
Yes, back in June.) For now, just get the GUI built
with some dummy text. Then get the searching to work
using your fixed text. Finally swap the text for the
result of a SQL query.

Don't rush at it and it will go faster.
--
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...