I have the following code:
from PyQt5.QtWidgets import QMainWindow,QApplication, QDesktopWidget
from PyQt5.QtCore import *
from PyQt5 import uic
from PyQt5 import QtCore
class Principal(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
uic.loadUi("23.ui",self)
self.s = 0
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
self.bmax.clicked.connect(self.W_Size)
self.bmin.clicked.connect(self.showMinimized)
self.bclose.clicked.connect(self.close)
def mousePressEvent(self,event):
if event.button() == QtCore.Qt.LeftButton:
self.dragPosition = event.globalPos() - self.frameGeometry().topLeft()
event.accept()
def mouseMoveEvent(self,event):
if event.buttons() == QtCore.Qt.LeftButton:
self.move(event.globalPos() - self.dragPosition)
event.accept()
def W_Size(self):
if self.s == 0:
self.showMaximized()
self.s=1
elif self.s==1:
self.s = 0
self.resize(878,575)
qRect = self.frameGeometry()
centerPoint = QDesktopWidget().availableGeometry().center()
qRect.moveCenter(centerPoint)
self.move(qRect.topLeft())
app = QApplication([])
p = Principal()
p.show()
app.exec_()
In which the variable s is responsible for manipulating the action taken by the self.bmax button event.
The idea is that by pressing the self.bmax button, compare if the value of the variable = 0 then when you press the button the window will be displayed in full screen and the value of s will change now "s = 1"; so that when you press the button again, change the size of the window and position it in the center. Again s return the value of "0", to repeat the whole process,
but it is in this last part where the code no longer works. Since it does not perform the action again to show the window in full screen.