更新时间:2022-05-22 15:15:29
如果要在.kv中创建对象,则:
If you are going to create the object in the .kv:
GroupScreen:
groupName:groupName
...
那么就没有必要在.py中声明它.
Then it is not necessary to declare it in the .py.
另一方面,将子项添加到窗口小部件不是立即进行的,因此在这些情况下始终建议使用 Clock
.
On the other hand the addition of children to a widget is not instantaneous so it is always recommended in these cases to use Clock
.
import kivy
kivy.require('1.9.0') # replace with your current kivy version !
from kivy.uix.screenmanager import Screen
from kivy.app import App
from kivy.lang import Builder
from kivy.core.window import Window
from kivy.clock import Clock
Window.size = (500, 230)
class GroupScreen(Screen):
def __init__(self, **kwargs):
super(GroupScreen, self).__init__(**kwargs)
Clock.schedule_once(lambda dt: setattr(self.groupName, 'text', "Test"))
class Group(App):
def build(self):
self.root = Builder.load_file('test.kv')
return self.root
if __name__ == '__main__':
Group().run()
Django South迁移引发错误' module'对象没有属性' SET_NULL'
AttributeError:' super'对象没有属性' __ getattr __'
AttributeError:' NoneType'对象没有属性' text'在python中
使用py2exe编译python产生错误:AttributeError:';GenericRdata';对象没有属性';target';
在 Keras 上使用回调 Tensorboard 时出现 AttributeError:'Model'对象没有属性 'run_eagerly'
django+mysql='DatabaseWrapper'对象没有属性 'Database'错误
HG-Git:AttributeError:' bytes'对象没有属性' encode'
AttributeError:' super'对象没有属性' __ getattr __'在Kivy中将BoxLayout与多个kv文件一起使用时出错