首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何减小树状视图的列宽?

如何减小树状视图的列宽?
EN

Stack Overflow用户
提问于 2020-08-23 05:33:32
回答 1查看 97关注 0票数 0

我想减少列的宽度,使之适合。正如您在这里(https://i.stack.imgur.com/VK6w8.png)所看到的,该表是不规则的,并且某些列不可见。我该如何解决这个问题?

下面是我的代码:

代码语言:javascript
运行
复制
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()
EN

Stack Overflow用户

回答已采纳

发布于 2020-08-23 05:56:21

可以使用column()方法设置Treeview列的宽度。

代码语言:javascript
运行
复制
...
Table.heading(1, text="Book name")
Table.column(1, width=50)
...
票数 1
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63541318

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档