<ToggleButtonWidget>:
orientation: 'vertical'
ToggleButton:
text: 'Male'
group: 'sex'
on_release: print('You have clicked Male Button')
ToggleButton:
text: 'Female'
group: 'sex'
state: 'down'
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.togglebutton import ToggleButton
class ToggleButtonWidget(BoxLayout):
def __init__(self, **kwargs):
super().__init__(**kwargs)
tb = ToggleButton(text='Mixed', group='sex')
self.add_widget(tb)
class ToggleButtonApp(App):
def build(self):
return ToggleButtonWidget()
if __name__ == '__main__':
from kivy.core.window import Window
Window.clearcolor = [.8,.8,.8,1]
ToggleButtonApp().run()
kivy学习完全解析 013 ToggleButton
最新推荐文章于 2022-11-03 22:41:18 发布