\pyrcc_main.py: File does not exist 'resources.qrc'

import sys, os, tempfile
import sip
sip.setapi('QString', 2)
from PyQt4 import QtCore
# from PyQt5 import QtCore

respath = os.path.abspath(sys.argv[1])
dirpath = os.path.dirname(respath)
sys.path.insert(0, dirpath)

import resources_rc

tmpdir = tempfile.mkdtemp(prefix='qrc_', dir=dirpath)

it = QtCore.QDirIterator(':', QtCore.QDirIterator.Subdirectories)

files = []

while it.hasNext():
    uri = it.next()
    path = uri.lstrip(':/')
    if path.startswith('qt-project.org'):
        continue
    tmp = os.path.join(tmpdir, path)
    if it.fileInfo().isDir():
        try:
            os.makedirs(tmp)
        except OSError:
            pass
    else:
        res = QtCore.QFile(uri)
        res.open(QtCore.QIODevice.ReadOnly)
        with open(tmp, 'wb') as stream:
            stream.write(bytes(res.readAll()))
        res.close()
        files.append('    <file>%s</file>\n' % path.lstrip(':/'))

with open(os.path.join(tmpdir, 'resources.qrc'), 'w') as stream:
    stream.write('<!DOCTYPE RCC><RCC version="1.0">\n')
    stream.write('<qresource>\n%s</qresource>\n' % ''.join(files))

Are there any code examples left?
New code examples in category Other
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Pleased to see you again

Sign up to unlock all of IQCode features:
  • Master useful skills
  • Improve learning outcomes
  • Share your knowledge
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Master useful skills
  • Improve learning outcomes
  • Share your knowledge
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source