TypeError: min() takes 1 positional argument but 2 were given
TypeError: min() takes 1 positional argument but 2 were given
To copy to clipboard, switch view to plain text mode
from PyQt5 import QtWidgets, QtCore, QtGui
from PyQt5.
QtGui import
QCursor, QWindow
def __init__(self):
super().__init__()
self.setWindowTitle("Wally")
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
# background
background
= QtGui.
QPixmap(r
"C:\Users\intel\Desktop\Wally\Background.png") background = background.scaled(1357, 728)
self.label.setPixmap(background)
self.label.show()
# red button
self.
label1 = QLabel("", self
) red
= QtGui.
QPixmap(r
"C:\Users\intel\Desktop\Wally\red.png") red = red.scaled(11, 11)
self.label1.setPixmap(red)
self.label1.show()
self.label1.move(11,11)
self.
label1.
setCursor(QCursor(QtCore.
Qt.
PointingHandCursor))
# yellow button
self.
label2 = QLabel("", self
) yellow
= QtGui.
QPixmap(r
"C:\Users\intel\Desktop\Wally\yellow.png") yellow = yellow.scaled(11, 11)
self.label2.setPixmap(yellow)
self.label2.show()
self.label2.move(30,11)
self.
label2.
setCursor(QCursor(QtCore.
Qt.
PointingHandCursor))
# green button
self.
label3 = QLabel("", self
) green
= QtGui.
QPixmap(r
"C:\Users\intel\Desktop\Wally\green.png") green = green.scaled(19, 11)
self.label3.setPixmap(green)
self.label3.show()
self.label3.move(44,11)
self.
label3.
setCursor(QCursor(QtCore.
Qt.
PointingHandCursor)) self.label3.mousePressEvent = self.min
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self.offset = None
def min(self):
self.setWindowState(QWindow.Minimized)
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(1920, 1000)
#MainWindow.move(50,50)
if __name__ == "__main__":
import sys
MainWindow = Ui_MainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
from PyQt5 import QtWidgets, QtCore, QtGui
from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QWidget
from PyQt5.QtGui import QCursor, QWindow
class Ui_MainWindow(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("Wally")
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
# background
self.label = QLabel("", self)
background = QtGui.QPixmap(r"C:\Users\intel\Desktop\Wally\Background.png")
background = background.scaled(1357, 728)
self.label.setPixmap(background)
self.label.show()
# red button
self.label1 = QLabel("", self)
red = QtGui.QPixmap(r"C:\Users\intel\Desktop\Wally\red.png")
red = red.scaled(11, 11)
self.label1.setPixmap(red)
self.label1.show()
self.label1.move(11,11)
self.label1.setCursor(QCursor(QtCore.Qt.PointingHandCursor))
# yellow button
self.label2 = QLabel("", self)
yellow = QtGui.QPixmap(r"C:\Users\intel\Desktop\Wally\yellow.png")
yellow = yellow.scaled(11, 11)
self.label2.setPixmap(yellow)
self.label2.show()
self.label2.move(30,11)
self.label2.setCursor(QCursor(QtCore.Qt.PointingHandCursor))
# green button
self.label3 = QLabel("", self)
green = QtGui.QPixmap(r"C:\Users\intel\Desktop\Wally\green.png")
green = green.scaled(19, 11)
self.label3.setPixmap(green)
self.label3.show()
self.label3.move(44,11)
self.label3.setCursor(QCursor(QtCore.Qt.PointingHandCursor))
self.label3.mousePressEvent = self.min
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self.offset = None
def min(self):
self.setWindowState(QWindow.Minimized)
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(1920, 1000)
#MainWindow.move(50,50)
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = Ui_MainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode
Bookmarks