| 1 | #!/usr/bin/python |
|---|
| 2 | |
|---|
| 3 | # Tkinter interface to the McMillan installer / PyInstaller |
|---|
| 4 | # (c) 2003 Alan James Salmoni - yes, all this bad code is all mine!!! |
|---|
| 5 | # (c) 2011 Hartmut Goebel: adopted to PyInstaller 1.6, use subprocess |
|---|
| 6 | # released under the MIT license |
|---|
| 7 | |
|---|
| 8 | import os |
|---|
| 9 | import sys |
|---|
| 10 | import subprocess |
|---|
| 11 | from Tkinter import * |
|---|
| 12 | import tkFileDialog |
|---|
| 13 | import FileDialog |
|---|
| 14 | |
|---|
| 15 | class PyInstallerGUI: |
|---|
| 16 | |
|---|
| 17 | def make_checkbutton(self, frame, text): |
|---|
| 18 | var = IntVar() |
|---|
| 19 | widget = Checkbutton(frame, text=text, variable=var) |
|---|
| 20 | widget.grid(sticky="NW") |
|---|
| 21 | return var |
|---|
| 22 | |
|---|
| 23 | def __init__(self): |
|---|
| 24 | root = Tk() |
|---|
| 25 | root.title("PyInstaller GUI") |
|---|
| 26 | fr1 = Frame(root, width=300, height=100) |
|---|
| 27 | fr1.pack(side="top") |
|---|
| 28 | |
|---|
| 29 | fr2 = Frame(root, width=300, height=300, |
|---|
| 30 | borderwidth=2, relief="ridge") |
|---|
| 31 | fr2.pack(ipadx=10, ipady=10) |
|---|
| 32 | fr4 = Frame(root, width=300, height=100) |
|---|
| 33 | fr4.pack(side="bottom", pady=10) |
|---|
| 34 | |
|---|
| 35 | getFileButton = Button(fr1, text="Script to bundle ...") |
|---|
| 36 | getFileButton.bind("<Button>", self.GetFile) |
|---|
| 37 | getFileButton.pack(side="left") |
|---|
| 38 | self.filein = Entry(fr1) |
|---|
| 39 | self.filein.pack(side="right") |
|---|
| 40 | self.filetype = self.make_checkbutton(fr2, "One File Package") |
|---|
| 41 | self.ascii = self.make_checkbutton(fr2, "Do NOT include decodings") |
|---|
| 42 | self.debug = self.make_checkbutton(fr2, "Use debug versions") |
|---|
| 43 | if sys.platform.startswith('win'): |
|---|
| 44 | self.noconsole = self.make_checkbutton(fr2, "No console (Windows only)") |
|---|
| 45 | else: |
|---|
| 46 | self.noconsole = IntVar() |
|---|
| 47 | if not sys.platform.startswith('win'): |
|---|
| 48 | self.strip = self.make_checkbutton(fr2, "Strip the exe and shared libs") |
|---|
| 49 | else: |
|---|
| 50 | self.strip = IntVar() |
|---|
| 51 | |
|---|
| 52 | okaybutton = Button(fr4, text="Okay ") |
|---|
| 53 | okaybutton.bind("<Button>", self.makePackage) |
|---|
| 54 | okaybutton.pack(side="left") |
|---|
| 55 | |
|---|
| 56 | cancelbutton = Button(fr4, text="Cancel") |
|---|
| 57 | cancelbutton.bind("<Button>", self.killapp) |
|---|
| 58 | cancelbutton.pack(side="right") |
|---|
| 59 | self.fin = '' |
|---|
| 60 | self.fout = '' |
|---|
| 61 | |
|---|
| 62 | ws = root.winfo_screenwidth() |
|---|
| 63 | hs = root.winfo_screenheight() |
|---|
| 64 | x = (ws/2) - (400/2) |
|---|
| 65 | y = (hs/2) - (250/2) |
|---|
| 66 | root.geometry('%dx%d+%d+%d' % (400, 250, x, y)) |
|---|
| 67 | |
|---|
| 68 | root.mainloop() |
|---|
| 69 | |
|---|
| 70 | def killapp(self, event): |
|---|
| 71 | sys.exit(0) |
|---|
| 72 | |
|---|
| 73 | def makePackage(self, event): |
|---|
| 74 | commands = ['python', 'pyinstaller.py'] |
|---|
| 75 | if self.filetype.get(): |
|---|
| 76 | commands.append('--onefile') |
|---|
| 77 | if self.ascii.get(): |
|---|
| 78 | commands.append('--ascii') |
|---|
| 79 | if self.debug.get(): |
|---|
| 80 | commands.append('--debug') |
|---|
| 81 | if self.noconsole.get(): |
|---|
| 82 | commands.append('--noconsole') |
|---|
| 83 | if self.strip.get(): |
|---|
| 84 | commands.append('--strip') |
|---|
| 85 | commands.append(self.fin) |
|---|
| 86 | retcode = subprocess.call(commands) |
|---|
| 87 | sys.exit(retcode) |
|---|
| 88 | |
|---|
| 89 | def GetFile(self, event): |
|---|
| 90 | self.fin = tkFileDialog.askopenfilename() |
|---|
| 91 | self.filein.insert(0, self.fin) |
|---|
| 92 | |
|---|
| 93 | if __name__ == "__main__": |
|---|
| 94 | try: |
|---|
| 95 | app = PyInstallerGUI() |
|---|
| 96 | except KeyboardInterrupt: |
|---|
| 97 | raise SystemExit("Aborted by user request.") |
|---|