1

I use python 3.1.1, and I have been trying to compile a program i wrote earlier today, I think the code is short enough to post below.

from tkinter import *

class Application(Frame):
    """ GUI application that creates a story based on user input. """
    def __init__(self, master):
        """ Initialize Frame. """
        super(Application, self).__init__(master)  
        self.grid()
        self.label1()
        self.label2()



    def label1(self):
        Label(self,
              text = "Shop Keeper 1.1",
              font = ("fixedsys",
                      72)).grid(row = 0, column = 0, sticky = W)
    def label2(self):
        Label(self,
              text = "Welcome to Shop Keeper 1.1!"
              ).grid(row = 1, column = 0, sticky = W)


        # create a label and text entry for a plural noun
        Label(self,
              text = "Block name:"
              ).grid(row = 2, column = 0, sticky = W)
        self.BlokID = Entry(self)
        self.BlokID.grid(row = 2, column = 1, sticky = W)

        # create a label and text entry for a verb
        Label(self,
              text = "Amount:"
              ).grid(row = 3, column = 0, sticky = W)
        self.Amound = Entry(self)
        self.Amound.grid(row = 3, column = 1, sticky = W)

        Label(self,
              text = "Name:"
              ).grid(row = 4, column = 0, sticky = W)
        self.nama = Entry(self)
        self.nama.grid(row = 4, column = 1, sticky = W)

        Label(self,
              text = "Desired price:"
              ).grid(row = 5, column = 0, sticky = W)
        self.desprice = Entry(self)
        self.desprice.grid(row = 5, column = 1, sticky = W)

       # create a submit button
        Button(self,
               text = "Submit order",
               command = self.submit
               ).grid(row = 6, column = 1, sticky = W)

        self.submit = Text(self, width = 75, height = 10, wrap = WORD)
        self.submit.grid(row = 7, column = 0, columnspan = 4)

    def submit(self):
        """ Fill text box with new story based on user input. """
        # get values from the GUI
        BlockID = self.BlokID.get()
        amount = self.Amound.get()
        name = self.nama.get()
        price = self.desprice.get()

        emess = name 
        emess += " ordered "
        emess += amount
        emess += " units of "
        emess += BlockID
        emess += " at the price of "
        emess += price
        emess += " each."
        emess += "\n"

        # display the story                                

        self.submit.insert(0.0, emess)



# main
root = Tk()
root.title("Shop Keeper 1.0")
app = Application(root)
root.mainloop()

I've been trying to compile it with cx_freeze for a few hours, with no luck. It creates the folder, but when I click on the .exe it opens and closes really fast. After clicking very fast multiple times, I found that it is missing some module to do with Tkinter, and after searching the forums here I've come to the conclusion that it is missing the module. I can't fix it, however! I've already tried to add the tcl8.5 and tk8.5 folders as suggested, but it doesn't seem to fix it. I've tried all that I can, so I create this question as a last resort. The folder created has the files:

_socket.pyd
_tkinter.pyd
library.zip
mad_lib.exe
python31.dll
select.pyd
tcl85.dll
tk85.dll
unicodedata.pyd

Please help!

1 Answers1

0

I tried the following and it worked fine for me.

Using activestate python 3.2.2.3 (http://www.activestate.com/activepython/downloads)

I then went to http://cx-freeze.sourceforge.net/ and downloaded & installed the MSI for Python 3.2 (I'm using 64 bit).

I saved your program as C:\Scripts\Shopkeeper.py

Next I ran this:

C:\Python32\Scripts\cxfreeze C:\Scripts\Shopkeeper.py --target-dir C:\cxfreezetest

Then I ran C:\cxfreezetest\Shopkeeper.exe and it worked fine.

enter image description here

twasbrillig
  • 17,084
  • 9
  • 43
  • 67