0

I want the second window which appears after clicking next to be scrollable. It is not working. I tried the same way for the first window but for the second window, it doesn't seem to be working.

import tkinter as tk

def option_window():
    def toplevel():
        top = tk.Toplevel()
        top.wm_geometry("794x370")
        top.title('Optimized Map')

        optimized_canvas = tk.Canvas(top)
        optimized_canvas.pack(fill='both', expand=True)
        optimized_canvas_scroll = tk.Scrollbar(optimized_canvas, command=optimized_canvas.yview)
        optimized_canvas_scroll.place(relx=1, rely=0, relheight=1, anchor=tk.NE)
        optimized_canvas.configure(yscrollcommand=optimized_canvas_scroll.set, scrollregion=())
        optimized_canvas.bind_all('<MouseWheel>', lambda event: optimized_canvas.yview_scroll(int(-1*(event.delta/120)), "units"))

        l0 = tk.Label(optimized_canvas, text="Sheet")
        l0.pack()

        l1 = tk.Label(optimized_canvas, text="Sheet")
        l1.pack()

    toplevel()

window = tk.Tk()
canvas = tk.Canvas(window, bg="white", width=1100, height=580, highlightthickness=0)
canvas.pack()
submit_button = tk.Button(canvas, text="Next >>>",font= "calibri 13", command = option_window)
canvas.create_window(50, 50, window=submit_button, anchor=tk.NW)




window.mainloop()
devinxxxd
  • 63
  • 2
  • 10
  • Possible duplicate of [Tkinter scrollbar for frame](https://stackoverflow.com/questions/16188420/tkinter-scrollbar-for-frame) – Ethan Field Aug 23 '19 at 12:54
  • What does "not working" mean? Does the program crash? Does the scrollbar not appear? Does it appear, but it scrolls the wrong window? Does it scroll in the wrong direction? ...? – Bryan Oakley Aug 23 '19 at 14:47
  • @BryanOakley The second window doesn't scroll. – devinxxxd Aug 28 '19 at 05:49
  • There's not enough information in the second window to scroll. Plus, you're explicitly setting the `scrollregion` to an empty value. – Bryan Oakley Aug 28 '19 at 15:10

0 Answers0