PythonGUI编程--向列表框添加滚动条


代码如下:

from tkinter import *
window = Tk()
window.title("New England")
yscroll = Scrollbar(window, orient=VERTICAL)
yscroll.grid(row=0,column=2,rowspan=4,padx=(0,100),pady=5,sticky=NS)
statesList = ["Connecticut","Maine","Masssachusetts","New Hampshired","Rhode ISsland", "Vermont"]
conOFlstNE = StringVar()
lstNE = Listbox(window,width=14,height=4,listvariable=conOFlstNE,yscrollcommand=yscroll.set)
lstNE.grid(row=0,column=1,rowspan=4,padx=(100,0),pady=5,sticky=E)
conOFlstNE.set(tuple(statesList))
yscroll["command"] = lstNE.yview
window.mainloop()

效果如下:

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM