Skip to content

Commit

Permalink
Merge pull request #2 from xiangpengm/master
Browse files Browse the repository at this point in the history
fix: pyinstaller win
  • Loading branch information
gitzhou authored Apr 3, 2024
2 parents c2c962b + ae9cce5 commit 5a02e42
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

basedir = os.path.abspath(os.path.dirname(sys.argv[0]))

if sys.platform == 'win32':
basedir = os.path.join(basedir, '_internal')


class UrlSchemeHandler(QWebEngineUrlSchemeHandler):

Expand All @@ -25,7 +28,7 @@ def requestStarted(self, job):
if match_groups:
filename = match_groups.group(2)
ext = match_groups.group(3)
file = QFile(os.path.join(basedir, f'contract/{filename}'), job)
file = QFile(os.path.join(basedir, os.path.join('contract', filename)), job)
file.open(QIODevice.OpenModeFlag.ReadOnly)
job.reply(mimetypes.types_map[ext].encode('utf-8'), file)

Expand All @@ -41,7 +44,7 @@ def __init__(self):
QWebEngineUrlScheme.registerScheme(QWebEngineUrlScheme(scheme))
profile = QWebEngineProfile.defaultProfile()
profile.installUrlSchemeHandler(scheme, UrlSchemeHandler(self))
self.setHtml(open(os.path.join(basedir, 'contract/index.html'), 'r', encoding='utf-8').read())
self.setHtml(open(os.path.join(basedir, os.path.join('contract', 'index.html')), 'r', encoding='utf-8').read())

channel = QWebChannel(self)
channel.registerObject('Bridge', self)
Expand Down

0 comments on commit 5a02e42

Please sign in to comment.