Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readonly vs. non-readonly specification lead to a different format #344

Closed
stefanoborini opened this issue Feb 10, 2017 · 3 comments
Closed

Comments

@stefanoborini
Copy link
Contributor

The following

    traits_view = View(
            VGroup(
                Item(
                    "model.name",
                    resizable=True,
                    style="readonly"
                ),
                Item(
                    "model.definition",
                    resizable=True,
                    style="readonly"
                ),
                Item("model.type",
                     style="readonly"
                     ),
                Item("model.shape",
                     editor=CSVListEditor(),
                     style="readonly"
                     ),
                Item(
                    "model.length",
                    visible_when="model.type == 'string'",
                    style="readonly"
                ),

                label="CUBA Data Type",
                show_border=True,
            ))

Results in this
untitled

However, if I remove the readonly, the result is more compact

untitled2

@corranwebster
Copy link
Contributor

DIfferent widgets under the covers (eg. QTextField vs. QLabels) so Qt has different default rules about how they can expand. Try playing with resizable=False or perhaps if it fits the UX, just use the non-readonly version, but have enabled_when='False'

@stefanoborini
Copy link
Contributor Author

True, but I think that if there's an underlying difference in the vertical expand, traitsui should guarantee that they behave the same.

@corranwebster
Copy link
Contributor

Note that you will get different layout behaviour also if you make the textbox style='custom', which I think will be closer to the readonly style. Based on that, its not clear what's "correct" and what behaviour should be guaranteed.

TraitsUI is not designed for pixel-perfect layout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants