不使用滚动条展开列表框

时间:2013-08-21 22:03:41

标签: python listbox scrollbar

我正在尝试使用滚动条创建列表框,但我发现了两个不便之处:

  1. 即使listox为空,也会显示滚动条。
  2. 列表框展开,我不想占用屏幕的总宽度,只有宽度= 50
  3. 我的代码:

    text=tkinter.Listbox(root,height=10,width=50)
    text.bindtags((text, root, "all"))
    for i in range(20):
        text.insert(i,i)
    
    scrl = Scrollbar(text, command=text.yview)
    text.config(yscrollcommand=scrl.set)
    scrl.pack(anchor='center', side = RIGHT, expand=FALSE, fill=BOTH, ipadx=0, ipady=0)
    text.pack(anchor='nw',side=TOP, expand=FALSE,padx=10,pady=10,fill=BOTH,ipadx=0,ipady=20)
    print (int(text.winfo_width()))
    

    如果我将填充更改为Y,结果是错误的:http://s6.postimg.org/x0e445ym9/Sin_t_tulo.png

    提前致谢。

0 个答案:

没有答案
相关问题