You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to implement a 1/3 - 2/3 UI with SplitContainer, by running this code inspired by the Toga documentation:
importtogafromtoga.style.packimportCOLUMN, PackclassTutorial2App(toga.App):
defstartup(self):
data= [("root%s"%i, "value %s"%i) foriinrange(1, 100)]
left_container=toga.Table(headings=["Hello", "World"], data=data)
right_content=toga.Box(style=Pack(direction=COLUMN, padding_top=50))
forbinrange(0, 10):
right_content.add(
toga.Button(
"Hello world %s"%b,
style=Pack(width=200, padding=20),
)
)
right_container=toga.ScrollContainer(horizontal=False)
right_container.content=right_contentsplit=toga.SplitContainer()
# The content of the split container can be specified as a simple list:# split.content = [left_container, right_container]# but you can also specify "weight" with each content item, which will# set an initial size of the columns to make a "heavy" column wider than# a narrower one. In this example, the right container will be twice# as wide as the left one.split.content= [(left_container, 1), (right_container, 2)]
self.main_window=toga.MainWindow()
self.main_window.content=splitself.main_window.show()
defmain():
returnTutorial2App("Tutorial 2", "org.beeware.toga.tutorial")
if__name__=="__main__":
main().main_loop()
As a result, I get a 1/2 - 1/2 ratio (see screenshot)
Steps to reproduce
Run the code above
Expected behavior
Getting a 1/3 - 2/3 ratio
Screenshots
Environment
Operating System: Ubuntu 24.04.1
Python version: 3.12
Toga version: 0.4.7
Logs
Additional context
No response
The text was updated successfully, but these errors were encountered:
It looks like the issue is related to setting the split proportion before the widget is visible. Due to a quirk of how GTK renders, we can't apply the split proportion at the time the content is defined - we need to wait until the widget is rendered, and the apply the split proportion. However, when this is done on a widget that hasn't been rendered yet, the set_bounds() operation that would apply the split occurs when the widget's size is "1x1"... which is ignored, because GTK's split position is based on actual pixels, not a proportion.
My guess is that there's a missing invocation to set_bounds() because the widget is the "top level" widget in the layout - but more investigation is required.
Describe the bug
I tried to implement a 1/3 - 2/3 UI with SplitContainer, by running this code inspired by the Toga documentation:
As a result, I get a 1/2 - 1/2 ratio (see screenshot)
Steps to reproduce
Run the code above
Expected behavior
Getting a 1/3 - 2/3 ratio
Screenshots
Environment
Logs
Additional context
No response
The text was updated successfully, but these errors were encountered: