cards
This module contains functions to generate HTML cards for use in pyRevit output.
Functions
card_start_style(limit, value, alt)
Generates an HTML div element with a specific background color based on the ratio of value to limit.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
limit
|
float
|
The limit value used to calculate the ratio. |
required |
value
|
float
|
The current value to be compared against the limit. |
required |
alt
|
str
|
The alt text for the div element. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
An HTML div element as a string with inline styles and the specified background color. |
The background color is determined by the following rules: - 'Grey' if value is 0 or if an exception occurs during ratio calculation. - 'Green' if 0 <= ratio < 0.5. - 'Orange' if 0.5 <= ratio <= 1. - 'Red' if ratio > 1.
Source code in pyrevitlib/pyrevit/output/cards.py
card_builder(limit, value, description)
Builds an HTML card with the given limit, value, and description.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
limit
|
int
|
The limit value to be displayed in the card. |
required |
value
|
int or str
|
The main value to be displayed in the card. |
required |
description
|
str
|
A description to be displayed in the card. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
A string containing the HTML representation of the card. |
Source code in pyrevitlib/pyrevit/output/cards.py
create_frame(title, *cards)
Creates an HTML div frame containing multiple cards with a rounded border and a title on the top left corner.
return card_start_style(limit, value, alt) + card_end cards (str): Multiple strings representing HTML card elements.
Returns:
Name | Type | Description |
---|---|---|
str |
A string containing the HTML representation of the div frame. |