Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. import os
  2. import sys
  3.  
  4. datafile = "calculator.ico"
  5. if not hasattr(sys, "frozen"):
  6. datafile = os.path.join(os.path.dirname(__file__), datafile)
  7. else:
  8. datafile = os.path.join(sys.prefix, datafile)
  9.  
  10.  
  11. window = tkinter.Tk()
  12. window.iconbitmap(default=datafile)
  13.  
  14. pyinstaller -w -F -i "C:PythonProjectsCalccalculator.ico" calculator.py
  15.  
  16. pyinstaller --onefile --windowed --icon=calculator.ico calculator.py
  17.  
  18. # -*- mode: python -*-
  19.  
  20. block_cipher = None
  21.  
  22.  
  23. a = Analysis(['calculator.py'],
  24. pathex=['C:\PythonProjects\calc'],
  25. binaries=[],
  26. datas=[],
  27. hiddenimports=[],
  28. hookspath=[],
  29. runtime_hooks=[],
  30. excludes=[],
  31. win_no_prefer_redirects=False,
  32. win_private_assemblies=False,
  33. cipher=block_cipher)
  34. pyz = PYZ(a.pure, a.zipped_data,
  35. cipher=block_cipher)
  36. exe = EXE(pyz,
  37. a.scripts,
  38. a.binaries + [('caclulator.ico', 'C:\PythonProjects\calc\calculator.ico', 'DATA')],
  39. a.zipfiles,
  40. a.datas,
  41. name='calculator',
  42. debug=False,
  43. strip=False,
  44. upx=True,
  45. console=False , icon='calculator.ico')
  46.  
  47. + [('caclulator.ico', 'C:\PythonProjects\calc\calculator.ico', 'DATA')]
  48.  
  49. pyinstaller calculator.spec
  50.  
  51. def resource_path(relative_path):
  52. try:
  53. base_path = sys._MEIPASS
  54. except Exception:
  55. base_path = os.path.abspath(".")
  56.  
  57. return os.path.join(base_path, relative_path)
  58.  
  59. window.iconbitmap(default=resource_path(datafile))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement