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

Python compat.to_qvariant函数代码示例

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

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



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

示例1: headerData

 def headerData(self, section, orientation, role=Qt.DisplayRole):
     """Set header data"""
     if role != Qt.DisplayRole:
         return to_qvariant()
     labels = self.xlabels if orientation == Qt.Horizontal else self.ylabels
     if labels is None:
         return to_qvariant(int(section))
     else:
         return to_qvariant(labels[section])
开发者ID:ChunHungLiu,项目名称:spyder,代码行数:9,代码来源:arrayeditor.py


示例2: headerData

 def headerData(self, section, orientation, role=Qt.DisplayRole):
     """Overriding method headerData"""
     if role != Qt.DisplayRole:
         return to_qvariant()
     i_column = int(section)
     if orientation == Qt.Horizontal:
         headers = (_("File"), _("Line"), _("Condition"), "")
         return to_qvariant( headers[i_column] )
     else:
         return to_qvariant()
开发者ID:0xBADCA7,项目名称:spyder,代码行数:10,代码来源:breakpointsgui.py


示例3: data

 def data(self, index, role=Qt.DisplayRole):
     """Cell content"""
     if not index.isValid():
         return to_qvariant()
     if role == Qt.DisplayRole or role == Qt.EditRole:
         column = index.column()
         row = index.row()
         if column == 0:
             return to_qvariant(to_text_string(self.df_index[row]))
         else:
             value = self.get_value(row, column-1)
             if isinstance(value, float):
                 try:
                     return to_qvariant(self._format % value)
                 except (ValueError, TypeError):
                     # may happen if format = '%d' and value = NaN;
                     # see issue 4139
                     return to_qvariant(DEFAULT_FORMAT % value)
             else:
                 try:
                     return to_qvariant(to_text_string(value))
                 except UnicodeDecodeError:
                     return to_qvariant(encoding.to_unicode(value))
     elif role == Qt.BackgroundColorRole:
         return to_qvariant(self.get_bgcolor(index))
     elif role == Qt.FontRole:
         return to_qvariant(get_font(font_size_delta=DEFAULT_SMALL_DELTA))
     return to_qvariant()
开发者ID:rlaverde,项目名称:spyder,代码行数:28,代码来源:dataframeeditor.py


示例4: headerData

 def headerData(self, section, orientation, role=Qt.DisplayRole):
     """Overriding method headerData"""
     if role != Qt.DisplayRole:
         return to_qvariant()
     i_column = int(section)
     if orientation == Qt.Horizontal:
         headers = (_("Module"), _(" Required "),
                    _(" Installed "), _("Provided features"))
         return to_qvariant( headers[i_column] )
     else:
         return to_qvariant()
开发者ID:silentquasar,项目名称:spyder,代码行数:11,代码来源:dependencies.py


示例5: data

 def data(self, index, role=Qt.DisplayRole):
     """Return a model data element"""
     if not index.isValid():
         return to_qvariant()
     if role == Qt.DisplayRole:
         return self._display_data(index)
     elif role == Qt.BackgroundColorRole:
         return to_qvariant(get_color(self._data[index.row()][index.column()], .2))
     elif role == Qt.TextAlignmentRole:
         return to_qvariant(int(Qt.AlignRight|Qt.AlignVCenter))
     return to_qvariant()
开发者ID:ShenggaoZhu,项目名称:spyder,代码行数:11,代码来源:importwizard.py


示例6: create_combobox

 def create_combobox(self, text, choices, option, default=NoDefault,
                     tip=None, restart=False):
     """choices: couples (name, key)"""
     label = QLabel(text)
     combobox = QComboBox()
     if tip is not None:
         combobox.setToolTip(tip)
     for name, key in choices:
         if not (name is None and key is None):
             combobox.addItem(name, to_qvariant(key))
     # Insert separators
     count = 0
     for index, item in enumerate(choices):
         name, key = item
         if name is None and key is None:
             combobox.insertSeparator(index + count)
             count += 1
     self.comboboxes[combobox] = (option, default)
     layout = QHBoxLayout()
     layout.addWidget(label)
     layout.addWidget(combobox)
     layout.addStretch(1)
     layout.setContentsMargins(0, 0, 0, 0)
     widget = QWidget(self)
     widget.label = label
     widget.combobox = combobox
     widget.setLayout(layout)
     combobox.restart_required = restart
     combobox.label_text = text
     return widget
开发者ID:impact27,项目名称:spyder,代码行数:30,代码来源:configdialog.py


示例7: 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:
        action.triggered.connect(triggered)
    if toggled is not None:
        action.toggled.connect(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:DLlearn,项目名称:spyder,代码行数:28,代码来源:qthelpers.py


示例8: data

    def data(self, index, role=Qt.DisplayRole):
        """Qt Override."""
        row = index.row()
        if not index.isValid() or not (0 <= row < len(self.shortcuts)):
            return to_qvariant()

        shortcut = self.shortcuts[row]
        key = shortcut.key
        column = index.column()

        if role == Qt.DisplayRole:
            if column == CONTEXT:
                return to_qvariant(shortcut.context)
            elif column == NAME:
                color = self.text_color
                if self._parent == QApplication.focusWidget():
                    if self.current_index().row() == row:
                        color = self.text_color_highlight
                    else:
                        color = self.text_color
                text = self.rich_text[row]
                text = '<p style="color:{0}">{1}</p>'.format(color, text)
                return to_qvariant(text)
            elif column == SEQUENCE:
                text = QKeySequence(key).toString(QKeySequence.NativeText)
                return to_qvariant(text)
            elif column == SEARCH_SCORE:
                # Treating search scores as a table column simplifies the
                # sorting once a score for a specific string in the finder
                # has been defined. This column however should always remain
                # hidden.
                return to_qvariant(self.scores[row])
        elif role == Qt.TextAlignmentRole:
            return to_qvariant(int(Qt.AlignHCenter | Qt.AlignVCenter))
        return to_qvariant()
开发者ID:ChunHungLiu,项目名称:spyder,代码行数:35,代码来源:shortcuts.py


示例9: data

 def data(self, index, role=Qt.DisplayRole):
     """Cell content"""
     if not index.isValid():
         return to_qvariant()
     value = self.get_value(index)
     if is_binary_string(value):
         try:
             value = to_text_string(value, 'utf8')
         except:
             pass
     if role == Qt.DisplayRole:
         if value is np.ma.masked:
             return ''
         else:
             try:
                 return to_qvariant(self._format % value)
             except TypeError:
                 self.readonly = True
                 return repr(value)
     elif role == Qt.TextAlignmentRole:
         return to_qvariant(int(Qt.AlignCenter|Qt.AlignVCenter))
     elif role == Qt.BackgroundColorRole and self.bgcolor_enabled \
       and value is not np.ma.masked:
         try:
             hue = (self.hue0 +
                    self.dhue * (float(self.vmax) - self.color_func(value))
                    / (float(self.vmax) - self.vmin))
             hue = float(np.abs(hue))
             color = QColor.fromHsvF(hue, self.sat, self.val, self.alp)
             return to_qvariant(color)
         except TypeError:
             return to_qvariant()
     elif role == Qt.FontRole:
         return to_qvariant(get_font(font_size_delta=DEFAULT_SMALL_DELTA))
     return to_qvariant()
开发者ID:impact27,项目名称:spyder,代码行数:35,代码来源:arrayeditor.py


示例10: highlight_current_line

 def highlight_current_line(self):
     """Highlight current line"""
     selection = TextDecoration(self.textCursor())
     selection.format.setProperty(QTextFormat.FullWidthSelection,
                                  to_qvariant(True))
     selection.format.setBackground(self.currentline_color)
     selection.cursor.clearSelection()
     self.set_extra_selections('current_line', [selection])
     self.update_extra_selections()
开发者ID:impact27,项目名称:spyder,代码行数:9,代码来源:base.py


示例11: data

    def data(self, index, role=Qt.DisplayRole):
        """Override Qt method"""
        if not index.isValid() or not 0 <= index.row() < len(self._rows):
            return to_qvariant()
        row = index.row()
        column = index.column()

        name, state = self.row(row)

        if role == Qt.DisplayRole or role == Qt.EditRole:
            if column == 0:
                return to_qvariant(name)
        elif role == Qt.CheckStateRole:
            if column == 0:
                if state:
                    return Qt.Checked
                else:
                    return Qt.Unchecked
            if column == 1:
                return to_qvariant(state)
        return to_qvariant()
开发者ID:0xBADCA7,项目名称:spyder,代码行数:21,代码来源:layoutdialog.py


示例12: data

 def data(self, index, role=Qt.DisplayRole):
     """Return data at table index"""
     if not index.isValid():
         return to_qvariant()
     dep = self.dependencies[index.row()]
     if role == Qt.DisplayRole:
         if index.column() == 0:
             value = self.get_value(index)
             return to_qvariant(value)
         else:
             value = self.get_value(index)
             return to_qvariant(value)
     elif role == Qt.TextAlignmentRole:
         return to_qvariant(int(Qt.AlignLeft|Qt.AlignVCenter))
     elif role == Qt.BackgroundColorRole:
         from spyder.dependencies import Dependency
         status = dep.get_status()
         if status == Dependency.NOK:
             color = QColor(Qt.red)
             color.setAlphaF(.25)
             return to_qvariant(color)
开发者ID:silentquasar,项目名称:spyder,代码行数:21,代码来源:dependencies.py


示例13: headerData

    def headerData(self, section, orientation, role=Qt.DisplayRole):
        """Set header data"""
        if role != Qt.DisplayRole:
            return to_qvariant()

        if orientation == Qt.Horizontal:
            if section == 0:
                return 'Index'
            elif section == 1 and PY2:
                # 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:
                    header = to_text_string(self.df_header[0],
                                            encoding='utf-8-sig')
                except:
                    header = to_text_string(self.df_header[0])
                return to_qvariant(header)
            elif isinstance(self.df_header[section-1], TEXT_TYPES):
                # Get the proper encoding of the text in the header.
                # Fixes Issue 3896
                if not PY2:
                    try:
                        header = self.df_header[section-1].encode('utf-8')
                        coding = 'utf-8-sig'
                    except:
                        header = self.df_header[section-1].encode('utf-8')
                        coding = encoding.get_coding(header)
                else:
                    header = self.df_header[section-1]
                    coding = encoding.get_coding(header)
                return to_qvariant(to_text_string(header, encoding=coding))
            else:
                return to_qvariant(to_text_string(self.df_header[section-1]))
        else:
            return to_qvariant()
开发者ID:rlaverde,项目名称:spyder,代码行数:38,代码来源:dataframeeditor.py


示例14: headerData

    def headerData(self, section, orientation, role=Qt.DisplayRole):
        """Set header data"""
        if role != Qt.DisplayRole:
            return to_qvariant()

        if orientation == Qt.Horizontal:
            if section == 0:
                return 'Index'
            elif section == 1 and PY2:
                # 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:
                    header = to_text_string(self.df_header[0],
                                            encoding='utf-8-sig')
                except:
                    header = to_text_string(self.df_header[0])
                return to_qvariant(header)
            else:
                return to_qvariant(to_text_string(self.df_header[section-1]))
        else:
            return to_qvariant()
开发者ID:ChunHungLiu,项目名称:spyder,代码行数:24,代码来源:dataframeeditor.py


示例15: createEditor

 def createEditor(self, parent, option, index):
     """Create editor widget"""
     model = index.model()
     value = model.get_value(index)
     if model._data.dtype.name == "bool":
         value = not value
         model.setData(index, to_qvariant(value))
         return
     elif value is not np.ma.masked:
         editor = QLineEdit(parent)
         editor.setFont(get_font(font_size_delta=DEFAULT_SMALL_DELTA))
         editor.setAlignment(Qt.AlignCenter)
         if is_number(self.dtype):
             editor.setValidator(QDoubleValidator(editor))
         editor.returnPressed.connect(self.commitAndCloseEditor)
         return editor
开发者ID:ChunHungLiu,项目名称:spyder,代码行数:16,代码来源:arrayeditor.py


示例16: headerData

 def headerData(self, section, orientation, role=Qt.DisplayRole):
     """Qt Override."""
     if role == Qt.TextAlignmentRole:
         if orientation == Qt.Horizontal:
             return to_qvariant(int(Qt.AlignHCenter | Qt.AlignVCenter))
         return to_qvariant(int(Qt.AlignRight | Qt.AlignVCenter))
     if role != Qt.DisplayRole:
         return to_qvariant()
     if orientation == Qt.Horizontal:
         if section == CONTEXT:
             return to_qvariant(_("Context"))
         elif section == NAME:
             return to_qvariant(_("Name"))
         elif section == SEQUENCE:
             return to_qvariant(_("Shortcut"))
         elif section == SEARCH_SCORE:
             return to_qvariant(_("Score"))
     return to_qvariant()
开发者ID:ChunHungLiu,项目名称:spyder,代码行数:18,代码来源:shortcuts.py


示例17: headerData

 def headerData(self, section, orientation, role=Qt.DisplayRole):
     """Qt Override."""
     if role == Qt.TextAlignmentRole:
         if orientation == Qt.Horizontal:
             return to_qvariant(int(Qt.AlignHCenter | Qt.AlignVCenter))
         return to_qvariant(int(Qt.AlignRight | Qt.AlignVCenter))
     if role != Qt.DisplayRole:
         return to_qvariant()
     if orientation == Qt.Horizontal:
         if section == LANGUAGE:
             return to_qvariant(_("Language"))
         elif section == ADDR:
             return to_qvariant(_("Address"))
         elif section == CMD:
             return to_qvariant(_("Command to execute"))
     return to_qvariant()
开发者ID:cfanpc,项目名称:spyder,代码行数:16,代码来源:lspmanager.py


示例18: headerData

    def headerData(self, section, orientation, role=Qt.DisplayRole):
        """Override Qt method"""
        if role == Qt.TextAlignmentRole:
            if orientation == Qt.Horizontal:
                return to_qvariant(int(Qt.AlignHCenter | Qt.AlignVCenter))
            return to_qvariant(int(Qt.AlignRight | Qt.AlignVCenter))

        elif role == Qt.DisplayRole and orientation == Qt.Horizontal:
            if section == C.COL_PACKAGE_TYPE:
                return to_qvariant(_("T"))
            if section == C.COL_NAME:
                return to_qvariant(_("Name"))
            elif section == C.COL_VERSION:
                return to_qvariant(_("Version"))
            elif section == C.COL_DESCRIPTION:
                return to_qvariant(_("Description"))
            elif section == C.COL_STATUS:
                return to_qvariant(_("Status"))
            else:
                return to_qvariant()
开发者ID:gitter-badger,项目名称:conda-manager,代码行数:20,代码来源:packages.py


示例19: 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:
        action.triggered.connect(triggered)
    if toggled is not None:
        action.toggled.connect(toggled)
        action.setCheckable(True)
    if icon is not None:
        if is_text_string(icon):
            icon = get_icon(icon)
        action.setIcon(icon)
    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)

    # Workround for Mac because setting context=Qt.WidgetShortcut
    # there doesn't have any effect
    if sys.platform == 'darwin':
        action._shown_shortcut = None
        if context == Qt.WidgetShortcut:
            if shortcut is not None:
                action._shown_shortcut = shortcut
            else:
                # This is going to be filled by
                # main.register_shortcut
                action._shown_shortcut = 'missing'
        else:
            if shortcut is not None:
                action.setShortcut(shortcut)
            action.setShortcutContext(context)
    else:
        if shortcut is not None:
            action.setShortcut(shortcut)
        action.setShortcutContext(context)

    return action
开发者ID:G-VAR,项目名称:spyder,代码行数:43,代码来源:qthelpers.py


示例20: highlight_current_cell

    def highlight_current_cell(self):
        """Highlight current cell"""
        if self.cell_separators is None or \
          not self.highlight_current_cell_enabled:
            return
        cursor, whole_file_selected, whole_screen_selected =\
            self.select_current_cell_in_visible_portion()
        selection = TextDecoration(cursor)
        selection.format.setProperty(QTextFormat.FullWidthSelection,
                                     to_qvariant(True))
        selection.format.setBackground(self.currentcell_color)

        if whole_file_selected:
            self.clear_extra_selections('current_cell')
        elif whole_screen_selected:
            if self.has_cell_separators:
                self.set_extra_selections('current_cell', [selection])
                self.update_extra_selections()
            else:
                self.clear_extra_selections('current_cell')
        else:
            self.set_extra_selections('current_cell', [selection])
            self.update_extra_selections()
开发者ID:impact27,项目名称:spyder,代码行数:23,代码来源:base.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python uic.loadUi函数代码示例发布时间:2022-05-26
下一篇:
Python QtWidgets.QWidget类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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