R
R
Romain_bucha2021-12-08 10:51:56
Python
Romain_bucha, 2021-12-08 10:51:56

How to use scrollbar in Tkinter Python 3 to list list from db?

I'm trying to install a scrollbar based on Tkinter Python 3 in the GUI of my program (homemade database), so far I can not win. A scrollbar frame is displayed without a slider, but even the frame is displayed not to the height of the displayed window, but to the entire height of the displayed list, part of which is hidden due to the window resolution. I am attaching a screenshot of the

F54by.jpg

Graph. the interface should display a list from the database, you can mark the lines with checkboxes, by clicking on the pelpk, correct or confirm the lines change the status, the idea is very simple.

After reading the forums, I came to the conclusion that you need to use frame_main for the entire window, the frame_canvas grid and buttons will be installed in it, and canvas will be installed in the frame_canvas pack to display a list from the database and scrollbar.
(I attach my diagram of my logic)

bpyea.jpg

But as a result, only a frame without a slider is displayed, and the height of the frame is displayed for the entire height of the list, and is not limited by the height of the interface window.

DivP5.jpg

Tell me what I'm wrong about and help defeat the scrollbar

Function code:

def admintable();
    import pickle
    global flsp1, root4, kolivanov, kolpetrov;

     #открытие файлов бд

    root4=Tk()
    root4.geometry(‘1100x900-0-0’)
    root4.title(“Администратор”)

    frame_main=Frame(root4)
    frame_main.grid(row=0, column=0)

    frame_canvas=Frame(frame_main)
    frame_canvas.grid(row=0, column=0)

    canvas=Canvas(frame_canvas)
    canvas.pack(side=RIGHT)

    scroll_canv=Scrollbar(frame_canvas, orient=VERTICAL)
    scroll_canv.pack(side=LEFT, fill=“y”)
    scroll_canv.config(command=canvas.yview)
   
     #вывод списка из бд в canvas

    but_0=Button(frame_main, text=‘Подтвердить’, command=ispoladm)
    but_1=Button(frame_main, text=‘Исправить’, command=ispolndm_ipsr)
    but_0.grid(row=0, column=1, sticky=‘nw’)
    but_1.grid(row=0, column=1)

    fraim_main.config(width=1100, height=900)
    fraim_canvas.config(width=1000, height=600)
    canvas.config(width=1100, height=500, yscrollcommand=scroll_canv.set)

    root4.mainloop()

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question