Adding a Full Screen ScrollBar - Python Tkinter GUI Tutorial #96

John Elder · 140K views · 2020 · 15:08

Open on YouTube

Python, Ruby & scripting languagesSoftware (other)tutorial

Why Stack Overflow recommends it

Stack Overflow users link it as the standard recipe for a full-window scrollbar in Tkinter, then build on or debug that canvas-and-frame pattern in their own questions.

Recommended by 2 people across 2 different months, 2020 to 2023.

What it is

A Python Tkinter tutorial by John Elder showing how to add a scrollbar that scrolls an entire app window. It works around Tkinter's lack of a scrollable frame by placing a frame inside a canvas and attaching a scrollbar to the canvas.

What people said

Recommends alex deralu · 2021-09 · Stack Overflow · on “How to display Option menu inside a frame in Tkinter?”

I am trying to display a bunch of OptionMenu in tkinter. The problem is that once there are too many OptionMenu they go out of screen and they cannot be accessed anymore. [LINK] So I thought of implementing a full-screen scrollbar to solve this. I followed this tutorial - link [this video] , in this, the full-screen scrollbar is implemented by putting buttons inside a frame The code from the tutorial - Working code with buttons [LINK] So I tried to use this code but instead of buttons, use OptionMenu . This is my code from tkinter import * import tkinter as tk from tkinter import ttk class App(tk.Frame): def __init__(self, master): tk.Frame.__init__(self, master) master.title('ATOM') master.geome

Recommends leavul · 2023-08 · Stack Overflow · on “tkinter: binding mousewheel to scrollbar”

self.canvas = Canvas(...) self.canvas.bind_all("<MouseWheel>", lambda event: self._on_mousewheel(where_to_scroll= (-1 * event.delta))) ... def _on_mousewheel(self, where_to_scroll): self.canvas.yview("scroll", where_to_scroll, "units") bind_all means = <"the thing that you want to target when happening">, then do something() 1- we want to target mouse wheel = <"MouseWheel"> 2 - we want to scroll to where the mouse wheel goes when you use the mouse wheel = lambda event: self._on_mousewheel(where_to_scroll=(-1 * event.delta)) when we use bind_all or bind methods they gives us a variable. Because that, we use lambda to take it and use it inside the function that variable has attributes one of t

Cites Rudraansh Patel · 2020-10 · Stack Overflow · on “Adding a scrollbar to multiple frames in tkinter in python 3.7x”

I am making a quiz software for myself and while making it when I crossed 400 lines of code I stumbled across a problem that is I have a screen in which I have to select the topics from various subjects and the number of topics I have is quite large they are like 30 in each subject. So it is not possible to accommodate them all into a single screen, so I decided to add scrollbars to each frame so that I could do so, I took reference from here [this video] , and there John Elder Sir told that this could be done in the following steps: Make a mainframe Add canvas to the frame( As canvas is the only tkinter widget which can be scrolled ) Add scrollbar to the canvas Add content frame to the canvas Co

Cites Aurorer D. Wysteria · 2020-12 · Stack Overflow · on “tkinter - Widgets are not showing with Scrollbar”

I tried to add a scrollbar for my app using this video as an example: [this video] When I tried it, with my widgets using place instead of pack, my widgets do not show up in the window. Anyone knows what is going on? Below is the snippet from my code: from tkinter import * from tkinter import ttk originY = 0 window = Tk() window.title("Applications Management System") window.geometry("100x100") main_frame = Frame(window) main_frame.pack(fill=BOTH, expand=1) canvas = Canvas(main_frame) canvas.pack(side=LEFT, fill=BOTH, expand=1) scrollBar = ttk.Scrollbar(main_frame, orient=VERTICAL, command=canvas.yview) scrollBar.pack(side=RIGHT, fill=Y) canvas.configure(yscrollcommand=scrollBar.set) canvas.bind(

Cites DEVEN JAIN · 2021-05 · Stack Overflow · on “Python Tkinter Scrollbar panning upwards instead of downwards also alignment issue while using Scrollbar”

I am using TKinter to build a GUI for my python application. I want to add a scrollbar to the main screen because I have a lot of data to display but very less space. Currently I use the lines: root=Tk() root.state("zoomed") #...rest of the code... (Relevant parts mentioned below:) root.mainloop() to take maximum advantage of available screen space but even that is not cutting it for me. Here is John Elder(CEO of Codemy.com)'s code [this video] that I use to add a scrollbar: # Create A Main Frame main_frame = Frame(root) main_frame.pack(fill=BOTH, expand=1) # Create A Canvas my_canvas = Canvas(main_frame) my_canvas.pack(side=LEFT, fill=BOTH, expand=1) # Add A Scrollbar To The Canvas my_scrollbar

Cites Silh0uett3 · 2022-03 · Stack Overflow · on “Tkinter background not fully shown”

I am coding a program for my dad to use in his office. The window will contain a lot of things. This is why I need a scrollbar. I did it like this video on YT shows: [this video] So far, this is my code: coax = Tk() coax.title("CYAN - COAX") coax.iconbitmap("Resources/Icon.ico") coax.geometry("1100x800") coax.resizable(False, False) coax_main_frame = Frame(coax) coax_main_frame.pack(fill=BOTH, expand=1) coax_canvas = Canvas(coax_main_frame) coax_canvas.pack(side=LEFT, fill=BOTH, expand=1) coax_canvas["bg"] = "white" coax_scrollbar = ttk.Scrollbar(coax_main_frame, orient=VERTICAL, command=coax_canvas.yview) coax_scrollbar.pack(side=RIGHT, fill=Y) coax_canvas.configure(yscrollcommand=coax_scrollbar

Cites QuagTeX · 2022-07 · Stack Overflow · on “Scrollbar in tkinter doesn't appear (using .place)”

I am trying to add a scrollbar to my GUI and found a pretty nice tutorial on [this video] . Even when he uses pack in the code, there is a comment which translates the code to make it able to use it with place . I made a few adaptions but it didn't work, only the (non-functional) arrows and the background of the scrollbar appear as you can see here [LINK] . I've tried some other solutions in SO like Scrollbar in Canvas doesn't work - Tkinter Python [LINK] Tkinter scrollbar not appearing [LINK] So here is what I tried so far: import tkinter as tk from tkinter import ttk window1.destroy() # previous window where user enters meta data input_window= tk.Tk() input_window.geometry(str(width) + 'x' + st

Cites Hung · 2022-10 · Stack Overflow · on “Tkinter scrollbar not moving”

After some searches from the internet, I found what you need. Note: Everything below is not mine, all the source I will put below. So, this is what you need: # Create A Main frame main_frame = Frame(root) main_frame.pack(fill=BOTH, expand=1) # Create Frame for X Scrollbar sec = Frame(main_frame) sec.pack(fill=X, side=BOTTOM) # Create A Canvas my_canvas = Canvas(main_frame) my_canvas.pack(side=LEFT, fill=BOTH, expand=1) # Add A Scrollbars to Canvas scrollbar = ttk.Scrollbar(main_frame, orient=VERTICAL, command=my_canvas.yview) scrollbar.pack(side=RIGHT, fill=Y) # Configure the canvas my_canvas.configure(yscrollcommand=scrollbar.set) my_canvas.bind("<Configure>", lambda e: my_canvas.config(scr