I am new to PyQt5 and want to make an app with custom titlebar. So i removed it and placed three macos like buttons in which if a user clicks on the green button, it minimizes the window, but it just closes the window instead of minimizing it . It is giving me this error:
Qt Code:
  1. TypeError: min() takes 1 positional argument but 2 were given
To copy to clipboard, switch view to plain text mode 
Here is my code:

Qt Code:
  1. from PyQt5 import QtWidgets, QtCore, QtGui
  2. from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QWidget
  3. from PyQt5.QtGui import QCursor, QWindow
  4.  
  5. class Ui_MainWindow(QWidget):
  6. def __init__(self):
  7. super().__init__()
  8. self.setWindowTitle("Wally")
  9. self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
  10.  
  11. # background
  12.  
  13. self.label = QLabel("", self)
  14. background = QtGui.QPixmap(r"C:\Users\intel\Desktop\Wally\Background.png")
  15. background = background.scaled(1357, 728)
  16. self.label.setPixmap(background)
  17. self.label.show()
  18.  
  19. # red button
  20.  
  21. self.label1 = QLabel("", self)
  22. red = QtGui.QPixmap(r"C:\Users\intel\Desktop\Wally\red.png")
  23. red = red.scaled(11, 11)
  24. self.label1.setPixmap(red)
  25. self.label1.show()
  26. self.label1.move(11,11)
  27. self.label1.setCursor(QCursor(QtCore.Qt.PointingHandCursor))
  28.  
  29. # yellow button
  30.  
  31. self.label2 = QLabel("", self)
  32. yellow = QtGui.QPixmap(r"C:\Users\intel\Desktop\Wally\yellow.png")
  33. yellow = yellow.scaled(11, 11)
  34. self.label2.setPixmap(yellow)
  35. self.label2.show()
  36. self.label2.move(30,11)
  37. self.label2.setCursor(QCursor(QtCore.Qt.PointingHandCursor))
  38.  
  39. # green button
  40.  
  41. self.label3 = QLabel("", self)
  42. green = QtGui.QPixmap(r"C:\Users\intel\Desktop\Wally\green.png")
  43. green = green.scaled(19, 11)
  44. self.label3.setPixmap(green)
  45. self.label3.show()
  46. self.label3.move(44,11)
  47. self.label3.setCursor(QCursor(QtCore.Qt.PointingHandCursor))
  48. self.label3.mousePressEvent = self.min
  49.  
  50. self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
  51. self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
  52. self.offset = None
  53.  
  54. def min(self):
  55. self.setWindowState(QWindow.Minimized)
  56.  
  57. def setupUi(self, MainWindow):
  58. MainWindow.setObjectName("MainWindow")
  59. MainWindow.resize(1920, 1000)
  60. #MainWindow.move(50,50)
  61.  
  62.  
  63. if __name__ == "__main__":
  64. import sys
  65. app = QtWidgets.QApplication(sys.argv)
  66. MainWindow = Ui_MainWindow()
  67. ui = Ui_MainWindow()
  68. ui.setupUi(MainWindow)
  69. MainWindow.show()
  70. sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode