Python Forum
Inherting from different class in PYQT - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Inherting from different class in PYQT (/thread-8164.html)



Inherting from different class in PYQT - zykbee - Feb-08-2018

I want to pull "self.t" from class Third and print the info in Class Fourth where it says "pass." How would I inherit it?
class Third(QWidget):
    def __init__(self, parent=None):
        super(Third, self).__init__()
        self.cp()

    def cp(self):
        for y in App.patientlist:
            if str(y[11]) == self.patnum:
                patselected = y
        self.t  = patselected
        self.bbbb.show()
    


class Fourth(QWidget):
    def __init__(self):
        super(Fourth, self).__init__()
        self.editor()
    def editor(self):
        pass ###I WANT self.t FROM CLASS THIRD PRINTED HERE.



RE: Inherting from different class in PYQT - Larz60+ - Feb-08-2018

in class forth:
local_t = Third.t



RE: Inherting from different class in PYQT - zykbee - Feb-08-2018

That's what I thought, but it keeps saying "Third has no attribute 't'", presumably because it's within a function and not right under Class. Of course, I can do this:
class Third(QWidget):
    t = "WHATEVER"
    def __init__(self, parent=None):
        super(Third, self).__init__()
        self.cp()
 
    def cp(self):
        for y in App.patientlist:
            if str(y[11]) == self.patnum:
                patselected = y
        t = patselected
        self.bbbb.show()
and call Third.T in another class. But it doesn't print the new value created by the function, only the one up top (in this case "WHATEVER")

Nevermind. Got it! Thank you, friend!

Nevermind. Got it! Thank you, friend!


RE: Inherting from different class in PYQT - Larz60+ - Feb-08-2018

That t wasn't there in post #1, what do you expect!