Возможно ошибка с конвертатором в .exe

Anarch

Известный
Автор темы
344
75
Короче - пытаюсь скомпилировать скрипт - компилируется. Вроде бы все хорошо - но при правильном вводе логина и пароля, - скрипт на нажатие кнопки Login - должен реагировать и открывать окно. Если я запущу с помощью открытия уже компилированного .exe`шника - то он не открывает доп меню. А если я с вс кода открою - он открывается и все нормально.
 
Последнее редактирование:

Anarch

Известный
Автор темы
344
75
Python:
import sys, os, subprocess
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
    QMetaObject, QObject, QPoint, QRect,
    QSize, QTime, QUrl, Qt)
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
    QFont, QFontDatabase, QGradient, QIcon,
    QImage, QKeySequence, QLinearGradient, QPainter,
    QPalette, QPixmap, QRadialGradient, QTransform)
from PySide6.QtWidgets import (QApplication, QFrame, QLineEdit, QMainWindow,
    QPushButton, QSizePolicy, QTabWidget, QWidget, QFileDialog)

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        if not MainWindow.objectName():
            MainWindow.setObjectName(u"MainWindow")
        MainWindow.setEnabled(True)
        MainWindow.resize(350, 284)
        MainWindow.setMinimumSize(MainWindow.size())
        MainWindow.setMaximumSize(MainWindow.size())
        MainWindow.setWindowFlags(Qt.CustomizeWindowHint | Qt.Window)
        MainWindow.setMouseTracking(False)
        MainWindow.setAutoFillBackground(False)
        MainWindow.setStyleSheet(u"background-color: rgba(20, 20, 20, 0.8)")
        MainWindow.setAnimated(True)
        MainWindow.setDocumentMode(False)
        MainWindow.setTabShape(QTabWidget.TabShape.Rounded)
        MainWindow.setUnifiedTitleAndToolBarOnMac(False)
        self.centralwidget = QWidget(MainWindow)
        self.centralwidget.setObjectName(u"centralwidget")
        self.pushButton_2 = QPushButton(self.centralwidget)
        self.pushButton_2.setObjectName(u"pushButton_2")
        self.pushButton_2.setGeometry(QRect(100, 170, 141, 40))
        self.pushButton_2.setMinimumSize(QSize(141, 0))
        self.pushButton_2.setStyleSheet(u"QPushButton{\n"
"    background-color: rgba(40, 40, 40, 0.8);\n"
"    font: 900 9pt \"Segoe UI Black\";\n"
"    border: 1px solid rgba(0, 0, 0, 1);\n"
"}\n"
"QPushButton:pressed{\n"
"    background-color: rgba(40, 40, 40, 0.28)\n"
"}")
        self.pushButton_2.setCheckable(False)
        self.pushButton_2.setAutoDefault(False)
        self.pushButton_2.setFlat(False)
        self.pushButton_3 = QPushButton(self.centralwidget)
        self.pushButton_3.setObjectName(u"pushButton_3")
        self.pushButton_3.setGeometry(QRect(100, 220, 141, 35))
        self.pushButton_3.setStyleSheet(u"QPushButton{\n"
"    background-color: rgba(40, 40, 40, 0.8);\n"
"    font: 900 9pt \"Segoe UI Black\";\n"
"    border: 1px solid rgba(0, 0, 0, 1);\n"
"}\n"
"QPushButton:pressed{\n"
"    background-color: rgba(40, 40, 40, 0.28)\n"
"}")
        self.pushButton_3.setFlat(False)
        self.lineEdit = QLineEdit(self.centralwidget)
        self.pushButton_2.clicked.connect(self.on_login_clicked)
        self.lineEdit.setObjectName(u"lineEdit")
        self.lineEdit.setGeometry(QRect(50, 50, 241, 31))
        self.lineEdit.setStyleSheet(u" background-color: rgba(40, 40, 40, 0.8)")
        self.lineEdit_2 = QLineEdit(self.centralwidget)
        self.lineEdit_2.setObjectName(u"lineEdit_2")
        self.lineEdit_2.setGeometry(QRect(50, 100, 241, 31))
        self.lineEdit_2.setLayoutDirection(Qt.LayoutDirection.LeftToRight)
        self.lineEdit_2.setStyleSheet(u" background-color: rgba(40, 40, 40, 0.8)")
        self.line = QFrame(self.centralwidget)
        self.line.setObjectName(u"line")
        self.line.setGeometry(QRect(-40, 5, 441, 16))
        self.line.setStyleSheet(u"background: linear-gradient(to bottom right, blue, pink);\n"
"width: 200px;\n"
"height: 100px;")
        self.line.setFrameShape(QFrame.Shape.HLine)
        self.line.setFrameShadow(QFrame.Shadow.Sunken)
        MainWindow.setCentralWidget(self.centralwidget)
        MainWindow.setWindowIcon(QIcon('gamesense/gs.jpg'))

        self.retranslateUi(MainWindow)

        self.pushButton_2.setDefault(False)

        QMetaObject.connectSlotsByName(MainWindow)

    # setupUi

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"gamesense", None))
        self.pushButton_2.setText(QCoreApplication.translate("MainWindow", u"Login", None))
        self.pushButton_3.setText(QCoreApplication.translate("MainWindow", u"Exit", None))
        self.lineEdit.setText("")
        self.lineEdit_2.setText("")
    def on_login_clicked(self):
        username = self.lineEdit.text()
        password = self.lineEdit_2.text()
        if username == "123" and password == "1234":
            MainWindow.close()
            print("Вы успешно вошли как администратор!")
            print("Открываю новое меню")
            script_dir = os.path.dirname(os.path.realpath(__file__))
            file_path = os.path.join(script_dir, 'gs_s.py')
            subprocess.Popen([sys.executable, file_path])
        else:
            print("Неверные учетные данные. Попробуйте снова.")

if __name__ == "__main__":
    app = QApplication(sys.argv)
    MainWindow = QMainWindow() 
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    ui.pushButton_3.clicked.connect(MainWindow.close)
    MainWindow.show()
    sys.exit(app.exec())
 

Dickson

Активный
186
55
Python:
import sys, os, subprocess
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
    QMetaObject, QObject, QPoint, QRect,
    QSize, QTime, QUrl, Qt)
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
    QFont, QFontDatabase, QGradient, QIcon,
    QImage, QKeySequence, QLinearGradient, QPainter,
    QPalette, QPixmap, QRadialGradient, QTransform)
from PySide6.QtWidgets import (QApplication, QFrame, QLineEdit, QMainWindow,
    QPushButton, QSizePolicy, QTabWidget, QWidget, QFileDialog)

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        if not MainWindow.objectName():
            MainWindow.setObjectName(u"MainWindow")
        MainWindow.setEnabled(True)
        MainWindow.resize(350, 284)
        MainWindow.setMinimumSize(MainWindow.size())
        MainWindow.setMaximumSize(MainWindow.size())
        MainWindow.setWindowFlags(Qt.CustomizeWindowHint | Qt.Window)
        MainWindow.setMouseTracking(False)
        MainWindow.setAutoFillBackground(False)
        MainWindow.setStyleSheet(u"background-color: rgba(20, 20, 20, 0.8)")
        MainWindow.setAnimated(True)
        MainWindow.setDocumentMode(False)
        MainWindow.setTabShape(QTabWidget.TabShape.Rounded)
        MainWindow.setUnifiedTitleAndToolBarOnMac(False)
        self.centralwidget = QWidget(MainWindow)
        self.centralwidget.setObjectName(u"centralwidget")
        self.pushButton_2 = QPushButton(self.centralwidget)
        self.pushButton_2.setObjectName(u"pushButton_2")
        self.pushButton_2.setGeometry(QRect(100, 170, 141, 40))
        self.pushButton_2.setMinimumSize(QSize(141, 0))
        self.pushButton_2.setStyleSheet(u"QPushButton{\n"
"    background-color: rgba(40, 40, 40, 0.8);\n"
"    font: 900 9pt \"Segoe UI Black\";\n"
"    border: 1px solid rgba(0, 0, 0, 1);\n"
"}\n"
"QPushButton:pressed{\n"
"    background-color: rgba(40, 40, 40, 0.28)\n"
"}")
        self.pushButton_2.setCheckable(False)
        self.pushButton_2.setAutoDefault(False)
        self.pushButton_2.setFlat(False)
        self.pushButton_3 = QPushButton(self.centralwidget)
        self.pushButton_3.setObjectName(u"pushButton_3")
        self.pushButton_3.setGeometry(QRect(100, 220, 141, 35))
        self.pushButton_3.setStyleSheet(u"QPushButton{\n"
"    background-color: rgba(40, 40, 40, 0.8);\n"
"    font: 900 9pt \"Segoe UI Black\";\n"
"    border: 1px solid rgba(0, 0, 0, 1);\n"
"}\n"
"QPushButton:pressed{\n"
"    background-color: rgba(40, 40, 40, 0.28)\n"
"}")
        self.pushButton_3.setFlat(False)
        self.lineEdit = QLineEdit(self.centralwidget)
        self.pushButton_2.clicked.connect(self.on_login_clicked)
        self.lineEdit.setObjectName(u"lineEdit")
        self.lineEdit.setGeometry(QRect(50, 50, 241, 31))
        self.lineEdit.setStyleSheet(u" background-color: rgba(40, 40, 40, 0.8)")
        self.lineEdit_2 = QLineEdit(self.centralwidget)
        self.lineEdit_2.setObjectName(u"lineEdit_2")
        self.lineEdit_2.setGeometry(QRect(50, 100, 241, 31))
        self.lineEdit_2.setLayoutDirection(Qt.LayoutDirection.LeftToRight)
        self.lineEdit_2.setStyleSheet(u" background-color: rgba(40, 40, 40, 0.8)")
        self.line = QFrame(self.centralwidget)
        self.line.setObjectName(u"line")
        self.line.setGeometry(QRect(-40, 5, 441, 16))
        self.line.setStyleSheet(u"background: linear-gradient(to bottom right, blue, pink);\n"
"width: 200px;\n"
"height: 100px;")
        self.line.setFrameShape(QFrame.Shape.HLine)
        self.line.setFrameShadow(QFrame.Shadow.Sunken)
        MainWindow.setCentralWidget(self.centralwidget)
        MainWindow.setWindowIcon(QIcon('gamesense/gs.jpg'))

        self.retranslateUi(MainWindow)

        self.pushButton_2.setDefault(False)

        QMetaObject.connectSlotsByName(MainWindow)

    # setupUi

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"gamesense", None))
        self.pushButton_2.setText(QCoreApplication.translate("MainWindow", u"Login", None))
        self.pushButton_3.setText(QCoreApplication.translate("MainWindow", u"Exit", None))
        self.lineEdit.setText("")
        self.lineEdit_2.setText("")
    def on_login_clicked(self):
        username = self.lineEdit.text()
        password = self.lineEdit_2.text()
        if username == "123" and password == "1234":
            MainWindow.close()
            print("Вы успешно вошли как администратор!")
            print("Открываю новое меню")
            script_dir = os.path.dirname(os.path.realpath(__file__))
            file_path = os.path.join(script_dir, 'gs_s.py')
            subprocess.Popen([sys.executable, file_path])
        else:
            print("Неверные учетные данные. Попробуйте снова.")

if __name__ == "__main__":
    app = QApplication(sys.argv)
    MainWindow = QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    ui.pushButton_3.clicked.connect(MainWindow.close)
    MainWindow.show()
    sys.exit(app.exec())
dai tg