i need little help..below is my codes:
root = Tk()
w, h = root.winfo_screenwidth(), root.winfo_screenheight()
root.geometry("%dx%d 0 0" % (w, h))
f_right = Frame(root,width = 400,height=h)
f_right.pack(side=RIGHT)
my_scrollbar = Scrollbar(f_right,width=30,orient=VERTICAL)
mylist = Listbox(f_right,width=25,height = h, yscrollcommand = my_scrollbar.set,font=('ariel',12),justify='center')
mylist.grid(row=3,column=0,columnspan=2) # row0,row1,row2,column0,column1 has some button and label design
my_scrollbar.config(command = mylist.yview)
my_scrollbar.grid(row=3,column=2,sticky=NS)
for i in range(1000):
mylist.insert(END,"a" str(i))
root.mainloop()
i try this code with integer items and scroll bar works, but when i try add the item with string, my scroll bar could not work.. please help
CodePudding user response:
Since the listbox occupies column 0 and 1 due to columnspan=2, and the scrollbar is put in column 1 which is covered by the listbox.
Move the scrollbar to column 2 and also set the sticky option to NS:
my_scrollbar.grid(row=3,column=2,sticky=NS)
