python - (不再求答案)Python input box inside a message box

标签 python ctypes messagebox

有没有办法在使用 ctypes 库打开的消息框内添加一个输入框?到目前为止我有:

import ctypes
messageBox = ctypes.windll.user32.MessageBoxA
title = 'Title'
text = 'Message box!'
returnValue = messageBox(None, text, title, 0x40 | 0x1)
print returnValue

这给出了一个带有图像图标和两个按钮的消息框,我知道如何更改这两个按钮,并将变量“returnValue”设置为表示单击的按钮的数字。但是,我还需要一个变量,该变量将设置为消息框中的字符串输入。我需要这个并且我不能只做简单的 a = raw_input('prompt') 的原因是我希望程序本身在后台运行(它会在登录时自行启动)。

最佳答案

如果您想要一个简单的解决方案,请使用 PyMsgBox 模块。它使用 Python 的内置 tkinter 库来创建消息框,包括让用户键入响应的消息框。使用 pip install pymsgbox 安装它。

文档在这里:https://pymsgbox.readthedocs.org/

你想要的代码是:

>>> import pymsgbox
>>> returnValue = pymsgbox.prompt('Message box!', 'Title')

关于python - (不再求答案)Python input box inside a message box,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21567426/

相关文章:

python - 数据框 groupby 的迭代

python - 如何使用 PyBox2d 检测碰撞并使用该信息

python:如何在一次搜索中找到\r\n\r\n

python - ctypes 中的 find_library()

python - 使用 Pandas 写入特定范围/列

python - 我试图用 python ctypes 打开一个用 c 编写的 dll 并运行其中的函数,但它是一个字符,而不是字符串

c++ - Python ctypes,C++ 对象销毁

python - 在 python 中获取屏幕顶部的 tkinter Messagebox

javascript - 为什么转义字符会破坏 Telerik 对 ResponseScripts.Add(string) 的调用?

c# - 如何编写 switch 语句来测试 DialogResult 并提供 fall through 逻辑