我正在尝试在tkinter的滚动文本小部件中显示SQL查询的结果。我能够做到这一点,但是我设想输出看起来会更加干净。
import mysql.connector
import tkinter as tk
from tkinter import scrolledtext
root=tk.Tk()
mydb = mysql.connector.connect(
host="localhost",
user="root",
passwd="Cranmore1",
database="scoutsdatabase"
)
print(mydb)
mycursor = mydb.cursor()
Quote=("")
mycursor.execute("SELECT * FROM events")
myresults = mycursor.fetchall()
Quote = myresults
EventText = scrolledtext.ScrolledText(root, height=10, width=50)
EventText.insert("end", Quote)
EventText.grid(row=1, column=1,columnspan=5)
我设想更多类似的事情:
还可以显示列标题吗?