Why does my program not work on the second page of its movement function and does not give an error?

15 views Asked by At

I need two pages in my program, one for entering and other one for record information and save in the database, both of which I have prepared at designer, but on the second page, the movement function does not work due to the borderless window and the page is fixed, please help me Thank you

from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QLineEdit,
QHBoxLayout, QVBoxLayout, QFileDialog, QMessageBox from PyQt5.QtCore import Qt, QPoint from PyQt5 import QtCore, QtGui, QtWidgets import pmicon import sys import sqlite3

class Ui_Form(object):

def openwindow(self):
    Form.close()
    self.MainWindow = QtWidgets.QMainWindow()
    self.ui = Ui_MainWindow()
    self.ui.setupUi(self.MainWindow)
    Form.close()
    self.MainWindow.show()

def setupUi(self, Form):
    Form.setObjectName("Form")
    Form.resize(326, 451)
    Form.setWindowFlags(QtCore.Qt.FramelessWindowHint)
    Form.setWindowFlags(QtCore.Qt.FramelessWindowHint)
    Form.setAttribute(QtCore.Qt.WA_TranslucentBackground)
    self.centralwidget = QtWidgets.QWidget(Form)
    self.centralwidget.setObjectName("centralwidget")
    self.transparent = QtWidgets.QFrame(self.centralwidget)

.....

    self.retranslateUi(Form)
    QtCore.QMetaObject.connectSlotsByName(Form)
    self.login.clicked.connect(self.btn_submit_handler)
    self.transparent.mouseMoveEvent = self.moveWindow
    self.transparent.mousePressEvent = self.mousePress

def retranslateUi(self, Form):
    _translate = QtCore.QCoreApplication.translate
    Form.setWindowTitle(_translate("Form", "Form"))
    self.login.setText(_translate("Form", "Log in"))

....

def mousePress(self, event):
    Form.dragPos = Form.pos()
    self.mouse_original_pos = Form.mapToGlobal(event.pos())

def moveWindow(self, event):
    if Form.isMaximized():
        Form.showNormal()
    else:
        if event.buttons() == Qt.LeftButton:
            MainWindow_last_pos = Form.dragPos + Form.mapToGlobal(event.pos()) - self.mouse_original_pos
            Form.move(MainWindow_last_pos)
            event.accept()

class Ui_MainWindow(QWidget):

def mousePress(self, event):
    MainWindow.dragPos = MainWindow.pos()
    self.mouse_original_pos = MainWindow.mapToGlobal(event.pos())

def moveWindow(self, event):
    if MainWindow.isMaximized():
        MainWindow.showNormal()
    else:
        if event.buttons() == Qt.LeftButton:
            MainWindow_last_pos = MainWindow.dragPos + MainWindow.mapToGlobal(event.pos()) - self.mouse_original_pos
            MainWindow.move(MainWindow_last_pos)
            event.accept()


def setupUi(self, MainWindow):
    global p
    p = 0
    global num
    num = 0
    MainWindow.setObjectName("MainWindow")
    MainWindow.resize(729, 776)
    MainWindow.setStyleSheet("")
    MainWindow.setWindowFlags(QtCore.Qt.FramelessWindowHint)
    MainWindow.setAttribute(QtCore.Qt.WA_TranslucentBackground)
    self.centralwidget = QtWidgets.QWidget(MainWindow)
    self.centralwidget.setObjectName("centralwidget")
    self.transparent01 = QtWidgets.QFrame(self.centralwidget)
    self.transparent01.setGeometry(QtCore.QRect(20, 20, 686, 731))
    sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
    sizePolicy.setHorizontalStretch(0)
    sizePolicy.setVerticalStretch(0)
    sizePolicy.setHeightForWidth(self.transparent01.sizePolicy().hasHeightForWidth())
    self.transparent01.setSizePolicy(sizePolicy)
    self.transparent01.setAccessibleName("")

.....

    MainWindow.setTabOrder(self.shiftradio, self.resonradio)
    MainWindow.setTabOrder(self.resonradio, self.brokenradio)
    MainWindow.setTabOrder(self.brokenradio, self.errorradio)
    MainWindow.setTabOrder(self.errorradio, self.actradio)
    MainWindow.setTabOrder(self.actradio, self.Searchbutton)
    MainWindow.setTabOrder(self.Searchbutton, self.clearbutton2)
    MainWindow.setTabOrder(self.clearbutton2, self.scrollArea)
    self.transparent01.mouseMoveEvent = self.moveWindow
    self.transparent01.mousePressEvent = self.mousePress
    self.numberofsave.setText(f"تعداد {num} کزارش ذخیره شده است")
    self.numberofsavefile.setText(f"تعداد : {p}")


def retranslateUi(self, MainWindow):
    _translate = QtCore.QCoreApplication.translate
    MainWindow.setWindowTitle(_translate("MainWindow", "قرم تعمیرات و نگهداری شرکت دارو سازی ثامن"))
    self.close.setText(_translate("MainWindow", "X"))
    self.empm.setHtml(_translate("MainWindow",

....

if name == "main":

app = QtWidgets.QApplication(sys.argv)
ui1 = Ui_Form()
ui2 = Ui_MainWindow()
Form = QtWidgets.QWidget()
MainWindow = QtWidgets.QMainWindow()
ui1.setupUi(Form)
ui2.setupUi(MainWindow)
Form.show()
sys.exit(app.exec_())
0

There are 0 answers