kviy TextInput 触发事件
from kivy.uix.widget import Widget from kivy.app import App from kivy.lang import Builder Builder.load_string(""" <WidgetLayoutWidget>: # 加一个白色画布 canvas: Color: rgba:(1,1,1,1) Rectangle: pos:self.pos size:self.size TextInput: text:'c0c.ink' multiline:False pos:400,380 allow_copy:False # 先中后按回车触发事件 on_text_validate:self.pos=[self.x,self.y-5] TextInput: text: 'hello' pos: 100, 180 halign: 'center' background_color: 100, 2, 2, 1 # 文本改变触发事件,改一个字也算 on_text: self.pos=[self.x+5, self.y] TextInput: text:'first' pos:400,180 readonly:True # 双击触发 on_double_tap:self.pos=[self.x-5,self.y] # 三击触发 on_triple_tap:self.pos = [self.x,self.y+5] # 四指触摸 on_quad_touch:self.pos=[400,180] """) class WidgetLayoutWidget(Widget): def __init__(self, **kwargs): super().__init__(**kwargs) class GotoApp(App): def build(self): return WidgetLayoutWidget() if __name__ == '__main__': GotoApp().run()