Skip to content

Instantly share code, notes, and snippets.

@Hzzkygcs
Forked from onecore/py2exeGUI.py
Created November 5, 2019 12:55
Show Gist options
  • Save Hzzkygcs/e5bd9178df41e2ad4e1c8ffd8dd73373 to your computer and use it in GitHub Desktop.
Save Hzzkygcs/e5bd9178df41e2ad4e1c8ffd8dd73373 to your computer and use it in GitHub Desktop.
Py2exe Graphical User Interface (GUi)
# -*- coding: utf-8 -*-
from PyQt4 import QtCore, QtGui
__author__ = 'Mark Anthony Pequeras'
__version__ = '1.0'
__date__ = '1.3.2014'
__website__ = 'markpequeras.sf.net'
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_pyGUI(object):
def setupUi(self, pyGUI):
pyGUI.setObjectName(_fromUtf8("pyGUI"))
pyGUI.resize(619, 435)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(_fromUtf8("python.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
pyGUI.setWindowIcon(icon)
pyGUI.setStyleSheet(_fromUtf8("background: rgb(95, 95, 95);"))
self.label = QtGui.QLabel(pyGUI)
self.label.setGeometry(QtCore.QRect(120, 30, 401, 61))
self.label.setStyleSheet(_fromUtf8("background: none;"))
self.label.setText(_fromUtf8(""))
self.label.setPixmap(QtGui.QPixmap(_fromUtf8("JLtthh1388364054.png")))
self.label.setScaledContents(True)
self.label.setObjectName(_fromUtf8("label"))
self.textEdit_2 = QtGui.QTextEdit(pyGUI)
self.textEdit_2.setEnabled(False)
self.textEdit_2.setGeometry(QtCore.QRect(190, 210, 421, 181))
self.textEdit_2.setStyleSheet(_fromUtf8("QTextEdit {\n"
" background: #008B8B;\n"
" background-image: linear-gradient(to bottom, #3cb0fd, #2980b9);\n"
" border-radius: 28px;\n"
" color: #ffffff;\n"
" padding: 10px 20px 10px 20px;\n"
"\n"
"}\n"
""))
self.textEdit_2.setObjectName(_fromUtf8("textEdit_2"))
self.textEdit = QtGui.QTextEdit(pyGUI)
self.textEdit.setGeometry(QtCore.QRect(10, 210, 411, 181))
self.textEdit.setStyleSheet(_fromUtf8("QTextEdit {\n"
" background: #008B8B;\n"
" background-image: linear-gradient(to bottom, #3cb0fd, #2980b9);\n"
" border-radius: 28px;\n"
" color: #ffffff;\n"
" padding: 10px 20px 10px 20px;\n"
"\n"
"}\n"
""))
self.textEdit.setObjectName(_fromUtf8("textEdit"))
self.pushButton = QtGui.QPushButton(pyGUI)
self.pushButton.setGeometry(QtCore.QRect(420, 260, 171, 81))
self.pushButton.setCursor(QtGui.QCursor(QtCore.Qt.OpenHandCursor))
self.pushButton.setStyleSheet(_fromUtf8("QPushButton {\n"
" background: #FF9933;\n"
" background-image: linear-gradient(to bottom, #3cb0fd, #2980b9);\n"
" border-radius: 38px;\n"
" font-family: Arial;\n"
" color: #ffffff;\n"
" font-size: 18px;\n"
" padding: 10px 20px 10px 20px;\n"
" text-decoration: none;\n"
"}\n"
"\n"
"QPushButton:hover {\n"
" background: #2ea7f2;\n"
" text-decoration: none;\n"
"}"))
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.label_2 = QtGui.QLabel(pyGUI)
self.label_2.setGeometry(QtCore.QRect(400, 89, 131, 31))
font = QtGui.QFont()
font.setFamily(_fromUtf8("Arial"))
font.setPointSize(11)
self.label_2.setFont(font)
self.label_2.setStyleSheet(_fromUtf8("background: none;\n"
"color: #008B8B;"))
self.label_2.setObjectName(_fromUtf8("label_2"))
self.textEdit_3 = QtGui.QTextEdit(pyGUI)
self.textEdit_3.setGeometry(QtCore.QRect(100, 130, 411, 31))
self.textEdit_3.setStyleSheet(_fromUtf8("QTextEdit {\n"
" background: #008B8B;\n"
" background-image: linear-gradient(to bottom, #3cb0fd, #2980b9);\n"
" border-radius: 9px;\n"
" color: #ffffff;\n"
" padding: 10px 20px 10px 20px;\n"
"\n"
"}\n"
""))
self.textEdit_3.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.textEdit_3.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.textEdit_3.setObjectName(_fromUtf8("textEdit_3"))
self.label_3 = QtGui.QLabel(pyGUI)
self.label_3.setGeometry(QtCore.QRect(30, 135, 71, 21))
self.label_3.setStyleSheet(_fromUtf8("color: white;"))
self.label_3.setObjectName(_fromUtf8("label_3"))
self.label_4 = QtGui.QLabel(pyGUI)
self.label_4.setGeometry(QtCore.QRect(40, 170, 61, 31))
self.label_4.setStyleSheet(_fromUtf8("color: white;"))
self.label_4.setObjectName(_fromUtf8("label_4"))
self.textEdit_4 = QtGui.QTextEdit(pyGUI)
self.textEdit_4.setGeometry(QtCore.QRect(100, 170, 411, 31))
self.textEdit_4.setStyleSheet(_fromUtf8("QTextEdit {\n"
" background: #008B8B;\n"
" background-image: linear-gradient(to bottom, #3cb0fd, #2980b9);\n"
" border-radius: 9px;\n"
" color: #ffffff;\n"
" padding: 10px 20px 10px 20px;\n"
"\n"
"}\n"
""))
self.textEdit_4.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.textEdit_4.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.textEdit_4.setObjectName(_fromUtf8("textEdit_4"))
self.pushButton_2 = QtGui.QPushButton(pyGUI)
self.pushButton_2.setGeometry(QtCore.QRect(500, 130, 91, 31))
self.pushButton_2.setCursor(QtGui.QCursor(QtCore.Qt.OpenHandCursor))
self.pushButton_2.setStyleSheet(_fromUtf8("QPushButton {\n"
" background: #FF9933;\n"
" font-family: Arial;\n"
" color: #ffffff;\n"
" font-size: 11px;\n"
" padding: 10px 20px 10px 20px;\n"
" text-decoration: none;\n"
"}\n"
"\n"
"QPushButton:hover {\n"
" background: #2ea7f2;\n"
" text-decoration: none;\n"
"}"))
self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))
self.pushButton_3 = QtGui.QPushButton(pyGUI)
self.pushButton_3.setGeometry(QtCore.QRect(500, 170, 91, 31))
self.pushButton_3.setCursor(QtGui.QCursor(QtCore.Qt.OpenHandCursor))
self.pushButton_3.setStyleSheet(_fromUtf8("QPushButton {\n"
" background: #FF9933;\n"
" font-family: Arial;\n"
" color: #ffffff;\n"
" font-size: 11px;\n"
" padding: 10px 20px 10px 20px;\n"
" text-decoration: none;\n"
"}\n"
"\n"
"QPushButton:hover {\n"
" background: #2ea7f2;\n"
" text-decoration: none;\n"
"}"))
self.pushButton_3.setObjectName(_fromUtf8("pushButton_3"))
self.pushButton_x = QtGui.QPushButton(pyGUI)
self.pushButton_x.setGeometry(QtCore.QRect(30, 400, 88, 31))
self.pushButton_x.setCursor(QtGui.QCursor(QtCore.Qt.OpenHandCursor))
self.pushButton_x.setStyleSheet(_fromUtf8("QPushButton {\n"
" background: #FF9933;\n"
" font-family: Arial;\n"
" color: #ffffff;\n"
" font-size: 11px;\n"
" padding: 10px 20px 10px 20px;\n"
" text-decoration: none;\n"
"}\n"
"\n"
"QPushButton:hover {\n"
" background: #2ea7f2;\n"
" text-decoration: none;\n"
"}"))
self.pushButton_x.setObjectName(_fromUtf8("pushButton_x"))
self.pushButton_a = QtGui.QPushButton(pyGUI)
self.pushButton_a.setGeometry(QtCore.QRect(117, 400, 88, 31))
self.pushButton_a.setCursor(QtGui.QCursor(QtCore.Qt.OpenHandCursor))
self.pushButton_a.setStyleSheet(_fromUtf8("QPushButton {\n"
" background: #FF9933;\n"
" font-family: Arial;\n"
" color: #ffffff;\n"
" font-size: 11px;\n"
" padding: 10px 20px 10px 20px;\n"
" text-decoration: none;\n"
"}\n"
"\n"
"QPushButton:hover {\n"
" background: #2ea7f2;\n"
" text-decoration: none;\n"
"}"))
self.pushButton_a.setObjectName(_fromUtf8("pushButton_a"))
self.pushButton_e = QtGui.QPushButton(pyGUI)
self.pushButton_e.setGeometry(QtCore.QRect(204, 400, 88, 31))
self.pushButton_e.setCursor(QtGui.QCursor(QtCore.Qt.OpenHandCursor))
self.pushButton_e.setStyleSheet(_fromUtf8("QPushButton {\n"
" background: #FF9933;\n"
" font-family: Arial;\n"
" color: #ffffff;\n"
" font-size: 11px;\n"
" padding: 10px 20px 10px 20px;\n"
" text-decoration: none;\n"
"}\n"
"\n"
"QPushButton:hover {\n"
" background: #2ea7f2;\n"
" text-decoration: none;\n"
"}"))
self.pushButton_e.setObjectName(_fromUtf8("pushButton_e"))
self.retranslateUi(pyGUI)
QtCore.QObject.connect(self.pushButton_2, QtCore.SIGNAL(_fromUtf8("clicked()")), self.getPythonPath)
QtCore.QObject.connect(self.pushButton_3, QtCore.SIGNAL(_fromUtf8("clicked()")), self.getSetupPath)
QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.compileNow)
QtCore.QObject.connect(self.pushButton_x, QtCore.SIGNAL(_fromUtf8("clicked()")), self.clearAll)
QtCore.QObject.connect(self.pushButton_a, QtCore.SIGNAL(_fromUtf8("clicked()")), self.About)
QtCore.QObject.connect(self.pushButton_e, QtCore.SIGNAL(_fromUtf8("clicked()")), self.editSup)
QtCore.QMetaObject.connectSlotsByName(pyGUI)
def retranslateUi(self, pyGUI):
pyGUI.setWindowTitle(_translate("pyGUI", "PY2EXE Graphical Version ", None))
self.pushButton.setText(_translate("pyGUI", "COMPILE", None))
self.label_2.setText(_translate("pyGUI", "Lemme Freeze Ya!", None))
self.label_3.setText(_translate("pyGUI", "Python Path", None))
self.label_4.setText(_translate("pyGUI", "Set-Up File", None))
self.pushButton_2.setText(_translate("pyGUI", "OPEN", None))
self.pushButton_3.setText(_translate("pyGUI", "OPEN", None))
self.pushButton_x.setText(_translate("pyGUI", "Clear All", None))
self.pushButton_a.setText(_translate("pyGUI", "About", None))
self.pushButton_e.setText(_translate("pyGUI", "Edit Setup", None))
def clearAll(self):
self.textEdit_3.clear()
self.textEdit_4.clear()
self.textEdit.clear()
def About(self):
mbox = self.textEdit
about = """
<html>
<head>
<title>HTML Online Editor Sample</title>
</head>
<body>
<p>
<span style="color:#ffffff;">Author:</span> &nbsp;<span style="color:#daa520;">Mark Anthony Pequeras</span></p>
<p>
<span style="color:#ffffff;">Author Website:</span> &nbsp;<span style="color:#daa520;">http://www.markpequeras.sf.net/</span></p>
<p>
<span style="color:#ffffff;">Organization:</span> <span style="color:#daa520;">CoreSEC Software Development</span></p>
<p>
<span style="color:#ffffff;">Version:</span> <span style="color:#daa520;">1.1</span></p>
<p>
<span style="color:#ffffff;">Release Website:</span> <span style="color:#daa520;">http://www.pegui.sourceforge.net/</span></p></body>
</html>
"""
mbox.clear(), mbox.insertHtml(about)
def editSup(self):
import subprocess
spath = self.textEdit_4.toPlainText()
mbox = self.textEdit
if (len(spath) == 0):
mbox.clear(),mbox.insertPlainText('Please Select a Setup File first!')
return False
else:
commnd = 'start notepad {sfile}'.format(sfile=spath)
process = subprocess.Popen(commnd, shell=True, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
def getPythonPath(self):
pyPath = None
pySetup = None
mainBox = self.textEdit
ppath = QtGui.QFileDialog.getOpenFileName(pyPath, 'Open File', '.')
if ('python.exe' not in str(ppath)):
mainBox.clear(), mainBox.insertPlainText('I Need Python!')
return 0
else:
tEdt = self.textEdit_3
mainBox.clear(),tEdt.insertPlainText(str(ppath)),tEdt.setDisabled(1)
mainBox.clear(), mainBox.insertPlainText('Python Path Configured!')
def getSetupPath(self):
pyPath = None
pySetup = None
tEdt = self.textEdit_4
mainBox = self.textEdit
spath = QtGui.QFileDialog.getOpenFileName(pySetup, 'Open File', '.')
if ('.py' not in str(spath)):
mainBox.clear(), mainBox.insertPlainText('Where\'s the Setup file?')
return 0
else:
mainBox.clear(),tEdt.insertPlainText(str(spath)),tEdt.setDisabled(1)
mainBox.clear(), mainBox.insertPlainText('Py2Exe File Path Configured!')
def compilexNow(self):
import subprocess
import os
import sys
QtCore.QThread.Thre
mainBox = self.textEdit
ppath = self.textEdit_3.toPlainText()
spath = self.textEdit_4.toPlainText()
if (len(str(ppath)) <= 2):
mainBox.clear(), mainBox.insertPlainText('Check your Python Path!')
return False
if (len(str(spath)) <= 2):
mainBox.clear(), mainBox.insertPlainText('Check your Setup Path!')
return False
commnd = '{p} {s} {c}'.format(p=ppath,s=spath,c='py2exe')
cwdcmd = ppath.replace('python.exe','')
process = subprocess.Popen(commnd, shell=True, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
mainBox.clear()
mainBox.insertPlainText(str(stdout))
mainBox.insertPlainText(str(stderr))
QtCore.QThread.connect()
if 1:
import sys
p2egui = QtGui.QApplication(sys.argv)
pyGUI = QtGui.QWidget()
ui = Ui_pyGUI()
ui.setupUi(pyGUI)
pyGUI.show()
sys.exit(p2egui.exec_())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment