0

I'm trying to do a scrollbar on the right side of the canvas ( the window ), but the scrollbar won't even show when plotting. What am I doing wrong?

from tkinter import *

# create canvas
root = Tk()
root.title("Aktieköp")
root.configure(background="white")
frame=Frame(root, width=1100, height=1000)
frame.grid(row=0, column=0)
canvas=Canvas(frame,bg="white",width=1100,height=1000)

# my photo
photo = PhotoImage(file="aktier.gif")
label0 = Label(frame, image = photo, bg="white"). grid(row=0, column=0)

# create scrollbar

scrollbar=Scrollbar(frame,orient=VERTICAL)
scrollbar.pack(side=RIGHT,fill=Y)
scrollbar.config(command=canvas.yview)
frame.config(width=1100,height=1000)
frame.config(yscrollcommand=scrollbar.set)
frame.pack(side=RIGHT,expand=True,fill=Y)

root.mainloop()
Ivan Sheihets
  • 802
  • 8
  • 17
Emelie
  • 1
  • 1
  • 2

1 Answers1

0

You use the layout managers wrong:

  1. Do not use grid() and pack() to layout children of a widget:
    1. frame.grid() and frame.pack() ==> root now uses two layout managers and frame needs to be mapped by two managers
    2. label0.grid() and scrollbar.pack() ==> frame uses two layout managers
  2. canvas is not mapped by grid or pack at all, so how you can see and draw on it I don't know.
rioV8
  • 24,506
  • 3
  • 32
  • 49