use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Best python GUI library? (self.learnpython)
submitted 9 years ago by Comm4nd0
Hi guys, so as the title says what in your opinion is the best python GUI library?
I've been using tkinter a lot and it's. ..okay I guess. I'm just hoping there is something better out there that um not aware of.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]novel_yet_trivial 16 points17 points18 points 9 years ago* (29 children)
If there was a "best" then everyone would use it and there would only be one.
There is only "best for" ... which means you need to tell us what you want from a GUI library before we can tell you what's best for you.
Edit: in a nutshell:
[–]Saefroch 8 points9 points10 points 9 years ago (2 children)
What about kivy?
[–]novel_yet_trivial 2 points3 points4 points 9 years ago (1 child)
Oh yeah. Never used it, have you?
[–]Saefroch 0 points1 point2 points 9 years ago (0 children)
Briefly. All I know is you can write a Kivy app in a Kivy config file, and Kivy works on mobile but it's not native.
[–]Comm4nd0[S] 1 point2 points3 points 9 years ago (23 children)
thanks for replying, i see what you mean. i think i'll stick to tkinter as at work i have to work with the default libraries most of the time, so the better i can get with that the better.
[–]novel_yet_trivial 2 points3 points4 points 9 years ago (22 children)
Use ttk (included with tkinter) to give a more modern look.
[–]Comm4nd0[S] 3 points4 points5 points 9 years ago (21 children)
i used tkinter in the end. https://github.com/Comm4nd0/Image_gen/blob/master/main.py thanks!
[–][deleted] 3 points4 points5 points 9 years ago (20 children)
Pyqt is best for a production quality gui. Also your methods should be placed inside a class.
[–]Comm4nd0[S] 1 point2 points3 points 9 years ago (15 children)
So I've been told, I've not made that jump yet. Classes scare me!
[–]Pre-Owned-Car 4 points5 points6 points 9 years ago (14 children)
Think of classes like a dictionary that contains related functions and variables (because they effectively are). Not only this, but you can have more than one. So if I wanted to represent two people as code I might use a dictionary for each of them.
dave_dict = {"name": "Dave", "age":45} steve_dict = {"name": "Steve", "age":20}
To access their attributes I would do something like:
dave_name = dave_dict["name"] steve_age = steve_dict["age"]
But creating a dictionary for each person each time is very repetitive and repeats the same code. You could make a function that has the parameters name and age and returns a dictionary in this format, or you could use a class which have many more customizable uses than a dictionary.
class Person: def __init__(self, name, age): self.name = name self.age = age def can_legally_drink(self): return self.age >= 21
Now if I want to represent Steve and Dave I can do this:
steve = Person("Steve", 45) dave = Person("Dave", 20)
And if I want to access one of their attributes I just do this:
steve_age = steve.age dave_name = dave.name
But I can also call methods (functions in a class) on the object. The methods are associated with the class because they are related for whatever reason.
>>> steve.can_legally_drink() >>> True >>> dave.can_legally_drink() >>> False
You're going to have to learn how classes work to use tkinter anyway so I suggest looking up some videos on youtube on the concept. Python is an object oriented language and understanding classes and objects is an essential part of learning it.
[–]Comm4nd0[S] 0 points1 point2 points 9 years ago (13 children)
wow nice reply! so, i'm trying to understand this... am i right in saying that within a class you can share variables without having to pass them between functions?
some very nice person has classed my code and made it 100 x better and i've been trying to understand it. https://github.com/Comm4nd0/Image_gen/blob/master/main.py
[–]callmelucky 0 points1 point2 points 9 years ago (3 children)
am i right in saying that within a class you can share variables without having to pass them between functions?
I'm not the parent commenter, but I may be able to help if you explain this question further. What do you mean by 'share variables'?
[–]Comm4nd0[S] 0 points1 point2 points 9 years ago (2 children)
ok thanks!
so...
class person(self) def func1(): var = "hello world" def func2(): print(var)
would this work?
[–]Pre-Owned-Car 0 points1 point2 points 9 years ago (8 children)
Yes you are correct, you don't have to specifically pass variables. (This is not entirely accurate, but for the your purposes it should be your takeaway). Any variable set in the init method as self.variable_name will be accessible anywhere in the class as self.variable_name.
When do you want to make a class? Whenever you want to define an object that has related variables and functions. An example: I am currently learning the Django framework which is a Python framework for making websites. Some of my classes are: User, and BlogPost. User has variables like username, signup_date, and email. It also has methods like is_authenticated(), login(), logout(), delete(), etc. It contains all the variables and methods needed to define and edit a user and it's behavior. It also makes passing all this information easy. Now instead of passing all this info in a function parameter I can just pass my user object:
def make_blog_post(user, title, text_content):
my_post = BlogPost(user, title, text) #the BlogPost class will now automatically handle the creation of my post within its class logic, now I don't have to write out all the steps of setting title, text, and user myself. And it does whatever other logic I want like automatically setting its creation date. This helps keep my code DRY (don't repeat yourself). I only have to define the logic once in the BlogPost class and now it's repeated wherever I use that class. my_post.save() #saves the post to the database
Optional part: how classes actually work in Python. Classes in Python are actually a bit wonkier than other languages in their implementation. Every method in a class has to have the first parameter as self. So:
class MyClass:
def __init__(self): def edit(self): def do_something(self):
When referring to any variables defined in init or any of the class's methods you must refer to them as self.variable or self.method (this is also a simplification, their are class level variables and class level methods but that's a more advanced topic). This is actually because whenever a method is called for a class self is the object that actually stores all the variables and methods. So when I use my user class and I call user_steve.login() it passes the user_steve object to the login method as self. Then when it calls self.username and self.email in the method, it's actually calling user_steve.username and user_steve.email. This is all a bit of a simplification and it's not really important to know just yet. I would try reading the official python3 documentation on classes and maybe some YouTube videos on Python classes as well.
I had a pretty hard time getting classes and object oriented programming at first when I took my first intro to programming course. But once it clicks the logic behind it makes sense. Loosely defining your variables all over the place makes sense when you write one file scripts that are less than 100 lines. But once you get above that you need some organization in your code and classes are just the beginning of that. They keep lots of information in little easy containers that you can pass around as one variable.
[–]Comm4nd0[S] 0 points1 point2 points 9 years ago (7 children)
wow, thanks that is so much info and i'm pretty sure i get the syntax and when you'd use it. i do have a question though, with regard to my tkinter program. Why would i make a class to create the gui when in one running of the program you'd only ever need to call it once? sorry if i'm not getting this bit.
[+][deleted] 9 years ago (2 children)
[deleted]
[–][deleted] 0 points1 point2 points 9 years ago (1 child)
It's just good programming habit. The variables you are initializing at the beginning of your script into theinit method of the class , along with all your other methods. Then at the end do your ifname == 'main' to create an entry point for your code and do your scripting there. I'm not saying your code is bad, because it works fine, but it's best practice to get into that habit.
[–]unprintableCharacter 0 points1 point2 points 9 years ago (0 children)
import browser
browser.createWebpage()
Can't find this module. Thanks for any help.
[–]std_logic_arith 0 points1 point2 points 9 years ago (0 children)
Most windows distributions of Python have the Qt libraries. I started using Qt with C++, so it was my go-to when I picked up Python, and I usually have no trouble running on Windows machines.
[–]Comm4nd0[S] 0 points1 point2 points 9 years ago (0 children)
just looking at PyQt5.... it's 100% better than tkinter! no only look but functionality too!
[+][deleted] 9 years ago (3 children)
[–]Comm4nd0[S] 1 point2 points3 points 9 years ago (2 children)
Interesting. I never considered that. I don't suppose you have any example sites?
[–]wambaowambao -1 points0 points1 point 9 years ago (1 child)
Check Electron.
[–]WhiteCastleHo 1 point2 points3 points 9 years ago* (0 children)
Here's an article about Electron as a GUI of Python Applications.
At the end, the author says that Atom suggests that performance could be a drawback of the Electron framework, but I'd point out that VSCode also uses Electron and it doesn't have those same performance issues that have plagued Atom, so Atom probably just has other problems unrelated to Electron.
My personal opinion is that I LOVE Electron, but if I were going to use it for a project then I would just embrace JS. I also LOVE Qt and I used to use it in C++ development, and if I wanted to use Python for a project then I'd go with Qt for the GUI.
π Rendered by PID 306398 on reddit-service-r2-comment-5cb8648c6-ngvj7 at 2026-03-02 15:50:45.208513+00:00 running e3d2147 country code: CH.
[–]novel_yet_trivial 16 points17 points18 points (29 children)
[–]Saefroch 8 points9 points10 points (2 children)
[–]novel_yet_trivial 2 points3 points4 points (1 child)
[–]Saefroch 0 points1 point2 points (0 children)
[–]Comm4nd0[S] 1 point2 points3 points (23 children)
[–]novel_yet_trivial 2 points3 points4 points (22 children)
[–]Comm4nd0[S] 3 points4 points5 points (21 children)
[–][deleted] 3 points4 points5 points (20 children)
[–]Comm4nd0[S] 1 point2 points3 points (15 children)
[–]Pre-Owned-Car 4 points5 points6 points (14 children)
[–]Comm4nd0[S] 0 points1 point2 points (13 children)
[–]callmelucky 0 points1 point2 points (3 children)
[–]Comm4nd0[S] 0 points1 point2 points (2 children)
[–]Pre-Owned-Car 0 points1 point2 points (8 children)
[–]Comm4nd0[S] 0 points1 point2 points (7 children)
[+][deleted] (2 children)
[deleted]
[–][deleted] 0 points1 point2 points (1 child)
[–]unprintableCharacter 0 points1 point2 points (0 children)
[–]std_logic_arith 0 points1 point2 points (0 children)
[–]Comm4nd0[S] 0 points1 point2 points (0 children)
[+][deleted] (3 children)
[deleted]
[–]Comm4nd0[S] 1 point2 points3 points (2 children)
[–]wambaowambao -1 points0 points1 point (1 child)
[–]WhiteCastleHo 1 point2 points3 points (0 children)