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


Python base._函数代码示例

本文整理汇总了Python中spyderlib.config.base._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: add_actions_to_context_menu

 def add_actions_to_context_menu(self, menu):
     """Add actions to IPython widget context menu"""
     # See spyderlib/widgets/ipython.py for more details on this method
     inspect_action = create_action(self, _("Inspect current object"),
                                 QKeySequence(get_shortcut('console',
                                                 'inspect current object')),
                                 icon=ima.icon('MessageBoxInformation'),
                                 triggered=self.inspect_object)
     clear_line_action = create_action(self, _("Clear line or block"),
                                       QKeySequence("Shift+Escape"),
                                       icon=ima.icon('editdelete'),
                                       triggered=self.clear_line)
     reset_namespace_action = create_action(self, _("Reset namespace"),
                                       QKeySequence("Ctrl+R"),
                                       triggered=self.reset_namespace)
     clear_console_action = create_action(self, _("Clear console"),
                                          QKeySequence(get_shortcut('console',
                                                            'clear shell')),
                                          icon=ima.icon('editclear'),
                                          triggered=self.clear_console)
     quit_action = create_action(self, _("&Quit"), icon=ima.icon('exit'),
                                 triggered=self.exit_callback)
     add_actions(menu, (None, inspect_action, clear_line_action,
                        clear_console_action, reset_namespace_action,
                        None, quit_action))
     return menu
开发者ID:G-VAR,项目名称:spyder,代码行数:26,代码来源:ipython.py

示例2: _set_step

 def _set_step(self, step):
     """Proceed to a given step"""
     new_tab = self.tab_widget.currentIndex() + step
     assert new_tab < self.tab_widget.count() and new_tab >= 0
     if new_tab == self.tab_widget.count() - 1:
         try:
             self.table_widget.open_data(
                 self._get_plain_text(),
                 self.text_widget.get_col_sep(),
                 self.text_widget.get_row_sep(),
                 self.text_widget.trnsp_box.isChecked(),
                 self.text_widget.get_skiprows(),
                 self.text_widget.get_comments(),
             )
             self.done_btn.setEnabled(True)
             self.done_btn.setDefault(True)
             self.fwd_btn.setEnabled(False)
             self.back_btn.setEnabled(True)
         except (SyntaxError, AssertionError) as error:
             QMessageBox.critical(
                 self,
                 _("Import wizard"),
                 _(
                     "<b>Unable to proceed to next step</b>"
                     "<br><br>Please check your entries."
                     "<br><br>Error message:<br>%s"
                 )
                 % str(error),
             )
             return
     elif new_tab == 0:
         self.done_btn.setEnabled(False)
         self.fwd_btn.setEnabled(True)
         self.back_btn.setEnabled(False)
     self._focus_tab(new_tab)
开发者ID:gyenney,项目名称:Tools,代码行数:35,代码来源:importwizard.py

示例3: 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:sonofeft,项目名称:spyder,代码行数:32,代码来源:explorer.py

示例4: get_toolbar_buttons

 def get_toolbar_buttons(self):
     ExternalShellBase.get_toolbar_buttons(self)
     if self.namespacebrowser_button is None and self.stand_alone is not None:
         self.namespacebrowser_button = create_toolbutton(
             self,
             text=_("Variables"),
             icon=ima.icon("dictedit"),
             tip=_("Show/hide global variables explorer"),
             toggled=self.toggle_globals_explorer,
             text_beside_icon=True,
         )
     if self.terminate_button is None:
         self.terminate_button = create_toolbutton(
             self,
             text=_("Terminate"),
             icon=ima.icon("stop"),
             tip=_(
                 "Attempts to stop the process. The process\n"
                 "may not exit as a result of clicking this\n"
                 "button (it is given the chance to prompt\n"
                 "the user for any unsaved files, etc)."
             ),
         )
     buttons = []
     if self.namespacebrowser_button is not None:
         buttons.append(self.namespacebrowser_button)
     buttons += [self.run_button, self.terminate_button, self.kill_button, self.options_button]
     return buttons
开发者ID:MarvinLiu0810,项目名称:spyder,代码行数:28,代码来源:pythonshell.py

示例5: _sel_to_text

 def _sel_to_text(self, cell_range):
     """Copy an array portion to a unicode string"""
     if not cell_range:
         return
     row_min, row_max, col_min, col_max = get_idx_rect(cell_range)
     if col_min == 0 and col_max == (self.model().cols_loaded-1):
         # we've selected a whole column. It isn't possible to
         # select only the first part of a column without loading more, 
         # so we can treat it as intentional and copy the whole thing
         col_max = self.model().total_cols-1
     if row_min == 0 and row_max == (self.model().rows_loaded-1):
         row_max = self.model().total_rows-1
     
     _data = self.model().get_data()
     if PY3:
         output = io.BytesIO()
     else:
         output = io.StringIO()
     try:
         np.savetxt(output, _data[row_min:row_max+1, col_min:col_max+1],
                    delimiter='\t')
     except:
         QMessageBox.warning(self, _("Warning"),
                             _("It was not possible to copy values for "
                               "this array"))
         return
     contents = output.getvalue().decode('utf-8')
     output.close()
     return contents
开发者ID:ChunHungLiu,项目名称:spyder,代码行数:29,代码来源:arrayeditor.py

示例6: start

    def start(self):
        """Main method of the WorkerUpdates worker"""
        self.url = 'https://api.github.com/repos/spyder-ide/spyder/releases'
        self.update_available = False
        self.latest_release = __version__

        error_msg = None
        try:
            page = urlopen(self.url)
            try:
                data = page.read()

                # Needed step for python3 compatibility
                if not isinstance(data, str):
                    data = data.decode()

                data = json.loads(data)
                releases = [item['tag_name'].replace('v', '') for item in data]
                version = __version__

                result = self.check_update_available(version, releases)
                self.update_available, self.latest_release = result
            except Exception:
                error_msg = _('Unable to retrieve information.')
        except HTTPError:
            error_msg = _('Unable to retrieve information.')
        except URLError:
            error_msg = _('Unable to connect to the internet. <br><br>Make '
                          'sure the connection is working properly.')
        except Exception:
            error_msg = _('Unable to check for updates.')

        self.error = error_msg
        self.sig_ready.emit()
开发者ID:ming-hai,项目名称:spyder,代码行数:34,代码来源:updates.py

示例7: setup

 def setup(self):
     iofuncs = self.get_internal_funcs()+self.get_3rd_party_funcs()
     load_extensions = {}
     save_extensions = {}
     load_funcs = {}
     save_funcs = {}
     load_filters = []
     save_filters = []
     load_ext = []
     for ext, name, loadfunc, savefunc in iofuncs:
         filter_str = to_text_string(name + " (*%s)" % ext)
         if loadfunc is not None:
             load_filters.append(filter_str)
             load_extensions[filter_str] = ext
             load_funcs[ext] = loadfunc
             load_ext.append(ext)
         if savefunc is not None:
             save_extensions[filter_str] = ext
             save_filters.append(filter_str)
             save_funcs[ext] = savefunc
     load_filters.insert(0, to_text_string(_("Supported files")+" (*"+\
                                           " *".join(load_ext)+")"))
     load_filters.append(to_text_string(_("All files (*.*)")))
     self.load_filters = "\n".join(load_filters)
     self.save_filters = "\n".join(save_filters)
     self.load_funcs = load_funcs
     self.save_funcs = save_funcs
     self.load_extensions = load_extensions
     self.save_extensions = save_extensions
开发者ID:JamesLinus,项目名称:spyder,代码行数:29,代码来源:iofuncs.py

示例8: create_file_new_actions

 def create_file_new_actions(self, fnames):
     """Return actions for submenu 'New...'"""
     if not fnames:
         return []
     new_file_act = create_action(
         self,
         _("File..."),
         icon=ima.icon('filenew'),
         triggered=lambda: self.new_file(fnames[-1]))
     new_module_act = create_action(
         self,
         _("Module..."),
         icon=ima.icon('spyder'),
         triggered=lambda: self.new_module(fnames[-1]))
     new_folder_act = create_action(
         self,
         _("Folder..."),
         icon=ima.icon('folder_new'),
         triggered=lambda: self.new_folder(fnames[-1]))
     new_package_act = create_action(
         self,
         _("Package..."),
         icon=ima.icon('package_new'),
         triggered=lambda: self.new_package(fnames[-1]))
     return [
         new_file_act, new_folder_act, None, new_module_act, new_package_act
     ]
开发者ID:rthouvenin,项目名称:spyder,代码行数:27,代码来源:explorer.py

示例9: set_user_env

    def set_user_env(reg, parent=None):
        """Set HKCU (current user) environment variables"""
        reg = listdict2envdict(reg)
        types = dict()
        key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, "Environment")
        for name in reg:
            try:
                _x, types[name] = winreg.QueryValueEx(key, name)
            except WindowsError:
                types[name] = winreg.REG_EXPAND_SZ
        key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, "Environment", 0, winreg.KEY_SET_VALUE)
        for name in reg:
            winreg.SetValueEx(key, name, 0, types[name], reg[name])
        try:
            from win32gui import SendMessageTimeout
            from win32con import HWND_BROADCAST, WM_SETTINGCHANGE, SMTO_ABORTIFHUNG

            SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, "Environment", SMTO_ABORTIFHUNG, 5000)
        except ImportError:
            QMessageBox.warning(
                parent,
                _("Warning"),
                _(
                    "Module <b>pywin32 was not found</b>.<br>"
                    "Please restart this Windows <i>session</i> "
                    "(not the computer) for changes to take effect."
                ),
            )
开发者ID:dimikara,项目名称:spyder,代码行数:28,代码来源:environ.py

示例10: __init__

    def __init__(self, parent):
        QWidget.__init__(self, parent)

        vert_layout = QVBoxLayout()

        # Type frame
        type_layout = QHBoxLayout()
        type_label = QLabel(_("Import as"))
        type_layout.addWidget(type_label)

        self.array_btn = array_btn = QRadioButton(_("array"))
        array_btn.setEnabled(ndarray is not FakeObject)
        array_btn.setChecked(ndarray is not FakeObject)
        type_layout.addWidget(array_btn)

        list_btn = QRadioButton(_("list"))
        list_btn.setChecked(not array_btn.isChecked())
        type_layout.addWidget(list_btn)

        if pd:
            self.df_btn = df_btn = QRadioButton(_("DataFrame"))
            df_btn.setChecked(False)
            type_layout.addWidget(df_btn)

        h_spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        type_layout.addItem(h_spacer)
        type_frame = QFrame()
        type_frame.setLayout(type_layout)

        self._table_view = PreviewTable(self)
        vert_layout.addWidget(type_frame)
        vert_layout.addWidget(self._table_view)
        self.setLayout(vert_layout)
开发者ID:gyenney,项目名称:Tools,代码行数:33,代码来源:importwizard.py

示例11: setup_top_toolbar

 def setup_top_toolbar(self, layout):
     toolbar = []
     movetop_button = create_toolbutton(self,
                                 text=_("Move to top"),
                                 icon=ima.icon('2uparrow'),
                                 triggered=lambda: self.move_to(absolute=0),
                                 text_beside_icon=True)
     toolbar.append(movetop_button)
     moveup_button = create_toolbutton(self,
                                 text=_("Move up"),
                                 icon=ima.icon('1uparrow'),
                                 triggered=lambda: self.move_to(relative=-1),
                                 text_beside_icon=True)
     toolbar.append(moveup_button)
     movedown_button = create_toolbutton(self,
                                 text=_("Move down"),
                                 icon=ima.icon('1downarrow'),
                                 triggered=lambda: self.move_to(relative=1),
                                 text_beside_icon=True)
     toolbar.append(movedown_button)
     movebottom_button = create_toolbutton(self,
                                 text=_("Move to bottom"),
                                 icon=ima.icon('2downarrow'),
                                 triggered=lambda: self.move_to(absolute=1),
                                 text_beside_icon=True)
     toolbar.append(movebottom_button)
     self.selection_widgets.extend(toolbar)
     self._add_widgets_to_layout(layout, toolbar)
     return toolbar
开发者ID:gyenney,项目名称:Tools,代码行数:29,代码来源:pathmanager.py

示例12: remove_path

 def remove_path(self):
     answer = QMessageBox.warning(self, _("Remove path"),
         _("Do you really want to remove selected path?"),
         QMessageBox.Yes | QMessageBox.No)
     if answer == QMessageBox.Yes:
         self.pathlist.pop(self.listwidget.currentRow())
         self.update_list()
开发者ID:gyenney,项目名称:Tools,代码行数:7,代码来源:pathmanager.py

示例13: synchronize

 def synchronize(self):
     """
     Synchronize Spyder's path list with PYTHONPATH environment variable
     Only apply to: current user, on Windows platforms
     """
     answer = QMessageBox.question(self, _("Synchronize"),
         _("This will synchronize Spyder's path list with "
                 "<b>PYTHONPATH</b> environment variable for current user, "
                 "allowing you to run your Python modules outside Spyder "
                 "without having to configure sys.path. "
                 "<br>Do you want to clear contents of PYTHONPATH before "
                 "adding Spyder's path list?"),
         QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel)
     if answer == QMessageBox.Cancel:
         return
     elif answer == QMessageBox.Yes:
         remove = True
     else:
         remove = False
     from spyderlib.utils.environ import (get_user_env, set_user_env,
                                          listdict2envdict)
     env = get_user_env()
     if remove:
         ppath = self.pathlist+self.ro_pathlist
     else:
         ppath = env.get('PYTHONPATH', [])
         if not isinstance(ppath, list):
             ppath = [ppath]
         ppath = [path for path in ppath
                  if path not in (self.pathlist+self.ro_pathlist)]
         ppath.extend(self.pathlist+self.ro_pathlist)
     env['PYTHONPATH'] = ppath
     set_user_env( listdict2envdict(env), parent=self )
开发者ID:gyenney,项目名称:Tools,代码行数:33,代码来源:pathmanager.py

示例14: setup

    def setup(self, fname):
        """Setup Run Configuration dialog with filename *fname*"""
        combo_label = QLabel(_("Select a run configuration:"))
        self.combo = QComboBox()
        self.combo.setMaxVisibleItems(20)
        self.combo.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLength)
        self.combo.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)

        self.stack = QStackedWidget()

        configurations = _get_run_configurations()
        for index, (filename, options) in enumerate(configurations):
            if fname == filename:
                break
        else:
            # There is no run configuration for script *fname*:
            # creating a temporary configuration that will be kept only if
            # dialog changes are accepted by the user
            configurations.insert(0, (fname, RunConfiguration(fname).get()))
            index = 0
        for filename, options in configurations:
            widget = RunConfigOptions(self)
            widget.set(options)
            self.combo.addItem(filename)
            self.stack.addWidget(widget)
        self.combo.currentIndexChanged.connect(self.stack.setCurrentIndex)
        self.combo.setCurrentIndex(index)

        self.add_widgets(combo_label, self.combo, 10, self.stack)
        self.add_button_box(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)

        self.setWindowTitle(_("Run Settings"))
开发者ID:ChunHungLiu,项目名称:spyder,代码行数:32,代码来源:runconfig.py

示例15: get_toolbar_buttons

 def get_toolbar_buttons(self):
     if self.run_button is None:
         self.run_button = create_toolbutton(
             self, text=_("Run"), icon=ima.icon("run"), tip=_("Run again this program"), triggered=self.start_shell
         )
     if self.kill_button is None:
         self.kill_button = create_toolbutton(
             self,
             text=_("Kill"),
             icon=ima.icon("kill"),
             tip=_("Kills the current process, " "causing it to exit immediately"),
         )
     buttons = [self.run_button]
     if self.options_button is None:
         options = self.get_options_menu()
         if options:
             self.options_button = create_toolbutton(self, text=_("Options"), icon=ima.icon("tooloptions"))
             self.options_button.setPopupMode(QToolButton.InstantPopup)
             menu = QMenu(self)
             add_actions(menu, options)
             self.options_button.setMenu(menu)
     if self.options_button is not None:
         buttons.append(self.options_button)
     buttons.append(self.kill_button)
     return buttons
开发者ID:gyenney,项目名称:Tools,代码行数:25,代码来源:baseshell.py


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