2017-06-02 29 views
0

我正在使用python應用程序創建對話框,其中包含幾個標準按鈕,如:重置,確定,取消,應用。 這裏是標準按鈕相關的代碼,如何禁用pyqt中的特定標準按鈕

self.buttonBox = QtGui.QDialogButtonBox(ROI) 
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Reset|QtGui.QDialogButtonBox.Apply|QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) 
self.buttonBox.setObjectName(("buttonBox")) 

我的問題是如何只禁用應用按鈕 即使我嘗試下面的代碼

QtGui.QDialogButtonBox.Apply.setEnabled(False) 

,但得到的錯誤

AttributeError: 'StandardButton' object has no attribute 'setEnabled' 

那麼如何禁用一組標準按鈕中的特定按鈕

回答

0

我還沒有使用它很廣泛,但認爲有可能是一個解決方案

嘗試使用.setVisible樣的API,如果你可以從readthedoc網站找到PyQt的

+0

我得到了解決只是跟着這個代碼BTN =自.buttonBox.button(QtGui.QDialogBu​​ttonBox.Apply) btn.setEnabled(False) – Omkar