Comments (7)
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()
from pysimplegui.
Thanks for the solution, could you please explain the code as I am unable to understand and also why does this problem occur?
from pysimplegui.
I got error NoneType object has no attribute frame_id
The code-
show_results_window = sg.Window(f'{results_window[result_event].get()} Results',[[sg.Column(result_layout,expand_y=True,expand_x=True,scrollable=True,vertical_scroll_only=True, key='result_container')]],size=(550,500),resizable=True,modal=True)
# Code to fix columns in result_layout not expanding
column = show_results_window['result_container'].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))
show_results_window.set_size((550, 200))
show_results_window.refresh()
show_results_window.move_to_center()
from pysimplegui.
AttributeError: 'NoneType' object has no attribute 'frame_id'
One extra option missed in your sg.Window
, finalize=True
.
Why element inside a scrollable Column not expanded ?
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.
So we need to adjust the size of the Canvas and the window/frame by ourself when related GUI configured event happened.
from pysimplegui.
I again got this error, (PSG 4.61.0.206)
from pysimplegui.
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"))
from pysimplegui.
Oh yes, sorry that I disturbed you because of my silly mistake.
from pysimplegui.
Related Issues (20)
- [ Bug] Garbled output on WSL HOT 5
- Question. How to get a value from a return? HOT 3
- [Question] PySimpleGUI Web Deprecated? HOT 1
- Bug: Error dialog when programatically updating PySimpleGUIQt Checkbox HOT 5
- [Question] How to add space between the background and text in input HOT 5
- [Question] I am unable to center frames inside column HOT 4
- [ Question] Window size is not restored properly when using C++ Window methods. HOT 1
- [Question] ImageFont OSError: cannot open resource HOT 1
- [Question] How do I change the on hover color of scroll bar? HOT 3
- [Question] PySide cannot accept a list of objects as the values for the Combobox element HOT 1
- [Question] PSG with Python 3.12.4 HOT 3
- [ Enhancement] Option to create window in maximized state HOT 4
- [Bug] PSG5 UnicodeDecodeError When Freezing with cx_Freeze HOT 21
- [Enhancement] Udemy Course Enhancement Request: Context Menu Course Module HOT 2
- Error HOT 13
- [Bug] Custom Titlebar window focus problems HOT 2
- [Question] scrolling 2 tables HOT 23
- [Question] Showing "Trial period ends...." HOT 1
- [Bug] Element still visible after setting visible=False HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pysimplegui.