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

[🐛 BUG] Setting width/height with CSS units not working for metrics #2141

Open
1 of 7 tasks
FlorianJacta opened this issue Oct 24, 2024 · 7 comments
Open
1 of 7 tasks
Labels
good first issue New-contributor friendly 🖰 GUI Related to GUI 💥Malfunction Addresses an identified problem. 🟧 Priority: High Must be addressed as soon

Comments

@FlorianJacta
Copy link
Member

FlorianJacta commented Oct 24, 2024

What went wrong? 🤔

Setting width and height for metrics with CSS units is not working. This won't change the width/height as expected.

This works when just putting a number. It took a while for me to figure out (I went looking at the actual PR).

If this issue could be backported to another patch, this would be great.

Expected Behavior

This should work with all CSS units supported by Taipy. Or the documentation should change to reflect this behavior.

Steps to Reproduce Issue

from taipy.gui import Gui

value = 50

page = """
<|{value}|metric|>

## Works
<|{value}|metric|width=300|height=300|>

## Height not working, Width not working
<|{value}|metric|width=150px|height=300px|>
<|{value}|metric|width=300px|height=300px|>


## Height not working, Width not working
<|{value}|metric|width=150rem|height=150rem|>
<|{value}|metric|width=300rem|height=150rem|>
"""

Gui(page).run()

Screenshots

image

Version of Taipy

4.0

Acceptance Criteria

  • A unit test reproducing the bug is added.
  • Any new code is covered by a unit tested.
  • Check code coverage is at least 90%.
  • The bug reporter validated the fix.
  • Related issue(s) in taipy-doc are created for documentation and Release Notes are updated.

Code of Conduct

  • I have checked the existing issues.
  • I am willing to work on this issue (optional)
@FlorianJacta FlorianJacta added 🖰 GUI Related to GUI 💥Malfunction Addresses an identified problem. 🟧 Priority: High Must be addressed as soon labels Oct 24, 2024
@naaa760
Copy link

naaa760 commented Oct 24, 2024

Hello @FlorianJacta :)

  • I think update Dimension Handling: Allow width and height to accept both numerical values and CSS units (e.g., px, rem).
  • Dimension Parsing: Implement logic to recognize CSS unit strings or convert numeric values to pixel-based strings (e.g., 150 becomes "150px").

@FlorianJacta
Copy link
Member Author

FlorianJacta commented Oct 25, 2024

I think 150 and 150px are two different units. It is related to this issue too: #2142 so you should also be assigned there

@vgauraha62
Copy link

Parameters in the 'metric' component do not accept units like, px or rem.
Use numerical values without units (e.g. width=150, height=300).
This should apply the desired dimensions to the metric component.

@Yubarajhalder
Copy link

The issue lies in how you're setting the width and height properties in the metric widget.

Taipy GUI uses a specific syntax for styling, and width and height should be defined within a style attribute.

Try modifying your page string as follows:

page = """
<|{value}|metric|style={"width": "300px", "height": "300px"}|>
"""

Or, for multiple styles:

page = """
<|{value}|metric|style={"width": "300px", "height": "300px", "font-size": "24px"}|>
"""

This should correctly apply the width and height styles to your metric widget.

Additionally, consider using units like px for pixels or % for percentage-based sizing.

For more information on Taipy GUI styling, refer to the official documentation:

@FlorianJacta
Copy link
Member Author

@Yubarajhalder your answer is not answering the issue

Copy link
Contributor

This issue has been labelled as "🥶Waiting for contributor" because it has been inactive for more than 14 days. If you would like to continue working on this issue, please add another comment or create a PR that links to this issue. If a PR has already been created which refers to this issue, then you should explicitly mention this issue in the relevant PR. Otherwise, you will be unassigned in 14 days. For more information please refer to the contributing guidelines.

@github-actions github-actions bot added the 🥶Waiting for contributor Issues or PRs waiting for a long time label Nov 12, 2024
@github-actions github-actions bot removed the 🥶Waiting for contributor Issues or PRs waiting for a long time label Nov 26, 2024
Copy link
Contributor

This issue has been unassigned automatically because it has been marked as "🥶Waiting for contributor" for more than 14 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue New-contributor friendly 🖰 GUI Related to GUI 💥Malfunction Addresses an identified problem. 🟧 Priority: High Must be addressed as soon
Projects
None yet
Development

No branches or pull requests

5 participants