title: pyinstaller single EXE file - ico image in title of tkinter main window
body: <p>I found some information here on Stack Overflow about this and have been trying it out, but it does not work for me. I need assistance from the community :)</p>
  
  <p>As the title suggests, I want to add an *.ico to my tkinter windows. The problem is when creating a single EXE file using pyinstaller, this is not very straight forward. So below is exactly what I implemented from information gathered on Stack Overflow. Using Python 3.5 on 64 bit machine.</p>
  
  <p>The name of my script is calculator.py
  The name of the ico is calculator.ico</p>
  
  <p><strong>1. I added the following lines of code to my Python script:</strong></p>
  
  <pre><code>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)
  </code></pre>
  
  <p><strong>2a. I then built my single EXE file with pyinstaller using the following commands:</strong></p>
  
  <pre><code>pyinstaller -w -F -i "C:\PythonProjects\Calc\calculator.ico" calculator.py
  </code></pre>
  
  <p><strong>2b. I also tried building my single EXE file with the following commands
      to see if it would help:</strong></p>
  
  <pre><code>pyinstaller --onefile --windowed --icon=calculator.ico calculator.py
  </code></pre>
  
  <p><strong>3. After pyinstaller built the single EXE file, I then added some content to the *.spec file - below is the complete *.spec file with added content:</strong></p>
  
  <pre><code># -*- 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')
  </code></pre>
  
  <p>I added the following to exe = EXE:</p>
  
  <pre><code>+ [('caclulator.ico', 'C:\\PythonProjects\\calc\\calculator.ico', 'DATA')]
  </code></pre>
  
  <p>After adding the above content to the spec file, I ran the following command.</p>
  
  <pre><code>pyinstaller calculator.spec
  </code></pre>
  
  <p>After the EXE is rebuilt, I run the EXE file and I receive the following error message:</p>
  
  <ul>
  <li>Failed to execute script calculator</li>
  </ul>
  
  <p>Thanks in advance!</p>