Python 使用 PyQt4 的简单对话框(问题、确定、取消)
simple dialog (questio, OK, Cancel) with Python using PyQt4
我正在尝试将带有 GUI 的程序从 Python+Tkinter 转移到 Python+PyQt4。我想知道是否有 PyQt4 等效于以下 Tkinter 命令:
tkMessageBox.askokcancel('Question', 'Do you really want to delete all Data?',default='cancel')
它应该是这样的:
我知道,可以使用 Qt-Designer 创建自定义对话框,但是仅使用一行的简单命令会很好。我没有找到任何使用常见搜索引擎的解决方案。
请原谅我的英语水平,感谢到目前为止的阅读。
有QMessageBox
一行代码就可以做消息框
http://pyqt.sourceforge.net/Docs/PyQt4/qmessagebox.html
来自页面的示例:http://zetcode.com/gui/pyqt4/firstprograms/
reply = QtGui.QMessageBox.question(self, 'Message',
"Are you sure to quit?", QtGui.QMessageBox.Yes |
QtGui.QMessageBox.No, QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes:
print("YES")
else:
print("NO")
我正在尝试将带有 GUI 的程序从 Python+Tkinter 转移到 Python+PyQt4。我想知道是否有 PyQt4 等效于以下 Tkinter 命令:
tkMessageBox.askokcancel('Question', 'Do you really want to delete all Data?',default='cancel')
它应该是这样的:
我知道,可以使用 Qt-Designer 创建自定义对话框,但是仅使用一行的简单命令会很好。我没有找到任何使用常见搜索引擎的解决方案。
请原谅我的英语水平,感谢到目前为止的阅读。
有QMessageBox
一行代码就可以做消息框
http://pyqt.sourceforge.net/Docs/PyQt4/qmessagebox.html
来自页面的示例:http://zetcode.com/gui/pyqt4/firstprograms/
reply = QtGui.QMessageBox.question(self, 'Message',
"Are you sure to quit?", QtGui.QMessageBox.Yes |
QtGui.QMessageBox.No, QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes:
print("YES")
else:
print("NO")