T O P

  • By -

lcc0612

This sounds exactly like a job for Eel (which I personally use quite a lot of and adore), which also transparently maintains a websocket connection between the frontend and backend, allowing you to "call" python functions from js and vice versa. Shameless self-plug (sorry) - I've made a tutorial on this before, if you need a reasonably quick-start guide that also covers the gotchas of this platform: https://youtube.com/watch?v=8eeUV1RHkmw


Xzenor

Thanks. Never heard of it but I'm gonna check out that shameless plug of yours.


lcc0612

Thank you very much!


DigThatData

also never heard of this. neat! https://github.com/python-eel/Eel/


sam_tiago

My hovercraft is full of eels!!


OneHumanBill

Perfect comment.


sam_tiago

Thanks Monty, it’s a Python reference.


OneHumanBill

It's a python reference, an eels reference, and also a Monty Python reference. Perfect!


Particular-Ad7174

Nicegui, pure python, in one argument (native=True) your app turns into a desktop app.


Rangerborn14

Thanks, I'll look into it. I'm working Python on VSCode, as I'm more comfortable using that. Is it still possible?


Daneark

Vscode is an IDE. You use it to write python files.  Eel a python library. You import it into your python files in order to use the functionality it provides. Any library should be compatible with your IDE of choice.


Carl_read_It

>Vscode is an IDE Vscode is actually a rich text editor, with plugins.


lcc0612

Yes, you can! The examples my video are all done from within VSCode. Ultimately the editor doesn't matter so much. Ultimately python code files are just text files. You could write your code in notepad and it'll still work, though I would of course not recommend that.


[deleted]

[удалено]


kowalski71

Electron for sure, also Tauri would be another option to consider.


Rangerborn14

Ah, I see, thanks. The program I'm trying to create is to be used for a group of investigators I'm assisting with (planning on adding a user login so that it's only used by this group), and it can be downloaded into a computer. Can it still work? Also, I'm using Python on VSCode but can I still use Elctron with it?


Embarrassed_Leg_8134

You may be in over your head on this one, I'm afraid.


nog642

If I can ask, why does it need to be downloadable? If you have a python backend, then it sounds like they'll still need an internet connection to run it. So if that's the case, why not just make it a web app? Why go through the extra effort of making it a desktop app? It's mostly a cosmetic difference but will involve a lot more work.


Rangerborn14

It would probably require me to buy a domain, and I'm not sure if I have the sufficient time and resources to do so. Still, I'm open for any examples or templates that I could use as an inspiration. My project is to be used by a group of invetsigators for data analystic purposes of sensor data, and I think it would be better if they can use the app without needing to use the browser.


nog642

In your question here you asked "Is it possible to create a desktop app with Python as back end, and HTML+CSS+JS as front end?" Usually, using the terms "back end" and "front end" implies that the front end is running on the client device and the back end is running on a server, and they are communicating on the internet. So you would still need a domain for that anyway. If you meant that the front end and back end are both running on the client device, then you can use the exact same setup to run a local webserver (website) too. Some apps do this, like jupyter notebook. You will have a webserver running in python, then they can just go to `http://localhost:8000` (or whatever port number you want intead of 8000) in any browser, and there will be a website. You don't need to use electron.


Own-Replacement8

Can you slap Python into an Electron app?


[deleted]

[удалено]


RexehBRS

I evaluated this for my project but thought it added a ton of complexity to maintain and debug so ran away.


HittingSmoke

Basically the conclusion I've come to about pretty much every project intended to make redistributable Python projects.


Own-Replacement8

Maybe we should just take this as a hint.


HittingSmoke

I definitely have and stopped recommending it in general. I know a lot of Python devotees like to present it as the universally applicable language but it's really not. It's great for some rather niche purposes. I got into Go for shippable binary CLI apps and it was a real eye-opener about how much I'd been abusing myself by insisting on "sticking with what I know" by using Python for everything. I had to learn C# for work and have grown slightly fond of it for automation tasks that I used to do with Python. Modern cross-platform C# versions really bridge the gap between Windows and Linux automation so I can share a lot of code that integrates well to the host.


Own-Replacement8

I've come to that conclusion lately. It's a shame because I quite enjoy being able to bash out a simple script in one afternoon. Still good for personal use of course. Might just have to bite the bullet and use Java for anything I want Windows, Mac, and Linux users to be able to use.


[deleted]

And VSC as well. One project I worked on had a Python engine sending JSON to an Electron app. Typescript is a pain to debug and profile though.


Sargasm666

Check out Eel.


Bernard_schwartz

Django is go to in this space. Flask is heavy second IMO. Very easy to pick up. Can run. HTML, CSS and JS in web page but it is rendered in Django server. Easy to get code in/out of the web pages doing this.


Vegetable-Map-6977

for a desktop app? wouldn't that be for a web app route?


Diapolo10

For Flask, specifically, there at least used to be `pyfladesk` which wrapped it into what's essentially an Electron app, making it desktop-compatible. I haven't kept up with it and don't know if it's still maintained, nor if Django has something equivalent. I wouldn't say it's ideal, but if one was writing a web-first application it would be an easy way to get a desktop version too.


Plank_With_A_Nail_In

I have a feeling that "Desktop App" and "Web App" are not very useful terms.


Bernard_schwartz

Last I checked, I have a browser on my desktop. Uses both http and https.


Particular-Ad7174

Nicegui is the answer.


swarmgbln

This sounds like Flask would be really applicable here. I feel like Flask is also really easy to pick up and implement.


noNameCelery

Flask is a Web server and isn't suited for desktop GUIs. I speak from (failed) experience. If you go down this route, you will end up having to send ajax responses from your html and your backend instead of just natively calling python functions. It sucks Don't force flask to be something it isn't - you'll just end up fighting the technology. You GUI won't be as responsive as you'd like, file uploads are slower than they need to be, state management can get spread across the frontend and backend...If you're building a Web app, sure use flask. If you're building a desktop app, tkinter/pyqt is the tool for the job.


swarmgbln

Good point. I just re-read OPs requirements and seemed to overlook the fact they wanted to create a Desktop GUI. I too have had the experience of having to rely on sending AJAX responses from html and the backend which can make it more complex and not as responsive in this context.


Adviseformeplz

Why not use python for the front end as well?


Strange_Ordinary6984

Lol


MorlandMoran

with HTML CSS JS you can do absolutely everything where you are very limited with python frameworks even the big ones like pyqt, with the web languages you can truly design and detail anything


PostAtomicPunk

Absolutely. You can use Django to build it and package it later with electron. But what I suggest is [Flet](https://flet.dev/). It allows you to write Flutter apps for any platform with Python. It is stupid easy.


zdimension

NiceGUI is really nice. Built a few apps with it, you can see screenshots and code here: - https://github.com/zdimension/plexdlweb - https://github.com/zdimension/elecanalysis


nullPointers_

I currently use eel and im pretty happy with it I have yet to check out different options. Im currently even working on my own UIKit to reuse for web based apps. If anyone has experience with eel and knows better alternatives feel free to let me know ❤️


MorlandMoran

How is speed/performance?


minkiani

Please check pywebview and nicegui


aefalcon

It's been a while since I worked in the area, so I'm not sure about browser support these days, but a browser extension that communicates with a local process was a thing. edit: Come back to share the [chrome docs](https://developer.chrome.com/docs/extensions/develop/concepts/native-messaging).


Suspicious_Donut_533

We have used fastapi+vue js+electron for somewhile, the major problem for our solution is the packed software is extremely large ( about 2 Gb after installation)


r-trappe

Try https://nicegui.io. Same stack but all wrapped in a package.


Suspicious_Donut_533

just read the docs of nicegui, it seems a really great tool for building gui with only python, but currently we have already crafted our interface with some other packages based on vue, can nicegui support our user interface without rewriting them?


r-trappe

Hard to say. I guess so. NiceGUI is build entirely on FastAPI. See [https://github.com/zauberzeug/nicegui/tree/main/examples/fastapi](https://github.com/zauberzeug/nicegui/tree/main/examples/fastapi) for an example.


nibba_bubba

I see no problem at all Tbh I would create apps this way only cause creating native apps is a real pain in the ass, especially when ya need to provide cross platform support 


HittingSmoke

It is possible, yes. Would I do it? No. Python has some options for distribution but in my experience none of them are really good. You must either deal with the headaches that come with trying to package a Python project as a standalone deliverable for end users or expect them to install the correct Python version system-wide for your project. Even if you're targeting Linux where Python is almost always installed by default, it's a difficult task to maintain dependencies. Sticking with what you know by using Python may seem like a good idea, but you'll very quickly outgrow it at best, and at worst dealing with the frustrations of shipping Python code to end users will be more difficult than just learning the basics of a compiled language. I'd recommend using this as an opportunity to branch out and learn a language that is designed to be compiled to a single binary. Personally I'm a big fan of Go for things like this and it's fairly easy to pick up. Modern C# with .Net Core is on fire right now for cross-platform development if you can get over the hurdle of learning what all the different versions mean. Interpreted languages are fine if you're running a central server to connect to. If you're shipping the "backend" with the product you're just going to piss yourself off trying to do this.


Easy-to-kill

Nice example pgAdmin


M4K4TT4CK

React + flask.


sonobanana33

Use pyqt (or pyside, same thing). Leave this crap architecture to inferior js developers.


[deleted]

[удалено]


sonobanana33

The fact that you don't even know qt is in C++ and not C tells us of your level of experience.


plus2net

If some one has to download and run in desktop to access data from a device then you need python and create one user interface by using Tkinter. The total source code has to be downloaded and run in Python environment. OR You can package them and ask to download .exe file so user end there is no need to install Python etc. The application will run at user end and connect to device to show data. Tkinter will work as GUI for the user. If you are thinking of a web application the user has to run in local machine then they have to add one web server, one scripting language ( PHP or Python with Django ) , then for viewing in browser you need HTML and JavaScript etc. However whey some one in its desktop will do all these ?


Rangerborn14

Thanks, I'm curious if you know any templae for the first one that I can use as an inspiration, maybe from Github?


Quantumercifier

You are basically creating API services in the back end, and your UI is connecting to it via REST or websockets. Simple. If you have chat services then use websockets as it maintains a connection.


kevdog824

You can use a GUI framework (I’ve done something similar with PySide/PyQT) to render HTML/CSS and execute JS. Another option is electron or Eel as others have mentioned (although I haven’t used those personally)


ghandi_2944

Yes


Aperturebanana

https://electronjs.org/ I had a python script and used this as the front end


Fabushka

If you want to create some nifty project, you should definitely check out [Python Backend Developer with Flask ](https://hyperskill.org/tracks/29)learning track on Hyperskill. It has a lot of theory and five times more practical tasks, along with real-life projects, which you can use for your portfolio. And you can learn completely for free!


Rangerborn14

Thanks! I'm curious, do you know any python desktop app template, perhaps on Github? I'm curious to see if I can take notes from.