我在python代码中使用Tkinter,而不是显示站点中可用房间列表的代码,它显示一个使用Entry
的列表,导致打印的列表被更改,而不是保持不变。是否有一种方法可以编辑代码,以便它可以打印出一个按钮列表,我可以选择打开该房间的问题
sitename3_info = sitename.get()
# the label should print all of the rooms in the site that was inputted in the audit function
cursor = cnn.cursor()
# retrieves the siteID from the inputted site name
siteID_fetch2 = "SELECT siteID FROM Sites WHERE siteName = %s"
cursor.execute(siteID_fetch2, [sitename3_info])
siteID_fetch2 = cursor.fetchall()
print(siteID_fetch2[0][0])
# searches for all the rooms for the site that was inputted
room = "SELECT roomname FROM rooms WHERE siteID_fk2 = %s"
cursor.execute(room,[siteID_fetch2[0][0]])
printrooms = cursor.fetchall()
print(printrooms[0][0])
# prints out a list of rooms in the site
i=0
for rooms in printrooms:
for j in range(len(rooms)):
e = Entry(screen13, width=10, fg='blue')
e.grid(row=i, column=j)
e.insert(END, rooms[j])
i=i+1
这是我用来选择图像并使用radiobutton功能从表中删除该行的代码的一部分,您可以用所选按钮的任何操作替换delete函数
您可以创建按钮而不是
Entry
小部件:更新:不使用上下文管理器的示例:
相关问题 更多 >
编程相关推荐