|
@@ -2,13 +2,19 @@ from typing import Optional
|
|
|
|
|
|
from nicegui import ui
|
|
from nicegui import ui
|
|
|
|
|
|
|
|
+from ..colors import set_text_color
|
|
from .mixins.value_element import ValueElement
|
|
from .mixins.value_element import ValueElement
|
|
|
|
|
|
|
|
|
|
class LinearProgress(ValueElement):
|
|
class LinearProgress(ValueElement):
|
|
VALUE_PROP = 'value'
|
|
VALUE_PROP = 'value'
|
|
|
|
|
|
- def __init__(self, value: float = 0.0, *, size: Optional[str] = None, show_value: bool = True) -> None:
|
|
|
|
|
|
+ def __init__(self,
|
|
|
|
+ value: float = 0.0, *,
|
|
|
|
+ size: Optional[str] = None,
|
|
|
|
+ show_value: bool = True,
|
|
|
|
+ color: Optional[str] = 'primary',
|
|
|
|
+ ) -> None:
|
|
"""Linear Progress
|
|
"""Linear Progress
|
|
|
|
|
|
A linear progress bar wrapping Quasar's
|
|
A linear progress bar wrapping Quasar's
|
|
@@ -17,9 +23,11 @@ class LinearProgress(ValueElement):
|
|
:param value: the initial value of the field (from 0.0 to 1.0)
|
|
:param value: the initial value of the field (from 0.0 to 1.0)
|
|
:param size: the height of the progress bar (default: "20px" with value label and "4px" without)
|
|
:param size: the height of the progress bar (default: "20px" with value label and "4px" without)
|
|
:param show_value: whether to show a value label in the center (default: `True`)
|
|
:param show_value: whether to show a value label in the center (default: `True`)
|
|
|
|
+ :param color: color (either a Quasar, Tailwind, or CSS color or `None`, default: "primary")
|
|
"""
|
|
"""
|
|
super().__init__(tag='q-linear-progress', value=value, on_value_change=None)
|
|
super().__init__(tag='q-linear-progress', value=value, on_value_change=None)
|
|
self._props['size'] = size if size is not None else '20px' if show_value else '4px'
|
|
self._props['size'] = size if size is not None else '20px' if show_value else '4px'
|
|
|
|
+ set_text_color(self, color)
|
|
|
|
|
|
if show_value:
|
|
if show_value:
|
|
with self:
|
|
with self:
|
|
@@ -29,23 +37,32 @@ class LinearProgress(ValueElement):
|
|
class CircularProgress(ValueElement):
|
|
class CircularProgress(ValueElement):
|
|
VALUE_PROP = 'value'
|
|
VALUE_PROP = 'value'
|
|
|
|
|
|
- def __init__(self, value: float = 0.0, *,
|
|
|
|
- min: float = 0.0, max: float = 1.0, size: str = 'xl', show_value: bool = True) -> None:
|
|
|
|
|
|
+ def __init__(self,
|
|
|
|
+ value: float = 0.0, *,
|
|
|
|
+ min: float = 0.0,
|
|
|
|
+ max: float = 1.0,
|
|
|
|
+ size: str = 'xl',
|
|
|
|
+ show_value: bool = True,
|
|
|
|
+ color: Optional[str] = 'primary',
|
|
|
|
+ ) -> None:
|
|
"""Circular Progress
|
|
"""Circular Progress
|
|
|
|
|
|
A circular progress bar wrapping Quasar's
|
|
A circular progress bar wrapping Quasar's
|
|
`QCircularProgress <https://quasar.dev/vue-components/circular-progress>`_.
|
|
`QCircularProgress <https://quasar.dev/vue-components/circular-progress>`_.
|
|
|
|
|
|
:param value: the initial value of the field
|
|
:param value: the initial value of the field
|
|
|
|
+ :param min: the minimum value (default: 0.0)
|
|
|
|
+ :param max: the maximum value (default: 1.0)
|
|
:param size: the size of the progress circle (default: "xl")
|
|
:param size: the size of the progress circle (default: "xl")
|
|
:param show_value: whether to show a value label in the center (default: `True`)
|
|
:param show_value: whether to show a value label in the center (default: `True`)
|
|
|
|
+ :param color: color (either a Quasar, Tailwind, or CSS color or `None`, default: "primary")
|
|
"""
|
|
"""
|
|
super().__init__(tag='q-circular-progress', value=value, on_value_change=None)
|
|
super().__init__(tag='q-circular-progress', value=value, on_value_change=None)
|
|
self._props['min'] = min
|
|
self._props['min'] = min
|
|
self._props['max'] = max
|
|
self._props['max'] = max
|
|
self._props['size'] = size
|
|
self._props['size'] = size
|
|
self._props['show-value'] = show_value
|
|
self._props['show-value'] = show_value
|
|
- self._props['color'] = 'primary'
|
|
|
|
|
|
+ set_text_color(self, color)
|
|
self._props['track-color'] = 'grey-4'
|
|
self._props['track-color'] = 'grey-4'
|
|
|
|
|
|
if show_value:
|
|
if show_value:
|