我有一个Python程序,最终用户将他们的用户名和密码插入程序,然后程序将其插入MySQL数据库。然后,程序可以从MySQL数据库中提取用户名,并在下拉列表Combobox
中显示数据。但是有一个用户名我希望对最终用户隐藏起来。这是我的代码:
try:
connect()
selectUsers = "select id, name from user"
cursor.execute (selectUsers)
bigfont = tkFont.Font(family = "Eurostile", size = 18)
txtUsers = tk.StringVar()
txtUsers.set("")
drpUsers = ttk.Combobox(self, textvariable=txtUsers, state='readonly', font=("Eurostile", 18))#, bg = 'red', fg = 'white')
root.option_add("*TCombobox*Listbox.font", bigfont)
for (id, name) in cursor:
valueStatement.append(id)
drpUsers['values'] = valueStatement
drpUsers.grid(column = 4, row = 4)#, padx = 5)
closeConnect()
except:
tkMessageBox.showinfo("Database Error", "ERR004 - There was an error communicating with the database")