Advertisement
Guest User

py2exe interface

a guest
Jan 31st, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.26 KB | None | 0 0
  1. #In the name of Allah
  2.  
  3. import sys, codecs, platform, os, subprocess
  4. from subprocess import check_call
  5. from PyQt4 import QtCore, QtGui, uic
  6. from PyQt4.QtGui import *
  7.  
  8. def isl32b():
  9.     dir = os.getcwd() + "\\AppData\\py2exe-0.9.2.0.win32.exe"
  10.  
  11.     print(subprocess.Popen(dir, shell = True, stdout = subprocess.PIPE).stdout.read())
  12.  
  13. def isl64b():
  14.     dir = os.getcwd() + "\\AppData\\py2exe-0.9.2.0.win-amd64.exe"
  15.  
  16.  
  17.     print(subprocess.Popen(dir, shell = True, stdout = subprocess.PIPE).stdout.read())
  18.  
  19. fc1 = uic.loadUiType("Appdata\\pg1.ui")[0]
  20. fc2 = uic.loadUiType("Appdata\\pg2.ui")[0]
  21. class Pg1(QtGui.QMainWindow, fc1):
  22.     def __init__(slf, prt = None):
  23.         QtGui.QMainWindow.__init__(slf, prt)
  24.         slf.setupUi(slf)
  25.         slf.Pb1.clicked.connect(slf.islp2x)
  26.  
  27.     def islp2x(slf):
  28.         if "64" in platform.architecture()[0]:
  29.             isl64b()
  30.         else:
  31.             isl32b()
  32. ise = rbn = qti = False
  33. class Pg2(QtGui.QMainWindow, fc2):
  34.     def __init__(slf, prt = None):
  35.         QtGui.QMainWindow.__init__(slf, prt)
  36.         slf.setupUi(slf)
  37.         slf.Pb1.clicked.connect(slf.Min)
  38.         slf.Pb4.clicked.connect(slf.Min)
  39.         slf.Cbx.currentIndexChanged.connect(slf.Ovs)
  40.         slf.Rb1.released.connect(slf.smd1)
  41.         slf.Rb2.released.connect(slf.smd2)
  42.         slf.CHb.released.connect(slf.pyq)
  43.         slf.Pbr.setValue(0)
  44.         slf.Pb3.clicked.connect(slf.oer)
  45.     oer = lambda slf:check_call("explorer dist", shell = True)
  46.     def pyq(slf):
  47.         global qti
  48.         qti = not qti
  49.     def smd1(slf):
  50.         global rbn
  51.         rbn = True
  52.     def smd2(slf):
  53.         global rbn
  54.         rbn = False
  55.     def Min(slf):
  56.         VRS = slf.Cbx.currentText()
  57.         if VRS == "\u0646\u0633\u062e\u0647 \u0647\u0627\u06cc \u062f\u06cc\u06af\u0631":
  58.             VRS = slf.Let.text()
  59.         Fwr = open("setup.py", "w")
  60.         FNM = QFileDialog.getOpenFileName()
  61.        
  62.        
  63.        
  64.         Fwr.write("from distutils.core import setup\nimport py2exe\nsetup(console = [" + ascii("\\".join(FNM.split("/"))) + "])")
  65.         Fwr.close()
  66.         global ise, qti
  67.         if ise or not rbn:
  68.             slf.Pbr.setValue(10)
  69.             check_call("py setup.py install", shell = True)
  70.             slf.Pbr.setValue(44)
  71.            
  72.             ils = " --includes sip"
  73.             check_call("py setup.py py2exe" + ils * qti, shell = True)
  74.             slf.Pbr.setValue(100)
  75.  
  76.         else:
  77.             slf.Pbr.setValue(10)
  78.             check_call("py -" + str(VRS) + " setup.py install", shell = True)
  79.             slf.Pbr.setValue(45)
  80.             ils = " --includes sip"
  81.             check_call("py -" + str(VRS) + " setup.py py2exe" + ils * qti, shell = True)
  82.             slf.Pbr.setValue(100)
  83.            
  84.            
  85.  
  86.        
  87.     def Ovs(slf):
  88.         global ise
  89.         if slf.Cbx.currentText() == "\u0646\u0633\u062e\u0647 \u0647\u0627\u06cc \u062f\u06cc\u06af\u0631":
  90.             slf.Lb2.setEnabled(True)
  91.             slf.Let.setEnabled(True)
  92.             ise = True
  93.         elif ise:
  94.             slf.Lb2.setEnabled(False)
  95.             slf.Let.setEnabled(False)
  96.             ise = False
  97.        
  98. app = QtGui.QApplication(sys.argv)
  99. def Exc(win):
  100.     mwn = win(None)
  101.     mwn.show()
  102.     app.exec_()
  103.  
  104. Exc(Pg1)
  105. Exc(Pg2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement