Python Forum
[Tkinter] Scrollbar doesn't work on Canvas in Tkinter
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Scrollbar doesn't work on Canvas in Tkinter
#1
Hello.
I'm trying to write a program that show a tkinter window with a list of names(labels) and a checkbox for every name in this list.

I want to be able to scroll through this list
but for some reason the scrollbar doesn't work on the canvas widget(gray, not clickable scrollbar),even if the there are more labels at the bottom of the window(the window cut all the remained names and doesn't let me scroll down.).

this is my code:
from tkinter import *

master = Tk()
master.title("Names")
master.geometry('300x200+750+480')

programs = ['yyy', 'yyy', 'yyy', 'yyy', 'yyy', 'yyy', 'yyy', 'yyy', 'yyy', 'yyy', 'yyy', 'yyy', 'yyy', 'yyy', 'yyy', 'yyy']
programs_path = []

frame = Frame(master)
frame.pack(side=LEFT)
canvas = Canvas(frame)
canvas.pack(side=LEFT, fill=Y)
scroll = Scrollbar(frame, orient=VERTICAL)
scroll.pack(side=RIGHT, fill=Y)

for i in range(len(programs)):
    program_label = Label(canvas, text=str(programs[i]))
    program_label.grid(row=i, column=0)
    check_box = Checkbutton(canvas)
    check_box.grid(row=i, column=1)

scroll.config(command=canvas.yview)
canvas.config(yscrollcommand=scroll.set)

master.mainloop()
I'm using Python3 with the tkinter module.
what I'm doing wrong here? Wall

thanks
Reply


Messages In This Thread
Scrollbar doesn't work on Canvas in Tkinter - by DeanAseraf1 - Sep-18-2019, 09:16 AM
RE: Scrollbar doesn't work on Canvas - by Denni - Sep-18-2019, 01:53 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] graphyview setdata() doesn't work after recieving a mount of data ugly_curry_garlic 3 773 Nov-22-2023, 05:58 PM
Last Post: Axel_Erfurt
  [Tkinter] Help create scrollbar in chatbot with tkinter on python fenec10 4 1,599 Aug-07-2023, 02:59 PM
Last Post: deanhystad
  tkinter.TclError: can't invoke "canvas" command cybertooth 8 6,121 Feb-23-2023, 06:58 PM
Last Post: deanhystad
  [Tkinter] Scrollbar apffal 7 3,188 Oct-11-2021, 08:26 PM
Last Post: deanhystad
  [Tkinter] Clickable Rectangles Tkinter Canvas MrTim 4 8,988 May-11-2021, 10:01 PM
Last Post: MrTim
  [Tkinter] Draw a grid of Tkinter Canvas Rectangles MrTim 5 8,046 May-09-2021, 01:48 PM
Last Post: joe_momma
Thumbs Up tkinter canvas; different page sizes on different platforms? philipbergwerf 4 4,211 Mar-27-2021, 05:04 AM
Last Post: deanhystad
  how to resize image in canvas tkinter samuelmv30 2 17,905 Feb-06-2021, 03:35 PM
Last Post: joe_momma
Question [Tkinter] How to configure scrollbar dimension? water 6 3,531 Jan-03-2021, 06:16 PM
Last Post: deanhystad
  how to rotate lines in tkinter canvas helpmewithpython 1 3,460 Oct-06-2020, 06:56 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020