首页 > 解决方案 > 在 Kivy 中更新 RstDocument

问题描述

我使用 RstDocument 来显示输出文本,我喜欢经常更新 RstDocument 中的文本。但是,更新不起作用

class fi(App)
 def build(self):
    self.title = "TOOL"
    self.root = BoxLayout(orientation="vertical")
    
    self.out2 = BoxLayout(orientation="horizontal")
    self.document = """

TOOLs \n

"""
    self.sh ="""
    
    .. _myreff:
    
    @#$


"""
    self.document += self.sh
    
    self.rst = RstDocument(text=self.document, colors={'paragraph':'ce5c00ff', 'background':'000000ff'},)
    if(Clock.schedule_once(partial(self.rst.goto, 'myreff'), 4)):
        print("build_good")
    self.rst.render()
    self.out2.add_widget(self.rst)
    self.root.add_widget(self.out2)
    return self.root

 def job_process(self, show_text=""""""):
    self.sh ="""
    
    .. _myreff:
    
    @#$


"""

    if(self.sh in self.document):
        time.sleep(2)
        self.document = self.document.replace(self.sh, "")
        print(self.document)
        time.sleep(2)
    self.document = self.document + """ \n """ 
    self.document = self.document + show_text + self.sh
    print(self.document)
    time.sleep(2)
    return()

当一些计算完成后,我调用函数job_process("some text")来更新self.document以打印更新的输出。但它没有更新。我不知道是什么问题。没有警告,没有来自 RstDocument() 的错误谢谢

标签: pythonkivykivy-language

解决方案


推荐阅读