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()
3.57
7
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()
Thank you!
7
0
Are there any code examples left?
New code examples in category Python
-
Python 2023-04-11 03:04:20
-
Python 2022-03-27 22:40:04 pycharm no module named
-
Python 2022-03-27 22:25:05 assign multiple variablesin one line
-
Python 2022-03-27 22:20:02 levenshtein distance
-
Python 2022-03-27 21:35:09 get text from url python last slash
-
Python 2022-03-27 21:30:30 df concatenate df
-
Python 2022-03-27 21:25:09 python odd or even
-
Python 2022-03-27 21:15:32 python include function from another file
-
Python 2022-03-27 21:10:01 color module python
-
Python 2022-03-27 21:00:27 python tkinter cursor types