python - 如果你写了多个,为什么在 kivy 中忽略 on_pre_enter 或 on_enter
问题描述
进口:
from kivy.app import App
from kivy.lang import Builder
from kivy.properties import StringProperty
from kivy.uix.textinput import TextInput
kv = '''
BoxLayout:
orientation: 'vertical'
TextInput:
id: t1
TextInput:
id: t2
TextInput:
id: t3
TextInput:
id: t4
'''
MyApp
班级:
class MyApp(App):
text = StringProperty('-.text')
def build(self):
return Builder.load_string(kv)
def on_pre_enter(self):
self.ids['t1'].text = "textinput1"
def on_enter(self):
self.ids['t2'].text = "textinput2"
def on_pre_enter(self):
self.ids['t3'].text = "textinput3"
def on_enter(self):
self.ids['t4'].text = "textinput4"
if __name__ == '__main__':
MyApp().run()
解决方案
这与 Kivy 无关,这只是 Python 的工作原理,编写第二个具有相同名称的方法替换之前的定义。
推荐阅读
- vb.net - 使用 oAuth2 重新连接 ews 流连接
- python - Discord.py: has_permissons() 不工作——错误不是 MissingPermissions 的一个实例
- java - 未指定获取目标主机
- arrays - 如何按键对数组中的哈希进行排序?
- aframe - Uncaught TypeError using A-Frame 1.0.4 + A-Frame Extras nav-mesh 和移动控制
- javascript - 传递 FlatList 标题
- javascript - 如何使javascript中的setTimeout适用于定义的函数?
- selenium - 输出类型
在 Webdriver 中没有得到解决 - php - 在 PHP SOAP SERVER 中验证 WS-security 密码摘要
- c# - WCF - 内存流未正确发送文件\流