Answers for "tkinter make window scrollable"

14

tkinter make window scrollable

from tkinter import *
class ScrollBar:
    def __init__(self):
        root = Tk()
        h = Scrollbar(root, orient = 'horizontal')
        h.pack(side = BOTTOM, fill = X)
        v = Scrollbar(root)
        v.pack(side = RIGHT, fill = Y)
        t = Text(root, width = 15, height = 15, wrap = NONE,
                 xscrollcommand = h.set,
                 yscrollcommand = v.set)
        for i in range(20):
            t.insert(END,"this is some text\n")
        t.pack(side=TOP, fill=X)
        h.config(command=t.xview)
        v.config(command=t.yview)
        root.mainloop()
s = ScrollBar()
Posted by: Guest on March-26-2021
2

scrollbar in tkinter

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()
Posted by: Guest on May-29-2020

Code answers related to "tkinter make window scrollable"

Python Answers by Framework

Browse Popular Code Answers by Language