파이썬[Python]: kivy - bind 함수 with Button_0002
kivy.event 모듈 - EventDispatcher 클래스 - bind 함수(functions)
/// 설명
이벤트 타입이나 속성을 callback 함수에 연결합니다.
Event: on_press, on_release, state
사용: BoxLayout.remove_widget()
참고: event 모듈 목록
※ 형식
bind(**kwargs)
reference
https://kivy.org/doc/stable/api-kivy.event.html
Event: on_press, on_release, state
사용: BoxLayout.remove_widget()
참고: 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.button import Button Window.clearcolor = (.6, 1, .8, 1) Window.size = (563, 1001) Window.top, Window.left = 30, 800 class FantasticApp(App): def bt_creating(self, bt_instance): self.bl.add_widget(Button(text='Cancel', on_press=self.bt_removing)) def bt_removing(self, bt_instance): self.bl.remove_widget(bt_instance) def build(self): bt_top = Button(text='Creating Button', size_hint=(1, None), height=200) bt_top.bind(on_press=self.bt_creating) self.bl = bl = BoxLayout(orientation='vertical') bl_root = BoxLayout(orientation='vertical') bl_root.add_widget(bt_top) bl_root.add_widget(bl) return bl_root FantasticApp().run() | cs |
/// 출력
* 실행환경: Microsoft Windows 10 Homes
* 인터프리터: 파이썬(Python 3.9)
– 당신을 응원합니다. –
contvoYpi-fu Kathy Smith link
답글삭제https://colab.research.google.com/drive/150xUd7q_v0GOUk-kbd5q3kTLGFV-xqDZ
link
click
midpugesttur
viamerfratno Robert Ritchie Everest
답글삭제Everest
Bandicam
tlinbucktina
consgravOcons-mi Sam Taylor Best
답글삭제This is there
moordmodasam