Hi there,
could someone please explain why with this bit of code I have copied, there is a second init statement in the init definition:
I'm really struggling with OOP, and have been for about 6 months (currently I am being paid to learn to program, so when I say 6 months, that's 8 hours a day for six months) to the point I can only copy code, I can't write my own, is this normal?
could someone please explain why with this bit of code I have copied, there is a second init statement in the init definition:
#!/usr/bin/python3 import sys from PyQt4 improt QtGui, QtCore class Window(QtGui.QMainWindow): def __init___(self, parent=None): QtGui.QWidget.__init__(self, parent) # <-- this line of code, what does it do??? self.setGeometry(0, 0, 1920, 1080) self.home() def home(self): self.lbl = QtGui.QLabel("Hello World!", self) self.lbl.setGeometry(QtCore.QRect(800, 30, 1161, 101)) self.show() if __name__ == "__main__": app = QtGui.QApplication(sys.argv) main_window = Window() sys.exit(app.exec_))So this seems to be the complete minimum code required in order to get a window and a label using object oriented programming. I also don't understand why I am having to call the home method from the init method, that doesn't make sense either, but if I take that out, then the code runs without error, but there is no window, and no way to stop the script either. If someone could help explain this that would really help.
I'm really struggling with OOP, and have been for about 6 months (currently I am being paid to learn to program, so when I say 6 months, that's 8 hours a day for six months) to the point I can only copy code, I can't write my own, is this normal?