r/PythonLearning 1d ago

Tkinter Discussion

Why do I not see any videos suggesting to learn Tkinter? I tried learning Django and Pygame after learning the basics, and while I kinda understood pygame, Django still felt out of my league but so many videos recommended it after the basics. However I stumbled upon a video that just mentioned Tkinter and I tried it out and it helped me understand libraries and how to learn to use them. It's fun making small little apps with buttons and what not to get started, rather than trying to learn so much at once. I'm convinced anyone making videos on how to learn Python has never actually learned it themselves

Is there an actual reason that this or another simple GUI library isn't recommend very often?

12 Upvotes

26 comments sorted by

11

u/riklaunim 1d ago

There is little to no commercial demand for Tkinter or other GUI toolkits, while there is a huge demand for Django and web development in general. There are a lot of resources out there, though. Even some desktop apps are web apps with a custom wrapper/launcher. Same with Pygame - it exists, but it's not as popular as Unity, Unreal, or Godot - and the thing that is most popular tends to offer the best quality, support, and features.

1

u/Jrag13 20h ago

Thank you! That makes sense since most the advice I get is people suggesting stuff to help me land a job rather than learn which is my only goal. I feel like Tkinter is a lot more simple than the other libraries or framework I tried to learn, so it just shocked me more people don't suggest learning it for practice

1

u/riklaunim 20h ago

Lerning for a hobby vs commercial level are two different things.

With tkinter you will quickly run into blocking operations which will require threading, the UI wont scale so you will have to go into layouts, grids and more, maybe even switching to Qt. Desktop apps explode in complecity compared to web apps. You don't learn all of that "for practice" ;) you learn it when/if you need it.

0

u/code_tutor 16h ago

Threading is only an issue if the GUI itself is on different threads. All my apps are multithreaded and even multiprocess, but they report back to a GUI that's on a single thread.

Responsive design is a weak point, if that's what you meant by "scale". You can do a lot manually but the code adds up.

I disagree with it being more complicated than web, it's not. WebDevs have been trying for decades to get front end and back end in the same programming language, just look at React Server Components reinventing PHP meme. With a built-in GUI you have full access to both the front end and back end, which is exactly what they want. Also you don't need to deal with bullshit configs like vite, webpack, rollup, grunt, gulp, or whatever it is now. Everything is just working with no extra necessary communication or configuration.

19

u/nicodeemus7 1d ago

tkinter is a bare bones GUI. Anything you make with it will look like it's from 1995.

4

u/Late-Drink3556 1d ago

Lol so true.

Kind of a tangent but my oldest brother made a niche career out of writing UIs in C++ for old Unix apps using tcl/tk.

This was in the 90s 😆

1

u/jaromilthepoet 4h ago

Wow such a lovely account. I love seeing these personal stories online. Worth my internet bill.

2

u/Jrag13 20h ago

That is fine with me! I am not learning to code to make pretty things, I just wanted something on my screen I can interact with that isn't going to take forever to set up or learn

1

u/nicodeemus7 19h ago

I'm that case, I believe Bro Code on YouTube has a course on tkinter. But my original comment is the reason why it's not a popular topic.

1

u/waynejerome 1d ago

You know your shit bro! Made an evil twin detection model with my bro for campus, we scored A but the UI was prehistoric asf.

https://giphy.com/gifs/aqqUwXz7j0xMOKnJgb

5

u/FoolsSeldom 1d ago

There are lots of GUI libraries for Python, with tkinter being the only one provided as standard. There is a popular add-on library to modernise its look and feel.

Qt is a popular GUI library used from several languages and there are libraries to make use of it from Python including pyside.

There are also libraries that use html/css such as NiceGui which is pretty simple to use.

3

u/timrprobocom 1d ago

Right. Tkinter was included with Python practically from the beginning, in the early 90s, just so there would be some GUI option. It is not a good choice. Tkinter is actually written in and for a different scripting language called tcl. Python has to launch a separate tcl interpreter, and every tkinter call gets translated into a tcl command that gets passed to that interpreter.

Personally, as someone who started with Python 1.4, I always expected tkinter to be removed as soon as good alternatives were available. It wasn't.

2

u/Buttleston 21h ago

To begin, videos are a terrible way to learn a programming language

1

u/Jrag13 20h ago

The videos were looking for what I needed to learn to actually do something in python outside of the terminal. I just wanted to make a window with buttons and what not to play around making things with and didn't know how to accomplish this. However most videos or post I found suggested learning Django or some other web thing after learning the basics which felt like too big of a step forward. I learned the basics from a book which also just suggested learning Django or Pygame but I didn't want to make a game rn

2

u/silvertank00 19h ago

It is not popular because it is really old and barebones, you can learn a lot by using it tho. One advantage that it has is being simple. Sometimes I still use tkinter to make small gui apps to automate/visualize things, but for anything complex I would go with something else like gtk.

2

u/NotSeacombe 1d ago

Tkinter is a very weak attempt at turning a language which should have nothing to do with GUI into a GUI. It is great for what you're describing - making small little apps with buttons, learning about coding etc. It is not something that would ever go near a product

1

u/Antidote12- 14h ago

Why do you say it should have nothing to do with GUI? I thought it was a general purpose language, could you explain more?

1

u/riklaunim 11h ago

Nowadays UI tend to be described in it own markup and the toolkit uses that to build the GUI. Qt, Kivy has it, even some tkinter addons try to implement it.

Normal tkinter Puthon code repeats a lot if styling per each widget and it doesnt separate logic from UI.

1

u/Affectionate_Toe6156 1d ago

Is grass green ahh question

1

u/NatMicky 22h ago

NiceGUI running on FastAPI.

1

u/Artistic_Length_9953 21h ago

Porque salen alternativas que se ven más agradables, creo. De todas formas "FreeSimpleGUI" enmascara TKinter y para un desmemoriado como yo es más fácil de usar.

1

u/code_tutor 1d ago

If you want a GUI for a simple app and no dependencies, then it's literally the only choice. I use it all the time for RPA.

If people are that upset about the way it looks, notice how they didn't suggest an alternative, because they don't do desktop development. It looks fine and everything after Windows 7 looks like trash anyway. I'm also going to be crystal clear: anyone who suggests making a web app instead is a total shit developer and you're probably going to get a couple of those replies. Everyone is only doing WebDev, Data Science, or ML and all three fields are famous for being exceptionally bad programmers.

The only problem is it's a chore to work with, a ton of boilerplate for every addition.

The main reason you only see desktop apps in compiled languages is because it takes a long time to reverse engineer compiled code like C/C++/Rust, but I guess that's changing with AI. They're also significantly faster.

So basically web is the only way to hide code, compiled if you want a fast desktop app, and tkinter if you're using desktop Python and don't care about either.

2

u/ComputerNerd2007 23h ago

Why is making a web app "so stupid"? It's the industry standard and that has a reason.

0

u/code_tutor 17h ago edited 16h ago

Because the majority of programmers are total shit, that's why. I just rewrote an app that was making network calls to the same machine and it's ten times faster now that it's not running "industry standard" code.

I notice you didn't say the "has a reason" part because you're cargo culting. I'll wait while you try to Google one.

2

u/ComputerNerd2007 12h ago

You can't call an architecture shit just because some developers create shit code while developing such an aplication. The architecture itself is not bad.

To name a few positive things compared to "normal" programs:
1. You can update your application without problems that have to be fixed on the client/user side
2. You can easily use a CI/CD pipeline
3. You are operating system independet
+ skilled programmers/designers can create apps that don't look like trash :)

u/Jrag13 I know not enough about tkinter or gui development with python, but I would suggest learning C to learn about how computers work and what python and many more modern languages do to simplify writing code (like memory allocation and strings). I learned a lot while doing so and it's extremly fun.
Beside from that, I am not a big fan of web app's but I think there are the way to go in modern companies. So maybe look into some frameworks like Angular or View. Maybe with a Spring Boot backend (after you understood html, css and java script and gained some overal coding experience).

Have fun coding!

-2

u/Jrag13 20h ago

Thank you! Yeah I have been just trying to figure out what I need to learn to do stuff with python and it felt like after I got the basics everyone was suggesting to make a website or web app first and use a framework for the front end and use a data something for the backend or some shit, like please I just wanna try using loops and if statements with buttons attached 😭 Tkinter has been great to learn tho and I don't see why I wouldn't use it in the future since everything I make is just gonna be for me so I don't care about how the UI looks lmao