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


Python QInputDialog.getItem方法代码示例

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


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

示例1: edit_parameters

# 需要导入模块: from spyderlib.qt.QtGui import QInputDialog [as 别名]
# 或者: from spyderlib.qt.QtGui.QInputDialog import getItem [as 别名]
 def edit_parameters(self):
     allaxes = self.canvas.figure.get_axes()
     if len(allaxes) == 1:
         axes = allaxes[0]
     elif len(allaxes) > 1:
         titles = []
         for axes in allaxes:
             title = axes.get_title()
             ylabel = axes.get_ylabel()
             if title:
                 text = title
                 if ylabel:
                     text += ": "+ylabel
                 text += " (%s)"
             elif ylabel:
                 text = ylabel+" (%s)"
             else:
                 text = "%s"
             titles.append(text % repr(axes))
         item, ok = QInputDialog.getItem(self, 'Customize',
                                         'Select axes:', titles,
                                         0, False)
         if ok:
             axes = allaxes[titles.index(unicode(item))]
         else:
             return
     else:
         return
     figure_edit(axes, self)
开发者ID:jromang,项目名称:retina-old,代码行数:31,代码来源:mpl_patch.py

示例2: import_data

# 需要导入模块: from spyderlib.qt.QtGui import QInputDialog [as 别名]
# 或者: from spyderlib.qt.QtGui.QInputDialog import getItem [as 别名]
    def import_data(self, filenames=None):
        """Import data from text file"""
        title = _("Import data")
        if filenames is None:
            if self.filename is None:
                basedir = getcwd()
            else:
                basedir = osp.dirname(self.filename)
            filenames, _selfilter = getopenfilenames(self, title, basedir,
                                                     iofunctions.load_filters)
            if not filenames:
                return
        elif is_text_string(filenames):
            filenames = [filenames]

        for filename in filenames:
            self.filename = to_text_string(filename)
            ext = osp.splitext(self.filename)[1].lower()

            if ext not in iofunctions.load_funcs:
                buttons = QMessageBox.Yes | QMessageBox.Cancel
                answer = QMessageBox.question(self, title,
                            _("<b>Unsupported file extension '%s'</b><br><br>"
                              "Would you like to import it anyway "
                              "(by selecting a known file format)?"
                              ) % ext, buttons)
                if answer == QMessageBox.Cancel:
                    return
                formats = list(iofunctions.load_extensions.keys())
                item, ok = QInputDialog.getItem(self, title,
                                                _('Open file as:'),
                                                formats, 0, False)
                if ok:
                    ext = iofunctions.load_extensions[to_text_string(item)]
                else:
                    return

            load_func = iofunctions.load_funcs[ext]
                
            # 'import_wizard' (self.setup_io)
            if is_text_string(load_func):
                # Import data with import wizard
                error_message = None
                try:
                    text, _encoding = encoding.read(self.filename)
                    if self.is_internal_shell:
                        self.editor.import_from_string(text)
                    else:
                        base_name = osp.basename(self.filename)
                        editor = ImportWizard(self, text, title=base_name,
                                      varname=fix_reference_name(base_name))
                        if editor.exec_():
                            var_name, clip_data = editor.get_data()
                            monitor_set_global(self._get_sock(),
                                               var_name, clip_data)
                except Exception as error:
                    error_message = str(error)
            else:
                QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
                QApplication.processEvents()
                if self.is_internal_shell:
                    namespace, error_message = load_func(self.filename)
                    interpreter = self.shellwidget.interpreter
                    for key in list(namespace.keys()):
                        new_key = fix_reference_name(key,
                                     blacklist=list(interpreter.namespace.keys()))
                        if new_key != key:
                            namespace[new_key] = namespace.pop(key)
                    if error_message is None:
                        interpreter.namespace.update(namespace)
                else:
                    error_message = monitor_load_globals(self._get_sock(),
                                                         self.filename, ext)
                QApplication.restoreOverrideCursor()
                QApplication.processEvents()
    
            if error_message is not None:
                QMessageBox.critical(self, title,
                                     _("<b>Unable to load '%s'</b>"
                                       "<br><br>Error message:<br>%s"
                                       ) % (self.filename, error_message))
            self.refresh_table()
开发者ID:ImadBouirmane,项目名称:spyder,代码行数:84,代码来源:namespacebrowser.py


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