I have a fraction calculator program that I wrote that has a GUI. I wrote it in Eclipse, but I want to turn it into a application that runs when you click on the icon. I've tried py2exe and cx_freeze, but all that happens when I click on the .exe file is a shell opens for a split second and then closes right away. It doesn't even show my GUI. I might need something in my code that I don't currently have, so I'll post that here:

# Import necessary libraries from tkinter import * from tkinter import ttk from fractions import gcd # Determines which function to call based on which # operator the user chose def calc(*args): opChoice = opVar.get() if opChoice == '*': mult() elif opChoice == '/': div() elif opChoice == '+': add() elif opChoice == '-': sub() # Multiplies two fractions def mult(*args): n1 = int(num1.get()) n2 = int(num2.get()) d1 = int(den1.get()) d2 = int(den2.get()) num = n1*n2 den = d1*d2 answ = reduce(num, den) answer.set(answ) # Divides two fractions def div(*args): n1 = int(num1.get()) n2 = int(num2.get()) d1 = int(den1.get()) d2 = int(den2.get()) num = n1*d2 den = d1*n2 answ = reduce(num, den) answer.set(answ) # Adds two fractions def add(*args): n1 = int(num1.get()) n2 = int(num2.get()) d1 = int(den1.get()) d2 = int(den2.get()) if d1 == d2: answ = reduce(n1+n2, d1) answer.set(answ) else: n1, n2 = n1*d2, n2*d1 d = d1*d2 answ = reduce(n1+n2, d) answer.set(answ) # Subtracts two fractions def sub(*args): n1 = int(num1.get()) n2 = int(num2.get()) d1 = int(den1.get()) d2 = int(den2.get()) if d1 == d2: answ = reduce(n1-n2, d1) answer.set(answ) else: n1, n2 = n1*d2, n2*d1 d = d1*d2 answ = reduce(n1-n2, d) answer.set(answ) # Checks to see if the answer is able to be reduced # If so, it returns the fraction in reduced form def reduce(num, den): divisor = gcd(num, den) if divisor <= 1: return ('%d/%d' % (num, den)) else: return ('%d/%d' % (num/divisor, den/divisor)) #-----------------------------GUI Components------------------------------# # Create root window root = Tk() root.title("Fraction Calculator") # Create a frame that all our widgets will go into mainframe = ttk.Frame(root, padding=5) mainframe.grid(row=0, column=0, sticky=(N, S, E, W)) mainframe.rowconfigure(0, weight=1) mainframe.columnconfigure(0, weight=1) # Create all necessary StringVars num1 = StringVar() den1 = StringVar() num2 = StringVar() den2 = StringVar() opVar = StringVar() answer = StringVar() # Create and display Entry, Combobox, and Label widgets # Numerator 1 n1_entry = ttk.Entry(mainframe, width=5, textvariable=num1) n1_entry.grid(row=0, column=0, sticky=(S, E)) # Denominator 1 d1_entry = ttk.Entry(mainframe, width=5, textvariable=den1) d1_entry.grid(row=1, column=0, sticky=(N, E)) # Numerator 2 n2_entry = ttk.Entry(mainframe, width=5, textvariable=num2) n2_entry.grid(row=0, column=2, sticky=(S, W)) # Denominator 2 d2_entry = ttk.Entry(mainframe, width=5, textvariable=den2) d2_entry.grid(row=1, column=2, sticky=(N, W)) # Operation drop down box op = ttk.Combobox(mainframe, width=5, values=('*', '/', '+', '-'), textvariable=opVar) op.grid(row=1, column=1, sticky=N) # Labels to display answer ttk.Label(mainframe, text="Answer: ").grid(row=2, column=0, sticky=E) ttk.Label(mainframe, relief=SUNKEN, width=10, textvariable=answer).grid(row=2, column=1, sticky=W) # Calculate button, performs specified operation when clicked calcBut = ttk.Button(mainframe, text="Calculate", command = calc).grid(row=2, column=2, sticky=(E, W)) # Adds some extra padding around each widget for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=5) # Cursor will start in the n1_entry box n1_entry.focus() # Specified operation will be executed when Enter key is pressed root.bind('<Return>', calc) mainloop()

If you have any ideas on how to do what I'm asking, I'd love to hear them. Also, if you have suggestions on how to make my code better I'd appreciate that feedback as well. Thanks!