Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It seems ScrolledFrame doesn't work for place layout. #265

Open
larryw3i opened this issue Jul 20, 2022 · 3 comments
Open

It seems ScrolledFrame doesn't work for place layout. #265

larryw3i opened this issue Jul 20, 2022 · 3 comments
Labels

Comments

@larryw3i
Copy link
Contributor

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

@alejandroautalan
Copy link
Owner

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
Copy link
Owner

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.

@larryw3i
Copy link
Contributor Author

larryw3i commented Jul 21, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants