我在比较combobox.get与python中的mysal数据时遇到问题

g6baxovj  于 2021-09-29  发布在  Java
关注(0)|答案(0)|浏览(188)

。我正在将从组合框返回的数据与存储在数据表中的数据进行比较,但它不起作用。我知道的都试过了。请帮我解决这个问题。我的项目取决于它。

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()

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题