[我知道這個問題已被問過多次,但我仍然無法找到適合我的選項]
我正在使用 replit.com 撰寫我的 python 代碼。
我用 python 制作了一個程式,但我想把它變成一個可執行的應用程式(而不是像我在 mac 上那樣的 .exe)。我看到很多人使用 py2app 但它對我不起作用(可能是因為我使用的是在線 IDE)。我也嘗試過 PyCharm,但是當我寫:“pip install py2app”來匯入包時,它只是說它不知道命令“pip”。
檔案名是:“main.py”
這是我的代碼,以防它有幫助(它非常混亂和混亂):
from tkinter import *
import math
root = Tk()
root.title('Minion Profit Calculator')
#Variables#
money = 0
actionT = 0
itemPerAc = 0
unitPr = 0
hasDia = IntVar()
diaSprMoney = 0
money1h = 0
#Labels#
acTime = Label(root, text="Action Time:")
itemAc = Label(root, text="Item/Action:")
unitPrice = Label(root, text="Unit Price:")
diaSpread = Label(root, text="Diamond Spreading:")
profitDis = Label(root, text="Profit (/24h):")
profit = Label(root, text="")
profit1Dis = Label(root, text="Profit (/1h)")
profit1 = Label(root, text="")
#Input Fields#
acTimeIn = Entry(root)
itemAcIn = Entry(root)
unitPriceIn = Entry(root)
#Checkboxes#
diaSpreadBox = Checkbutton(root, variable=hasDia, onvalue=1, offvalue=0)
#Click Event#
def isClicked():
actionT = float(acTimeIn.get())
itemPerAc = float(itemAcIn.get())
unitPr = float(unitPriceIn.get())
money = (86400/actionT*itemPerAc*unitPr)
diaSprMoney = (138240/actionT)
if (hasDia.get() == 1):
money = money diaSprMoney
money = math.trunc(money)
money1h = (money / 24)
money1h = math.trunc(money1h)
#Add $ before the number
money = str(money)
money1h = str(money1h)
money = ("$" money)
money1h = ("$" money1h)
profit.configure(text=money)
profit1.configure(text=money1h)
#Buttons#
cal = Button(root, text="Calculate", command=isClicked)
#Grid Placing#
acTime.grid(row = 0, column = 0)
itemAc.grid(row = 1, column = 0)
unitPrice.grid(row = 2, column = 0)
diaSpread.grid(row=3, column = 0)
profitDis.grid(row=5)
profit.grid(row=5, column=1)
profit1Dis.grid(row=6)
profit1.grid(row=6, column=1)
acTimeIn.grid(row=0, column=1)
itemAcIn.grid(row=1, column=1)
unitPriceIn.grid(row=2, column=1)
diaSpreadBox.grid(row=3, column=1)
cal.grid(row=4, columnspan=2)
root.mainloop
uj5u.com熱心網友回復:
請嘗試將您的代碼移動到您機器上的新 python 檔案中。我認為使用 replit 不可能做到這一點。
您必須下載 pip 才能正確執行此操作。你可以在這里下載 pip 。
下載 pip 后,您可以使用Pyinstaller庫將 Python 程式打包為獨立的可執行檔案。它適用于 Windows、Linux 和 Mac。
閱讀此答案以獲取更多詳細資訊。
如果您想堅持使用py2app,請pip install py2app在下載 pip 后在終端中運行。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/323843.html
