Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Trouble with scrollbar tkinter python

How i can fix this trouble? In this scrollbar works only arrows.Scrollbar I have 500 + strings in my listbox. I used insert to add elements to listbox

I think i have problems with config but i don’t know how to fix it

connect listbox and slider

def show_popup():
    # popup settings
    popup = tk.Toplevel(window)
    popup.title("Add/Remove")
    popup.geometry("400x500")

    # listbox of keys and values
    list_frame = ttk.Frame(popup, height=15)
    list_frame.pack(side="top")

    # add slider
    scrollbar = tk.Scrollbar(list_frame, orient="vertical")
    scrollbar.grid(row=0, column=3)

    # listbox
    global listbox
    listbox = tk.Listbox(list_frame, width=60, height=15)
    listbox.grid(row=0, column=0, columnspan=3)

    # connect listbox and slider
    scrollbar.config(command=listbox.yview)
    listbox.config(yscrollcommand=scrollbar.set)

    # display pairs
    display_json_data(original_data)

    # add function
    add_frame = ttk.Frame(popup)
    add_frame.pack(side="top")
    add_title = ttk.Label(popup, text="Add function")
    add_title.pack(padx=20, pady=20)

    # Close toplevel window
    close_button = ttk.Button(
        popup, text="Close window", command=popup.destroy)
    close_button.pack(side="bottom")

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Configure your scrollbar so it takes up all the height of its row:

...
# add slider
    scrollbar = tk.Scrollbar(list_frame, orient="vertical")
    scrollbar.grid(row=0, column=3, sticky="ns")
...
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading