Okay first
This
1) You are not using Command Line arguments in this program
2) If you were using Command Line arguments those are better handled by argparser library
So the above should be
Passing the parent in this
Next you need to understand what the QScrollArea functionality does -- which I cannot tell you as I have not used it yet. However I can tell you this it shuts off the dynamic resizing of QWidget which makes sense if a Box can resize you do not need scroll bars. So the question is do you want a dynamic box for static box with scroll bars? As you cannot have both. This is not to say you cannot code a static box to seem semi-dynamic but that really opens a whole can of worms that I personally would not want to mess with.
So here is your cleaned up program and I want to applaud you for not using
Oh and I added a few label and a lineedit so I could see what was occurring a bit better
sys.exit(app.exec_())
this is PyQt4 and this is app.exec()
is PyQt5 This
app = QApplication(sys.argv)
is basically wrong for 2 reasons1) You are not using Command Line arguments in this program
2) If you were using Command Line arguments those are better handled by argparser library
So the above should be
MainEventThread = QApplication([])
also I changed it from app to MainEventThread because that is what it represents and it is always best to be reminded of that and to tell others that is what it is.Passing the parent in this
QWidget.__init__(self, parent)
especially since your parent = None
but regardless understand what you are doing and why or do not do it. The fact that you do not seem to be using it at all implies to me that you do not know why you are even doing beyond the fact that the other guy jumped out of the plane without a parachute so you did tooNext you need to understand what the QScrollArea functionality does -- which I cannot tell you as I have not used it yet. However I can tell you this it shuts off the dynamic resizing of QWidget which makes sense if a Box can resize you do not need scroll bars. So the question is do you want a dynamic box for static box with scroll bars? As you cannot have both. This is not to say you cannot code a static box to seem semi-dynamic but that really opens a whole can of worms that I personally would not want to mess with.
So here is your cleaned up program and I want to applaud you for not using
super( )
that was one bullet you dodge ;-)Oh and I added a few label and a lineedit so I could see what was occurring a bit better
USE_PYSIDE2 = False if USE_PYSIDE2: from PySide2.QtCore import Qt, QSize, Slot from PySide2.QtGui import QColor, QPainter, QBrush from PySide2.QtWidgets import QApplication, QWidget, QHBoxLayout from PySide2.QtWidgets import QLineEdit, QLabel else: from PyQt5.QtCore import pyqtSlot as Slot from PyQt5.QtCore import Qt, QSize from PyQt5.QtGui import QColor, QPainter, QBrush from PyQt5.QtWidgets import QApplication, QWidget, QHBoxLayout from PyQt5.QtWidgets import QLineEdit, QLabel, QFrame, QSplitter class MyWidget(QWidget): def __init__(self, parent): QWidget.__init__(self) self.color = QColor(255, 255, 255) self.Parent = parent self.lneHere = QLineEdit('Over Here Is Better') layout = QHBoxLayout() layout.addWidget(self.lneHere) self.setLayout(layout) def paintEvent(self, event): painter = QPainter() painter.begin(self) painter.fillRect(event.rect(), QBrush(self.color)) painter.end() def sizeHint(self): return QSize(250, 300) class Window(QWidget): def __init__(self): QWidget.__init__(self) self.lblHere = QLabel('Here We Are') FrmBox = QHBoxLayout() FrmBox.addWidget(self.lblHere) self.mywidget = MyWidget(self) # custom widget for left pane # scroll = QScrollArea() # scroll.setWidget(self.mywidget) self.frmRite = QFrame() # dummy QFrame for right pane self.frmRite.setFrameShape(QFrame.StyledPanel) self.frmRite.setLayout(FrmBox) splitter = QSplitter(Qt.Horizontal) splitter.addWidget(self.mywidget) splitter.addWidget(self.frmRite) layout = QHBoxLayout() layout.addWidget(splitter) self.setLayout(layout) if __name__ == '__main__': MainEventThread = QApplication([]) MainApp = Window() MainApp.show() MainEventThread.exec()