Skip to content

Commit

Permalink
Added push button control
Browse files Browse the repository at this point in the history
  • Loading branch information
vilim committed Jan 16, 2019
1 parent fab9d91 commit 67fcedb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lightparam/gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
combo=ControlCombo,
text=ControlText,
folder=ControlFolder,
button=ControlButton,
range_slider=RangeSliderWidgetWithNumbers,
)


class ParameterTreeGui(QWidget):
def __init__(self, param_tree):
super().__init__()
Expand Down
17 changes: 15 additions & 2 deletions lightparam/gui/controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ def __init__(self, parametrized, name):
except TypeError:
pass

self.control.setValue(self.param.value)

if self.param.limits is not None and len(self.param.limits) > 2:
self.control.setDecimals(int(-round(log(self.param.limits[2])/log(10))))

self.control.setValue(self.param.value)

self.setLayout(QHBoxLayout())
self.layout().addWidget(self.label)
self.layout().addWidget(self.control)
Expand Down Expand Up @@ -86,6 +86,19 @@ def update_param(self):
setattr(self.parametrized, self.param_name, self.control.isChecked())


class ControlButton(Control):
def __init__(self, parametrized, name):
super().__init__(parametrized, name)
self.control = QPushButton(pretty_name(name))
self.setLayout(QHBoxLayout())
self.layout().addWidget(self.control)
self.layout().setContentsMargins(0, 0, 0, 0)
self.control.clicked.connect(self.update_param)

def update_param(self):
setattr(self.parametrized, self.param_name,
not getattr(self.parametrized, self.param_name))

class ControlToggleIcon(QToolButton, Control):
"""A toggle button for a boolean parameter"""
def __init__(self, parametrized, name, icon_on=None, icon_off=None,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name="lightparam",
version="0.3.5",
version="0.3.6",
author="Vilim Stich, Luigi Petrucco",
author_email="[email protected]",
packages=find_packages(),
Expand Down

0 comments on commit 67fcedb

Please sign in to comment.