当前位置: 首页>>代码示例>>Python>>正文


Python QInputDialog.getText方法代码示例

本文整理汇总了Python中qtpy.QtWidgets.QInputDialog.getText方法的典型用法代码示例。如果您正苦于以下问题:Python QInputDialog.getText方法的具体用法?Python QInputDialog.getText怎么用?Python QInputDialog.getText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qtpy.QtWidgets.QInputDialog的用法示例。


在下文中一共展示了QInputDialog.getText方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: rename_file

# 需要导入模块: from qtpy.QtWidgets import QInputDialog [as 别名]
# 或者: from qtpy.QtWidgets.QInputDialog import getText [as 别名]
 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,代码行数:27,代码来源:explorer.py

示例2: create_new_folder

# 需要导入模块: from qtpy.QtWidgets import QInputDialog [as 别名]
# 或者: from qtpy.QtWidgets.QInputDialog import getText [as 别名]
 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,代码行数:34,代码来源:explorer.py

示例3: change_format

# 需要导入模块: from qtpy.QtWidgets import QInputDialog [as 别名]
# 或者: from qtpy.QtWidgets.QInputDialog import getText [as 别名]
    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,代码行数:27,代码来源:dataframeeditor.py

示例4: set_umr_namelist

# 需要导入模块: from qtpy.QtWidgets import QInputDialog [as 别名]
# 或者: from qtpy.QtWidgets.QInputDialog import getText [as 别名]
 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,代码行数:28,代码来源:maininterpreter.py

示例5: get_arguments

# 需要导入模块: from qtpy.QtWidgets import QInputDialog [as 别名]
# 或者: from qtpy.QtWidgets.QInputDialog import getText [as 别名]
 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,代码行数:10,代码来源:baseshell.py

示例6: change_exteditor

# 需要导入模块: from qtpy.QtWidgets import QInputDialog [as 别名]
# 或者: from qtpy.QtWidgets.QInputDialog import getText [as 别名]
 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,代码行数:10,代码来源:plugin.py

示例7: edit_filter

# 需要导入模块: from qtpy.QtWidgets import QInputDialog [as 别名]
# 或者: from qtpy.QtWidgets.QInputDialog import getText [as 别名]
 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,代码行数:12,代码来源:explorer.py

示例8: insert_node

# 需要导入模块: from qtpy.QtWidgets import QInputDialog [as 别名]
# 或者: from qtpy.QtWidgets.QInputDialog import getText [as 别名]
    def insert_node(self):
        index = self.currentIndex()
        parentnode = index.internalPointer() or self.model().root

        key, b = QInputDialog.getText(
            self, "Insert Json node", "Insert key for new node:")
        if not b:
            return
        node = JsonNode(key)
        parentnode.add(node)
        row = parentnode.index(node)
        self.model().beginInsertRows(index, row, row)
        self.model().endInsertRows()
开发者ID:MrLeeh,项目名称:jsonwatchqt,代码行数:15,代码来源:objectexplorer.py

示例9: change_format

# 需要导入模块: from qtpy.QtWidgets import QInputDialog [as 别名]
# 或者: from qtpy.QtWidgets.QInputDialog import getText [as 别名]
 def change_format(self):
     """Change display format"""
     format, valid = QInputDialog.getText(
         self, _("Format"), _("Float formatting"), QLineEdit.Normal, self.model.get_format()
     )
     if valid:
         format = str(format)
         try:
             format % 1.1
         except:
             QMessageBox.critical(self, _("Error"), _("Format (%s) is incorrect") % format)
             return
         self.model.set_format(format)
开发者ID:jitseniesen,项目名称:spyder,代码行数:15,代码来源:arrayeditor.py

示例10: edit_key

# 需要导入模块: from qtpy.QtWidgets import QInputDialog [as 别名]
# 或者: from qtpy.QtWidgets.QInputDialog import getText [as 别名]
    def edit_key(self):
        index = self.currentIndex()
        if index.isValid():
            node = index.internalPointer()
            key, b = QInputDialog.getText(
                self, "Edit Json item", "Insert new key for item:",
                text=node.key
            )

            if not b:
                return

            node.key = key

            try:  # PyQt5
                self.model().dataChanged.emit(index, index, [Qt.DisplayRole])
            except TypeError:  # PyQt4, PySide
                self.model().dataChanged.emit(index, index)
开发者ID:MrLeeh,项目名称:jsonwatchqt,代码行数:20,代码来源:objectexplorer.py

示例11: insert_item

# 需要导入模块: from qtpy.QtWidgets import QInputDialog [as 别名]
# 或者: from qtpy.QtWidgets.QInputDialog import getText [as 别名]
    def insert_item(self):
        index = self.currentIndex()

        if index.isValid():
            node = index.internalPointer()
        else:
            node = self.model().root

        key, b = QInputDialog.getText(
            self, "Insert Json item", "Insert key for new item:")

        if not b:
            return

        item = JsonItem(key)
        node.add(item)
        row = node.index(item)
        self.model().beginInsertRows(index, row, row)
        self.model().endInsertRows()
开发者ID:MrLeeh,项目名称:jsonwatchqt,代码行数:21,代码来源:objectexplorer.py

示例12: set_umr_namelist

# 需要导入模块: from qtpy.QtWidgets import QInputDialog [as 别名]
# 或者: from qtpy.QtWidgets.QInputDialog import getText [as 别名]
 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 = []
             non_ascii_namelist = []
             for module_name in namelist:
                 if PY2:
                     if all(ord(c) < 128 for c in module_name):
                         if programs.is_module_installed(module_name):
                             fixed_namelist.append(module_name)
                     else:
                         QMessageBox.warning(self, _('Warning'),
                         _("You are working with Python 2, this means that "
                           "you can not import a module that contains non-"
                           "ascii characters."), QMessageBox.Ok)
                         non_ascii_namelist.append(module_name)
                 elif programs.is_module_installed(module_name):
                     fixed_namelist.append(module_name)
             invalid = ", ".join(set(namelist)-set(fixed_namelist)-
                                 set(non_ascii_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:0xBADCA7,项目名称:spyder,代码行数:42,代码来源:maininterpreter.py

示例13: toogle_breakpoint

# 需要导入模块: from qtpy.QtWidgets import QInputDialog [as 别名]
# 或者: from qtpy.QtWidgets.QInputDialog import getText [as 别名]
 def toogle_breakpoint(self, line_number=None, condition=None,
                       edit_condition=False):
     """Add/remove breakpoint."""
     if not self.editor.is_python_like():
         return
     if line_number is None:
         block = self.editor.textCursor().block()
     else:
         block = self.editor.document().findBlockByNumber(line_number-1)
     data = block.userData()
     if not data:
         data = BlockUserData(self.editor)
         data.breakpoint = True
     elif not edit_condition:
         data.breakpoint = not data.breakpoint
         data.breakpoint_condition = None
     if condition is not None:
         data.breakpoint_condition = condition
     if edit_condition:
         condition = data.breakpoint_condition
         condition, valid = QInputDialog.getText(self.editor,
                                                 _('Breakpoint'),
                                                 _("Condition:"),
                                                 QLineEdit.Normal,
                                                 condition)
         if not valid:
             return
         data.breakpoint = True
         data.breakpoint_condition = str(condition) if condition else None
     if data.breakpoint:
         text = to_text_string(block.text()).strip()
         if len(text) == 0 or text.startswith(('#', '"', "'")):
             data.breakpoint = False
     block.setUserData(data)
     self.editor.sig_flags_changed.emit()
     self.editor.sig_breakpoints_changed.emit()
开发者ID:impact27,项目名称:spyder,代码行数:38,代码来源:debugger.py


注:本文中的qtpy.QtWidgets.QInputDialog.getText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。