Как сделать всплывающее окно с информацией "О программе"?

Есть приложение, надо сделать так, чтобы при нажатии на эту иконку открывалось новое окошко с информацией "О программе".

Скриншот приложения


main.py

import sys
from PySide6.QtGui import QKeySequence, QShortcut, QPalette, QAction
from PySide6.QtWidgets import QApplication, QMainWindow, QMessageBox, QMenuBar, QMenu
from design import Ui_root

class MainWindow(QMainWindow, Ui_root):
 def __init__(self):
    super().__init__()
    self.setupUi(self)

    self.btnSummer.clicked.connect(self.funcSummer)
    self.outSummer.show()

    self.btnWinter.clicked.connect(self.funcWinter)
    self.outWinter.show()

    self.createMenuBar()
    self.createActions()

 def createMenuBar(self):

    self.menuinfo = QMenu(self.menuBar)
    self.menuinfo.setObjectName(u"menuinfo")

 def createActions(self):

    self.newAction = QAction(self)
    self.newAction.setText("info")

if __name__ == "__main__":
app = QApplication(sys.argv)
w = MainWindow()
w.show()
sys.exit(app.exec())

design.py

from PySide6.QtCore import (QCoreApplication, QMetaObject, QRect, QSize, Qt)
from PySide6.QtGui import (QCursor, QIcon, QShortcut)
from PySide6.QtWidgets import (QLabel, QLineEdit, QMenu, QMenuBar, QPushButton, 
QTabWidget, QWidget)

import files_rc

class Ui_root(object):
    def setupUi(self, root):
        if not root.objectName():
            root.setObjectName(u"root")
        root.resize(560, 440)
        root.setMinimumSize(QSize(560, 460))
        root.setMaximumSize(QSize(560, 460))

    self.menuBar = QMenuBar(root)
    self.menuBar.setObjectName(u"menuBar")
    self.menuBar.setStyleSheet(u"background-color: rgb(240, 240, 240);")
    self.menuBar.setGeometry(QRect(0, 0, 560, 22))
    self.menuBar.setDefaultUp(False)

    self.menuinfo = QMenu(self.menuBar)
    self.menuinfo.setObjectName(u"menuinfo")
    icon1 = QIcon()
    icon1.addFile(u":/icon/info.svg", QSize(), QIcon.Normal, QIcon.Off)
    self.menuinfo.setIcon(icon1)

    self.menuhelp = QMenu(self.menuBar)
    self.menuhelp.setObjectName(u"menuhelp")
    icon2 = QIcon()
    icon2.addFile(u":/icon/help.svg", QSize(), QIcon.Normal, QIcon.Off)
    self.menuhelp.setIcon(icon2)

    root.setMenuBar(self.menuBar)

    self.menuBar.addAction(self.menuinfo.menuAction())
    self.menuBar.addAction(self.menuhelp.menuAction())

    self.retranslateUi(root)

    QMetaObject.connectSlotsByName(root)

Ответы (1 шт):

Автор решения: S. Nick

Как вариант:

import sys
'''          Установите свои импорты
from PySide6.QtGui import QKeySequence, QShortcut, QPalette, QAction
from PySide6.QtWidgets import QApplication, QMainWindow, QMessageBox, QMenuBar, QMenu
'''
from PyQt5.Qt import *

# from design import Ui_root                     #  Установите свои иконки
class Ui_root(object):
    def setupUi(self, root):
        if not root.objectName():
            root.setObjectName(u"root")
        root.resize(560, 440)
        root.setMinimumSize(QSize(560, 460))
        root.setMaximumSize(QSize(560, 460))
        
        self.setStyleSheet(u"background-color: rgb(107, 142, 35);")

        self.menuBar = QMenuBar(root)
        self.menuBar.setObjectName(u"menuBar")
        self.menuBar.setStyleSheet(u"background-color: rgb(34, 139, 34);")
        self.menuBar.setGeometry(QRect(0, 0, 560, 22))
        self.menuBar.setDefaultUp(False)

        self.menuinfo = QMenu(self.menuBar)
        self.menuinfo.setObjectName(u"menuinfo")
        icon1 = QIcon()
#        icon1.addFile(u":/icon/info.svg", QSize(), QIcon.Normal, QIcon.Off)
        icon1.addFile(u"ball.png", QSize(), QIcon.Normal, QIcon.Off)
        self.menuinfo.setIcon(icon1)

        self.menuhelp = QMenu(self.menuBar)
        self.menuhelp.setObjectName(u"menuhelp")
        icon2 = QIcon()
#        icon2.addFile(u":/icon/help.svg", QSize(), QIcon.Normal, QIcon.Off)
        icon2.addFile(u"Ok.png", QSize(), QIcon.Normal, QIcon.Off)
        self.menuhelp.setIcon(icon2)

        root.setMenuBar(self.menuBar)

        self.menuBar.addAction(self.menuinfo.menuAction())
        self.menuBar.addAction(self.menuhelp.menuAction())

# ?      self.retranslateUi(root)

        QMetaObject.connectSlotsByName(root)
    

class MainWindow(QMainWindow, Ui_root):
    def __init__(self):
        super().__init__()
        self.setupUi(self)

# ?        self.btnSummer.clicked.connect(self.funcSummer)
# ?        self.outSummer.show()

# ?        self.btnWinter.clicked.connect(self.funcWinter)
# ?        self.outWinter.show()

# ?        self.createMenuBar()
# ?        self.createActions()

# +++ vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
        #action_about
        self.action_about = QAction(QIcon('about.png'), '&About', self)
        self.action_about.setStatusTip('About this App')
        self.action_about.setShortcut('Ctrl+F1')
        self.action_about.triggered.connect(self.func_about)
        self.menuinfo.addAction(self.action_about)
        
    def func_about(self):
        str_about = """Это приложение создано для ...
Разработчики:
blackpurpz

https://ru.stackoverflow.com/questions/1574999"""
        msgBox_about = QMessageBox()
        msgBox_about.setWindowTitle("About")
        msgBox_about.setText(str_about)
        msgBox_about.setWindowIcon(QIcon('Qt.png'))
        
        #msgBox_about.setIcon(QMessageBox.Information)
        msgBox_about.setIconPixmap(
            QPixmap("Qt.png").scaled(100, 100, Qt.KeepAspectRatio))
        
        msgBox_about.setStandardButtons(QMessageBox.Ok)
        msgBox_about.exec_()
# +++ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
  
''' ??? 
    def createMenuBar(self):
        self.menuinfo = QMenu(self.menuBar)
        self.menuinfo.setObjectName(u"menuinfo")

    def createActions(self):
        self.newAction = QAction(self)
        self.newAction.setText("info")
'''
    

if __name__ == "__main__":
    app = QApplication(sys.argv)
    w = MainWindow()
    w.show()
    sys.exit(app.exec())

введите сюда описание изображения

введите сюда описание изображения

→ Ссылка