Open tomdertech opened 7 years ago
This works for me:
Knob:
min: 0
max: 100
size: 100, 100
value: 0
show_marker: False
knobimg_source: "img/knob_metal.png"
Label:
text: "{}".format(int(self.parent.value))
center: self.parent.center
font_size: 20
color: 0.1, 0.1, 0.1, 1
from kivy.app import App from kivy.uix.gridlayout import GridLayout from kivy.lang import Builder from kivy.garden.knob import Knob from kivy.properties import StringProperty, NumericProperty
class KnobWithLabel(Knob): label_text = StringProperty("") voltage = NumericProperty(0)
def __init__(self, **kwargs):
super(KnobWithLabel, self).__init__(**kwargs)
self.bind(value=self.update_label_text)
self.update_label_text()
def update_label_text(self, *args):
voltage = round(self.value * 5 / 360, 2)
self.voltage = voltage
self.label_text = f"{voltage}V"
KV = '''
The previous code convert the Label 0-360º to 0-5Vdc. Use as you wish.
Since
show_label
has been removed, please could someone provide an example of how to overlay alabel
to show the value? I cannot figure it out - Thank you.