Im trying to make a app that launches two .exe files but I also want to make it work on any computer and preferably just one big .exe file

╄→гoц情女王★ 提交于 2020-07-16 07:46:23

问题


Im new to all this and all im trying to do is make a little file that looks decent, has a exit button and a launch button that when you hit it, it launches two other .exe files and closes. I also tried to make it launch but I saw that with the current path it would only work on my computer and not anyone elses.

Here is my code so far:

import tkinter as tk
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
import os
from PyQt5.QtWidgets import * 
from PyQt5.QtGui import * 
import PyQt5.QtCore
from PyQt5.QtCore import Qt


class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(600, 600)   
        MainWindow.setFixedSize(600, 600)
        MainWindow.setWindowFlag(Qt.FramelessWindowHint)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(0, 0, 600, 600))
        self.label.setStyleSheet("background-image: url(:/newPrefix/41294778_ML-2_1_600x600.jpg);")
        self.label.setText("")
        self.label.setObjectName("label")

        self.Exitbtn = QtWidgets.QPushButton(self.centralwidget)
        self.Exitbtn.setGeometry(QtCore.QRect(570, 5, 21, 23))
        self.Exitbtn.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.Exitbtn.setAutoFillBackground(False)
        self.Exitbtn.setStyleSheet("background-image: url(:/newPrefix/Exit.png);")
        self.Exitbtn.setText("")
        self.Exitbtn.clicked.connect(app.exit)
        self.Exitbtn.setDefault(False)
        self.Exitbtn.setFlat(True)
        self.Exitbtn.setObjectName("Exitbtn")
        self.Exitbtn.clearFocus()

        self.label_2 = QtWidgets.QLabel(self.centralwidget)
        self.label_2.setGeometry(QtCore.QRect(60, 20, 501, 151))
        self.label_2.setStyleSheet("image: url(:/newPrefix/Logo1.png);")
        self.label_2.setText("")
        self.label_2.setScaledContents(True)
        self.label_2.setObjectName("label_2")

        self.pushButton = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton.setGeometry(QtCore.QRect(90, 300, 421, 71))
        self.pushButton.setStyleSheet("image: url(")
        self.pushButton.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.pushButton.setFlat(True)
        self.pushButton.setObjectName("pushButton")
        self.pushButton.clicked.connect(self.FuncName)

        self.label_3 = QtWidgets.QLabel(self.centralwidget)
        self.label_3.setGeometry(QtCore.QRect(90, 300, 421, 71))
        self.label_3.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.label_3.setStyleSheet("image: url(:/newPrefix/Inject.png);")
        self.label_3.setText("")
        self.label_3.setScaledContents(True)
        self.label_3.setObjectName("label_3")

        self.label_4 = QtWidgets.QLabel(self.centralwidget)
        self.label_4.setEnabled(False)
        self.label_4.setGeometry(QtCore.QRect(10, 580, 511, 16))    
        font = QtGui.QFont()
        font.setFamily("System")
        font.setPointSize(12)
        font.setBold(True)
        font.setWeight(75)
        self.label_4.setFont(font)
        self.label_4.setObjectName("label_4")
       

        MainWindow.setCentralWidget(self.centralwidget)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
    

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.pushButton.setText(_translate("MainWindow", "FORTNITE"))
        self.label_4.setText(_translate("MainWindow", "Anarchy Injector © 2015 - 2020 | All Rights Reserved "))

    def mousePressEvent(self, MainWindow):
        focused_widget = QtGui.QApplication.focusWidget()
        if isinstance(focused_widget, MyLineEdit):
            focused_widget.clearFocus()
        QtGui.QMainWindow.mousePressEvent(self, event)

    def FuncName(self):
        subprocess.Popen(r'C:\Users\immba\OneDrive\Desktop\Anarchy Test\Minecraft Injector.exe')
        





import background_rc
import exit_rc
import logo_rc
import inject_rc


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_()) ```

回答1:


you can use pyinstaller to make exe file from python code that run on all computers (windows os)




回答2:


how about os.system?

# importing os module  
import os  
# Command to execute 
cmd = 'whatever you want to run'
# Using os.system() method 
os.system(cmd) 


来源:https://stackoverflow.com/questions/62870059/im-trying-to-make-a-app-that-launches-two-exe-files-but-i-also-want-to-make-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!