'How can I use the member variable in class when using QThread?

I'm testing the QThread with pyqt.

Below is the my test code.

from PyQt5.QtCore import QThread, pyqtSignal


class TestThread(QThread):
    set_signal = pyqtSignal(object)

    def __int__(self):
        super().__init__()
        self.int_var = 0
        self.bool_var = False
        self.list_var = list()

    def run(self):
        pass

    def get_int_var(self):
        return self.int_var

    def get_bool_var(self):
        return self.bool_var

    def get_list_var(self):
        return self.list_var

    def stop(self):
        self.quit()
        self.wait()

if __name__ == "__main__":
    test_thread = TestThread()

    print(test_thread.get_int_var())
    print(test_thread.get_bool_var())
    print(test_thread.get_list_var())

I'd like to use member variable in class.

But when I call the get function, error occurs and error message is follows.

ErrorMessage "AttributeError: 'TestThread' object has no attribute 'int_var'"



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source