-
Notifications
You must be signed in to change notification settings - Fork 1
/
gui_functions.py
39 lines (28 loc) · 1.42 KB
/
gui_functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from oscpy.client import OSCClient
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtWidgets import QVBoxLayout, QHBoxLayout, QLabel, QComboBox, QPushButton, QLineEdit, QSlider
class DoubleSlider(QSlider):
# Based on https://stackoverflow.com/questions/42820380/use-float-for-qslider
# create our our signal that we can connect to if necessary
doubleValueChanged = pyqtSignal(float)
def __init__(self, decimals=3, *args, **kargs):
super(DoubleSlider, self).__init__( *args, **kargs)
self._multi = 10 ** decimals
self.valueChanged.connect(self.emitDoubleValueChanged)
def emitDoubleValueChanged(self):
value = float(super(DoubleSlider, self).value())/self._multi
self.doubleValueChanged.emit(value)
def value(self):
return float(super(DoubleSlider, self).value()) / self._multi
def setMinimum(self, value):
return super(DoubleSlider, self).setMinimum(value * self._multi)
def setMaximum(self, value):
return super(DoubleSlider, self).setMaximum(value * self._multi)
def setSingleStep(self, value):
return super(DoubleSlider, self).setSingleStep(value * self._multi)
def singleStep(self):
return float(super(DoubleSlider, self).singleStep()) / self._multi
def setValue(self, value):
super(DoubleSlider, self).setValue(int(value * self._multi))