-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Bug] Column doesn't expand when placed in a column with scrollable = True #6770
Comments
It looks like that it is same as the issue #6766, or #5770 (comment) I reduce your code and make it executable as following. import PySimpleGUI as sg
sg.theme("DarkBlue")
engines = ["Google", "Bing", "Perplexity.ai", "You.com", "Yep.com", "Openverse"]
result_layout = []
for i in engines:
candidate_result_layout = [[sg.Text(f'Post: {i}')]]
for j in range(3):
vote_text = sg.Text(f'{j} Vote)')
candidate_result_layout += [[vote_text], [sg.ProgressBar(j, size=(j, 25), bar_color=('#4E46B4', '#4E46B4'))]]
result_layout.append([sg.Column(candidate_result_layout, expand_x=True, size=(100, 130), background_color='#FFFFFF')])
layout = [[sg.Column(result_layout, expand_y=True, expand_x=True, scrollable=True, vertical_scroll_only=True, key="COLUMN")]]
window = sg.Window(f'Results', layout, resizable=True, finalize=True)
window.set_size((550, 200))
window.refresh()
window.move_to_center()
while True:
event, values = window.read()
if event==sg.WIN_CLOSED:
break
window.close() After the workaround applied import PySimpleGUI as sg
def configure_canvas(event, canvas, frame_id):
canvas.itemconfig(frame_id, width=canvas.winfo_width())
def configure_frame(event, canvas):
canvas.configure(scrollregion=canvas.bbox("all"))
sg.theme("DarkBlue")
engines = ["Google", "Bing", "Perplexity.ai", "You.com", "Yep.com", "Openverse"]
result_layout = []
for i in engines:
candidate_result_layout = [[sg.Text(f'Post: {i}')]]
for j in range(3):
vote_text = sg.Text(f'{j} Vote)')
candidate_result_layout += [[vote_text], [sg.ProgressBar(j, size=(j, 25), bar_color=('#4E46B4', '#4E46B4'))]]
result_layout.append([sg.Column(candidate_result_layout, expand_x=True, size=(100, 130), background_color='#FFFFFF')])
layout = [[sg.Column(result_layout, expand_y=True, expand_x=True, scrollable=True, vertical_scroll_only=True, key="COLUMN")]]
window = sg.Window(f'Results', layout, resizable=True, finalize=True)
column = window['COLUMN'].widget
frame_id, frame, canvas = column.frame_id, column.TKFrame, column.canvas
canvas.bind("<Configure>", lambda event, canvas=canvas, frame_id=frame_id:configure_canvas(event, canvas, frame_id))
frame.bind("<Configure>", lambda event, canvas=canvas:configure_frame(event, canvas))
window.set_size((550, 200))
window.refresh()
window.move_to_center()
while True:
event, values = window.read()
if event==sg.WIN_CLOSED:
break
window.close() |
Thanks for the solution, could you please explain the code as I am unable to understand and also why does this problem occur? |
I got error NoneType object has no attribute frame_id
|
One extra option missed in your
It is caused by that the scrollable Column is built with the tkinter Canvas widget, and the child elements/widgets are created inside the window which is on the canvas and no expand function. |
Maybe you forgot those two functions defined in the beginning import PySimpleGUI as sg
def configure_canvas(event, canvas, frame_id):
canvas.itemconfig(frame_id, width=canvas.winfo_width())
def configure_frame(event, canvas):
canvas.configure(scrollregion=canvas.bbox("all")) |
Oh yes, sorry that I disturbed you because of my silly mistake. |
Type of Issue (Bug)
[Bug] Column doesn't expand when placed in a column with scrollable = True
Operating System
Windows 10
PySimpleGUI Port (tkinter, Qt, Wx, Web)
Tkinter
Versions
Python version (
sg.sys.version
)3.12.0
PySimpleGUI Version (
sg.__version__
)4.61.0.206
GUI Version (tkinter (
sg.tclversion_detailed
), PySide2, WxPython, Remi)tkinter version: 8.6.13
Troubleshooting
These items may solve your problem. Please check those you've done by changing - [ ] to - [X]
Detailed Description
Column doesn't expand when placed in a column with scrollable = True. Column would expand when its parent Column had scrollable=False.
Code To Duplicate
This pre-formatted code block is all set for you to paste in your bit of code:
Screenshot, Sketch, or Drawing
scrollable=True
scrollable=False
Watcha Makin?
I am making an e-voting software for my school
The text was updated successfully, but these errors were encountered: