lableSlider1.kv文件<LabelSlider>: orientation:‘vertical‘ BoxLayout: MyLabelSlider: name: ‘Slider1‘ onValue: root.onMySlider id:mySlider Label: text:str(mySlider.ids.slider.value) BoxLayout: orientation:‘vertical‘ MyLabelSlider: name: ‘slider2‘ MyLabelSlider: name: ‘slider3‘ MyLabelSlider: name: ‘slider4‘ MyLabelSlider: name: ‘slider5‘ <[email protected]BoxLayout>: name: ‘Slider‘ onValue: lambda value: print(‘MyLabelSlider no onValue function:‘,value) Label: text:root.name Slider: id:slider on_value:root.onValue(self.value)labelSlider.py文件from kivy.app import Appfrom kivy.uix.boxlayout import BoxLayout class LabelSlider(BoxLayout): def onMySlider(self, value): print(value) pass class LabelSlider1App(App): def build(self): return LabelSlider() if __name__ == ‘__main__‘: LabelSlider1App().run()
时间: 2024-10-12 16:13:02