1

私はpython 3.1.1を使用しており、今日以前に書いたプログラムをコンパイルしようとしています.コードは以下に投稿するのに十分短いと思います.

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()

数時間 cx_freeze でコンパイルしようとしましたが、うまくいきませんでした。フォルダーが作成されますが、.exe をクリックすると、非常に速く開いたり閉じたりします。非常に速く何度もクリックした後、Tkinter に関係するモジュールが欠落していることがわかりました。ここでフォーラムを検索した後、モジュールが欠落しているという結論に達しました。しかし、私はそれを修正することはできません!提案どおりに tcl8.5 および tk8.5 フォルダーを追加しようとしましたが、修正されていないようです。できる限りのことを試したので、最後の手段としてこの質問を作成します。作成されたフォルダーには、次のファイルがあります。

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

助けてください!

4

1 に答える 1

0

私は次のことを試しましたが、うまくいきました。

activestate python 3.2.2.3 の使用 ( http://www.activestate.com/activepython/downloads )

次に、http://cx-freeze.sourceforge.net/にアクセスし、Python 3.2 用の MSI をダウンロードしてインストールしました (64 ビットを使用しています)。

プログラムを C:\Scripts\Shopkeeper.py として保存しました

次にこれを実行しました:

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

それから私は走りましたC:\cxfreezetest\Shopkeeper.exe、そしてそれはうまくいきました。

ここに画像の説明を入力

于 2013-04-06T05:03:56.347 に答える