Reputation: 591
I'm unable to get PyInstaller to find my program. I have tried to but still can't get it to work.
Could somebody tell me how to use PyInstaller or link me to a simple tutorial that doesn't say things like 'run this' without telling you where it is.
I have gotten as far as telling PyInstaller where my program is in the command prompt, but it can't find it.
"""
VERSION 0.1
TIDE
CREATOR: THEDUDXO / ISAAC BOON
"""
from Tkinter import *
food_storage = 100
height = 1
tide = 0
food = 100
population = 50
crabfarms = 1
pop_rise = 0
food_rise = 50
clay_income = population/5
clay = 1
tide_rise = 1
stat = '[ height: ' +str(height)+' ] [ tide: '+str(tide)+' ] [ food: '+ str(food) +'/'+str(food_storage)+'] [ food rise: '+str(food_rise)+' ] [ population: '+ str(population)+ ' ] [ clay: '+ str(clay)+'] [ Clay Income: '+str(clay_income)+' ]'
def update_stat():
global stat, stats
stat = '[ height: ' +str(height)+' ] [ tide: '+str(tide)+' ] [ food: '+ str(food) +'/'+str(food_storage)+'] [ food rise: '+str(food_rise)+' ] [ population: '+ str(population)+ ' ] [ clay: '+ str(clay)+'] [ Clay Income: '+str(clay_income)+' ]'
stats.config(text=stat)
print 'update_stat taceback' ,stat
def crabfarm():
global crabfarms,clay,food_rise,Hhelp
if clay >= 5:
crabfarms +=1 # $$$ note to self - Make crabfarms cost more clay each build, without it being buggy? $$$ #
food_rise += 15
clay = clay - 5
print 'crabfarm check'
else:
Hhelp.config(text = 'Not enougth clay.')
print 'crabfarm traceback'
update_stat()
def granary():
print 'granary trace'
global food_storage,clay,Hhelp
if clay > 4:
print 'granary trace sucsess'
food_storage += 10
print clay
clay = clay -5
else:
Hhelp.config(text = 'Not enougth clay.')
update_stat()
def turn_end():
global height, clay, stat, tide_rise, tide,population,pop_rise,food,food_rise,clay_income,game
Hhelp.config(text='Turn ended.')
previous_height = height
height += clay
clay = 0
previous_clay = clay
clay += clay_income
tide += tide_rise
tide_rise += 0.5
pop_rise = int(population/26)
population += pop_rise
clay_income = int(population/5)
food = (food - population)+food_rise
food = min(food,food_storage)
if clay <= 0:
clay = 0
if height < tide:
Hhelp.config(text = 'Your civilization drowned!')
end_turn.destroy()
population = 0
if food < 0:
food = 0
clay = previous_clay
print 'endturn traceback' , stat
update_stat()
def exit_game():
global game
game.destroy()
print 'quit traceback'
#save feature here? (add load as a seprate button prehaps in main menu)
def farm_menu():
def Exit():
farm.destroy()
farm = Tk()
frame=Frame(farm,background='grey',border='3')
frame.pack()
build_farm = Button(frame,text='Build a Crabfarm (5 clay)',command = crabfarm)
build_granary = Button(frame,text='Build a Granary (5 clay)',command=granary)
done=Button(frame,text='done',command=Exit)
build_farm.pack(side='top')
build_granary.pack(side='top')
done.pack()
farm.mainloop()
game = Tk()
frame1=Frame(background='blue',border = '3')
frame = Frame(background='grey',border='10')
frame2 = Frame(background='black',border ='5')
frame3 = Frame(background = 'orange',border='3')
frame1.pack(side='top')
frame.pack(side='left')
frame2.pack(side='right')
frame3.pack()
stats = Label(frame1,text=stat)
stats.pack()
end_turn = Button(frame2,text='End turn', command = turn_end)
Qquit= Button(frame2,text='Quit',command = exit_game,background='red')
Qquit.pack(side='right')
end_turn.pack(side='left')
Hhelp = Label(frame3,background = 'grey',text = 'Welcome to Tide! version; 0.1')
Hhelp.pack()
farms=Button(frame,text='Build Farms',command = farm_menu)
farms.pack()
game.mainloop()
Upvotes: 0
Views: 403
Reputation: 114098
not sure what you mean ... pyinstaller is very easy to use . here is step by step
C:\pyinstaller-2.1\<bunchafiles>
C:\path\to\code> _
python C:\pyinstaller-2.1\pyinstaller.py --onefile my_main_prog.py
I went ahead and copied and pasted your code into a file c:\py_exp\tk_stackoverflow_thedudxo.py
I opened a console and entered the following commands
cd c:\py_exp
python c:\pyinstaller\pyinstaller.py --onefile --console tk_stackoverflow_thedudxo.py
I now have a new file located at c:\py_exp\dist\tk_stackoverflow_thedudxo.py
if I double click this executable(or run it from the console/terminal/cmd.exe) your program pops right up ...
Upvotes: 2