Reputation: 2065
I'm trying to append a simple string to a list in and object. But I'm guessing the self keyword is interfereing with the pyqt window?
How can I work around this?
class Window(qt.QMainWindow):
def __init__(self, parent=None):
super(Window, self).__init__(parent)
self.CreateWidgets()
self.q = Qfetch.DataFetch()
def CreateWidgets(self):
toPortfolio = "str"
self.q.Portfolio.append(toPortfolio) #<---- This cause the error
q class
class DataFetch():
def __init__(self):
self.Portfolio = []
Upvotes: 0
Views: 2444
Reputation: 417
You are trying to fetch the member q before it is initialized. Call Qfetch.DataFetch() before self.CreateWidgets().
This code for the constructor should work:
class Window(qt.QMainWindow):
def __init__(self, parent=None):
super(Window, self).__init__(parent)
self.q = Qfetch.DataFetch()
self.CreateWidgets()
Upvotes: 5