Python Forum
[Tkinter] Displaying Data from a database and run a function when clicked? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [Tkinter] Displaying Data from a database and run a function when clicked? (/thread-24914.html)



Displaying Data from a database and run a function when clicked? - PythonNPC - Mar-10-2020

Hello,

I am writing a simple GUI in Tkinter.

I want to connect to my database and show the data onto my GUI. There might be more data so a scroll bar needs to appear.

And when one of the rows of my data is clicked, I want to run some action, let's say that I want to run a function on that particular row of data.


Is this doable in Tkinter?
If not, is it possible in any of the other GUI designs??


RE: Displaying Data from a database and run a function when clicked? - Larz60+ - Mar-11-2020

It can certainly be done in tkinter.
I would however recommend one of the following Kivy, QT5, or wxpython (pheonix)
My choice is wxpython. Here's an example that does most of what you want.
Hooking into a database (you disn't mention which one) is also easy and probably covered by the
wxpython demo.
Installation of wxpython is done using pip: pip install wxpython
the (most excellent) demo (and source code) program can be found here: https://github.com/wxWidgets/Phoenix
documentation here: https://docs.wxpython.org/wx.1moduleindex.html

and finally a gallery here: https://docs.wxpython.org/gallery.html