Comments (8)
Another option would be to allow some kind of variables which can be changed from outside, but not from the solver, but I can't see those in Kiwi as well (
from kiwi.
I believe what you are looking for are EditVariables. You can look at cassowary examples as kiwi implement the same solver. This example in particular seems to describe your use case: http://cassowary.readthedocs.io/en/latest/topics/examples.html
from kiwi.
@MatthieuDartiailh, I doubt it. The example you're providing is using stay constraints (grep for add_stay), which is missing in kiwi.
To somehow rephrase my question I can provide a use case which I want to implement. Let's say there's a UI system, with view hierarchies, where every view has x, y, width and height variables. All the variables are tied with constraints. Then there's the window with its width and height variables. The user may resize it, so I "edit" the width and height of the window and it works for the first relayout, but subsequent calls to solver.solve
may randomly change these variables again. So I want those variables to stay and be changed when its otherwise impossible to solve the constraints.
from kiwi.
I believe you can still achieve your goal without stay constraints, as it is done in enaml (https://github.com/nucleic/enaml/blob/master/enaml/layout/layout_manager.py#L244). You can look at how the constraints are defined and how resize is done.
I must say I am not an expert here, @sccolbert would be more qualified to answer you.
from kiwi.
See also this discussion #9
from kiwi.
Thanks, #9 explains a lot. Maybe this info should be mentioned on the front page, that stay constraints can be "simulated" by adding/removing external EQ constraints.
from kiwi.
@yglukhov The right way to do what you want is with edit variables. In Enaml, each widget has a variable for left
, top
, width
, and height
. Child widgets are ultimately constrained based on their parent's width
and height
variables. Those variables are added to the solver via solver.addEditVariable
. When solving for the layout of the children, the current size of the parent is used to suggest values for the width
and height
variables via solver.suggestValue
. The system is then solved via solver.updateVariables
.
https://github.com/nucleic/enaml/blob/master/enaml/layout/layout_manager.py#L358-L360
from kiwi.
@sccolbert, ah that makes even more sense. Thank you. Still worth mentioning in the docs I think.
from kiwi.
Related Issues (20)
- Failed building wheel for kiwisolver :( HOT 4
- Cann't install on python 3.11b3 HOT 2
- 1.4.3 has no attribute __version__ HOT 2
- ERROR: Failed building wheel for kiwisolver: C2440: 'static_cast': cannot convert from 'expr_type' to 'type' HOT 2
- Provide cp311 releases HOT 1
- Objective cell memory leak? HOT 26
- Continuous fuzzing by way of Google's OSS-Fuzz HOT 1
- Tests fail on pypy
- #egg=kiwisolver See assertion error when installing kiwisolver HOT 4
- about duplicate constraints HOT 3
- Add Python API to get all constraints HOT 14
- Is it possible to get the absolute value of an expression? HOT 10
- Is it possible to tell the Solver to prefer smaller or larger solutions? HOT 3
- Missing type hint for `Constraint.violated()` HOT 1
- Python 3.12 manylinux wheels HOT 2
- PyInstaller executable with matplotlib cannot find _cext DLL HOT 6
- `top_level.txt` include a non existing module `src`
- DLL load failed while importing _cext HOT 2
- How do we define an "objective function" and maximize or minimize it? HOT 1
- On Windows 10 LTSC, import kiwisolver (and/or import matplotlib) fails with DLL _cext even after installing VS runtime (solution incl) HOT 1
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 kiwi.