Today I've started learning python. I only ever used PHP for various things and never had to bother with building exe files.
Using some internet Python programming tutorials and a little of my own editing I came up with random "How many times you've clicked" application as shown below
import winsound
from tkinter import *
class Application(Frame):
def __init__(self, master):
Frame.__init__(self,master)
self.pack()
self.counts = 0
self.create_widgets()
def create_widgets(self):
Label(self, text = "Test Label").pack()
self.button = Button(self, text = "click", command = self.update_text).pack()
self.result = Label(self, text = "Clicked 0 times")
self.result.pack()
def update_text(self):
self.counts += 1
self.result["text"] = "Clicked " + str(self.counts) + " times"
winsound.PlaySound('sound1.wav', winsound.SND_FILENAME | winsound.SND_ASYNC)
root = Tk()
root.title("Title")
root.geometry("300x120")
app = Application(root)
root.mainloop
Application works fine but the problems started when I tried to compile it to a single exe file for a convenience reasons as I intend to write small "making something a bit easier" programs. Py2Exe doesn't want to compile the program with bundle_files 1 at all. PyInstaller did compile it with --onefile, but upon executing, application gives you nothing more than tkinter errors.
Is there a way of creating small one exe files with GUI or is it a dead end? I'm not going to lie but I really loved the idea of learning python and being able to use it in both web and desktop applications which wasn't very possible in PHP.
I'm using Python 3.4 and tested builtin py2exe and development PyInstaller for Python 3.3 - 3.4.
Edit: Sample setup.py for py2exe and the error
from distutils.core import setup
import py2exe
setup( windows=[{"script": "text.py"}],
options = {"py2exe": {"bundle_files": 1}
})
Error
C:\Users\SEJBR\Desktop\Python>python setup.py py2exe
running py2exe
1 missing Modules
------------------
? readline imported from cmd, code, pdb
OOPS: tkinter 2
PyInstaller compilation error
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named 'Tkinter'
2515 ERROR: TCL/TK seams to be not properly installed on this system