user1749431
user1749431

Reputation: 569

Tkinter; how to use scrollbar in a popup/top-level window that opens when a button is pressed in main root window

I'm trying to create an app with a scrollbar in a top level window that opens when a button,bttn, is pressed in the main root window and from the code below I'd need help with the following:

Upvotes: 2

Views: 2778

Answers (1)

M_the_C
M_the_C

Reputation: 415

You're passing root as the parent to VerticalScrolledFrame, you need to pass self.top instead:

class SampleApp(Frame):

     # ...Other code...

     def open_new_window_with_text_and_scrollbar(self):
        self.top = tk.Toplevel(self)
        frame = VerticalScrolledFrame(self.top)
        frame.pack()
        # Other widgets

That's why it's adding itself to the main root window instead of the Toplevel.

Upvotes: 4

Related Questions