• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python py3compat.is_text_string函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: set

 def set(self, section, option, value, verbose=False, save=True):
     """
     Set an option
     section=None: attribute a default section name
     """
     section = self.__check_section_option(section, option)
     default_value = self.get_default(section, option)
     if default_value is NoDefault:
         # This let us save correctly string value options with
         # no config default that contain non-ascii chars in
         # Python 2
         if PY2 and is_text_string(value):
             value = repr(value)
         default_value = value
         self.set_default(section, option, default_value)
     if isinstance(default_value, bool):
         value = bool(value)
     elif isinstance(default_value, float):
         value = float(value)
     elif isinstance(default_value, int):
         value = int(value)
     elif not is_text_string(default_value):
         value = repr(value)
     self._set(section, option, value, verbose)
     if save:
         self._save()
开发者ID:AungWinnHtut,项目名称:spyder,代码行数:26,代码来源:user.py


示例2: __check_section_option

 def __check_section_option(self, section, option):
     """
     Private method to check section and option types
     """
     if section is None:
         section = self.DEFAULT_SECTION_NAME
     elif not is_text_string(section):
         raise RuntimeError("Argument 'section' must be a string")
     if not is_text_string(option):
         raise RuntimeError("Argument 'option' must be a string")
     return section
开发者ID:jromang,项目名称:spyderlib,代码行数:11,代码来源:userconfig.py


示例3: register_plugin

 def register_plugin(self):
     """Register plugin in Spyder's main window"""
     self.connect(self, SIGNAL("edit_goto(QString,int,QString)"),
                  self.main.editor.load)
     self.connect(self, SIGNAL('redirect_stdio(bool)'),
                  self.main.redirect_internalshell_stdio)
     self.main.add_dockwidget(self)
     
     c2p_act = create_action(self, _("Import COMBINE as Python"),
                                triggered=self.run_c2p)
     c2p_act.setEnabled(True)
     #self.register_shortcut(c2p_act, context="Combine to Python",
     #                       name="Import combine archive", default="Alt-C")
     for item in self.main.file_menu_actions:
         try:
             menu_title = item.title()
         except AttributeError:
             pass
         else:
             if not is_text_string(menu_title): # string is a QString
                 menu_title = to_text_string(menu_title.toUtf8)
             if item.title() == str("Import"):
                 item.addAction(c2p_act)
     c2p_actions = (None, c2p_act)
     import_menu = QMenu(_("Import"))
     add_actions(import_menu, c2p_actions)
     self.main.file_menu_actions.insert(8, import_menu)
开发者ID:sys-bio,项目名称:spyderplugins,代码行数:27,代码来源:p_import_combine.py


示例4: create_toolbutton

def create_toolbutton(parent,
                      text=None,
                      shortcut=None,
                      icon=None,
                      tip=None,
                      toggled=None,
                      triggered=None,
                      autoraise=True,
                      text_beside_icon=False):
    """Create a QToolButton"""
    button = QToolButton(parent)
    if text is not None:
        button.setText(text)
    if icon is not None:
        if is_text_string(icon):
            icon = get_icon(icon)
        button.setIcon(icon)
    if text is not None or tip is not None:
        button.setToolTip(text if tip is None else tip)
    if text_beside_icon:
        button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
    button.setAutoRaise(autoraise)
    if triggered is not None:
        button.clicked.connect(triggered)
    if toggled is not None:
        button.toggled.connect(toggled)
        button.setCheckable(True)
    if shortcut is not None:
        button.setShortcut(shortcut)
    return button
开发者ID:yoyobbs,项目名称:spyder,代码行数:30,代码来源:qthelpers.py


示例5: go_to

 def go_to(self, url_or_text):
     """Go to page *address*"""
     if is_text_string(url_or_text):
         url = QUrl(url_or_text)
     else:
         url = url_or_text
     self.webview.load(url)
开发者ID:CVML,项目名称:spyder,代码行数:7,代码来源:browser.py


示例6: register_plugin

    def register_plugin(self):
        """Register plugin in Spyder's main window"""
        self.edit_goto.connect(self.main.editor.load)
        # self.redirect_stdio.connect(self.main.redirect_internalshell_stdio)
        self.clear_all_breakpoints.connect(self.main.editor.clear_all_breakpoints)
        self.clear_breakpoint.connect(self.main.editor.clear_breakpoint)
        self.main.editor.breakpoints_saved.connect(self.set_data)
        self.set_or_edit_conditional_breakpoint.connect(self.main.editor.set_or_edit_conditional_breakpoint)

        self.main.add_dockwidget(self)

        list_action = create_action(self, _("List breakpoints"), triggered=self.show)
        list_action.setEnabled(True)

        # A fancy way to insert the action into the Breakpoints menu under
        # the assumption that Breakpoints is the first QMenu in the list.
        for item in self.main.debug_menu_actions:
            try:
                menu_title = item.title()
            except AttributeError:
                pass
            else:
                # Depending on Qt API version, could get a QString or
                # unicode from title()
                if not is_text_string(menu_title):  # string is a QString
                    menu_title = to_text_string(menu_title.toUtf8)
                item.addAction(list_action)
                # If we've reached this point it means we've located the
                # first QMenu in the run_menu. Since there might be other
                # QMenu entries in run_menu, we'll break so that the
                # breakpoint action is only inserted once into the run_menu.
                break
        self.main.editor.pythonfile_dependent_actions += [list_action]
开发者ID:ChunHungLiu,项目名称:spyder,代码行数:33,代码来源:breakpoints.py


示例7: setData

    def setData(self, index, value, role=Qt.EditRole, change_type=None):
        """Cell content change"""
        column = index.column()
        row = index.row()

        if change_type is not None:
            try:
                value = self.data(index, role=Qt.DisplayRole)
                val = from_qvariant(value, str)
                if change_type is bool:
                    val = bool_false_check(val)
                self.df.iloc[row, column - 1] = change_type(val)
            except ValueError:
                self.df.iloc[row, column - 1] = change_type('0')
        else:
            val = from_qvariant(value, str)
            current_value = self.get_value(row, column-1)
            if isinstance(current_value, bool):
                val = bool_false_check(val)
            if isinstance(current_value, ((bool,) + _sup_nr + _sup_com)) or \
               is_text_string(current_value):
                try:
                    self.df.iloc[row, column-1] = current_value.__class__(val)
                except ValueError as e:
                    QMessageBox.critical(self.dialog, "Error",
                                         "Value error: %s" % str(e))
                    return False
            else:
                QMessageBox.critical(self.dialog, "Error",
                                     "The type of the cell is not a supported "
                                     "type")
                return False
        self.max_min_col_update()
        return True
开发者ID:gyenney,项目名称:Tools,代码行数:34,代码来源:dataframeeditor.py


示例8: get_bgcolor

 def get_bgcolor(self, index):
     """Background color depending on value"""
     column = index.column()
     if column == 0:
         color = QColor(Qt.lightGray)
         color.setAlphaF(.8)
         return color
     if not self.bgcolor_enabled:
         return
     value = self.get_value(index.row(), column-1)
     if isinstance(value, _sup_com):
         color_func = abs
     else:
         color_func = float
     if isinstance(value, _sup_nr+_sup_com) and self.bgcolor_enabled:
         vmax, vmin = self.return_max(self.max_min_col, column-1)
         hue = self.hue0 + self.dhue*(vmax-color_func(value)) / (vmax-vmin)
         hue = float(abs(hue))
         color = QColor.fromHsvF(hue, self.sat, self.val, self.alp)
     elif is_text_string(value):
         color = QColor(Qt.lightGray)
         color.setAlphaF(.05)
     else:
         color = QColor(Qt.lightGray)
         color.setAlphaF(.3)
     return color
开发者ID:gyenney,项目名称:Tools,代码行数:26,代码来源:dataframeeditor.py


示例9: value_to_display

def value_to_display(value, truncate=False, trunc_len=80, minmax=False):
    """Convert value for display purpose"""
    if minmax and isinstance(value, (ndarray, MaskedArray)):
        if value.size == 0:
            return repr(value)
        try:
            return 'Min: %r\nMax: %r' % (value.min(), value.max())
        except TypeError:
            pass
        except ValueError:
            # Happens when one of the array cell contains a sequence
            pass
    if isinstance(value, Image):
        return '%s  Mode: %s' % (address(value), value.mode)
    if isinstance(value, DataFrame):
        cols = value.columns
        cols = [to_text_string(c) for c in cols]
        return 'Column names: ' + ', '.join(list(cols))
    if is_binary_string(value):
        try:
            value = to_text_string(value, 'utf8')
        except:
            pass
    if not is_text_string(value):
        if isinstance(value, (list, tuple, dict, set)):
            value = CollectionsRepr.repr(value)
        else:
            value = repr(value)
    if truncate and len(value) > trunc_len:
        value = value[:trunc_len].rstrip() + ' ...'
    return value
开发者ID:jayitb,项目名称:Spyderplugin_ratelaws,代码行数:31,代码来源:dicteditorutils.py


示例10: getobjdir

def getobjdir(obj):
    """
    For standard objects, will simply return dir(obj)
    In special cases (e.g. WrapITK package), will return only string elements
    of result returned by dir(obj)
    """
    return [item for item in dir(obj) if is_text_string(item)]
开发者ID:Poneyo,项目名称:spyderlib,代码行数:7,代码来源:dochelpers.py


示例11: create_action

def create_action(parent, text, shortcut=None, icon=None, tip=None,
                  toggled=None, triggered=None, data=None, menurole=None,
                  context=Qt.WindowShortcut):
    """Create a QAction"""
    action = QAction(text, parent)
    if triggered is not None:
        parent.connect(action, SIGNAL("triggered()"), triggered)
    if toggled is not None:
        parent.connect(action, SIGNAL("toggled(bool)"), toggled)
        action.setCheckable(True)
    if icon is not None:
        if is_text_string(icon):
            icon = get_icon(icon)
        action.setIcon(icon)
    if shortcut is not None:
        action.setShortcut(shortcut)
    if tip is not None:
        action.setToolTip(tip)
        action.setStatusTip(tip)
    if data is not None:
        action.setData(to_qvariant(data))
    if menurole is not None:
        action.setMenuRole(menurole)
    #TODO: Hard-code all shortcuts and choose context=Qt.WidgetShortcut
    # (this will avoid calling shortcuts from another dockwidget
    #  since the context thing doesn't work quite well with these widgets)
    action.setShortcutContext(context)
    return action
开发者ID:jromang,项目名称:spyderlib,代码行数:28,代码来源:qthelpers.py


示例12: send_to_process

    def send_to_process(self, text):
        if not self.is_running():
            return
            
        if not is_text_string(text):
            text = to_text_string(text)
        if self.mpl_backend == 'Qt4Agg' and os.name == 'nt' and \
          self.introspection_socket is not None:
            communicate(self.introspection_socket,
                        "toggle_inputhook_flag(True)")
#            # Socket-based alternative (see input hook in sitecustomize.py):
#            while self.local_server.hasPendingConnections():
#                self.local_server.nextPendingConnection().write('go!')
        if any([text == cmd for cmd in ['%ls', '%pwd', '%scientific']]) or \
          any([text.startswith(cmd) for cmd in ['%cd ', '%clear ']]):
            text = 'evalsc(r"%s")\n' % text
        if not text.endswith('\n'):
            text += '\n'
        self.process.write(to_binary_string(text, 'utf8'))
        self.process.waitForBytesWritten(-1)
        
        # Eventually write prompt faster (when hitting Enter continuously)
        # -- necessary/working on Windows only:
        if os.name == 'nt':
            self.write_error()
开发者ID:Micseb,项目名称:spyder,代码行数:25,代码来源:pythonshell.py


示例13: create_python_script_action

def create_python_script_action(parent, text, icon, package, module, args=[]):
    """Create action to run a GUI based Python script"""
    if is_text_string(icon):
        icon = get_icon(icon)
    if programs.python_script_exists(package, module):
        return create_action(parent, text, icon=icon,
                             triggered=lambda:
                             programs.run_python_script(package, module, args))
开发者ID:jromang,项目名称:spyderlib,代码行数:8,代码来源:qthelpers.py


示例14: set_eol_chars

 def set_eol_chars(self, text):
     """Set widget end-of-line (EOL) characters from text (analyzes text)"""
     if not is_text_string(text): # testing for QString (PyQt API#1)
         text = to_text_string(text)
     eol_chars = sourcecode.get_eol_chars(text)
     if eol_chars is not None and self.eol_chars is not None:
         self.document().setModified(True)
     self.eol_chars = eol_chars
开发者ID:arvindchari88,项目名称:newGitTest,代码行数:8,代码来源:mixins.py


示例15: translate_gettext

 def translate_gettext(x):
     if not PY3 and is_unicode(x):
         x = x.encode("utf-8")
     y = lgettext(x)
     if is_text_string(y) and PY3:
         return y
     else:
         return to_text_string(y, "utf-8")
开发者ID:ChunHungLiu,项目名称:spyder,代码行数:8,代码来源:base.py


示例16: setup_page

 def setup_page(self):
     tabs = QTabWidget()
     names = self.get_option("names")
     names.pop(names.index(CUSTOM_COLOR_SCHEME_NAME))
     names.insert(0, CUSTOM_COLOR_SCHEME_NAME)
     fieldnames = {
                   "background":     _("Background:"),
                   "currentline":    _("Current line:"),
                   "currentcell":    _("Current cell:"),
                   "occurence":      _("Occurence:"),
                   "ctrlclick":      _("Link:"),
                   "sideareas":      _("Side areas:"),
                   "matched_p":      _("Matched parentheses:"),
                   "unmatched_p":    _("Unmatched parentheses:"),
                   "normal":         _("Normal text:"),
                   "keyword":        _("Keyword:"),
                   "builtin":        _("Builtin:"),
                   "definition":     _("Definition:"),
                   "comment":        _("Comment:"),
                   "string":         _("String:"),
                   "number":         _("Number:"),
                   "instance":       _("Instance:"),
                   }
     from spyderlib.utils import syntaxhighlighters
     assert all([key in fieldnames
                 for key in syntaxhighlighters.COLOR_SCHEME_KEYS])
     for tabname in names:
         cs_group = QGroupBox(_("Color scheme"))
         cs_layout = QGridLayout()
         for row, key in enumerate(syntaxhighlighters.COLOR_SCHEME_KEYS):
             option = "%s/%s" % (tabname, key)
             value = self.get_option(option)
             name = fieldnames[key]
             if is_text_string(value):
                 label, clayout = self.create_coloredit(name, option,
                                                        without_layout=True)
                 label.setAlignment(Qt.AlignRight|Qt.AlignVCenter)
                 cs_layout.addWidget(label, row+1, 0)
                 cs_layout.addLayout(clayout, row+1, 1)
             else:
                 label, clayout, cb_bold, cb_italic = self.create_scedit(
                                         name, option, without_layout=True)
                 label.setAlignment(Qt.AlignRight|Qt.AlignVCenter)
                 cs_layout.addWidget(label, row+1, 0)
                 cs_layout.addLayout(clayout, row+1, 1)
                 cs_layout.addWidget(cb_bold, row+1, 2)
                 cs_layout.addWidget(cb_italic, row+1, 3)
         cs_group.setLayout(cs_layout)
         if tabname in sh.COLOR_SCHEME_NAMES:
             def_btn = self.create_button(_("Reset to default values"),
                                      lambda: self.reset_to_default(tabname))
             tabs.addTab(self.create_tab(cs_group, def_btn), tabname)
         else:
             tabs.addTab(self.create_tab(cs_group), tabname)
     
     vlayout = QVBoxLayout()
     vlayout.addWidget(tabs)
     self.setLayout(vlayout)
开发者ID:gyenney,项目名称:Tools,代码行数:58,代码来源:configdialog.py


示例17: create_program_action

def create_program_action(parent, text, name, icon=None, nt_name=None):
    """Create action to run a program"""
    if is_text_string(icon):
        icon = get_icon(icon)
    if os.name == "nt" and nt_name is not None:
        name = nt_name
    path = programs.find_program(name)
    if path is not None:
        return create_action(parent, text, icon=icon, triggered=lambda: programs.run_program(name))
开发者ID:yoyobbs,项目名称:spyder,代码行数:9,代码来源:qthelpers.py


示例18: load_config

 def load_config(self):
     """Load configuration: tree widget state"""
     expanded_state = self.get_option('expanded_state', None)
     # Sometimes the expanded state option may be truncated in .ini file
     # (for an unknown reason), in this case it would be converted to a
     # string by 'userconfig':
     if is_text_string(expanded_state):
         expanded_state = None
     if expanded_state is not None:
         self.treewidget.set_expanded_state(expanded_state)
开发者ID:gyenney,项目名称:Tools,代码行数:10,代码来源:outlineexplorer.py


示例19: eval

 def eval(self, text):
     """
     Evaluate text and return (obj, valid)
     where *obj* is the object represented by *text*
     and *valid* is True if object evaluation did not raise any exception
     """
     assert is_text_string(text)
     try:
         return eval(text, self.locals), True
     except:
         return None, False
开发者ID:ImadBouirmane,项目名称:spyder,代码行数:11,代码来源:interpreter.py


示例20: value_to_display

def value_to_display(value, truncate=False, trunc_len=80, minmax=False):
    """Convert value for display purpose"""
    try:
        if isinstance(value, recarray):
            fields = value.names
            display = 'Field names: ' + ', '.join(fields)
        elif minmax and isinstance(value, (ndarray, MaskedArray)):
            if value.size == 0:
                display = repr(value)
            try:
                display = 'Min: %r\nMax: %r' % (value.min(), value.max())
            except TypeError:
                pass
            except ValueError:
                # Happens when one of the array cell contains a sequence
                pass
        elif isinstance(value, (list, tuple, dict, set)):
            display = CollectionsRepr.repr(value)
        elif isinstance(value, Image):
            display = '%s  Mode: %s' % (address(value), value.mode)
        elif isinstance(value, DataFrame):
            cols = value.columns
            if PY2 and len(cols) > 0:
                # Get rid of possible BOM utf-8 data present at the
                # beginning of a file, which gets attached to the first
                # column header when headers are present in the first
                # row.
                # Fixes Issue 2514
                try:
                    ini_col = to_text_string(cols[0], encoding='utf-8-sig')
                except:
                    ini_col = to_text_string(cols[0])
                cols = [ini_col] + [to_text_string(c) for c in cols[1:]]
            else:
                cols = [to_text_string(c) for c in cols]
            display = 'Column names: ' + ', '.join(list(cols))
        elif isinstance(value, NavigableString):
            # Fixes Issue 2448
            display = to_text_string(value)
        elif is_binary_string(value):
            try:
                display = to_text_string(value, 'utf8')
            except:
                pass
        elif is_text_string(value):
            display = value
        else:
            display = repr(value)
            if truncate and len(display) > trunc_len:
                display = display[:trunc_len].rstrip() + ' ...'
    except:
        display = to_text_string(type(value))

    return display
开发者ID:MerouaneBen,项目名称:spyder,代码行数:54,代码来源:utils.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python py3compat.to_binary_string函数代码示例发布时间:2022-05-27
下一篇:
Python py3compat.getcwd函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap