#scrolly是垂直滚动条,scrolly2是水平滚动条
scrolly=Scrollbar(win,width=25,orient=VERTICAL)
scrolly.grid(row=0,column=1,padx=(0,0),pady=(250,0),sticky=NS) #grid是一种布局设置
#padx决定在该组件在本单元格中左右边距,
#例如padx=20,则表示左右边距都是20;padx=(20,10)则表示左边距是20,右边距是10。pady表示上下边距.
#rowspan表示合并行,colums表示合并列。sticky表示对齐方式。
scrolly2=Scrollbar(win,width=25,orient=HORIZONTAL)
scrolly2.grid(row=1,column=0,padx=(30,0),pady=0,sticky=EW)
statesList = [“Connecticut”,“Maine”,“Masssachusetts”,“New Hampshired”,“Rhode ISsland”, “Vermont”,“Masssachusetts”,“New Hampshired”,“Rhode ISsland”, “Vermont”,“Masssachusetts”,“New Hampshired”,“Rhode ISsland”, “Vermont”,“Masssachusetts”,“New Hampshired”,“Rhode ISsland”, “Vermont”]
conOFlstNE = StringVar()
List1=Listbox(win,width=105,height=16,listvariable=conOFlstNE)
List1.grid(row=0,column=0,padx=(30,0),pady=(250,0),sticky=E)
List1[‘yscrollcommand’]=scrolly.set #注意垂直滚动条用yscrollcommand
List1[‘xscrollcommand’]=scrolly2.set #注意垂直滚动条用xscrollcommand
conOFlstNE.set(tuple(statesList))
scrolly[“command”] = List1.yview #注意垂直滚动条用yview
scrolly2[“command”] = List1.xview #注意垂直滚动条用yview