-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdials.py
106 lines (91 loc) · 2.63 KB
/
dials.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
'''
Dial
Interaction
* Control + Click = Default value
* Double Click = Input value
* Mouse Wheel increases/decreases value
* Mouse Wheel + Control = Corse = 2x less precision
* Mouse Wheel + Shift = Fine = 2x more precision
TODO: Add secondary slider/value
TODO: Option to span from center
TODO: Alignment
TODO if needed: Keyboard Events
TODO if needed: Steps
'''
from PySide6.QtCore import *
from PySide6.QtGui import *
from PySide6.QtWidgets import *
from daw_tools import Dial
from daw_tools import mf
# Creating the application
app = QApplication([])
# Creating the display window
window = QWidget()
window.setWindowTitle('Daw Tools Dials')
window.setMinimumSize(300,300)
window.setStyleSheet("""
background-color: rgb(60, 60, 60);
""")
# Window layout
l = QGridLayout()
# Function for labels
def makeLabel(text):
label = QLabel(text)
label.setStyleSheet("color: #fff;")
label.setAlignment(Qt.AlignCenter)
return label
# Dial events
def changed(v):print('Dial Changed:',v)
# Default Dial
dDial = Dial()
dDial.setFixedSize(50,50)
dDial.valueChanged.connect(changed)
l.addWidget(makeLabel('Default Dial'),0,0)
l.addWidget(dDial,1,0)
# Value Dial
vDial = Dial()
vDial.setFixedSize(50,50)
vDial.setDisplayValue(True)
vDial.setValueFont(QFont("Times", 12, QFont.Bold))
vDial.valueChanged.connect(changed)
l.addWidget(makeLabel('Value Dial'),0,1)
l.addWidget(vDial,1,1)
# Text Dial
tDial = Dial()
tDial.setFixedSize(100,100)
tDial.setRange(0,200)# setMinimum() and setMaximum() also available
tDial.setValue(10)
tDial.setDefaultValue(100)
tDial.setMouseMoveRange(50)# Click and drag distance
tDial.setText('Attack', QFont("Times", 8, QFont.Bold))
tDial.valueChanged.connect(changed)
l.addWidget(makeLabel('Text Dial'),2,0)
l.addWidget(tDial,3,0)
# Other Dial
oDial = Dial(-100,100,0)# min, max, default
oDial.setFixedSize(100,100)
oDial.setValueFont(QFont("Times", 12, QFont.Bold))
oDial.setDisplayValue(True)# display the value
oDial.setPrefix('V')# value Prefix
oDial.setSuffix('ms')# value Suffix
oDial.setInverted(True)
oDial.setTextFont(QFont("Times", 7))
oDial.setText('Decay')
oDial.setPadding(10)
oDial.setStyleSheet("""
background-color: rgb(50, 100, 50);
border-radius:50;
""")
# Style the pen/bar
pen = oDial.pen()
pen.setWidth(10)
pen.setCapStyle(Qt.RoundCap)
oDial.setPen(pen)
oDial.valueChanged.connect(changed)
l.addWidget(makeLabel('Other Dial'),2,1)
l.addWidget(oDial,3,1)
# Adding layout to the window
window.setLayout(l)
# Showing the window
window.show()
exit(app.exec())