Python 如何减少树视图';s列';宽度是多少?
我想减小柱子的宽度,这样就更合适了。正如您在这里看到的()表是不规则的,有些列是不可见的。我怎样才能解决这个问题 这是我的密码:Python 如何减少树视图';s列';宽度是多少?,python,sqlite,tkinter,treeview,ttkwidgets,Python,Sqlite,Tkinter,Treeview,Ttkwidgets,我想减小柱子的宽度,这样就更合适了。正如您在这里看到的()表是不规则的,有些列是不可见的。我怎样才能解决这个问题 这是我的密码: def show(): # connect to database if exist or if doesnt exit create one conn= sqlite3.connect("Books_table.bd") #create cursors Cursor = conn.cursor()
def show():
# connect to database if exist or if doesnt exit create one
conn= sqlite3.connect("Books_table.bd")
#create cursors
Cursor = conn.cursor()
Cursor.execute("SELECT * , oid FROM books")
records = Cursor.fetchall()
Query_window = Toplevel()
Query_window.title("Show Table ...")
Frm = Frame(Query_window)
Frm.pack()
Table = ttk.Treeview(Frm , column = (1,2,3,4,5,6,7,8) , show = "headings" , height = 5 )
Table.pack()
Table.heading(1 , text = "Book name")
Table.heading(2 , text = "Book number")
Table.heading(3 , text = "Book writer")
Table.heading(4 , text = "Book subject")
Table.heading(5 , text = "Quantity")
Table.heading(6 , text = "Borrower")
Table.heading(7 , text = "Return date")
Table.heading(8 , text = "Availability")
# insert values to the table
for record in records:
Table.insert("", "end" , value = record )
#Commit changes
conn.commit()
#close database
conn.close()
可以使用column()方法设置Treeview列的宽度
...
Table.heading(1, text="Book name")
Table.column(1, width=50)
...