파이썬[Python]: kivy - ButtonBehavior 클래스 - kv
kivy.uix.behaviors.button 모듈 - ButtonBehavior 클래스(class)
/// 설명
Button의 행동을 활용할 수 있는 클래스입니다. 다른 클래스와 같이 사용하셔도 됩니다.
참고: uix 모듈 목록
※ 형식
ButtonBehavior(**kwargs)
reference
https://kivy.org/doc/stable/api-kivy.uix.behaviors.button.html
참고: uix 모듈 목록
※ 형식
ButtonBehavior(**kwargs)
reference
https://kivy.org/doc/stable/api-kivy.uix.behaviors.button.html
/// 예제
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 | import kivy kivy.require('2.0.0') from kivy.app import App from kivy.core.window import Window from kivy.uix.boxlayout import BoxLayout from kivy.uix.behaviors import ButtonBehavior from kivy.uix.label import Label from kivy.lang import Builder Window.clearcolor = (.6, 1, .8, 1) Window.size = (563, 1001) Window.top, Window.left = 30, 800 Builder.load_string(''' <TestButton@ButtonBehavior+BoxLayout> Label: id: id_lb text: 'GUI Programming' color: 'black' ''') class TestButton(ButtonBehavior, BoxLayout): def on_press(self): lb = self.ids.id_lb lb.text = 'It is interesting\n' +\ 'min_state_time: ' + str(self.min_state_time) + '\n' +\ 'state: ' + str(self.state) def on_release(self): lb = self.ids.id_lb lb.text = 'GUI Programming\n' +\ 'last_touch(pos): ' + str(self.last_touch.pos) + '\n' +\ 'state: ' + str(self.state) class FantasticApp(App): def build(self): return TestButton() FantasticApp().run() | cs |
/// 출력
* 실행환경: Microsoft Windows 10 Homes
* 인터프리터: 파이썬(Python 3.9)
– 당신을 응원합니다. –
댓글
댓글 쓰기