Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.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 3.x Python:如何从GTK+;中的另一个类实例访问属性;类实例_Python 3.x_Multithreading_Gtk3_Pygtk - Fatal编程技术网

Python 3.x Python:如何从GTK+;中的另一个类实例访问属性;类实例

Python 3.x Python:如何从GTK+;中的另一个类实例访问属性;类实例,python-3.x,multithreading,gtk3,pygtk,Python 3.x,Multithreading,Gtk3,Pygtk,下面是一个MWE——当然它还不起作用除外:-) 如何使gtk标签从流式处理类持续更改(更新)为值“count” 我明白,这可以在没有两个独立类的情况下完成,但实际上流式类将读取串行数据,我希望将其与gtk循环分开 我知道类似的问题,但这些问题与GTK的类实例无关 import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk import threading class mainWindow(Gtk.Windo

下面是一个MWE——当然它还不起作用除外:-)

如何使gtk标签从流式处理类持续更改(更新)为值“count”

我明白,这可以在没有两个独立类的情况下完成,但实际上流式类将读取串行数据,我希望将其与gtk循环分开

我知道类似的问题,但这些问题与GTK的类实例无关

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
import threading


class mainWindow(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__(self, title="Welcome to GNOME")
        self.set_default_size(800, 600)

        label = Gtk.Label("Hello World")
        self.add(label)
        self.show_all()
    
class streaming():
    def __init__(self):
        
        self.count = 0
        
        thread = threading.Thread(target=self.stream)
        thread.daemon = True
        thread.start()
    
    def stream(self):
        while True: # This runs/loops in a separate thread to GUI
            self.count = self.count + 1
            print(self.count)


if __name__ == "__main__":
    mon = streaming()
    app = mainWindow()
    Gtk.main()