<i id='XqmpL'><tr id='XqmpL'><dt id='XqmpL'><q id='XqmpL'><span id='XqmpL'><b id='XqmpL'><form id='XqmpL'><ins id='XqmpL'></ins><ul id='XqmpL'></ul><sub id='XqmpL'></sub></form><legend id='XqmpL'></legend><bdo id='XqmpL'><pre id='XqmpL'><center id='XqmpL'></center></pre></bdo></b><th id='XqmpL'></th></span></q></dt></tr></i><div id='XqmpL'><tfoot id='XqmpL'></tfoot><dl id='XqmpL'><fieldset id='XqmpL'></fieldset></dl></div>

      <legend id='XqmpL'><style id='XqmpL'><dir id='XqmpL'><q id='XqmpL'></q></dir></style></legend>
    1. <small id='XqmpL'></small><noframes id='XqmpL'>

        • <bdo id='XqmpL'></bdo><ul id='XqmpL'></ul>
      1. <tfoot id='XqmpL'></tfoot>

        在 Python 中弹出图形对话框的最简单的跨平台方法

        时间:2023-10-09
          <tfoot id='7QYpQ'></tfoot>

          <small id='7QYpQ'></small><noframes id='7QYpQ'>

            <bdo id='7QYpQ'></bdo><ul id='7QYpQ'></ul>

            • <legend id='7QYpQ'><style id='7QYpQ'><dir id='7QYpQ'><q id='7QYpQ'></q></dir></style></legend>
                  <tbody id='7QYpQ'></tbody>
                <i id='7QYpQ'><tr id='7QYpQ'><dt id='7QYpQ'><q id='7QYpQ'><span id='7QYpQ'><b id='7QYpQ'><form id='7QYpQ'><ins id='7QYpQ'></ins><ul id='7QYpQ'></ul><sub id='7QYpQ'></sub></form><legend id='7QYpQ'></legend><bdo id='7QYpQ'><pre id='7QYpQ'><center id='7QYpQ'></center></pre></bdo></b><th id='7QYpQ'></th></span></q></dt></tr></i><div id='7QYpQ'><tfoot id='7QYpQ'></tfoot><dl id='7QYpQ'><fieldset id='7QYpQ'></fieldset></dl></div>

                1. 本文介绍了在 Python 中弹出图形对话框的最简单的跨平台方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想要在 Python 脚本中弹出简单对话框的最简单方法.理想情况下,解决方案是:

                  • 在 Windows、OS X、Gnome、KDE ​​上工作
                  • 看起来像任何操作系统上的原生对话框
                  • 需要最少的代码

                  要弹出一个简单的标准对话框,只需要最少的代码.本质上,您只是说弹出一个带有此文本的标准对话框",或弹出一个带有问题 x 的对话框并将响应输入变量 y".

                  这适用于在命令行上运行的简单脚本.我不想了解 GUI 框架,也不想设置启动 GUI 线程、注册事件处理程序、配置一些窗口属性、运行循环"等代码.我不想设置之后打开一个窗口或关闭窗口.我给它文本以放入窗口和/或按钮和/或复选框,它返回用户点击的内容.其他一切都应该自动处理.例如:

                  message_box('文件转换完成')

                  对于带有确定"按钮的标准对话框,或

                  balloon_tip('文件转换完成')

                  用于系统托盘弹出气球,或

                  format = button_box('你想要哪种文件格式?', 'JPG', 'PNG')

                  他们按下两个按钮之一,然后 format 等于 'JPG',或者

                  response = text_query('你想给文件取什么名字?')

                  在他们输入框并按确定后,response 现在等于 'bananas.txt'.无需其他代码.可怜的用户没有丑陋的命令行提示.

                  我将 Zenity 和 EasyGUI 列为示例答案,因为它们与我想要的相似,但并不完美.

                  [ 和 文档非常整洁.

                  之前,还有一个名为 EasyGuiTtk 的分支,遗憾的是不再可用.p>

                  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.

                  [Previously asked on Python Forum]

                  解决方案

                  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')
                  

                  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.

                  这篇关于在 Python 中弹出图形对话框的最简单的跨平台方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:pyparsing 一种查询格式到另一种 下一篇:“wait_window"是什么意思?方法呢?

                  相关文章

                  最新文章

                2. <small id='btZHG'></small><noframes id='btZHG'>

                3. <legend id='btZHG'><style id='btZHG'><dir id='btZHG'><q id='btZHG'></q></dir></style></legend>
                    <bdo id='btZHG'></bdo><ul id='btZHG'></ul>

                  1. <tfoot id='btZHG'></tfoot>
                  2. <i id='btZHG'><tr id='btZHG'><dt id='btZHG'><q id='btZHG'><span id='btZHG'><b id='btZHG'><form id='btZHG'><ins id='btZHG'></ins><ul id='btZHG'></ul><sub id='btZHG'></sub></form><legend id='btZHG'></legend><bdo id='btZHG'><pre id='btZHG'><center id='btZHG'></center></pre></bdo></b><th id='btZHG'></th></span></q></dt></tr></i><div id='btZHG'><tfoot id='btZHG'></tfoot><dl id='btZHG'><fieldset id='btZHG'></fieldset></dl></div>