代码创建了一个带有单个QPushButton的QDialog窗口。点击按钮会弹出一个带有三个按钮的QMessageBox窗口。是否有一种方法可以重新排列按钮的顺序?
from PyQt4 import QtGui, QtCore
app = QtGui.QApplication([])
class Dialog(QtGui.QDialog):
def __init__(self, parent=None):
super(Dialog, self).__init__(parent)
self.resize(300, 100)
self.setLayout(QtGui.QVBoxLayout())
button = QtGui.QPushButton('Submit')
button.clicked.connect(self.onclick)
self.layout().addWidget(button)
def onclick(self):
self.close()
messagebox = QtGui.QMessageBox(QtGui.QMessageBox.Warning, "Title text", "body text", buttons = QtGui.QMessageBox.Ok | QtGui.QMessageBox.No | QtGui.QMessageBox.Cancel, parent=self)
messagebox.setDefaultButton(QtGui.QMessageBox.No)
exe = messagebox.exec_()
print exe
dialog = Dialog()
dialog.show()
app.exec_()