I need the easiest way to display simple dialogs in a Python script. Ideally, the solution would be:
- Work with Windows, OS X, Gnome, KDE
- See how the native dialogue on any OS
- Require minimum code
Only a minimal code is required to display a simple standard dialog. In fact, you simply say "pop up a standard dialog box with this text" or "pop up a dialog box with a question x and the response of the feed to the variable y".
This is for simple scripts that would otherwise be executed on the command line. I don’t want to know about the graphical user interface infrastructure or I need to install code that says: “Run the GUI thread, register an event handler, configure some window properties, start the loop”, etc. I do not want to install then close the window or close the window. I give him the text to enter in the window and / or buttons and / or flags, it returns what the user clicked. Everything else should be taken care of automatically. For example:
message_box('File conversion complete')
for a standard dialog box with an OK button or
balloon_tip('File conversion complete')
for the system tray popup window, or
format = button_box('Which file format do you want?', 'JPG', 'PNG')
and press one of the two buttons, and then format is 'JPG' or
response = text_query('What would you like to name the file?')
and after they type in the field and click OK, response now equal to 'bananas.txt' . No other code is required. The lack of an ugly command line tells the poor user.
I cited Zenity and EasyGUI as examples of answers, as they are similar to what I want, but not perfect.
[ Previously asked a question on the Python forum ]
python cross-platform dialog zenity
endolith Oct 28 '09 at 3:20 2009-10-28 03:20
source share