mardi 27 juillet 2021

I'm having a problem comparing Combobox.get with mysal data in python

.I am comparing the data returned from the ComboBox with the data stored in my data table and it does not work. I tried everything I know. Please help me to solve the problem. My project depends on it.

import mysql.connector
from tkinter import *
from tkinter import ttk
from tkinter import messagebox

mydb = mysql.connector.connect(
host="localhost",
user="root",
passwd="root",
database="storedb"
)
root = Tk()
root.geometry('500x500')

com9_sql = "SELECT name FROM kitchen"
mycursar.execute(com9_sql)
di9 = mycursar.fetchall()

n3f3 = StringVar()
combox9 = ttk.Combobox(root, state="readonly", width=35, textvariable=n3f3)
combox9['values'] = di9
combox9.pack()

c = combox9.get()
def correct():
    d = di9
    if c in d[1]:    #the problem here
        print("its work")
    else:
        print("error")

bt_1 = Button(root, text="Saving data", pady=15, padx=20, font=("tajawal", 14, "bold"), command=correct)
bt_1.pack()
root.mainloop()

Aucun commentaire:

Enregistrer un commentaire