Python Forum
[PyQt] Is there a better way of laying out my GUI?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] Is there a better way of laying out my GUI?
#4
Okay first off if you do this:

from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
You do not need this:

from PyQt5 import QtWidgets
from PyQt5 import QtCore
from PyQt5 import QtGui
And the latter does not work well (if at all) within pyqt5

Next you want to display it like a Window then you need to use one as follows:

class Window(QMainWindow):
    def __init__(self, DatabaseFile, parent=None):
        super(Window, self).__init__(parent)

        self.setCentralWidget(CenterPane(self))

class CenterPane(QWidget):
    def __init__(self, parent):
        QWidget.__init__(self)

        self.Panel1 = CreatePanel1()
        self.Panel2 = CreatePanel2()

        CenterPane = QSplitter(Qt.Horizontal, self)
        CenterPane.addWidget(self.Panel1)
        CenterPane.addWidget(self.Panel2)
        CenterPane.setSizes([100,200])

        hbox = QHBoxLayout(self)
        hbox.addWidget(CenterPane)

        self.setLayout(hbox)
Note: I am fairly new to pyqt5 so there might be a better way to implement the above but so far this has worked for me and perhaps you can glean something form it that will help you. Also the above is an extremely small snippet just to show you how to layout the center pane of a window as I found that a bit of an issue initially myself
Reply


Messages In This Thread
RE: Is there a better way of laying out my GUI? - by Denni - May-24-2019, 08:27 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020