Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 从另一个类函数更新kivy textinput_Python_Kivy - Fatal编程技术网

Python 从另一个类函数更新kivy textinput

Python 从另一个类函数更新kivy textinput,python,kivy,Python,Kivy,我有一个Kivy文件选择器,当选择一个文件时,我想用文件名更新文本输入 文本输入在另一个Screen类Screentwo中,该函数从on submit函数运行,但文本框不会更新,除非我从Screentwo运行它 main.py def on_submit(self, selected, touch=None): import os global fp global filesize global flsize global file glob

我有一个Kivy文件选择器,当选择一个文件时,我想用文件名更新文本输入

文本输入在另一个Screen类Screentwo中,该函数从on submit函数运行,但文本框不会更新,除非我从Screentwo运行它

main.py

def on_submit(self, selected, touch=None):



    import os
    global fp
    global filesize
    global flsize
    global file
    global fileread
    global selection
    global selected1
    global filename


    selection = self.selection
    selected1 = selected


    fz = ''.join(selection)
    flsize = Path(fz).stat().st_size
    filesize = str(flsize)
    fp = os.path.join(fz)  # (f"'{fz}'")


    fileread = open(fz, 'rb')

    popup.dismiss()

    print(flsize)
    filenam = str(selected)
    filename1 = os.path.basename(filenam)
    filename = filename1[:-2]

    print(filename)

    ScreenTwo().update_file()
第二类屏幕(屏幕):

ScreenTwo().update\u file()
创建
ScreenTwo
的新实例,并调用该新实例的
update\u file()
方法。不幸的是,这个新实例不是GUI中的实例。您需要使用GUI中的
ScreenTwo
实例的引用,并在该实例上调用
update\u file()
。如果没有看到更多的代码,我无法确定如何访问该实例。
def __init__(self, **kwargs):
    super(ScreenTwo, self).__init__(**kwargs)


global lread
files_input = ObjectProperty
rv2 = ObjectProperty()
global filesize
global fp
global fsize
global flsize
global filename
mc = MyFileChooser()




def update_file(self):

    global files_input

    self.ids.files_input.text = str(filename)