From bdfb388fb234a157191343fb81c1b3cbc565391d Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sat, 16 Jan 2021 16:35:58 -0500 Subject: [PATCH 1/2] add progress bar --- magicgui/backends/_qtpy/__init__.py | 2 ++ magicgui/backends/_qtpy/widgets.py | 20 ++++++++++++++++++-- magicgui/widgets/__init__.py | 2 ++ magicgui/widgets/_concrete.py | 5 +++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/magicgui/backends/_qtpy/__init__.py b/magicgui/backends/_qtpy/__init__.py index b08fc5c60..8ab4f6b59 100644 --- a/magicgui/backends/_qtpy/__init__.py +++ b/magicgui/backends/_qtpy/__init__.py @@ -8,6 +8,7 @@ FloatSpinBox, Label, LineEdit, + ProgressBar, PushButton, RadioButton, Slider, @@ -28,6 +29,7 @@ "FloatSpinBox", "Label", "LineEdit", + "ProgressBar", "PushButton", "RadioButton", "Slider", diff --git a/magicgui/backends/_qtpy/widgets.py b/magicgui/backends/_qtpy/widgets.py index e17ef539d..26e9ead01 100644 --- a/magicgui/backends/_qtpy/widgets.py +++ b/magicgui/backends/_qtpy/widgets.py @@ -319,8 +319,8 @@ def _mgui_set_value(self, value) -> None: class Slider(QBaseRangedWidget, _protocols.SupportsOrientation): _qwidget: QtW.QSlider - def __init__(self): - super().__init__(QtW.QSlider) + def __init__(self, qwidg=QtW.QSlider): + super().__init__(qwidg) self._mgui_set_orientation("horizontal") def _mgui_set_orientation(self, value) -> Any: @@ -334,6 +334,22 @@ def _mgui_get_orientation(self) -> Any: return "vertical" if orientation == Qt.Vertical else "horizontal" +class ProgressBar(Slider): + _qwidget: QtW.QProgressBar + + def __init__(self): + super().__init__(QtW.QProgressBar) + self._mgui_set_orientation("horizontal") + + def _mgui_get_step(self) -> float: + """Get the step size.""" + return 1 + + def _mgui_set_step(self, value: float): + """Set the step size.""" + pass + + class ComboBox(QBaseValueWidget, _protocols.CategoricalWidgetProtocol): _qwidget: QtW.QComboBox diff --git a/magicgui/widgets/__init__.py b/magicgui/widgets/__init__.py index ac27d673b..1bc90a71c 100644 --- a/magicgui/widgets/__init__.py +++ b/magicgui/widgets/__init__.py @@ -25,6 +25,7 @@ LineEdit, LiteralEvalLineEdit, LogSlider, + ProgressBar, PushButton, RadioButton, RangeEdit, @@ -68,6 +69,7 @@ "LiteralEvalLineEdit", "LogSlider", "PushButton", + "ProgressBar", "RadioButton", "RangeEdit", "SliceEdit", diff --git a/magicgui/widgets/_concrete.py b/magicgui/widgets/_concrete.py index a61ccee7f..1961658fa 100644 --- a/magicgui/widgets/_concrete.py +++ b/magicgui/widgets/_concrete.py @@ -201,6 +201,11 @@ class FloatSpinBox(RangedWidget): """A widget to edit a float with clickable up/down arrows.""" +@backend_widget +class ProgressBar(SliderWidget): + """A progress bar widget.""" + + @backend_widget class Slider(SliderWidget): """A slider widget to adjust an integer value within a range.""" From 87597239708b3d4e337994374bd25263c79c1a4d Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sat, 16 Jan 2021 16:36:54 -0500 Subject: [PATCH 2/2] add to docs --- docs/api/widgets.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/api/widgets.md b/docs/api/widgets.md index 0c2ef4294..c1389eeba 100644 --- a/docs/api/widgets.md +++ b/docs/api/widgets.md @@ -64,6 +64,7 @@ Slider Widgets Slider FloatSlider LogSlider + ProgressBar Categorical Widgets -------------------