I have some problem making scrollbar on grid. Most codes use pack and I never really used canvas but I think I have to somehow include it. I am quite new to programming.Thank you for any help.
tkinter import *
class test():
def add_label(self, name, row, column):
return Label(self.master, text=name, width=11, height=1, borderwidth=1, relief="groove",
font=("Helvetica", 12), fg="black",
bg="white", ).grid(row=row, column=column, sticky='nesw')
def __init__(self, master):
# constructor
self.master = master
for x in range(6):
for y in range(21):
Grid.columnconfigure(master, x, weight=1)
Grid.rowconfigure(master, y, weight=1)
master.title("Emotion test")
master.geometry('1100x500')
master.iconbitmap(r'emotion test icon.ico')
master.minsize(1100, 500)
root = Tk()
obj = test(root)
root.mainloop()
Welp, here is a scroll bar example I found via quick google search:
from Tkinter import *
root = Tk()
scrollbar = Scrollbar(root)
scrollbar.pack( side = RIGHT, fill = Y )
mylist = Listbox(root, yscrollcommand = scrollbar.set )
for line in range(100):
mylist.insert(END, "This is line number " + str(line))
mylist.pack( side = LEFT, fill = BOTH )
scrollbar.config( command = mylist.yview )
mainloop()
I took it form here: https://www.tutorialspoint.com/python/tk_scrollbar.htm
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.