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

Add ProgressBar widget #104

Merged
merged 2 commits into from
Jan 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api/widgets.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Slider Widgets
Slider
FloatSlider
LogSlider
ProgressBar

Categorical Widgets
-------------------
Expand Down
2 changes: 2 additions & 0 deletions magicgui/backends/_qtpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
FloatSpinBox,
Label,
LineEdit,
ProgressBar,
PushButton,
RadioButton,
Slider,
Expand All @@ -28,6 +29,7 @@
"FloatSpinBox",
"Label",
"LineEdit",
"ProgressBar",
"PushButton",
"RadioButton",
"Slider",
Expand Down
20 changes: 18 additions & 2 deletions magicgui/backends/_qtpy/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand Down
2 changes: 2 additions & 0 deletions magicgui/widgets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
LineEdit,
LiteralEvalLineEdit,
LogSlider,
ProgressBar,
PushButton,
RadioButton,
RangeEdit,
Expand Down Expand Up @@ -68,6 +69,7 @@
"LiteralEvalLineEdit",
"LogSlider",
"PushButton",
"ProgressBar",
"RadioButton",
"RangeEdit",
"SliceEdit",
Expand Down
5 changes: 5 additions & 0 deletions magicgui/widgets/_concrete.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down