srcanamdw/codescanner/pyinstaller/McGUI.py
changeset 1 22878952f6e2
equal deleted inserted replaced
0:509e4801c378 1:22878952f6e2
       
     1 #!/usr/bin/python
       
     2 
       
     3 # Tkinter interface to the McMillan installer
       
     4 # (c) 2003 Alan James Salmoni - yes, all this bad code is all mine!!!
       
     5 # released under the MIT license
       
     6 
       
     7 import os, os.path
       
     8 from Tkinter import *
       
     9 import tkFileDialog
       
    10 import FileDialog
       
    11 
       
    12 class McGUI:
       
    13     def __init__(self):
       
    14         root = Tk()
       
    15         fr1 = Frame(root)
       
    16         fr1["width"] = 200
       
    17         fr1["height"] = 100
       
    18         fr1.pack(side="top")
       
    19         fr2 = Frame(root)
       
    20         fr2["width"] = 200
       
    21         fr2["height"] = 300
       
    22         fr2["borderwidth"] = 2
       
    23         fr2["relief"] = "ridge"
       
    24         fr2.pack()
       
    25         fr4 = Frame(root)
       
    26         fr4["width"]=200
       
    27         fr4["height"]=100
       
    28         fr4.pack(side="bottom")
       
    29         getFileButton = Button(fr1)
       
    30         getFileButton["text"] = "Script..."
       
    31         getFileButton.bind("<Button>",self.GetFile)
       
    32         getFileButton.pack(side="left")
       
    33         self.filein = Entry(fr1)
       
    34         self.filein.pack(side="right")
       
    35         self.filetypecheck = Checkbutton(fr2)
       
    36         self.filetypecheck["text"] = "One File Package                 "
       
    37         self.filetype = IntVar()
       
    38         self.filetypecheck["variable"] = self.filetype
       
    39         self.filetypecheck.pack()
       
    40         self.tkcheck = Checkbutton(fr2)
       
    41         self.tkcheck["text"] = "Include Tcl/Tk                         "
       
    42         self.tk = IntVar()
       
    43         self.tkcheck["variable"] = self.tk
       
    44         self.tkcheck.pack()
       
    45         self.asciicheck = Checkbutton(fr2)
       
    46         self.asciicheck["text"] = "Do NOT include decodings"
       
    47         self.ascii = IntVar()
       
    48         self.asciicheck["variable"] = self.ascii
       
    49         self.asciicheck.pack()
       
    50         self.debugcheck = Checkbutton(fr2)
       
    51         self.debugcheck["text"] = "Use debug versions             "
       
    52         self.debug = IntVar()
       
    53         self.debugcheck["variable"] = self.debug
       
    54         self.debugcheck.pack()
       
    55         self.noconsolecheck = Checkbutton(fr2)
       
    56         self.noconsolecheck["text"] = "No console (Windows only)"
       
    57         self.noconsole = IntVar()
       
    58         self.noconsolecheck["variable"] = self.noconsole
       
    59         self.noconsolecheck.pack()
       
    60         okaybutton = Button(fr4)
       
    61         okaybutton["text"] = "Okay   "
       
    62         okaybutton.bind("<Button>",self.makePackage)
       
    63         okaybutton.pack(side="left")
       
    64         cancelbutton = Button(fr4)
       
    65         cancelbutton["text"] = "Cancel"
       
    66         cancelbutton.bind("<Button>",self.killapp)
       
    67         cancelbutton.pack(side="right")
       
    68         self.fin = ''
       
    69         self.fout = ''
       
    70         root.mainloop()
       
    71 
       
    72     def killapp(self, event):
       
    73         sys.exit(0)
       
    74 
       
    75     def makePackage(self, event):
       
    76         commands = 'python Makespec.py '
       
    77         if (self.filetype.get() == 1):
       
    78             commands = commands + '--onefile '
       
    79         if (self.tk.get() == 1):
       
    80             commands = commands + '--tk '
       
    81         if (self.ascii.get() == 1):
       
    82             commands = commands + '--ascii '
       
    83         if (self.debug.get() == 1):
       
    84             commands = commands + '--debug '
       
    85         if (self.noconsole.get() == 1):
       
    86             commands = commands + '--noconsole '
       
    87         commands = commands + self.fin
       
    88         x = os.path.split(self.fin)
       
    89         y = os.path.splitext(x[1])
       
    90         os.system(commands)
       
    91         commands = 'python Build.py '+str(y[0])+os.sep+str(y[0])+'.spec'
       
    92         os.system(commands)
       
    93         sys.exit(0)
       
    94 
       
    95     def GetFile(self, event):
       
    96         self.fin = tkFileDialog.askopenfilename()
       
    97         self.filein.insert(0,self.fin)
       
    98 
       
    99 if __name__ == "__main__":
       
   100     app = McGUI()