파이썬[Python]: kivy - bind 함수 with Slider_0002
kivy.event 모듈 - EventDispatcher 클래스 - bind 함수(functions)
/// 설명
이벤트 타입이나 속성을 callback 함수에 연결합니다.
Event: on_touch_down(touch), on_touch_move(touch), on_touch_up(touch)
Attribute: value
참고: event 모듈 목록
※ 형식
bind(**kwargs)
reference
https://kivy.org/doc/stable/api-kivy.event.html
Event: on_touch_down(touch), on_touch_move(touch), on_touch_up(touch)
Attribute: value
참고: event 모듈 목록
※ 형식
bind(**kwargs)
reference
https://kivy.org/doc/stable/api-kivy.event.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  | 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.label import Label from kivy.uix.slider import Slider from functools import partial Window.clearcolor = (.5, .0, .5, .1) Window.size = (563, 1001) Window.top = 30 Window.left = 800 class TestApp(App):     def sd_move(self, lb, slider_instance, MouseMotionEvent):         print(MouseMotionEvent)         original_size = 5         lb.font_size = slider_instance.value * original_size     def build(self):         lb = Label(text='A', font_size='5dp')         sd = Slider(size_hint=(1, None), height=100,                     min=1, max=101, value=1)         sd.bind(on_touch_move=partial(self.sd_move, lb))         bl = BoxLayout(orientation='vertical')         bl.add_widget(lb)         bl.add_widget(sd)         return bl TestApp().run()  | cs | 
/// 출력
* 실행환경: Microsoft Windows 10 Homes
* 인터프리터: 파이썬(Python 3.9)
– 당신을 응원합니다. –
댓글
댓글 쓰기