【问题标题】:Printing sys.stdout console on a "textBox" from customtkinter从 customtkinter 在 \"textBox\" 上打印 sys.stdout 控制台
【发布时间】:2023-02-13 18:43:59
【问题描述】:

早上好, 我想在 customtkinter 对象的文本框中打印控制台输出。代码来自这里:Github from TomSchimansky

我怎样才能用控制台的输出替换文本“Lorem Ipsum ...等”。

【问题讨论】:

    标签: python-3.x tkinter customtkinter


    【解决方案1】:

    我得到了解决方案:

    包括:

    class StdoutRedirector(object):
        def __init__(self,text_widget):
            self.text_space = text_widget
    
        def write(self,string):
            self.text_space.insert('end', string)
            self.text_space.see('end')
    

    并致电文本框像那样:

    sys.stdout = StdoutRedirector(self.textbox)
    

    现在我正在寻找对 stdin xd 做同样的事情

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-13
      • 2013-06-15
      • 1970-01-01
      • 2016-03-31
      • 2016-11-12
      • 1970-01-01
      • 1970-01-01
      • 2022-01-08
      相关资源
      最近更新 更多