1
該代碼創建一個帶有單個QPushButton
的QDialog
窗口。單擊該按鈕將彈出帶有三個按鈕的QMessageBox
窗口。有沒有辦法重新排列按鈕順序?如何更改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_()
任何人都知道是怎麼回事與OSX按鈕文本填充?它不居中。 – eephillip