当前位置: 首页>>代码示例>>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;未经允许,请勿转载。