What's the simplest cross-platform way to pop up graphical dialogs in Python? What's the simplest cross-platform way to pop up graphical dialogs in Python? python python

What's the simplest cross-platform way to pop up graphical dialogs in Python?


EasyGUI is a single file, and provides a simple way to work with Tkinter dialogs, but they're still ugly non-native Tkinter dialogs.

from easygui import msgboxmsgbox('Stuff')

Tkinter is ugly on UbuntuTKinter is ugly on Windows 7

It can easily be installed using:

$ sudo pip3 install --upgrade easygui

There is a GitHub repository and documentation is very neat.

Previously, there was also a fork called EasyGuiTtk, which unfortunately is no longer available.

enter image description here


Zenity works under Linux and Windows, and can be called from Python directly:

import osos.system('zenity --info --text="Stuff"')

Using --warning instead of --info gives a warning dialog box instead of an info box. Other options can be found here: https://help.gnome.org/users/zenity/stable/

The return values from question boxes need to be captured for acting on, though, which is more complex, and you have to learn about communicating with subprocesses, etc.

It can also be used with the PyZenity front-end, which makes capturing return values simple:

from PyZenity import InfoMessageInfoMessage('Stuff')

I have tested PyZenity in both Ubuntu and Windows XP, and it works in both.

Zenity looks pretty good in GnomeZenity looks good in KDE, too, suprisinglyZenity in Windows has the wrong GTK theme

I read that Zenity is GTK+ only, but I tried it in Gnome and KDE and it looks native in both. The port to Windows does not look native, though, because it uses the wrong GTK theme?

There are also other programs like KDialog and Xdialog that might be interfaced to a similar Python frontend that could check and see what executables are available so that it automatically takes care of everything? (There's a Ruby frontend for KDialog, too.)

I don't know if PyZenity works under OS X, either.


TkInter is usually supplied with Python

# File: hello1.pyfrom Tkinter import *root = Tk()w = Label(root, text="Hello, world!")w.pack()root.mainloop()

If you want something more native looking, you'll have to install something like wxpython