Python Forum

Full Version: Widget Guidance for GUI layout
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a GUI layout that I want to implement in PyQt6, but I'm a complete Qt n00b and need some guidance.
This is the layout I want to implement:
[attachment=3074]

The tab container contains various functions that can be run via the buttons. Each function has an info icon. Clicking on an info icon will open a help panel to the right which can be closed. Some functions have a "copy" icon which will copy some template text into the clipboard to paste e.g. into Excel.
Functions can be grouped (this could use a Qt Group Box widget).

The help panel to the right will contain information about the selected function, including:
- a description of what it does
- examples of how it can be used, with screenshots

I'm expecting the help information to be read from files with a defined filename format.

The bottom panel is an output console which will output stuff to the user after they've clicked a function button. Things like info and errors.

My questions are:
  1. How should I implement the layout of the different panels?
  2. How should I create the buttons and icons? Should these be created as a custom widget?
  3. Can I make the output console collapsable?
  4. Should I be using Qt Designer to create this layout, or just Python code it up?

Thanks!

Nick
If you really want to learn, don't use Qt Designer

Layout Management
PyQt6 Layouts
Layout management in PyQt6
I would write a custom widget since you are reusing the same pattern multiple times.

QT has a tab widget for the Tags, Views, Text, Misc tabs. A simple example:
https://www.pythontutorial.net/pyqt/pyqt...8python%29

I don't think there is a Qt collapsable console, but it would be easy to implement. from standard components. There are examples online like this:
https://github.com/MichaelVoelkel/qt-col...le-section

I agree with @Axel_Erfurt about using Designer. I think it a waste of time. You'll spend a lot of time up front learning how to use designer, so that slows you down at the start. When you eventually know enough to be efficient using designer it may save you some time, but you soon run into Designer's limitations. Eventually you give up on Designer because it hiders more than helps, and all the code you wrote using designer isn't really reusable.
Thanks for the replies, I'm going the non-Qt Designer route.

I'm trying to build my widget, and not sure how to lay out the button with the two icons. I thought I could use a QHBoxLayout or a QGridLayout, but I want the size of the icons to be 24px square and the button to grow/shrink to the remaining width of the widget. Can I do that?

I've got this for the widget so far:

class IgnitionFunctionButton(QtWidgets.QWidget):
	def __init__(self, label: str, fn: str, template: str, *args, **kwargs):
		super(IgnitionFunctionButton, self).__init__(*args, **kwargs)

		layout = QGridLayout()

		fn_button = QPushButton(label)

		info_icon = QtSvgWidgets.QSvgWidget('../img/ic_info_blue_24px.svg')
		info_icon.setGeometry(24, 24)

		layout.addWidget(fn_button)
		layout.addWidget(info_icon)

		self.setLayout(layout)
Edit: Gemini helped, giving me setFixedSize :)