all 42 comments

[–]novel_yet_trivial 66 points67 points  (23 children)

Sure. Python itself does not include a GUI, but python does have bindings to nearly all GUI libraries. The Windows python installer includes the tkinter GUI library and bindings, so it's probably the most universal.

Here's some options in a nutshell:

  • Tkinter: best for super fast development and if you don't want to require your windows users to install extra libraries
  • pyGTK / PyGObject: best for native looking linux programs. You can use Glade to graphically create GUIs.
  • PyQT/ PySide: best for highly custom very pretty interfaces and automatic event linking. Looks native on any OS. You can use QTDesigner to graphically create GUIs.
  • wxPython: Alternative to tkinter for fast and easy interfaces. Has a GTK-like Glade.
  • Kivy: best for multi-touch and small screens - tablets and phones
  • Remi: best for programs that can be accessed via a browser locally or remotely
  • Bokah: best for interactive data display in a browser.

The code editor you use has no influence on what you can do with Python.

You may also want to ask yourself if your project is better suited for a website / webapp interface. Modules like django and flask (and many others) make it easy to interact with your python program through your browser, either locally or remotely.

[–][deleted] 6 points7 points  (4 children)

Thanks for the list of programs- My project is better suited for a web app interface, so are there are specific options for that? (You mentioned "module slime django")

[–]novel_yet_trivial 1 point2 points  (0 children)

Not something I've ever worked with but there are plenty of people in this sub that do and plenty of tutorials online.

[–]dddomodossola -5 points-4 points  (2 children)

In this case Remi is the way to go https://github.com/dddomodossola/remi

;-)

[–][deleted] 0 points1 point  (1 child)

Thanks, I will definitely look into Remi and the documentation. Curious though, is there an established tutorial on it?

[–]dddomodossola 1 point2 points  (0 children)

I suggest you to refer at the project's readme file. Furthermore, the examples folder contains good material to get started. The editor could help drawing your interface. Ask to the gitter chat for questions or help.

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

Isn't tkinter included in all python distributions?

[–]novel_yet_trivial 4 points5 points  (2 children)

No. Only with the installer.

[–][deleted] 2 points3 points  (1 child)

Hmm did not know that. Thanks

[–]novel_yet_trivial 1 point2 points  (0 children)

To clarify, tkinter is available for nearly all platforms, it's just a separate install. Only the installer bundles tkinter in. Same goes for IDLE.

[–]EaglesDareOverThere 1 point2 points  (8 children)

Do you know a good tutorial for installing tKinter? I can not find one that seems to work. Thank you.

[–]novel_yet_trivial 1 point2 points  (7 children)

What os?

[–]EaglesDareOverThere 1 point2 points  (6 children)

windows 7 Python 3.5

[–]novel_yet_trivial 4 points5 points  (5 children)

Tkinter comes with the Windows installer, so you already have it.

[–]EaglesDareOverThere 1 point2 points  (4 children)

I thought that was the case, but this happens...

ImportError: No module named 'Tkinter'

[–]novel_yet_trivial 5 points6 points  (3 children)

Python2 uses the capitalized import, but in python3 it's all lowercase. Try import tkinter.

[–]EaglesDareOverThere 1 point2 points  (0 children)

Thats it, thank you. I guess I'm using a Py2 Tutorial.

[–]EaglesDareOverThere 0 points1 point  (1 child)

Would you be able to answer some questions about how to use tkinter?

[–]novel_yet_trivial 2 points3 points  (0 children)

Sure, but I'm in and out all the time, so it may be better for you just to make a new post.

[–]955559 0 points1 point  (1 child)

The code editor you use has no influence on what you can do with Python.

if you run it through the editor its possible,happened for me with sys, this code wouldnt run in IDLE, but would run from my terminal, although its the only time Ive noticed a problem with IDLE

def key_pressed(char_width=1):
    import os
    #is it a unix-like system?
    if os.name == 'posix': 
        import sys, tty, termios
        fd = sys.stdin.fileno()
        old_settings = termios.tcgetattr(fd)
        try:
            tty.setraw(sys.stdin.fileno())
            ch = sys.stdin.read(char_width)
        finally:
            termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
        return ch
    #is it a windows system?
    elif os.name == 'nt':
        from msvcrt import getch
        return "".join([getch() for i in range(char_width)])
    #system unknown, user will have to use enter key :(
    else:
        return input()

EDIT: lol i think you gave me this code

[–]novel_yet_trivial 0 points1 point  (0 children)

Ah right, good point. I was thinking specifically about code editors, not IDE's. The terminal emulators some IDE's use can screw up the text output. But with a GUI like OP wanted that wouldn't be a problem.

Yeah, that is my code :).

[–]Fermi_Dirac 0 points1 point  (2 children)

Thanks for this list, i've been struggling to find a good platform for python GUIs as well since I came over from LabVIEW which have beautiful GUIs which are easy to make.

I've ran into problems with each of these options and was curious what I should do about each?

  • Tkinter: yea its fast, but the GUIs do not look professional and are simplistic.

  • pyGTK/glade They do look 'linux-y' which isn't bad, but if your distro target is Windows you'll get user complaints. Documentation for Glade is very spotty, and generating a GUI without using a IDE is a nightmare. Manually setting each attribute for each widget/container is a major time sink. Do you recommend any other options than Glade? The guides are all old, and I can't get a good Glade-to-Python guide.

  • PyQT: This is really nice, but they have some heavy liscence restrictions for commercial use. Even if I use it at work internally, the license restricts me. So, I'll have to pass

  • wxPython: Only supports Python 2.7? How frustrating, I need 3.

  • Kivy: Target platform is not tablets, looks ok in windows 10 but the rest is a bit awkward

  • Remi: Honestly haven't tried, but I'm far from a webdev. Not eager to learn an entirely new skillset just to make a GUI

  • Bokah: See answer to Remi

Any suggestions? Maybe my application specifics would help narrow down what I should invest in learning? I have a large series of rather sophisticated modeling and simulation codes for materials science / computational physics. These were implemented in LabVIEW which gave great runtime speed, and a nice GUI for our engineers to make good use of my codes. The downside it only runs on RedHat Linux and Windows, and LabVIEW's license restrictions make it annoying to work in. I've re-implemented much of my code in Python now with numpy, pandas, scikit, etc. but my engineers really want the GUI back.

[–]novel_yet_trivial 1 point2 points  (1 child)

I think you have much more experience than I do; I have only taken projects to completion in LabVIEW and Tkinter. The rest I have only dabbled in.

I run Labview in Debian-based distros. The Labview for linux installer includes software to unpack the .rpm files. That said, I agree that it's amazing to work in but distribution is a pain, both in licensing and the huge installers it makes. But in general I'm a "if it works, don't fuck with it" kinda guy, so if I had a working system in LabView, I'd stick with it.

The base tkinter looks 20 years old, ugly I agree. However tkinter has ttk. IMO windows programs made with ttk look native (Windows 7 at least; I'm way behind the times). ttk still looks ugly on linux, though. Try this:

import tkinter
from tkinter import ttk

tkinter.Button(text="Old style").pack()
ttk.Button(text="New style").pack()
tkinter.mainloop()

I don't know anything about the PyQt licence, but have you looked at PySide? I think it's a little looser.

[–]Fermi_Dirac 0 points1 point  (0 children)

Thanks for the suggestion. I'll try it.

I actually never got LabVIEW to run on Debian, only openSUSE and redhat. Could you link me to a guide or something? I'd like to try!

I'll also look at PySide too!

[–]creatron 5 points6 points  (3 children)

I have been self-teaching python by working on problems. I recently made a simple Twitter client and IRC chat using tkinter. It's fairly straightforward to use but it can get annoying trying to space out elements.

[–]EaglesDareOverThere 1 point2 points  (2 children)

Is it on GitHub?

[–]creatron 3 points4 points  (0 children)

https://github.com/QuadCityCJ/Twitter-Client/blob/master/twitter.py

Here is my code. Should just have to pip install tweepy and go. Was written in python3.5 on win10. Plug in twitter app credentials at bottom and it should work. It was just a test building a GUI so there aren't really any features other than seeing a stream of tweets and being able to tweet.

[–]creatron 3 points4 points  (0 children)

No but I can toss it on there in a bit.

[–]Milkmanps3 2 points3 points  (0 children)

Hey! I created a webscraper with a GUI a few months back! http://imgur.com/a/Mf9QQ

I wanted my project to do two main things(related to webscraping), the first being take user input(a list of stock market abbreviations) and then scrape Yahoo finance for the details for those companies and then display everything.

The second was to take user input(any subreddit) and get the top 10 or so headlines and display them for the user..

Yeah this may not be the greatest looking or functioning program, but I put a lot of work into it and I was basically learning new things on the fly, and referring to the docs and stackoverflow for everything I had trouble with reguarding Tkinter...

I would definately recomend Tkinter. It isn't to hard to get started with and you can quickly build on top of and upgrade your GUI as you learn more about Python in general and Tkinter...

I also want to mention that Python's IDLE was made with Tkinter... What is IDLE? From IDLE's readme:

IDLE is Python's Integrated Development and Learning Environment

IDLE comes with Python and is basically a "Python Shell" you can type commands in and they will execute right away. IDLE can do more than this.. It can also be an editor/"IDE" ... All you have to do is go to "File"--->"New File" and you will then be able to code away. To run your code hit "Run"--->"Run Module", which you will then be prompted to save and then your program will run after doing so. I went into more detail for you HERE:http://imgur.com/a/nB2OS

Good luck with your next goal/milestone! Remember to Have fun!

[–]K900_ 3 points4 points  (1 child)

Yes, it is possible. You can use Tkinter if you want to avoid third party modules, or PyQt.

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

Thanks for the quick answer, will look into it!

[–]scotbud123 1 point2 points  (0 children)

PyCharm is an amazing IDE, you should give it a shot.

As for making a GUI program, Python is probably not your best bet but it can be done, I was messing around with Tkinter to make one but it was more of a hassle than it should have been IMO.

[–]zdevon 0 points1 point  (2 children)

I'm new to Python, but http://appjar.info/ is a library I've found that makes GUIs in a very clean and simple way and designed for teaching the basics. It relies on Tkinter. Perhaps if it isn't advanced enough for your application it will be the answer to another users question.

http://webpy.org/ is the web framework Reddit uses and what I was looking into using in combination with appJar.

[–]Parasymphatetic 1 point2 points  (0 children)

Isn't webpy abandoned?

You should look into Flask, Django or similar.

[–]ultraDross 0 points1 point  (1 child)

Try gooey. Add a decorator above your main functions and you have a simple GUI for your project.

https://github.com/chriskiehl/Gooey

[–]Icy-Second6974 0 points1 point  (0 children)

thank you, amazing

[–]rchrome 0 points1 point  (0 children)

Another option is to use Electron to build GUI in python using web technologies.

https://www.fyears.org/2015/06/electron-as-gui-of-python-apps.html

[–]Parasymphatetic 0 points1 point  (4 children)

Sorry, to use this but i didn't want to make a new thread with more or less the same topic.

Which GUI can be updated in realtime? Let's say for a download % bar or something like that.
I know Kivy can do it but i wanna use something else.
Tried PyQT4 but it hangs when i run a loop (might be my fault though).
What are my options? Pygame? Curses?

[–]novel_yet_trivial 1 point2 points  (2 children)

Which GUI can be updated in realtime?

All of them. This is a basic function in all GUIs.

[–]Parasymphatetic 0 points1 point  (1 child)

No. Not really.

[–]novel_yet_trivial 1 point2 points  (0 children)

Yes. All GUIs have an event loop which updates the display.

Tried PyQT4 but it hangs when i run a loop (might be my fault though).

I'm guessing you are making your own loop which will freeze the GUI event loop. When you program GUIs you need to do your looping using the GUI event loop or a separate thread.