A
A
Alexander Rublev2016-06-03 16:27:20
Python
Alexander Rublev, 2016-06-03 16:27:20

How to get information from a dialog box?

Good afternoon everyone.
I, as always, with questions)
Guys, please tell me how to make the dialog box return the entered information?
I'm doing this right now:

def build_exel_registration(self):
        info = ExelInfo()  # Создаю экземпляр диалогового окна
        info.exec()  # Ставлю этот скрипт на паузу (Не понимаю как это работает)
        if info.ok:  # Смотрю переменную диалогового окна, проверяя нажал кнопку ok или cancel
            name = info.name.text()  # Беру имя из строки ввода

# класс диалогового окна
class ExelInfo(QDialog, exel_info_class):
    def __init__(self, *args):
        super(ExelInfo, self).__init__()
        self.setupUi(self)
        self.setModal(True)
        self.setWindowIcon(QIcon(getcwd() + "/images/icon.ico"))
        self.show()

    def accept(self):  # Если нажата кнопка Ok
        self.ok = True
        self.close()

    def rect(self):  # Если нажата кнопка cancel
        self.ok = False
        self.close()

But I would like it to look human.
For example, so that the dialog box would immediately return the name (For example)
name = ExelInfo()
Is it possible to do this? After all, QMessageBox works like this!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question