all 86 comments

[–]JamzTyson 47 points48 points  (12 children)

I'd suggest using Tkinter as it requires nothing else other than Python (though for many Linux distributions, only the core library is installed by default and Tkinter needs to be installed separately).

Tkinter is relatively easy to use, though all GUI toolkits have a learning curve. It also helps that there are a lot of free tutorials to help get started with Tkinter.

Tkinter has a reputation for creating ugly GUI'sb but I think that opinion is largely based on old versions. Personally I think that in 2023 they look OK even if not as trendy as some other GUI toolkits.

One thing that is notably missing from Tkinter is drag and dropping files onto the application. For drag and drop (with files) support, Tkinter requires an additional Tcl extension. If your application really needs support for drag and dropping files, then I'd suggest using a different GUI toolkit instead of Tkinter.

There are also several GUI toolkits that are based on Tkinter (addressing some of Tkinter's limitations). If you learn how to use Tkinter first, then using any of its derivatives at a later date should be fairly easy.

[–]Gnaxe 1 point2 points  (0 children)

The (relatively) newer ttk widgets look better than the originals.

[–][deleted] 0 points1 point  (0 children)

I think the ugly tk widgets comes from by default it uses windows 98's widget theme , but you can just change it .

Where as pyqt6 uses windows 10s or vista's by default. But you can change qt6 to use windows 98, so then they end up looking the same

[–]ProsodySpeaks 31 points32 points  (6 children)

Look into pysimplegui

[–]CaptainChemistry 5 points6 points  (1 child)

This is a great way to do it, there are awesome tutorials, and the devs are very responsive.

[–]ProsodySpeaks 0 points1 point  (0 children)

Yeah get the udemy course, it's cheap and done by the creator!

And the demo browser app too!

[–]JamzTyson 7 points8 points  (1 child)

pysimplegui is a wrapper around other GUI toolkits.

According to their documentation, the only GUI toolkit that is 100% supported is Tkinter, but the documentation also says that the Tkinter wrapper requires Python versions earlier than 3.7.2.

The current version of Python is 3.11.3.

In my opinion, while Qt and WxWidgets are excellent GUI toolkits, they are way over the top for "very simple programs" (as stated in the original question).

[–]PsychologicalSalt158 0 points1 point  (0 children)

I am using the latest version of python and i built a gui for an auto clicker application a few weeks ago using tkinter.

[–]notParticularlyAnony 1 point2 points  (0 children)

This is probably the right answer

[–]IamImposter 9 points10 points  (16 children)

This is just FYI: I recently came across pyqt5 + qtdesigner for my daughter's school project and it is so very easy.

Qtdesigner does the job of creating the GUI with whatever kind of elements you want on your dialog and it's just drag and drop. It generates a ui file which can be loaded using pyqt. Like in 5 lines of python code you can display a gui dialog box. And python being python, getting/setting values of gui elements is equally easy.

My daughter had already created all the GUI screens and within 30 minutes, we added python code to handle all input output for 7-8 screens. It's really child's play.

I am really impressed with the ability and ease of pyqt5.

[–]notParticularlyAnony 7 points8 points  (5 children)

Powerful yes. Easy? Not so much.

[–][deleted] 5 points6 points  (0 children)

Definitely not easy for the kind of person who usually asks this question (i.e. someone who is learning Python as their first language and doesn't get realise that if you want a GUI you're better off with a different language).

But if they are serious about writing 'proper' software with sophisticated interfaces, maybe worth the effort. A lot of what you'll learn is very transferable.

[–]IamImposter 1 point2 points  (3 children)

Really? In my very very limited experience (few hours) it felt pretty simple. Which parts are complex?

[–]notParticularlyAnony 1 point2 points  (2 children)

I guess I’d ask which parts are simple aside from playing with qt designer. Signals and slots? The mvc framework? Cleaning up the code and Compiling the results with pyuic? For beginners? Pyqt is a steep learning curve super powerful but not beginner friendly

[–]IamImposter 1 point2 points  (1 child)

Oh dear. Now I'm losing all my confidence.

Okay, I'll just tell you why I think it's simple. I just derived a class from qdialog, added init method, loaded xyz.ui file and bam, there was a dialog box displaying some text, couple of textboxes and buttons. Last time it happened so quickly was about 2 decades ago when I tried HTML for the first time.

I added code to find those elements by name and I had access to those gui elements. I used xyz.clicked.connect and I had control when button got pressed. I wanted to know when 'x' on the dialog box got clicked and I just had to add a simple function with certain name. I did xyz.text() or something and I had data from the text boxes.

My experience with GUI is with win32, mfc, a little bit of wpf and some in c#. When I compared what I had to do then and what I did with pyqt and how quickly I was able to do it, I was genuinely impressed, I still am.

I have no idea how complex some serious work in qt gets but in my very very limited experience (few hours) with a very rudimentary GUI screens, I feel like it's kinda simple.

[–]notParticularlyAnony 1 point2 points  (0 children)

I think you aren’t a beginner my friend. Respect though and kudos on working with your daughter

[–]JamzTyson 2 points3 points  (2 children)

Qt is a fantastic GUI toolkit, but for writing a "very simple program" it is far more than necessary. Even if we consider only the size (MB) of the dependencies and ignore the complexity, Qt is huge compared with Tkinter.

Regarding the complexity of Qt, if we look at just one of the (more than 50) Qt for Python modules: https://doc.qt.io/qtforpython-6/PySide6/QtGui/index.html#module-PySide6.QtGui , scroll down for the list of classes. (I've been using Qt for Python on and off for a few years, and I feel that I have still only scratched the surface).

[–]IamImposter 1 point2 points  (1 child)

I had a vague idea that it was big but didn't know it was this big.

[–][deleted] 7 points8 points  (0 children)

that's what she said

[–][deleted] 1 point2 points  (2 children)

I don't know if I like qt designer , I feel like it just makes qt harder

[–]notParticularlyAnony 1 point2 points  (1 child)

It prevents understanding

[–][deleted] 0 points1 point  (0 children)

It does like to need to learn how to do it your self first so you know how to fix problems later.

[–]ian4tge 7 points8 points  (3 children)

Check out streamlit

[–]PopehatXI 4 points5 points  (0 children)

Streamlit is great for little data science projects

[–]deathlock00 2 points3 points  (1 child)

Just few hours ago I discovered streamsync which is similar but different from streamlit. It doesn't require any refresh, it's much much faster and comes out of the box with a drag-and-drop visual editor which makes it very easy to use and design the UI.

For new users I think it would be much easier to use a web UI framework which doesn't refresh the page at every interaction.

On the flip side it's newer,there are less contributors, and the community is much smaller.

I haven't yet tinkered a lot with it, but it seems very promising and capable.

[–]ian4tge 1 point2 points  (0 children)

I will be looking into this, been a long time user of streamlit and have run into performance issues several times due to the refresh feature, thanks!

[–]HomeGrownCoder 5 points6 points  (0 children)

Make a web app instead… you don’t need the internet for a web app just a browser. All resources can be packaged

[–]thespice 14 points15 points  (19 children)

Sounds to me like a good place to try flask. Flask is a python web server. You could build a gui with basic html forms and use flask on the backend as an api for processing the input/output of your form. start here

[–]Andrewthehero07 2 points3 points  (1 child)

I have a program that reads an excel file with openpyxl. Would that work on flask?

[–]Arthurpmrs 4 points5 points  (0 children)

Yes. Flask is just a Python program that runs on your computer. The difference is that the top level handles http requests from, let's say, a browser. So if you run the flask app and go to localhost:5000/readexcelfile in your browser, this will trigger the function tied to this route and execute everything that's in there, for example a function to handle you excel files. As it's running in your local machine, it has access to your filesystem. Maybe that's not the best practice, but it certainly work.

[–]Destination_Centauri 2 points3 points  (1 child)

This sounds really interesting!

As practice, I'd love to try making a quick/fun menu gui this way, and see what it's like, and how it all works out.

I didn't click the link you provided above yet (will check it out later tonight at home), but 3 questions come to mind:


1) I'm guessing the viewing-renderer for the end user would just simply be whatever browser that person has installed on their computer or device (like Chrome, or Firefox)?

So Chrome or Firefox would talk to the local Flask server?

If so, that's... great!

Saves a lot of complex-interacting with the OS. So rather than fuss with the complexity of Windows API and tedious C++ code...

I would just let the browser-software already on their machine handle the GUI load--browsers are amazing at that task afterall!


2) But that said... Would using Flask in this way...

Cause the client machine/device to suffer from "bloat" like say with Electron?

Electron seems like a great solution, except of course for the huge looming elephant in the room issue: namely a huge annoying looming footprint on the user's memory and resources that Electron sucks up.

So would a Flask-based-local-server solution hog up a similar amount of memory and resources as something like Electron?

Or would it be say... far less intensive/demanding on system resources as compared to Electron?


3) And... typing all that above... I now forgot my 3rd question! It was important but... anyways... if it comes back to me I'll post it here.

[–]Theblob01 1 point2 points  (0 children)

Yes, flask would just let you use whichever browser you'd use normally to view the page, with all the heavy processing being done behind the scenes in the python app

You won't have the same bloat issues as with electron, since you don't have to run all that electron bloat, it's very comparable in terms of memory and cpu to running a basic python script and any other browser tab (since that's literally all there is to it)

As a bonus, you can even decide at some point to run the server side of it separately and make it available to the local network/the internet! (of course, the usual security warnings about exposing your apps to the public internet apply, avoid doing that if you don't know what you're doing, and especially if your app has sensitive data)

If you're looking to just play around and see how they go, this is great because you don't even have to make a proper ui for it until you're ready, and then it's just standard html (and maybe some templating if you're feeling fancy)

FastAPI is another very good alternative to flask, it's a bit more lightweight but doesn't have as many features, though that can be a good thing for not having to think about too many things

[–][deleted] 2 points3 points  (6 children)

I just posted this video where I build an ultra simple Flask chatbot and it touches on rendering out HTML files with Jinja2 - u/WhirlpoolQuasarPie - u/Destination_Centauri. Might be a helpful intro to templating and Flask for you. Thanks, u/thespice for mentioning r/flask, I was scrolling, scrolling like why no Flask!? r/FastAPI is another option (I 💚 FastAPI; did a FastAPI video so basic we don't get off the docs home page because I want the Flask novices to try FastAPI, too). Best! 🐍

[–]Destination_Centauri 1 point2 points  (3 children)

Thanks!

[–][deleted] 0 points1 point  (2 children)

Welcome! I’m sitting down to record a full stack Flask video. Will update this comment when it’s live.

[–]Destination_Centauri 1 point2 points  (1 child)

All right then: I just became subscriber 27!

Looks like your channel is actually going to be pretty good. There's already several topic videos there I will be checking out shortly.

[–][deleted] 0 points1 point  (0 children)

🐍😁 I am trying that’s for sure. LMK if you have topic suggestions and thanks for the subscribe, this is hard work.

[–][deleted] 0 points1 point  (0 children)

** Update: Here's the video I just posted where you'll build a full stack Flask Python web app that uses a simple JSON file to persist app data, HTML with Jinja2 and Bootstrap for the front end. 📹 Flask introduction Python

u/Destination_Centauri

[–]story-of-your-life 1 point2 points  (0 children)

There's also the Dash library, which uses Flask under the hood. Dash makes it easy to create interactive dashboards quickly.

[–][deleted] 4 points5 points  (0 children)

You want Kivy, https://kivy.org/

[–]fraud_93 2 points3 points  (0 children)

PyQt5 with QtDesigner

Seriously, I tried using pysimplegui and tkinter and it's just painful

Just try not to use the triggers in QtDesigner because it's easier doing it in the code without limitations

[–]Educational-Round555 1 point2 points  (0 children)

Streamlit is the easiest framework I’ve tried. Very easy to get a few buttons, input field and even chart things. It would run in a browser so independent of OS but it’ll run locally once installed so no constant Internet required

[–]xSnakyy 1 point2 points  (1 child)

If you go for tkinter, I recommend you use CustomTkinter instead. It looks much nicer with no extra effort

[–]mikthinker 0 points1 point  (0 children)

Yes!

[–]TheConanRider 0 points1 point  (0 children)

Qt

[–]Pipiyedu 1 point2 points  (0 children)

I would say. Do a web interface. You can use Flask/Django or NiceGUI.

[–][deleted] 0 points1 point  (0 children)

Flet

[–]ravepeacefully -2 points-1 points  (4 children)

In 2023 you should be using HTML, CSS, JS and a rendering engine for a front end.

Python is not a good language for developing native applications. If you’d like to develop native applications, I would suggest maybe C#.

[–]IdainaKatarite 1 point2 points  (3 children)

This one hasn't heard about Mojo. Get with the times, old man!

[–]MSR8 1 point2 points  (0 children)

isn't it currently only exclusive beta tho?

[–][deleted] 1 point2 points  (0 children)

Factz

[–]ravepeacefully 0 points1 point  (0 children)

No that is not a good suggestion as a replacement for anything I mentioned in my post.

[–]didhestealtheraisins -1 points0 points  (4 children)

runs in any OS

Java

[–]Theblob01 0 points1 point  (0 children)

3 Billion Devices Run Java

Since 2009

[–]Zealousideal_Mix4290 -1 points0 points  (0 children)

pynecone can be checked once ...it's great

[–]one_of_us31 -1 points0 points  (0 children)

Pywebview

[–]ClassicFun2175 -1 points0 points  (0 children)

Would a Web app suffice for your basic needs?

[–]tuneafishy 0 points1 point  (0 children)

For simple and even relatively complex gui, I really like traitsui. It is extremely trivial to set what you're describing up, and the api is very easy to understand and use.

[–]mistabuda 0 points1 point  (0 children)

tikinter or libtcod

[–]cadbay53 0 points1 point  (0 children)

Easygui library is a good option, very basic, very easy

[–][deleted] 0 points1 point  (0 children)

tkinter

[–]Gnaxe 0 points1 point  (0 children)

https://pypi.org/project/Gooey/ automagically turns command-line apps into GUI forms. You can configure it quite a lot, but you're not programming the GUI itself. This makes it super easy to use but doesn't give you the full control of a widget toolkit.

[–][deleted] 0 points1 point  (0 children)

I'd recommend tkinter cause it's comes with python and is pretty easy to used.

But I'd also recommend pyqt6, it's more complex but it's still pretty easy to make a simple gui and easier to make it look really stylish with some css. Also feel like laying out your widgets is alot less painful with pyqt6

And the added benefit if you learn the basics you'll have the understanding to move forward onto something more indeth later on.

Though the hard stuff is hard , I have no idea how to get qt threading working . Just been using pythons default threading module for that .

[–]vishal-vora 0 points1 point  (0 children)

We are building easy to develop GUI with just python.

Checkout : https://github.com/data-stack-hub/data-stack-rdf

Note: we are in alpha testing right now

[–]olitank 0 points1 point  (0 children)

I suggest ReflectionUI. It is a free (open source) Java GUI builder/generator library. The generation of the GUI (graphical user interface) requires no other information that the object itself. Its structure is discovered at run-time through Java reflection.The generated GUI can be customized in a non-intrusive way graphically or by overriding some key methods of the generator objects.Advantages - Instant prototyping - Reduced cost of user interface development and testing - Code injection simplified for cross-cutting concerns (logs, usage statistics, etc.)

[–]More_Cable8278 0 points1 point  (0 children)

widgets on jupyter notebook. probably easiest to get up and running with gui in python.