-
-
Notifications
You must be signed in to change notification settings - Fork 560
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
Could the ability to add images be made a feature? #1551
Comments
At first I was a bit intimidated that the recommended solution was to roll your own web server, but in reality it was not very difficult using Python's HTTPServer class, and the ThreadingHTTPServer class. Now I have a elegant way to host only image/file in the local folder for my WebView on Windows, and the web server even exits when the main application closes! Here is a minimal example showing how to launch a web server to host local images that can be accessed by the WebView:
[EDIT] Anyone using PyInstaller to compile to a application, I found when running the application the root directory was no longer pointing to the same folder as the script, where I placed the images folder in the same folder as the script, so when HTTPServer was pointing to a different root folder it caused the image links to break. But the solution was simply to change the working directory:
Adding those lines before staring the server ensures the hosted folder will always point to the same folder as the .py script. |
I haven't considered an image support, but since 5.0 introduced a DOM support, not having native support for images in a serverless mode looks a bit silly indeed. |
Hi I started using this tool thinking it was really amazing, upon realizing there is no support for local images I then started researching if there was even a single example of a way to accomplish adding a image to the gui, or any built-in way to add images. This being a tool for designing GUIs I was pretty surprised to not see this available , as it was very unexpected there is no recommended way to support image files. I was wondering if there is any plan to add built-in web server capability , or provide a example on how to use local images. I might not be able to continue using pywebview as my project requires images and icons. But hopefully in the future this will be supported or a example given that others can follow , after searching the internet I have exhausted all options, reading every post in this git and the author merely recommends a possible solution, never provides a functional example that I could find . If there is a example how to use image files with pywebview it could be really helpful!!
The text was updated successfully, but these errors were encountered: