I have just come across Enaml for python GUI programming. I only used PySide2 once before for a simple calculator GUI mockup, so I'm new to both Qt and Enaml. Forgive my ignorance ;)
Essentially, I want to have a regular grid of Field
or other elements, with fixed, square sizes. After going over some of the examples, I came up with:
from enaml.layout.api import grid
from enaml.widgets.api import Window, Container, Field
enamldef DigitField(Field):
# The fields will contain a single digit for testing.
mask = 'D'
max_length = 1
# These don't have any effect?
hug_width = 'required'
hug_height = 'required'
enamldef Main(Window):
Container:
constraints = [
grid(
[f11, f12],
[f21, f22],
),
]
DigitField: f11:
text = '1'
DigitField: f12:
text = '1'
DigitField: f21:
text = '1'
DigitField: f22:
text = '1'
But the hug_width
and hug_height
don't seem to work. I then tried manually setting f11.width == 50
, for example, inside the constraints, but the kiwisolver shouts at me about unresolvable constraints. I tried everything I could find from the examples about setting width values, but stuff that works for vbox
doesn't seem to play with grid
.
Any ideas? Also, if someone has a full app made with Enaml, that is open source, I would love to take a look. The docs are OK but some more advanced examples would be awesome.