Python 属性错误:';结果页';对象没有属性';查询';

Python 属性错误:';结果页';对象没有属性';查询';,python,user-interface,kivy,Python,User Interface,Kivy,我正在为我的课程创建这个个人助理,并使用KIVY为其制作UI。 我有两个屏幕,其中一个有一个名为query的变量。当我尝试访问另一个屏幕时,它会给出AttributeError:'ResultPage'对象没有属性'query'错误。我尝试了stackoverflow上的所有帮助,但没有一个有效 代码:- class CommandPage(Gridlayout): ... ... def input_button(self, instance): # creating the but

我正在为我的课程创建这个个人助理,并使用KIVY为其制作UI。 我有两个屏幕,其中一个有一个名为
query
的变量。当我尝试访问另一个屏幕时,它会给出
AttributeError:'ResultPage'对象没有属性'query'
错误。我尝试了stackoverflow上的所有帮助,但没有一个有效

代码:-

class CommandPage(Gridlayout):
... 
...
    def input_button(self, instance): # creating the button that when pressed updates the label
        self.query = "You Said {}".format(self.command()) # making the query
        if self.query == "You Said None":
            self.update_info('Please input a command')
        else:
            self.update_info(self.query) # updating the label
            Clock.schedule_once(self.change_screen, 10) 
            #waits for 10 frames and calls the change screen function.
...
class ResultPage(GridLayout):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.cols = 1
        self.testLabel = Label(text=self.query) 
        self.add_widget(self.testLabel)

这是我想从CommandPage访问的查询,并在ResultPage中将其显示为标签。

如果您想要共享属性,可以在App类中定义
query
。然后在python中以
App.get_running_App().query
和kv中以
App.query