當前位置: 首頁>>代碼示例>>Python>>正文


Python QtWidgets.QInputDialog類代碼示例

本文整理匯總了Python中qtpy.QtWidgets.QInputDialog的典型用法代碼示例。如果您正苦於以下問題:Python QInputDialog類的具體用法?Python QInputDialog怎麽用?Python QInputDialog使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了QInputDialog類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: validate_password

    def validate_password(self):
        """
        If the widget is ```passwordProtected```, this method will propmt
        the user for the correct password.

        Returns
        -------
        bool
            True in case the password was correct of if the widget is not
            password protected.
        """
        if not self._password_protected:
            return True

        pwd, ok = QInputDialog().getText(None, "Authentication", "Please enter your password:",
                                         QLineEdit.Password, "")
        pwd = str(pwd)
        if not ok or pwd == "":
            return False

        sha = hashlib.sha256()
        sha.update(pwd.encode())
        pwd_encrypted = sha.hexdigest()
        if pwd_encrypted != self._protected_password:
            msg = QMessageBox()
            msg.setIcon(QMessageBox.Critical)
            msg.setText("Invalid password.")
            msg.setWindowTitle("Error")
            msg.setStandardButtons(QMessageBox.Ok)
            msg.setDefaultButton(QMessageBox.Ok)
            msg.setEscapeButton(QMessageBox.Ok)
            msg.exec_()
            return False
        return True
開發者ID:slaclab,項目名稱:pydm,代碼行數:34,代碼來源:pushbutton.py

示例2: rename_file

 def rename_file(self, fname):
     """Rename file"""
     path, valid = QInputDialog.getText(self, _('Rename'),
                           _('New name:'), QLineEdit.Normal,
                           osp.basename(fname))
     if valid:
         path = osp.join(osp.dirname(fname), to_text_string(path))
         if path == fname:
             return
         if osp.exists(path):
             if QMessageBox.warning(self, _("Rename"),
                      _("Do you really want to rename <b>%s</b> and "
                        "overwrite the existing file <b>%s</b>?"
                        ) % (osp.basename(fname), osp.basename(path)),
                      QMessageBox.Yes|QMessageBox.No) == QMessageBox.No:
                 return
         try:
             misc.rename_file(fname, path)
             self.parent_widget.renamed.emit(fname, path)
             return path
         except EnvironmentError as error:
             QMessageBox.critical(self, _("Rename"),
                         _("<b>Unable to rename file <i>%s</i></b>"
                           "<br><br>Error message:<br>%s"
                           ) % (osp.basename(fname), to_text_string(error)))
開發者ID:ShenggaoZhu,項目名稱:spyder,代碼行數:25,代碼來源:explorer.py

示例3: set_umr_namelist

 def set_umr_namelist(self):
     """Set UMR excluded modules name list"""
     arguments, valid = QInputDialog.getText(self, _('UMR'),
                               _("Set the list of excluded modules as "
                                 "this: <i>numpy, scipy</i>"),
                               QLineEdit.Normal,
                               ", ".join(self.get_option('umr/namelist')))
     if valid:
         arguments = to_text_string(arguments)
         if arguments:
             namelist = arguments.replace(' ', '').split(',')
             fixed_namelist = [module_name for module_name in namelist
                               if programs.is_module_installed(module_name)]
             invalid = ", ".join(set(namelist)-set(fixed_namelist))
             if invalid:
                 QMessageBox.warning(self, _('UMR'),
                                     _("The following modules are not "
                                       "installed on your machine:\n%s"
                                       ) % invalid, QMessageBox.Ok)
             QMessageBox.information(self, _('UMR'),
                                 _("Please note that these changes will "
                                   "be applied only to new Python/IPython "
                                   "consoles"), QMessageBox.Ok)
         else:
             fixed_namelist = []
         self.set_option('umr/namelist', fixed_namelist)
開發者ID:jitseniesen,項目名稱:spyder,代碼行數:26,代碼來源:maininterpreter.py

示例4: create_new_folder

 def create_new_folder(self, current_path, title, subtitle, is_package):
     """Create new folder"""
     if current_path is None:
         current_path = ''
     if osp.isfile(current_path):
         current_path = osp.dirname(current_path)
     name, valid = QInputDialog.getText(self, title, subtitle,
                                        QLineEdit.Normal, "")
     if valid:
         dirname = osp.join(current_path, to_text_string(name))
         try:
             os.mkdir(dirname)
         except EnvironmentError as error:
             QMessageBox.critical(self, title,
                                  _("<b>Unable "
                                    "to create folder <i>%s</i></b>"
                                    "<br><br>Error message:<br>%s"
                                    ) % (dirname, to_text_string(error)))
         finally:
             if is_package:
                 fname = osp.join(dirname, '__init__.py')
                 try:
                     with open(fname, 'wb') as f:
                         f.write(to_binary_string('#'))
                     return dirname
                 except EnvironmentError as error:
                     QMessageBox.critical(self, title,
                                          _("<b>Unable "
                                            "to create file <i>%s</i></b>"
                                            "<br><br>Error message:<br>%s"
                                            ) % (fname,
                                                 to_text_string(error)))
開發者ID:ShenggaoZhu,項目名稱:spyder,代碼行數:32,代碼來源:explorer.py

示例5: change_history_depth

 def change_history_depth(self):
     "Change history max entries" ""
     depth, valid = QInputDialog.getInt(
         self, _("History"), _("Maximum entries"), self.get_option("max_entries"), 10, 10000
     )
     if valid:
         self.set_option("max_entries", depth)
開發者ID:silentquasar,項目名稱:spyder,代碼行數:7,代碼來源:history.py

示例6: change_format

    def change_format(self):
        """
        Ask user for display format for floats and use it.

        This function also checks whether the format is valid and emits
        `sig_option_changed`.
        """
        format, valid = QInputDialog.getText(self, _('Format'),
                                             _("Float formatting"),
                                             QLineEdit.Normal,
                                             self.dataModel.get_format())
        if valid:
            format = str(format)
            try:
                format % 1.1
            except:
                msg = _("Format ({}) is incorrect").format(format)
                QMessageBox.critical(self, _("Error"), msg)
                return
            if not format.startswith('%'):
                msg = _("Format ({}) should start with '%'").format(format)
                QMessageBox.critical(self, _("Error"), msg)
                return
            self.dataModel.set_format(format)
            self.sig_option_changed.emit('dataframe_format', format)
開發者ID:rlaverde,項目名稱:spyder,代碼行數:25,代碼來源:dataframeeditor.py

示例7: change_exteditor

 def change_exteditor(self):
     """Change external editor path"""
     path, valid = QInputDialog.getText(self, _('External editor'),
                       _('External editor executable path:'),
                       QLineEdit.Normal,
                       self.get_option('external_editor/path'))
     if valid:
         self.set_option('external_editor/path', to_text_string(path))
開發者ID:burrbull,項目名稱:spyder,代碼行數:8,代碼來源:plugin.py

示例8: get_arguments

 def get_arguments(self):
     arguments, valid = QInputDialog.getText(self, _('Arguments'),
                                             _('Command line arguments:'),
                                             QLineEdit.Normal,
                                             self.arguments)
     if valid:
         self.arguments = to_text_string(arguments)
     return valid
開發者ID:ChunHungLiu,項目名稱:spyder,代碼行數:8,代碼來源:baseshell.py

示例9: change_history_depth

 def change_history_depth(self):
     "Change history max entries"""
     depth, valid = QInputDialog.getInteger(self, _('History'),
                                    _('Maximum entries'),
                                    self.get_option('max_entries'),
                                    10, 10000)
     if valid:
         self.set_option('max_entries', depth)
開發者ID:ChunHungLiu,項目名稱:spyder,代碼行數:8,代碼來源:history.py

示例10: change_max_line_count

 def change_max_line_count(self):
     "Change maximum line count" ""
     mlc, valid = QInputDialog.getInteger(
         self, _("Buffer"), _("Maximum line count"), self.get_option("max_line_count"), 0, 1000000
     )
     if valid:
         self.shell.setMaximumBlockCount(mlc)
         self.set_option("max_line_count", mlc)
開發者ID:jitseniesen,項目名稱:spyder,代碼行數:8,代碼來源:console.py

示例11: add_other_dialog

 def add_other_dialog(self):
     """
     A QAction callback. Start a dialog to choose a name of a function except a peak or a background. The new
     function is added to the browser.
     """
     selected_name = QInputDialog.getItem(self.canvas, 'Fit', 'Select function', self.other_names, 0, False)
     if selected_name[1]:
         self.add_other_requested.emit(selected_name[0])
開發者ID:mantidproject,項目名稱:mantid,代碼行數:8,代碼來源:interactive_tool.py

示例12: change_max_line_count

 def change_max_line_count(self):
     "Change maximum line count"""
     mlc, valid = QInputDialog.getInt(self, _('Buffer'),
                                        _('Maximum line count'),
                                        self.get_option('max_line_count'),
                                        0, 1000000)
     if valid:
         self.shell.setMaximumBlockCount(mlc)
         self.set_option('max_line_count', mlc)
開發者ID:burrbull,項目名稱:spyder,代碼行數:9,代碼來源:plugin.py

示例13: edit_filter

 def edit_filter(self):
     """Edit name filters"""
     filters, valid = QInputDialog.getText(self, _('Edit filename filters'),
                                           _('Name filters:'),
                                           QLineEdit.Normal,
                                           ", ".join(self.name_filters))
     if valid:
         filters = [f.strip() for f in to_text_string(filters).split(',')]
         self.parent_widget.sig_option_changed.emit('name_filters', filters)
         self.set_name_filters(filters)
開發者ID:ShenggaoZhu,項目名稱:spyder,代碼行數:10,代碼來源:explorer.py

示例14: add_peak_dialog

 def add_peak_dialog(self):
     """
     A QAction callback. Start a dialog to choose a peak function name. After that the tool will expect the user
     to click on the canvas to where the peak should be placed.
     """
     selected_name = QInputDialog.getItem(self.canvas, 'Fit', 'Select peak function', self.peak_names,
                                          self.peak_names.index(self.current_peak_type), False)
     if selected_name[1]:
         self.peak_type_changed.emit(selected_name[0])
         self.mouse_state.transition_to('add_peak')
開發者ID:mantidproject,項目名稱:mantid,代碼行數:10,代碼來源:interactive_tool.py

示例15: add_background_dialog

 def add_background_dialog(self):
     """
     A QAction callback. Start a dialog to choose a background function name. The new function is added to the
     browser.
     """
     current_index = self.background_names.index(self.default_background)
     if current_index < 0:
         current_index = 0
     selected_name = QInputDialog.getItem(self.canvas, 'Fit', 'Select background function', self.background_names,
                                          current_index, False)
     if selected_name[1]:
         self.add_background_requested.emit(selected_name[0])
開發者ID:mantidproject,項目名稱:mantid,代碼行數:12,代碼來源:interactive_tool.py


注:本文中的qtpy.QtWidgets.QInputDialog類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。