Python Forum
[PyQt] Widget Guidance for GUI layout
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] Widget Guidance for GUI layout
#1
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:
   

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
Reply
#2
If you really want to learn, don't use Qt Designer

Layout Management
PyQt6 Layouts
Layout management in PyQt6
njminchin likes this post
Reply
#3
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.
njminchin likes this post
Reply
#4
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 :)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pyqt5 layout Nickd12 8 6,275 Jan-18-2021, 09:09 AM
Last Post: Axel_Erfurt
  Python GUI layout off between different OS shift838 5 5,046 Jan-02-2019, 02:53 AM
Last Post: shift838
  [Tkinter] grid layout neech 8 20,495 Oct-14-2016, 07:06 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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