0

the "MINI" function has the purpose of minimizing the window when the appropriate button is clicked. needless to say it doesn't work it doesn't give me any kind of error, I really don't know how to do it

from PyQt5 import QtCore, QtGui, QtWidgets
import win32com.client as win32

class Ui_MainWindow(object):
#more code before
    def setupUi(self, MainWindow):
        self.pushButton_3 = QtWidgets.QPushButton(self.widget_7, clicked=lambda: self.mini())
        self.pushButton_3.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.pushButton_3.setText("")
#more code after

    def mini(self):
        w = QtWidgets.QMainWindow()
        w.showMinimized()

if "__ name__" == '__ main __':

    import sys
    import salvataggioicone_rc
    app = QtWidgets.QApplication(sys.argv)
    ex = Ui_MainWindow()
    w = QtWidgets.QMainWindow()
    ex.setupUi(w)
    statusbar = w.statusBar()
    w.show()
    sys.exit(app.exec_())

I tried putting "w.showMinimize() in the section "if name == 'main':" and it works, but as soon as I put it inside the "MINI" function it does nothing

  • Where did you put that `mini` method? Please provide a valid [mre] (and also ensure that you're properly [format code](//meta.stackoverflow.com/a/251362) by checking the post preview before submitting modifications. – musicamante Mar 20 '23 at 19:56
  • i'm sorry it's the first question I ask and I didn't know how to change the layout, I updated the question, now it should be clearer – Edward Gavril Mar 20 '23 at 20:07
  • Regenerate that file with pyuic and **never edit again**, then follow the official guidelines about [using Designer](//www.riverbankcomputing.com/static/Docs/PyQt5/designer.html) by creating a new python file as you *main* one script, create a subclass of QMainWindow by following what explained in the above link (I suggest you the multiple inheritance approach), add `mini` there and `self.showMinimized()` in it, finally connect the `clicked` signal of the button to `self.mini` in the init. Then look for tutorials about signals and slots, like [this one](//zetcode.com/gui/pyqt5/eventssignals/). – musicamante Mar 20 '23 at 21:52

0 Answers0