5 ms·
What are the advantages of using something like Pywebview compared to opening the user’s browser to localhost?
by abrichr 3y ago
What 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.
- mkesper 3y agoI really hate it when text select is disabled. Often very useful, e.g. for reporting.
- danudey 3y agoConversely, it can also be very annoying when you accidentally select some of the UI text and you have to manually deselect it (or maybe you can't deselect it).
- kissaprofeetta 3y agoText select is user controlled option for the whole window or you can enable text select for individual elements with CSS.
- JodieBenitez 3y agoin my case, having access to the local filesystem through a non-crippled API (looking at you JS...) was invaluable.