Tkinter Combobox options taken from MySQL, SQLite database table, CSV file and Json string

plus2net
plus2net
5.5 هزار بار بازدید - 3 سال پیش - 00:48
00:48  Json string as source
04:05 CSV file as source
07:47 MySQL database table as source
14:17 SQLite database table as source

Tkinter Combobox to select Option or ...   Part I Details Tkinter Combobbox
Tkinter two interlinked Comboboxes wh... Part III Two interlinked dropdown list

We can source options of a Tkinter Combobox from Database tables , CSV  or from JSon String.
We will connect to MySQL database and create the connection object, this connection object is the only difference between MySQL and SQLite script and rest of the code is common.
In our student table we will collect unique student classes and use them as options of student table.
query="SELECT distinct(class) as class FROM student"

We will get sqlalchemy result set with data by using the above query. We will convert this result set to a list as we are planning to use as options of OptionMenu.
my_data=engine.execute(query)

Using this result set of SQLalchem we will create one list
my_list = [r for r, in my_data]
We will use the my_list as values option for the combobox.
For Using SQLite Database In above code only the connection part will be changed.
We can use JSON string and use the name part to populate the options
Similarly one CSV file data can be used to create options for the Combobox

Sample Json Data
https://www.plus2net.com/php_tutorial...  
Sample SQL code to create student table
https://www.plus2net.com/sql_tutorial...
Sample CSV file with student data
https://www.plus2net.com/python/downl...

Create SQLite database or download the database file from here
https://www.plus2net.com/python/sqlit...  

#OptionsfromMySQL #optionsfromSQLITE #optionsCSV #optionsJSON #tkinter #combobox #python #plus2net #GUI #tkinter
3 سال پیش در تاریخ 1400/05/30 منتشر شده است.
5,575 بـار بازدید شده
... بیشتر