-
-
Notifications
You must be signed in to change notification settings - Fork 671
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
style(Pack(visibility=VISIBLE) does not work #951
Comments
Thanks for the report! I'm guessing the underlying problem is that assigning the entire style isn't triggering the re-application of styles. |
The label object does not have style attribute. Style attribute in inherited from widget object, which is further inherited from Node object (travertino package node.py file). Node object does not have a setter method for style attribute.
The changes works if and only if the label is visible and button is clicked to make it hidden. To make a hidden label visible this setter method is not working. The below program works. But the above program, mentioned in the issue is not working
I hope I have helped in solving the issue. I am beginner in python and would like to contribute. |
@Vipul-Cariappa Definitely looks like you're on the right track. The fact that you've traced this back to the Travertino |
I managed to figure out the problem. This bug is occurring due to a if statement in |
@Vipul-Cariappa That might resolve the problem, but it's not a viable fix in this case. The line you're referenced is an optimization - if width is already set to 200, and you set the width to 200, no calculation is required. The case that is a problem is when the entire style is changed, which is entirely different. In that case, the value isn't changing - because it's being set for the first time. |
What can I do to help resolve this issue? |
@swapniljha001 We need to establish a patch that does trigger the application of the style change, but doesn't require removal of the overall optimization. I'm not sure if @Vipul-Cariappa is still looking at this problem (it's been a few months since the last update); any investigation/exploration you want to do would be helpful. |
I'm going to close this as fixed; we now have a test suite that explicitly tests for visibility, and it seems to be working. |
Tracing down a more complicated case (where I can't create something hidden, but if I change
(If instead I put If the test mentioned above was I couldn't find documentation for how visible/hidden were supposed to be used (and applicators don't seem to be in the API Reference at all?) so maybe this is the wrong approach - while I'd love detail on more generically dynamic content, for my purposes creating hidden elements and unveiling them later is fine.) |
@eichin FY I'm not sure if this is the same issue you're seeing but #2447 is tracking a known issue with visibility under GTK; the act of fixing that issue in #2435 has revealed there are some co-morbid problems with The key distinction between "visible=HIDDEN" and "display=NONE" is that HIDDEN means the layout will leave space for the widget as if it were there, but not actually display it; but As far as the applicator API goes - it's not in the API docs because it's not part of the public API for Toga - you shouldn't be touching the applicator API directly. If you want to modify a style, you should be modifying the style attribute; that should propegate through the style object, and be reflected on the layout. Applicators are part of Travertino. Travertino is the underlying API we're using to manage styles; it's provides the base classes for Pack, with the ultimate goal that it will serve as the base classes for Colosseum, a full implementation of CSS. The applicator is the mechanism by which a change in style is "applied" to the nodes in a layout tree. |
Thanks for clearing that up about the applicator API (the hazards of picking things up from reading code :-) What I'm seeing with visibility doesn't seem gtk-specific, in that android (emulated and hardware) (mis)behaves exactly the same way as gtk does. (I confirmed what #2435 says about toggling style.display not working at all, gtk or android; css-style display as you describe it would definitely be a better match for what I'm trying to do than visibility, though I noticed that the documentation at https://toga.readthedocs.io/en/latest/reference/style/pack.html#display says "Space will be allocated for the element as if it were there, but the element itself will not be visible." which isn't that. Perhaps once .display works I should ticket clarifying the docs?) |
Agreed that clarification/correctly is definitely required. At this point, I'd say #2435 has stalled, as we haven't heard from the contributor for a while. If you're feeling enthusiastic, I think that PR isn't that far from the finish line - it's mostly missing tests. |
Expected Behavior
self.busy_label.style=Pack(visibility=VISIBLE)
should workCurrent Behavior
I had a label:
self.busy_label = toga.Label('Fetching data...Please wait...', style=Pack(visibility=HIDDEN))
Later I tried to hide it:
self.busy_label.style=Pack(visibility=VISIBLE)
This did not work. Resizing the window did not help.
This. did work:
self.busy_label.style.visibility = VISIBLE
Steps to reproduce
If you click the 2nd or 3rd buttons, everything works fine, but as soon as you click the 1st button, everything is broken.
Your Environment
Python Version: 3.7.7
Operating System and Version (select from the following and list the specific version number; if your OS is not listed, list that as well)
Toga Version: 0.2.15
Toga Target (the type of app you are trying to generate)
The text was updated successfully, but these errors were encountered: