按下确定按钮后如何使对话框变灰

时间:2018-07-04 12:54:37

标签: python pyqt

我在应用程序中有一个对话框,该对话框作为菜单时间打开。对话框/窗口从用户那里获取一些输入,并花费一些时间来处理输出。尽管在我按下“确定”按钮后,该窗口似乎被禁用,但它确实显示为处于活动状态。如何将对话框(窗口)显示为灰色,以便用户可见,但用户知道正在运行某些进程

DoSomethingDialog.py

我有一个Python UI文件,从中继承了DoSomethingDialog的GUI元素

class DoSomethingDialog(QtGui.QDialog, myapp.ui.do_something.Ui_Dialog):
    def __init__(self, parent=None):
        super(DoSomethingDialog, self).__init__(parent)
        self.setupUi(self)
        self.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), self.button_box_ok_click)

    def button_box_ok_click(self):
    # processing happens here
    ....
    ....
    self.close()

def run():
    app = QtGui.QApplication(sys.argv)
    form = DoSomethingDialog()
    form.show()
    sys.exit(app.exec_())

if __name__ == "__main__":
run()

app.py

class MainWindow(QtGui.QMainWindow, main_window.Ui_myapp):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        self.actionDoSomething.connect(self.actionDoSomething, QtCore.SIGNAL("triggered()"),
                                          self.open_do_something_dialog)
    def open_do_something_dialog(self):
       self.ui = DoSomethingDialog()
       self.ui.show()

main.py

if __name__ == '__main__':

import sys
from myapp import app

sys.exit(app.run())

0 个答案:

没有答案