Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import sys
- datafile = "calculator.ico"
- if not hasattr(sys, "frozen"):
- datafile = os.path.join(os.path.dirname(__file__), datafile)
- else:
- datafile = os.path.join(sys.prefix, datafile)
- window = tkinter.Tk()
- window.iconbitmap(default=datafile)
- pyinstaller -w -F -i "C:PythonProjectsCalccalculator.ico" calculator.py
- pyinstaller --onefile --windowed --icon=calculator.ico calculator.py
- # -*- mode: python -*-
- block_cipher = None
- a = Analysis(['calculator.py'],
- pathex=['C:\PythonProjects\calc'],
- binaries=[],
- datas=[],
- hiddenimports=[],
- hookspath=[],
- runtime_hooks=[],
- excludes=[],
- win_no_prefer_redirects=False,
- win_private_assemblies=False,
- cipher=block_cipher)
- pyz = PYZ(a.pure, a.zipped_data,
- cipher=block_cipher)
- exe = EXE(pyz,
- a.scripts,
- a.binaries + [('caclulator.ico', 'C:\PythonProjects\calc\calculator.ico', 'DATA')],
- a.zipfiles,
- a.datas,
- name='calculator',
- debug=False,
- strip=False,
- upx=True,
- console=False , icon='calculator.ico')
- + [('caclulator.ico', 'C:\PythonProjects\calc\calculator.ico', 'DATA')]
- pyinstaller calculator.spec
- def resource_path(relative_path):
- try:
- base_path = sys._MEIPASS
- except Exception:
- base_path = os.path.abspath(".")
- return os.path.join(base_path, relative_path)
- window.iconbitmap(default=resource_path(datafile))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement