knobs module takes an attribute 'values'
This commit is contained in:
4
knob.py
4
knob.py
@ -4,13 +4,13 @@ from colors import *
|
|||||||
|
|
||||||
class Knob:
|
class Knob:
|
||||||
|
|
||||||
def __init__(self, group, name, radius, position):
|
def __init__(self, group, name, radius, position, value = 0):
|
||||||
self.group = group
|
self.group = group
|
||||||
self.name = name
|
self.name = name
|
||||||
self.color = color_primary
|
self.color = color_primary
|
||||||
self.radius = radius
|
self.radius = radius
|
||||||
self.position = position
|
self.position = position
|
||||||
self.value = 0
|
self.value = value
|
||||||
self.focused = False
|
self.focused = False
|
||||||
|
|
||||||
def set_value(self, value):
|
def set_value(self, value):
|
||||||
|
|||||||
8
knobs.py
8
knobs.py
@ -5,7 +5,7 @@ from knob import *
|
|||||||
|
|
||||||
class Knobs:
|
class Knobs:
|
||||||
|
|
||||||
def __init__(self, gui):
|
def __init__(self, gui, values):
|
||||||
|
|
||||||
self.gui = gui
|
self.gui = gui
|
||||||
|
|
||||||
@ -20,6 +20,8 @@ class Knobs:
|
|||||||
'Gain'
|
'Gain'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
self.values = values
|
||||||
|
|
||||||
# Create and position the knobs
|
# Create and position the knobs
|
||||||
self.knobs_radius = self.gui.screenW / 25
|
self.knobs_radius = self.gui.screenW / 25
|
||||||
knobs_spacing = self.knobs_radius * 2
|
knobs_spacing = self.knobs_radius * 2
|
||||||
@ -29,7 +31,7 @@ class Knobs:
|
|||||||
y = knobs_y
|
y = knobs_y
|
||||||
self.knobs = []
|
self.knobs = []
|
||||||
for i in range(8):
|
for i in range(8):
|
||||||
self.knobs.append(Knob(self, knob_names[i], self.knobs_radius, (x, y)))
|
self.knobs.append(Knob(self, knob_names[i], self.knobs_radius, (x, y), values[i]))
|
||||||
y += self.knobs_radius + knobs_spacing
|
y += self.knobs_radius + knobs_spacing
|
||||||
if i == 3 or i == 6:
|
if i == 3 or i == 6:
|
||||||
x += self.knobs_radius + knobs_spacing
|
x += self.knobs_radius + knobs_spacing
|
||||||
@ -37,7 +39,7 @@ class Knobs:
|
|||||||
|
|
||||||
def display_label(self, knob):
|
def display_label(self, knob):
|
||||||
label_fx_name = font_helvetica.render(knob.name, False, color_primary_light)
|
label_fx_name = font_helvetica.render(knob.name, False, color_primary_light)
|
||||||
label_fx_value = font_helvetica.render('[ ' + str(knob.value) + '% ]',
|
label_fx_value = font_helvetica.render('[ ' + str(knob.value*100) + '% ]',
|
||||||
False, color_primary_light)
|
False, color_primary_light)
|
||||||
|
|
||||||
label_x = self.gui.screenW - label_fx_name.get_width() - 20
|
label_x = self.gui.screenW - label_fx_name.get_width() - 20
|
||||||
|
|||||||
2
main.py
2
main.py
@ -35,7 +35,7 @@ class GuiMain:
|
|||||||
|
|
||||||
self.fx_mode_buttons[0].focused = True
|
self.fx_mode_buttons[0].focused = True
|
||||||
|
|
||||||
self.knobs = Knobs(self)
|
self.knobs = Knobs(self, [0, 0.1, 0.4, 0.9, 0.2, 0.5, 0.8, 0.3])
|
||||||
|
|
||||||
self.clock = pygame.time.Clock()
|
self.clock = pygame.time.Clock()
|
||||||
self.running = True
|
self.running = True
|
||||||
|
|||||||
Reference in New Issue
Block a user