kivy/python中更改屏幕的倒计时/计时器

kivy/python中更改屏幕的倒计时/计时器,python,timer,kivy,screen,Python,Timer,Kivy,Screen,我想做的是在第一个屏幕上显示一个图像2秒钟,然后切换到另一个屏幕 我尝试使用kivy的时钟,我认为它工作正常,但我收到了错误: self.parent.current = "tela_01" AttributeError: 'float' object has no attribute 'parent' 我想我写错了我下一步想进入屏幕的部分。我看到了一大堆关于屏幕管理器的答案、视频和教程,但都不起作用,我不知道我做错了什么。可能是因为我对这种语言和学习还很陌生,但似乎很简单 为了测试我是否可

我想做的是在第一个屏幕上显示一个图像2秒钟,然后切换到另一个屏幕

我尝试使用kivy的时钟,我认为它工作正常,但我收到了错误:

self.parent.current = "tela_01" 
AttributeError: 'float' object has no attribute 'parent'
我想我写错了我下一步想进入屏幕的部分。我看到了一大堆关于屏幕管理器的答案、视频和教程,但都不起作用,我不知道我做错了什么。可能是因为我对这种语言和学习还很陌生,但似乎很简单

为了测试我是否可以进入所有的屏幕,我为有问题的屏幕创建了一个按钮(代码中有注释),但是我想要一个计时器/倒计时之类的东西来改变屏幕

白痴

.kv

#:导入Clock kivy.Clock.Clock
Gerenciador_Telas:
影视处:
影视处01:
影视处02:
影视处03:
影视处04:
影视处05:
名称:“影视处00”
盒子布局:
在以下情况之前:
颜色:
rgba:1,1,1,1
矩形:
pos:self.pos
大小:self.size
图片:
资料来源:“inicial.png”
#浮动布局:
#
#按钮:
#案文:“普罗西莫”
#背景_正常:“
#背景颜色:0,0,0,1
#大小提示:.2,.1
#位置:32550
#发布时:
#app.root.current=“tela_01”
#root.manager.transition.direction=“左”
名称:“影视处01”
网格布局:
科尔斯:1
尺寸:根.宽度,根.高度
填充:200
间距:20
标签:
正文:“第2.0期贷款协议”
按钮:
文本:“Novo”
发布时:
app.root.current=“tela_02”
root.manager.transition.direction=“左”
按钮:
正文:“连续”
按钮:
案文:“重新分配”
发布时:
app.root.current=“tela_05”
root.manager.transition.direction=“左”
名称:“影视处02”
e1n1:e1n1
e1n2:e1n2
e2n1:e2n1
e2n2:e2n2
网格布局:
科尔斯:1
尺寸:根.宽度,根.高度
填充:200,50,200,50
间距:10
标签:
正文:“设备01”
文本输入:
多行:False
id:e1n1
文本输入:
多行:False
id:e1n2
标签:
正文:“设备02”
文本输入:
多行:False
id:e2n1
文本输入:
多行:False
编号:e2n2
按钮:
文本:“Prosseguir”
按下:root.button()
发布时:
app.root.current=“tela_01”如果e1n1.text和e1n2.text以及e2n1.text和e2n2.text!=“其他”tela_03
root.manager.transition.direction=“右”
名称:“影视处03”
名称:“影视处04”
名称:“影视处05”
主持人安排:
填充:100
主播x:“中心”
主播:“顶部”
标签:
文本大小:self.width,无
文本:str("第11批圣约翰分发给第11批圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣约翰圣这是一份有利于核实利益的《买办宪章》。这是一份《买办宪章》,是一份《买办宪章》,是一份《买办宪章》,是一份《买办宣言》,是一份《买办宪章》,是一份《买办宪章》,是一份《买办宪章》,是一份《买办宪章》,是一份《买办宪章》,是一份《买办宪章》,是一份《买办宪章》,是一份《买办宣言》,是一份《买办宣言》一个台地,你可以坐在一辆新的慢跑车上,一辆三辆普雷托、nãoépossível compá-la、pois essas cartas tranca mesa.aós o início de cada rodada、o jogador poderábaixar uma combinaço de cartas,sendo no mínimo
浮动布局:
大小提示:.2,.1
位置:200、50
按钮:
文本:“菜单”
发布时:
app.root.current=“tela_01”
root.manager.transition.direction=“右”
提前感谢您的帮助

class Tela_00(Screen):
#self.parent is the equivalent to app.root
    def switch(self):
        self.parent.current = "tela_01"

    Clock.schedule_once(switch, 2)
由于您在任何方法或函数之外编写了一次
Clock.schedule\u
,因此在创建类时会立即执行。它会自动将一个参数传递给
switch
,一个表示自调度以来的时间的浮点数。您已将该参数命名为
self
。因此,
self.parent
对于这就是你看到的原因

您需要在应用程序控制流中进行时钟调度,调度类的某个实例的
开关
方法

由于您在任何方法或函数之外编写了一次
Clock.schedule\u
,因此在创建类时会立即执行。它会自动将一个参数传递给
switch
,一个表示自调度以来的时间的浮点数。您已将该参数命名为
self
。因此,
self.parent
对于这就是你看到的原因


您需要在应用程序控制流中执行时钟调度,调度类的某个实例的
开关
方法。

您可以使用
on\u enter
事件,通过向
Tela\u 00
类添加
on\u enter()
方法来启动
时钟
计时器:

class Tela_00(Screen):
#self.parent is the equivalent to app.root
    def switch(self, *args):
        self.parent.current = "tela_01"

    def on_enter(self, *args):
        # called when this Screen is displayed
        Clock.schedule_once(self.switch, 2)

通过在
Tela\u 00
类中添加
on\u enter()
方法,您可以使用
on\u enter
事件启动
Clock
计时器:

class Tela_00(Screen):
#self.parent is the equivalent to app.root
    def switch(self, *args):
        self.parent.current = "tela_01"

    def on_enter(self, *args):
        # called when this Screen is displayed
        Clock.schedule_once(self.switch, 2)

谢谢你的解释。我做了缩进修正,但仍然不起作用。错误消失了,但屏幕在2秒钟后没有改变。谢谢你的解释
class Tela_00(Screen):
#self.parent is the equivalent to app.root
    def switch(self, *args):
        self.parent.current = "tela_01"

    def on_enter(self, *args):
        # called when this Screen is displayed
        Clock.schedule_once(self.switch, 2)