nucleic / enaml

Declarative User Interfaces for Python
http://enaml.readthedocs.io/en/latest/
Other
1.53k stars 130 forks source link

Using enaml just to invoke kiwisolver #468

Closed maxme1 closed 2 years ago

maxme1 commented 2 years ago

Hi!

Is it possible to create a nested widgets structure (e.g. some Labels in a Container) in Python without *.enaml files and generate the coordinates and sizes for each widget?

Basically, I am trying to render a static gui (without user interaction or resizing), and I would like to use kiwisolver to correctly position the widgets.

sccolbert commented 2 years ago

You can use kiwi without Enaml.

The layout helpers included with Enaml are pretty tightly coupled to the Enaml widget hierarchy.

You could what you ask procedurally, but it would probably be less effort to just use Kiwi directly.

On Tue, Jan 4, 2022 at 13:42 Max @.***> wrote:

Hi!

Is it possible to create a nested widgets structure (e.g. some Labels in a Container) in Python without *.enaml files and generate the coordinates and sizes for each widget?

Basically, I am trying to render a static gui (without user interaction or resizing), and I would like to use kiwisolver to correctly position the widgets.

— Reply to this email directly, view it on GitHub https://github.com/nucleic/enaml/issues/468, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABBQSNSV2D2GIW5WZ3NWODUUNESFANCNFSM5LIG5MSQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

sccolbert commented 2 years ago

I take that back. You might be able to create your own subclass of Constrainable, and use that with Enaml’s layout helper functions. You would just need to bootstrap your own Kiwi solver instance that solves the constraints generated by the helpers.

On Tue, Jan 4, 2022 at 13:47 Chris Colbert @.***> wrote:

You can use kiwi without Enaml.

The layout helpers included with Enaml are pretty tightly coupled to the Enaml widget hierarchy.

You could what you ask procedurally, but it would probably be less effort to just use Kiwi directly.

On Tue, Jan 4, 2022 at 13:42 Max @.***> wrote:

Hi!

Is it possible to create a nested widgets structure (e.g. some Labels in a Container) in Python without *.enaml files and generate the coordinates and sizes for each widget?

Basically, I am trying to render a static gui (without user interaction or resizing), and I would like to use kiwisolver to correctly position the widgets.

— Reply to this email directly, view it on GitHub https://github.com/nucleic/enaml/issues/468, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABBQSNSV2D2GIW5WZ3NWODUUNESFANCNFSM5LIG5MSQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

tstordyallison commented 2 years ago

Or do you still actually want to use enaml just without the files (that is possible too)?

maxme1 commented 2 years ago

I found out here that each Container already has a solver which is recursively invoked to solve the constraints for the tree. However, I couldn't find the solver in the class definition, nor how to provide my own solver a solve the constraints.

Also, I couldn't figure out how to create a Container which has some children. Neither Container(children=[...]) nor

c = Container()
c.insert_children(None, [...])

seem to work.

I could implement my own widgets tree from scratch just by using kiwisolver, but enaml feels like a very promising framework for that.

sccolbert commented 2 years ago

Don’t give up so easy. You only spent like 20 minutes trying to “figure it out”.

On Tue, Jan 4, 2022 at 14:02 Max @.***> wrote:

I found out here https://kiwisolver.readthedocs.io/en/latest/use_cases/enaml.html#setting-up-the-solver that each Container already has a solver which is recursively invoked to solve the constraints for the tree. However, I couldn't find the solver in the class definition, nor how to provide my own solver a solve the constraints.

Also, I couldn't figure out how to create a Container which has some children. Neither Container(children=[...]) nor

c = Container()c.insert_children(None, [...])

seem to work.

I could implement my own widgets tree from scratch just by using kiwisolver, but enaml feels like a very promising framework for that.

— Reply to this email directly, view it on GitHub https://github.com/nucleic/enaml/issues/468#issuecomment-1005129844, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABBQSI5RN66ZJBFKKWIKWLUUNG4VANCNFSM5LIG5MSQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

maxme1 commented 2 years ago

I read all the docs from here, the relevant parts from here as well as parts of enaml's source code regarding the Container and Constrainable.

I am sorry if my question is too basic, but some pointers or examples would be very helpful.

maxme1 commented 2 years ago

I ended up generating python bindings for yoga. Thanks for your time though.