运行python文件弹出对话框的操作是_在Python中弹出图形对话框的最简单的跨平台方式是什么?...

I want the simplest possible way to pop up simple dialogs in Python scripts. Ideally, the solution would:

Work on Windows, OS X, Gnome, KDE

Look like a native dialog on any OS

Require minimal code

To pop up a simple standard dialog should require only minimal code. Essentially you're just saying "Pop up a standard dialog with this text", or "Pop up a dialog with question x and feed response into variable y".

This is for simple scripts that would otherwise run on the command line. I don't want to know about GUI frameworks or have to set up code that says "start a GUI thread, register an event handler, configure some window properties, run a loop", etc. I don't want to have to set up a window or close the window afterward. I give it the text to put in the window and/or buttons and/or checkboxes, it returns what the user clicked on. 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 a system tray popup balloon, or

format = button_box('Which file format do you want?', 'JPG', 'PNG')

and they press one of the two buttons, and then format equals 'JPG', or

response = text_query('What would you like to name the file?')

and after they type in the box and press Ok, response now equals 'bananas.txt'. No other code required. No ugly command line prompts for the poor user.

I've listed Zenity and EasyGUI as example answers, since they're similar to what I want, but not perfect.

解决方案

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 msgbox

msgbox('Stuff')

Apparently it is now abandonware, but there's also a fork called EasyGuiTtk, obtainable via pip install https://github.com/Who8MyLunch/EasyGuiTtk/archive/master.zip

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值