0
import Tkinter
import tkMessageBox

def created():
    tkMessageBox.showinfo('File Created!', 'Letter.html Created on Desktop')

class simpleapp_tk(Tkinter.Tk):
    def __init__(self,parent):
        Tkinter.Tk.__init__(self,parent)
        self.parent = parent
        self.initialize()

    def initialize(self):
        self.grid()

# --- Everything Fine Here ---

        self.B = Tkinter.Button(self, text = 'Create Document', command = self.OnButtonClick)
        self.B.grid(column = 0, row = 6)


    def OnButtonClick(self):
        created()


if __name__ == "__main__":
    app = simpleapp_tk(None)
    app.title('Receipt Form')
    app.iconbitmap(os.getcwd() + '/M.tiff')
    app.mainloop()

I use py2app to create a standalone application with this, but when I run it and press the button, it seems to crash.

I am very certain it is tkMessageBox that is causing the problem but the message box works perfectly fine in IDLE.

It also worked fine on my Windows 10 computer with pyinstaller.

cs95
  • 379,657
  • 97
  • 704
  • 746
Michael Zheng
  • 136
  • 1
  • 9

1 Answers1

0

py2exe is windows version of py2app.

first of all to build we need a setup file like this:

[setup.py]

from distutils.core import setup
import py2exe                      #in your case import py2app
setup(console=['myFile.py'])

on running this file using python setup.py py2exe :

it will call setup and tell it that we want a single console application and the main entry point is "myFile.py".

On complete build, two directories are created . Look into the dist directory and run your app.

It is working completely fine.

No errors

PS - make sure path to your icon is correct

output screenshot here

swayamraina
  • 2,958
  • 26
  • 28