obernardovieira

[Tutorial+Examples] To Executable (using cx_Freeze)

Feb 25th, 2014
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.68 KB | None | 0 0
  1. #+++++++     FIRST OF ALL    +++++++++++
  2. #Download cx_Freeze and install, and then, follow this tutorial
  3.  
  4. #create a folder in Python directory folder named mycodes
  5. #save this two codes inside
  6.  
  7. #toexe.py
  8. #++++++++++++++++++++
  9.  
  10. import sys
  11. from cx_Freeze import setup, Executable
  12.  
  13. # Dependencies are automatically detected, but it might need fine tuning.
  14. build_exe_options = {"packages": ["os"], "excludes": ["tkinter"]}
  15.  
  16. # GUI applications require a different base on Windows (the default is for a
  17. # console application).
  18. base = None
  19. if sys.platform == "win32":
  20.     base = "console" #if you want to make a Windows GUI use "Win32Gui" but don't use console functions!
  21.  
  22. setup(  name = "WeakDay",
  23.         version = "0.1",
  24.         description = "My Console application!",
  25.         options = {"build_exe": build_exe_options},
  26.         executables = [Executable("mycodes/weak.py", base=base)])
  27.  
  28. #++++++++++++++++++++
  29. #weak.py
  30. #++++++++++++++++++++
  31.  
  32. import sys
  33.  
  34. days = ["monday","tuesday","wednesday","thursday","friday","saturday","sunday"]
  35. def weakday( day_s) :
  36.         if int(day_s) in range(1,7) :
  37.                 print(days[int(day_s)-1])
  38.         else :
  39.                 print("Enter a valid day of the week!")
  40.                 day = input('Enter the day of the week: ')
  41.                 weakday(day)
  42.         return;
  43.  
  44. day = input('Enter the day of the week: ')
  45. weakday(day)
  46.  
  47. #++++++++++++++++++++
  48.  
  49.  
  50. #and now, open the a command line, go to python directory folder (something like [ cd "C:\Python33" ])
  51. #and execute the command "python mycodes/toexe.py build"
  52. #back to python directory folder, then build folder, then exe.win32-3.3 folder, and execute the file named weak.exe
  53. #done
Add Comment
Please, Sign In to add comment