-2

This is how my window starts:

I want to ask if I can scroll down those buttons like calc, bmi, tictactoe so that I can add some more button below.

Thanks for help

Ayush Raj
  • 294
  • 3
  • 14
  • 2
    Does this answer your question? [Adding a scrollbar to a group of widgets ](https://stackoverflow.com/a/3092341/7414759) – stovfl May 08 '20 at 18:20

1 Answers1

-2

Add a canvas. Set canvas to be scrollable. Make buttons canvas children. Here is a rough example:

from tkinter import *

root=Tk()
frame=Frame(root,width=50,height=300)
frame.pack(expand=True, fill=BOTH)
canvas=Canvas(frame,bg='#FFFFFF',width=300,height=300,scrollregion=(0,0,50,500))

bar=Scrollbar(frame,orient=VERTICAL)
bar.pack(side=RIGHT,fill=Y)
bar.config(command=canvas.yview)

canvas.config(width=50,height=300)
canvas.config(yscrollcommand=bar.set)
canvas.pack(side=LEFT,expand=True,fill=BOTH)

frame = Frame(root)
for _ in range(10):
    Button(frame, text=str(_)).grid(row=_)

canvas.create_window(0, 0, anchor='nw', window=frame)

root.mainloop()

Hope that's helpful!

rizerphe
  • 1,340
  • 1
  • 14
  • 24