pct
pdwidgets.pct ¶
pdwidgets.pct¶
Classes that dynamically calculate the percentage of the width and height of a Widget
Classes¶
Height ¶
Height(percent, widget)
A class that dynamically calculates the percentage of the height of a Widget
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
percent
|
int | float
|
The percentage of the height of the widget |
required |
widget
|
Widget
|
The widget whose height will be used to calculate the percentage |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the percent is not between 0 and 100 |
AttributeError
|
If the widget has no attribute 'area' |
Returns:
| Type | Description |
|---|---|
int
|
The calculated percentage of the height of the widget |
Usage
import pdwidgets as pd ... widget = pd.Widget(parent, h=100) my_height = pd.pct.Height(50, widget) print(my_height) # 50 widget.height = 200 print(my_height) # 100
Width ¶
Width(percent, widget)
A class that dynamically calculates the percentage of the width of a Widget
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
percent
|
int | float
|
The percentage of the width of the widget |
required |
widget
|
Widget
|
The widget whose width will be used to calculate the percentage |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the percent is not between 0 and 100 |
AttributeError
|
If the widget has no attribute 'area' |
Returns:
| Type | Description |
|---|---|
int
|
The calculated percentage of the width of the widget |
Usage
import pdwidgets as pd ... widget = pd.Widget(parent, w=100) my_width = pd.pct.Width(50, widget) print(my_width) # 50 widget.width = 200 print(my_width) # 100