9 ms·
Show HN: Pywebview 5
I am happy to announce a new major version of pywebview
- deleted 3y ago[deleted]
- rkwz 3y agoThanks, this feels like Tauri but with Python (correct me of wrong). Hoping to give it a try soon!
- kissaprofeetta 3y agoAuthor here. Yes you are correct with the exception that pywebview predates Tauri by five years.
- yuppiepuppie 3y agoVery nice! Congrats on the release. Side note: I find it funny how we go to such lengths in order not to write JavaScript.
- toyg 3y agoActually, using this the chances are you'll still write JS. The examples are all JS-based. Most of this project seems to be about replacing Electron specifically.
- fock 3y agoAre there any sizable examples without Javascript at all? Also this uses a whole lot of custom code (and some DLLs vendored and created from the interop-native-packages...) to hook up to native Webviews (which might be fine for simple things, but so is tkinter), so this is not electron, where you get a specific verson of blink/whatever and build on that. In addition, it uses heavy toolkits to get the webview (i.e. Kivy on Android and Qt on Linux) – all of which incidentally also support all the platforms. EDIT: it doesn't package them though... So why multiply your problems: from GUI-framework Y on platform (X1,X2,X3) to GUI-framework (Y1,Y2,Y3)on platform (X1,X2,X3) using render-engine (Z1,Z2,Z3). If you want to use the platform-browser anyway: why not create a small native shim (with Tkinter everywhere but Android) to control your server and package that? To end on a very positive note: this is a herculean collection of tools to deploy Python GUIs on nearly any platform and as such seems like a very nice ressource if you want to do that!
- p4bl0 3y agoUsing Pywebview you can either use a "normal" web backend, e.g., using Flask to make a backend HTTP API, or you can expose Python code to make it callable "directly" (a more correct term would be "transparently") from JavaScript on the frontend side. In the latter case it's quite useful be able to update the DOM directly from Python :).
- dade_ 3y agoI'm not. I see the Javascript guy, the GO guy, but I am surprised not to see the Rust guy, probably just running late though.
- lolinder 3y agoThis post isn't specifically recommending it as a substitute, but it references Tauri, which is Rust [0]. [0] https://news.ycombinator.com/item?id=39689206 https://news.ycombinator.com/item?id=39689206
- p4bl0 3y agoI used Pywebview for a project and had to contribute a few bug fixes to have it working right but it's been a pleasure to work with. Especially since it is fully supported by pyinstaller to build stand-alone executables that can then be distributed and easily used (simple double click) by people who otherwise wouldn't open a terminal, activate a python virtual environment, and then launch the program.
- kissaprofeetta 3y agoThanks for the kinds words and your contributions. :)
- throwaway38375 3y agoThis looks really neat! I'm just about to start a desktop application project, so I've found this at the perfect time. Is this production ready? I need to target Windows and MacOS with a high level of stability.
- kjksf 3y agoI would recommend wails (https://wails.io/ https://wails.io/) which is the same thing but for Go. Nothing against this project it's just Python is not an optimal technology for shipping self-contained desktop apps. You'll have to bundle the whole of Python distro which is very bloaty. A Go will compile to a statically linked executable that only contains the code actually used in the app. Still not tiny but probably 10x smaller than packaged Python app. And I used wails so can vouch that it works. There's also an option for Rust (which I haven't used because I don't particularly want to learn Rust).
- Thorrez 3y agoAre wails and pywebview bloaty? Do they bundle Chrome?
- jszymborski 3y agoYou can force it to use CEF, but otherwise uses what the OS/DE provides. https://pywebview.flowrl.com/guide/web_engine https://pywebview.flowrl.com/guide/web_engine
- kjksf 3y agoNo. They use whatever webview OS provides. On Windows it's webview that is Edge (based on Chrome). On Mac it's webview based on Safari. They re-use the executable that is already installed in the OS. They don't provide all the features that Electron does but you can do anything that a modern browser can do + add OS specific things with backend code (written in Go or Python or Rust, depending on which project you use).
- zitterbewegung 3y ago
- djfobbz 3y agoWe tried using pywebview for a cross-platform desktop app when it was version 3.x and some of the features were limited, especially when it came to systray interactions. Will have to try it out again. In the end, for that specific project, we ended up settling on NeutralinoJS. Wails was another big contender but due to limited GoLang resources in-house, we decided not to use it. Reference: https://neutralino.js.org/ https://neutralino.js.org/
- kissaprofeetta 3y agoAuthor here. Systray icon is not supported natively, but you can create one with a third party pystray package. Here is an example https://pywebview.flowrl.com/examples/pystray_icon.html https://pywebview.flowrl.com/examples/pystray_icon.html
- abrichr 3y agoWhat are the advantages of using something like Pywebview compared to opening the user’s browser to localhost?
- simonw 3y agoYou get to control the chrome a bit more - with Pywebview you can open something that looks like a regular application window, with the fact that it's HTML+CSS+JavaScript a hidden (from the user) implementation detail. You can make Python functionality available to your custom JavaScript via a bridge. The bridge goes both ways - your Python application can trigger JavaScript to run inside the visible windows too. You can add application menus.
- abrichr 3y agoThanks! Are there any drawbacks to Pywebview compared to a browser?
- simonw 3y agoProbably loads. It's an extra dependency so it adds complexity (though it does seem to be very cleanly designed from what I've seen so far). Stuff people do in Pywebview won't be added to their browser history, doesn't get access to their existing cookies, presumably doesn't work with password managers and browser extensions. But if you want to give people a separate app experience it looks like a great option to me.
- kissaprofeetta 3y agoAuthor here. Here are top advantages from the top of my head * pywebview hides its browser nature. Right click, text select, shortcut keys, swipe gestures etc are disabled by default. * window manipulation functionality. Move, resize, minimize, maximize etc * native file dialog support. These are more capable than browser's own file dialogs. * native application menu * with the new version you can get a full file path on file drag and drop. This is not possible in browser. * two way Javascript-Python bridge. You can invoke Javascript from Python and Python from Javascript * If Javascript is not your cup of tea, you can do quite a bit in pure Python.
- JodieBenitez 3y agoI've been using Pywebview for a couple of internals tools at work, on windows desktops. I had to install Edge WebView2 (cf. https://developer.microsoft.com/en-us/microsoft-edge/webview2/#download-section https://developer.microsoft.com/en-us/microsoft-edge/webview... ) because it wouldn't work without it, but apart from this, very easy to use. Happy to see further improvements to this library !