Adding a .qss file to the pyinstaller bundle












0















I have a simple application where I am trying to bundle it into a executable. I am having problems where I add the path of the my .qss stylesheet to the .spec file but it causes an error when I try and run the exe from the bin directory. I get the error:



 Exception:[Errno 2] No such file or directory: 'FrontEnd\Styles\App.qss'


This will run if I put the executable in the base directory of the project but no where else although i'm using the --onefile flag. I have other files that I put the in the .spec file and they are picked up properly. But this seems to be a problem with .qss.



Jernel.spec



# -*- mode: python -*-

block_cipher = None

app_resources = [("FrontEnd/Styles/App.qss", "FrontEnd/Styles/"),
("Assets/Icons/*.png", "Assets/Icons/")]

a = Analysis(['Jernel.py'],
pathex=
['C:\Users\Fidel\Dropbox\Create\CProjects\MyProjects\Jernel'],
binaries=,
datas=app_resources,
hiddenimports=,
hookspath=,
runtime_hooks=,
excludes=,
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
,
name='Jernel',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
runtime_tmpdir=None,
console=True,
icon='C:\Users\Fidel\Dropbox\Create\CProjects\MyProjects\Jernel\Assets\Icons\Windows\AppIcon.ico')


Jernel.py



import sys
import ctypes
import pathlib
from FrontEnd import QMainWindow, QApplication, Qt, QDockWidget,
QGridLayout, QDockWidget, QIcon, QSize, QLabel
from BackEnd import Navigator

class Jernel(QMainWindow):
def __init__(self, parent = None):
super().__init__(parent)
self.stack = Navigator()
self.setWindowFeatures()
self.setWindowContent()
self.setAppIcons()
self.setMenuBar()
self.show()

def setWindowFeatures(self):
self.setGeometry(1280, 1280, 1280, 1280)
self.setWindowFlags(Qt.FramelessWindowHint)


def setAppIcons(self):
print("Adding Icons")
appIcon = QIcon()
sizes = [512, 256, 48, 32, 24, 16]
for size in sizes:
appIcon.addFile(str(pathlib.Path("Assets/Icons/AppIcon.png")),
QSize(size, size))
self.setWindowIcon(appIcon)
print("Finished")

def setMenuBar(self):
self.menuDock = QDockWidget()

def setWindowContent(self):
self.setCentralWidget(self.stack)

if __name__ == '__main__':
try:
jernelApp = QApplication(sys.argv)
jernelApp.setApplicationName("Jernel")
jernelApp.setApplicationDisplayName("Jernel")
jernelApp.setApplicationVersion("1.0.0")
if sys.platform == "win32":
jernelAppID = "FiddyTT.GuiApp.1.0.0"

ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(jernelAppID)
window = Jernel()
with open(str(pathlib.Path("FrontEnd/Styles/App.qss")), "r") as stylesSheet:
window.setStyleSheet(stylesSheet.read())
jernelApp.exec_()
except Exception as exe:
print("Exception:{}".format(exe))
finally:
check = input()


The icons do not cause an exception when they are loaded only the sytleSheet. Thank you in advance for any help.










share|improve this question



























    0















    I have a simple application where I am trying to bundle it into a executable. I am having problems where I add the path of the my .qss stylesheet to the .spec file but it causes an error when I try and run the exe from the bin directory. I get the error:



     Exception:[Errno 2] No such file or directory: 'FrontEnd\Styles\App.qss'


    This will run if I put the executable in the base directory of the project but no where else although i'm using the --onefile flag. I have other files that I put the in the .spec file and they are picked up properly. But this seems to be a problem with .qss.



    Jernel.spec



    # -*- mode: python -*-

    block_cipher = None

    app_resources = [("FrontEnd/Styles/App.qss", "FrontEnd/Styles/"),
    ("Assets/Icons/*.png", "Assets/Icons/")]

    a = Analysis(['Jernel.py'],
    pathex=
    ['C:\Users\Fidel\Dropbox\Create\CProjects\MyProjects\Jernel'],
    binaries=,
    datas=app_resources,
    hiddenimports=,
    hookspath=,
    runtime_hooks=,
    excludes=,
    win_no_prefer_redirects=False,
    win_private_assemblies=False,
    cipher=block_cipher,
    noarchive=False)
    pyz = PYZ(a.pure, a.zipped_data,
    cipher=block_cipher)
    exe = EXE(pyz,
    a.scripts,
    a.binaries,
    a.zipfiles,
    a.datas,
    ,
    name='Jernel',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    runtime_tmpdir=None,
    console=True,
    icon='C:\Users\Fidel\Dropbox\Create\CProjects\MyProjects\Jernel\Assets\Icons\Windows\AppIcon.ico')


    Jernel.py



    import sys
    import ctypes
    import pathlib
    from FrontEnd import QMainWindow, QApplication, Qt, QDockWidget,
    QGridLayout, QDockWidget, QIcon, QSize, QLabel
    from BackEnd import Navigator

    class Jernel(QMainWindow):
    def __init__(self, parent = None):
    super().__init__(parent)
    self.stack = Navigator()
    self.setWindowFeatures()
    self.setWindowContent()
    self.setAppIcons()
    self.setMenuBar()
    self.show()

    def setWindowFeatures(self):
    self.setGeometry(1280, 1280, 1280, 1280)
    self.setWindowFlags(Qt.FramelessWindowHint)


    def setAppIcons(self):
    print("Adding Icons")
    appIcon = QIcon()
    sizes = [512, 256, 48, 32, 24, 16]
    for size in sizes:
    appIcon.addFile(str(pathlib.Path("Assets/Icons/AppIcon.png")),
    QSize(size, size))
    self.setWindowIcon(appIcon)
    print("Finished")

    def setMenuBar(self):
    self.menuDock = QDockWidget()

    def setWindowContent(self):
    self.setCentralWidget(self.stack)

    if __name__ == '__main__':
    try:
    jernelApp = QApplication(sys.argv)
    jernelApp.setApplicationName("Jernel")
    jernelApp.setApplicationDisplayName("Jernel")
    jernelApp.setApplicationVersion("1.0.0")
    if sys.platform == "win32":
    jernelAppID = "FiddyTT.GuiApp.1.0.0"

    ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(jernelAppID)
    window = Jernel()
    with open(str(pathlib.Path("FrontEnd/Styles/App.qss")), "r") as stylesSheet:
    window.setStyleSheet(stylesSheet.read())
    jernelApp.exec_()
    except Exception as exe:
    print("Exception:{}".format(exe))
    finally:
    check = input()


    The icons do not cause an exception when they are loaded only the sytleSheet. Thank you in advance for any help.










    share|improve this question

























      0












      0








      0








      I have a simple application where I am trying to bundle it into a executable. I am having problems where I add the path of the my .qss stylesheet to the .spec file but it causes an error when I try and run the exe from the bin directory. I get the error:



       Exception:[Errno 2] No such file or directory: 'FrontEnd\Styles\App.qss'


      This will run if I put the executable in the base directory of the project but no where else although i'm using the --onefile flag. I have other files that I put the in the .spec file and they are picked up properly. But this seems to be a problem with .qss.



      Jernel.spec



      # -*- mode: python -*-

      block_cipher = None

      app_resources = [("FrontEnd/Styles/App.qss", "FrontEnd/Styles/"),
      ("Assets/Icons/*.png", "Assets/Icons/")]

      a = Analysis(['Jernel.py'],
      pathex=
      ['C:\Users\Fidel\Dropbox\Create\CProjects\MyProjects\Jernel'],
      binaries=,
      datas=app_resources,
      hiddenimports=,
      hookspath=,
      runtime_hooks=,
      excludes=,
      win_no_prefer_redirects=False,
      win_private_assemblies=False,
      cipher=block_cipher,
      noarchive=False)
      pyz = PYZ(a.pure, a.zipped_data,
      cipher=block_cipher)
      exe = EXE(pyz,
      a.scripts,
      a.binaries,
      a.zipfiles,
      a.datas,
      ,
      name='Jernel',
      debug=False,
      bootloader_ignore_signals=False,
      strip=False,
      upx=True,
      runtime_tmpdir=None,
      console=True,
      icon='C:\Users\Fidel\Dropbox\Create\CProjects\MyProjects\Jernel\Assets\Icons\Windows\AppIcon.ico')


      Jernel.py



      import sys
      import ctypes
      import pathlib
      from FrontEnd import QMainWindow, QApplication, Qt, QDockWidget,
      QGridLayout, QDockWidget, QIcon, QSize, QLabel
      from BackEnd import Navigator

      class Jernel(QMainWindow):
      def __init__(self, parent = None):
      super().__init__(parent)
      self.stack = Navigator()
      self.setWindowFeatures()
      self.setWindowContent()
      self.setAppIcons()
      self.setMenuBar()
      self.show()

      def setWindowFeatures(self):
      self.setGeometry(1280, 1280, 1280, 1280)
      self.setWindowFlags(Qt.FramelessWindowHint)


      def setAppIcons(self):
      print("Adding Icons")
      appIcon = QIcon()
      sizes = [512, 256, 48, 32, 24, 16]
      for size in sizes:
      appIcon.addFile(str(pathlib.Path("Assets/Icons/AppIcon.png")),
      QSize(size, size))
      self.setWindowIcon(appIcon)
      print("Finished")

      def setMenuBar(self):
      self.menuDock = QDockWidget()

      def setWindowContent(self):
      self.setCentralWidget(self.stack)

      if __name__ == '__main__':
      try:
      jernelApp = QApplication(sys.argv)
      jernelApp.setApplicationName("Jernel")
      jernelApp.setApplicationDisplayName("Jernel")
      jernelApp.setApplicationVersion("1.0.0")
      if sys.platform == "win32":
      jernelAppID = "FiddyTT.GuiApp.1.0.0"

      ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(jernelAppID)
      window = Jernel()
      with open(str(pathlib.Path("FrontEnd/Styles/App.qss")), "r") as stylesSheet:
      window.setStyleSheet(stylesSheet.read())
      jernelApp.exec_()
      except Exception as exe:
      print("Exception:{}".format(exe))
      finally:
      check = input()


      The icons do not cause an exception when they are loaded only the sytleSheet. Thank you in advance for any help.










      share|improve this question














      I have a simple application where I am trying to bundle it into a executable. I am having problems where I add the path of the my .qss stylesheet to the .spec file but it causes an error when I try and run the exe from the bin directory. I get the error:



       Exception:[Errno 2] No such file or directory: 'FrontEnd\Styles\App.qss'


      This will run if I put the executable in the base directory of the project but no where else although i'm using the --onefile flag. I have other files that I put the in the .spec file and they are picked up properly. But this seems to be a problem with .qss.



      Jernel.spec



      # -*- mode: python -*-

      block_cipher = None

      app_resources = [("FrontEnd/Styles/App.qss", "FrontEnd/Styles/"),
      ("Assets/Icons/*.png", "Assets/Icons/")]

      a = Analysis(['Jernel.py'],
      pathex=
      ['C:\Users\Fidel\Dropbox\Create\CProjects\MyProjects\Jernel'],
      binaries=,
      datas=app_resources,
      hiddenimports=,
      hookspath=,
      runtime_hooks=,
      excludes=,
      win_no_prefer_redirects=False,
      win_private_assemblies=False,
      cipher=block_cipher,
      noarchive=False)
      pyz = PYZ(a.pure, a.zipped_data,
      cipher=block_cipher)
      exe = EXE(pyz,
      a.scripts,
      a.binaries,
      a.zipfiles,
      a.datas,
      ,
      name='Jernel',
      debug=False,
      bootloader_ignore_signals=False,
      strip=False,
      upx=True,
      runtime_tmpdir=None,
      console=True,
      icon='C:\Users\Fidel\Dropbox\Create\CProjects\MyProjects\Jernel\Assets\Icons\Windows\AppIcon.ico')


      Jernel.py



      import sys
      import ctypes
      import pathlib
      from FrontEnd import QMainWindow, QApplication, Qt, QDockWidget,
      QGridLayout, QDockWidget, QIcon, QSize, QLabel
      from BackEnd import Navigator

      class Jernel(QMainWindow):
      def __init__(self, parent = None):
      super().__init__(parent)
      self.stack = Navigator()
      self.setWindowFeatures()
      self.setWindowContent()
      self.setAppIcons()
      self.setMenuBar()
      self.show()

      def setWindowFeatures(self):
      self.setGeometry(1280, 1280, 1280, 1280)
      self.setWindowFlags(Qt.FramelessWindowHint)


      def setAppIcons(self):
      print("Adding Icons")
      appIcon = QIcon()
      sizes = [512, 256, 48, 32, 24, 16]
      for size in sizes:
      appIcon.addFile(str(pathlib.Path("Assets/Icons/AppIcon.png")),
      QSize(size, size))
      self.setWindowIcon(appIcon)
      print("Finished")

      def setMenuBar(self):
      self.menuDock = QDockWidget()

      def setWindowContent(self):
      self.setCentralWidget(self.stack)

      if __name__ == '__main__':
      try:
      jernelApp = QApplication(sys.argv)
      jernelApp.setApplicationName("Jernel")
      jernelApp.setApplicationDisplayName("Jernel")
      jernelApp.setApplicationVersion("1.0.0")
      if sys.platform == "win32":
      jernelAppID = "FiddyTT.GuiApp.1.0.0"

      ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(jernelAppID)
      window = Jernel()
      with open(str(pathlib.Path("FrontEnd/Styles/App.qss")), "r") as stylesSheet:
      window.setStyleSheet(stylesSheet.read())
      jernelApp.exec_()
      except Exception as exe:
      print("Exception:{}".format(exe))
      finally:
      check = input()


      The icons do not cause an exception when they are loaded only the sytleSheet. Thank you in advance for any help.







      python user-interface pyqt pyinstaller






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 2 at 21:13









      Fidel ElieFidel Elie

      11




      11
























          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54013265%2fadding-a-qss-file-to-the-pyinstaller-bundle%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54013265%2fadding-a-qss-file-to-the-pyinstaller-bundle%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          MongoDB - Not Authorized To Execute Command

          How to fix TextFormField cause rebuild widget in Flutter

          Npm cannot find a required file even through it is in the searched directory