Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to load files from pyinstaller's temp directory? #52

Open
GirkovArpa opened this issue Oct 20, 2021 · 3 comments
Open

How to load files from pyinstaller's temp directory? #52

GirkovArpa opened this issue Oct 20, 2021 · 3 comments

Comments

@GirkovArpa
Copy link

GirkovArpa commented Oct 20, 2021

Graphics.Image.load('image.png')

This tries to load the file image.png from the same folder as the executable. But, image.png is actually in a temp folder, because I've packaged everything into a single executable with pyinstaller, and when running it extracts everything to a temp folder.

So, how to tell Sciter to load image.png from the temp folder, and not the current executable's folder?

In other words, the same folder as index.html.

@GirkovArpa
Copy link
Author

GirkovArpa commented Oct 20, 2021

Also take note about Host.on_load_data, where you can intercept resources load requests and override with your own path:

Originally posted by @pravic in #11 (comment)

How would one go about this? I tried this:

def on_load_data(self, nm):
    nm.uri = sys._MEIPASS + '/' + nm.uri
    pass

But got this error:

Exception ignored on calling ctypes callback function: <bound method Host.handle_notification of <main.Frame object at 0x000002D5325D4430>>

TypeError: unicode string or integer address expected instead of bytes instance

@GirkovArpa
Copy link
Author

I got around this issue by editing main.html on every run via python in order to insert the necessary path information. But others may still need a less hackish solution.

@pravic
Copy link
Member

pravic commented Oct 20, 2021

unicode string or integer address expected instead of bytes instance

What's the type of sys._MEIPASS + '/' + nm.uri?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants