pygubu icon indicating copy to clipboard operation
pygubu copied to clipboard

It seems `ScrolledFrame` doesn't work for `place layout`.

Open larryw3i opened this issue 1 year ago • 3 comments

Hello, @alejandroautalan , it seems ScrolledFrame doesn't work for place layout.
my code:

import tkinter as tk
from pygubu.widgets.scrolledframe import ScrolledFrame

root = tk.Tk()

scrolledframe =  ScrolledFrame(
    root,
    scrolltype="horizontal"
)

prev_x = 0
for i in range(100):
    label= Label(
        scrolledframe.innerframe,
        text="ABCD ")
    label.place(x=prev_x, y=0)
    prev_x += label.winfo_reqwidth()    
    
scrolledframe.place(x=0, y=0, height=500, width=200)

root.mainloop()

and the widget appears without scrollbar.
Screenshot from 2022-07-21 04-19-38

Regards. larryw3i

larryw3i avatar Jul 20 '22 20:07 larryw3i

Hello @larryw3i thanks for the report. It seems that the method winfo_reqwidth is not informing correctly about the size of the frame when contains placed children widgets.

import tkinter as tk

root = tk.Tk()
root.geometry("200x500")
frame =  tk.Frame(root)

prev_x = 0
for i in range(100):
    label= tk.Label(
        frame,
        text="ABCD ")
    label.place(x=prev_x, y=0)
    #print(prev_x)
    prev_x += label.winfo_reqwidth()    
frame.place(x=0, y=0, width=200, height=500)

def print_width():
    print(f"Width: {frame.winfo_width()}")
    print(f"ReqWidth: {frame.winfo_reqwidth()}")

root.after(800, print_width)
root.mainloop()

Output:

Width: 200
ReqWidth: 1

I will investigate that and find a solution. Regards

Alejandro A

alejandroautalan avatar Jul 20 '22 21:07 alejandroautalan

As indicated on this page, the place manager does not compute geometric propagation. Therefore to support place in the ScrolledFrame, the size of the innerframe it has to be calculated manually.

alejandroautalan avatar Jul 20 '22 22:07 alejandroautalan

@alejandroautalan Ok, It looks normally, I really appreciate your help.
Screenshot from 2022-07-21 17-03-18

larryw3i avatar Jul 21 '22 09:07 larryw3i