Use the stretch
attribute on each SplitItem
. The initial widths will be proportional to the fraction of total stretch values. So for the left one, use stretch = 3
and the right one stretch = 1
. This will allocate 3/4 of the space to the left side and 1/4 of the space to the right side. The stretch values must be integers, not floating point values since this is what the underlying toolkits are expecting.
How to accomplish initial Splitter and SplitItem layout with enaml?
Question
I'm using the enaml toolkit and would like to know how to initialize Splitter
/ SplitItem
layouts.
Below is some very simple sample code. I'd like the window to start with the left SplitItem
taking about 2/3 of the window width with the right SplitItem
getting the other third. I've tried a variety of constraints in a variety of places but can't seem to hit on what I need to do.
Window starts like this:
I want it to start like this:
from enaml.widgets.api import (
Window, Container, Splitter, SplitItem, Html
)
enamldef Left(Container):
Html:
source = '<center><h1>Hello Left!</h1></center>'
enamldef Right(Container):
Html:
source = '<center><h1>Hello Right!</h1></center>'
enamldef Main(Window):
initial_size = (800,400)
Container:
Splitter:
SplitItem:
Left:lt:
pass
SplitItem:
Right:rt:
pass
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow