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

Python sip.cast函数代码示例

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

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



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

示例1: layout_item

def layout_item(layout, item_id, item_class):
    """Fetch a specific item according to its type in a layout.

    There's some sip casting conversion issues with QgsLayout::itemById.
    Don't use it, and use this function instead.
    See https://github.com/inasafe/inasafe/issues/4271

    :param layout: The layout to look in.
    :type layout: QgsLayout

    :param item_id: The ID of the item to look for.
    :type item_id: basestring

    :param item_class: The expected class name.
    :type item_class: cls

    :return: The layout item, inherited class of QgsLayoutItem.
    """
    item = layout.itemById(item_id)
    if item is None:
        # no match!
        return item

    if issubclass(item_class, QgsLayoutMultiFrame):
        # finding a multiframe by frame id
        frame = sip.cast(item, QgsLayoutFrame)
        multi_frame = frame.multiFrame()
        return sip.cast(multi_frame, item_class)
    else:
        # force sip to correctly cast item to required type
        return sip.cast(item, item_class)
开发者ID:inasafe,项目名称:inasafe,代码行数:31,代码来源:default.py


示例2: gradient_darker

def gradient_darker(grad, factor):
    """Return a copy of the QGradient darkened by factor.

    .. note:: Only QLinearGradeint and QRadialGradient are supported.

    """
    if type(grad) is QGradient:
        if grad.type() == QGradient.LinearGradient:
            grad = sip.cast(grad, QLinearGradient)
        elif grad.type() == QGradient.RadialGradient:
            grad = sip.cast(grad, QRadialGradient)

    if isinstance(grad, QLinearGradient):
        new_grad = QLinearGradient(grad.start(), grad.finalStop())
    elif isinstance(grad, QRadialGradient):
        new_grad = QRadialGradient(grad.center(), grad.radius(),
                                   grad.focalPoint())
    else:
        raise TypeError

    new_grad.setCoordinateMode(grad.coordinateMode())

    for pos, color in grad.stops():
        new_grad.setColorAt(pos, color.darker(factor))

    return new_grad
开发者ID:RachitKansal,项目名称:orange3,代码行数:26,代码来源:utils.py


示例3: QGraphicsItem_itemChange

 def QGraphicsItem_itemChange(self, change, value):
     if change in changeset:
         if isinstance(value, QGraphicsItem):
             value = sip.cast(value, QGraphicsItem)
         rval = QGraphicsItem_itemChange_old(self, change, value)
         if isinstance(rval, QGraphicsItem):
             rval = sip.cast(rval, QGraphicsItem)
         return rval
     else:
         return QGraphicsItem_itemChange_old(self, change, value)
开发者ID:ales-erjavec,项目名称:anyqt,代码行数:10,代码来源:_fixes.py


示例4: __init__

    def __init__(self, _model, parent):
        """
        Connect to all of the models signals, Whenever anything happens recheck everything.
        """
        QtCore.QObject.__init__(self,parent)
        self._model = _model
        self.model = sip.cast(_model, QtCore.QAbstractItemModel)
        self.insert = []
        self.remove = []
        self.fetchingMore = False
        assert(self.model)

        self.connect( self.model, QtCore.SIGNAL("columnsAboutToBeInserted(const QModelIndex&, int, int)"), self.runAllTests)
        self.connect( self.model, QtCore.SIGNAL("columnsAboutToBeRemoved(const QModelIndex&, int, int)"), self.runAllTests)
        self.connect( self.model, QtCore.SIGNAL("columnsBeInserted(const QModelIndex&, int, int)"), self.runAllTests)
        self.connect( self.model, QtCore.SIGNAL("columnsRemoved(const QModelIndex&, int, int)"), self.runAllTests)
        self.connect( self.model, QtCore.SIGNAL("dataChanged(const QModelIndex&, const QModelIndex&)"), self.runAllTests)
        self.connect( self.model, QtCore.SIGNAL("headerDataChanged(Qt::Orientation, int, int)"), self.runAllTests)
        self.connect( self.model, QtCore.SIGNAL("layoutAboutToBeChanged()"), self.runAllTests)
        self.connect( self.model, QtCore.SIGNAL("layoutChanged()"), self.runAllTests)
        self.connect( self.model, QtCore.SIGNAL("modelReset()"), self.runAllTests)
        self.connect( self.model, QtCore.SIGNAL("rowsAboutToBeInserted(const QModelIndex&, int, int)"), self.runAllTests)
        self.connect( self.model, QtCore.SIGNAL("rowsAboutToBeRemoved(const QModelIndex&, int, int)"), self.runAllTests)
        self.connect( self.model, QtCore.SIGNAL("rowsBeInserted(const QModelIndex&, int, int)"), self.runAllTests)
        self.connect( self.model, QtCore.SIGNAL("rowsRemoved(const QModelIndex&, int, int)"), self.runAllTests)

        # Special checks for inserting/removing
        self.connect( self.model, QtCore.SIGNAL("rowsAboutToBeInserted(const QModelIndex&, int, int)"), self.rowsAboutToBeInserted)
        self.connect( self.model, QtCore.SIGNAL("rowsAboutToBeRemoved(const QModelIndex&, int, int)"), self.rowsAboutToBeRemoved)
        self.connect( self.model, QtCore.SIGNAL("rowsBeInserted(const QModelIndex&, int, int)"), self.rowsInserted)
        self.connect( self.model, QtCore.SIGNAL("rowsRemoved(const QModelIndex&, int, int)"), self.rowsRemoved)
        self.runAllTests()
开发者ID:velorientc,项目名称:git_test7,代码行数:32,代码来源:modeltest.py


示例5: itemChange

    def itemChange(self, change, value):
        if change == QtGui.QGraphicsItem.ItemPositionChange and self.scene():

            # If Left mouse + alt is pressed then don't snap
            button = QtGui.QApplication.mouseButtons() == QtCore.Qt.LeftButton
            modifier = QtGui.QApplication.keyboardModifiers() == QtCore.Qt.AltModifier

            if button and modifier:
                self.position_changed.emit(value)
                return super(CoordinateSnapMixin, self).itemChange(change, value)

            # Get all items under the mouse
            # TODO: Use try instead of isinstance
            # TODO: Add priority
            # TODO: Use childItems
            items = [x for x in self.scene().items(value) if isinstance(x, SnapsCoordinates) and x.parentItem() is not self]

            for item in items:
                value = item.snap_coordinate(value)

            self.position_changed.emit(value)

        # itemChange and setParentItem causes error in PyQt4
        # TODO: Test with PySide and PyQt5
        # See http://www.riverbankcomputing.com/pipermail/pyqt/2012-August/031818.html
        result =  super(CoordinateSnapMixin, self).itemChange(change, value)
        if isinstance(result, QtGui.QGraphicsItem):
            result = sip.cast(result, QtGui.QGraphicsItem)
        return result
开发者ID:chrisbura,项目名称:pythoncad-qt,代码行数:29,代码来源:scene_item.py


示例6: __init__

    def __init__(self, _model, verbose=True, parent=None):
        """
        Connect to all of the models signals, Whenever anything happens recheck everything.
        """
        QtCore.QObject.__init__(self,parent)
        self._model = _model
        self.model = sip.cast(_model, QtCore.QAbstractItemModel)
        self.insert = []
        self.remove = []
        self.fetchingMore = False
        self._verbose = verbose
        assert(self.model)

        self.model.columnsAboutToBeInserted.connect(self.runAllTests)
        self.model.columnsAboutToBeRemoved.connect(self.runAllTests)
        self.model.columnsInserted.connect(self.runAllTests)
        self.model.columnsRemoved.connect(self.runAllTests)
        self.model.dataChanged.connect(self.runAllTests)
        self.model.headerDataChanged.connect(self.runAllTests)
        self.model.layoutAboutToBeChanged.connect(self.runAllTests)
        self.model.layoutChanged.connect(self.runAllTests)
        self.model.modelReset.connect(self.runAllTests)
        self.model.rowsAboutToBeInserted.connect(self.runAllTests)
        self.model.rowsAboutToBeRemoved.connect(self.runAllTests)
        self.model.rowsInserted.connect(self.runAllTests)
        self.model.rowsRemoved.connect(self.runAllTests)

        # Special checks for inserting/removing
        self.model.rowsAboutToBeInserted.connect(self.rowsAboutToBeInserted)
        self.model.rowsAboutToBeRemoved.connect(self.rowsAboutToBeRemoved)
        self.model.rowsInserted.connect(self.rowsInserted)
        self.model.rowsRemoved.connect(self.rowsRemoved)
        self.runAllTests()
开发者ID:The-Compiler,项目名称:PyQt5_modeltest,代码行数:33,代码来源:modeltest.py


示例7: supercast

def supercast(obj):
    """
    cast a QObject subclass to the best known wrapped super class
    """
    if not qtclasses:
        # To get really all Qt classes I would have to 
        # import QtNetwork, QtXml, QtSvg and QtScript, too.
        import PyQt4
        qtclasses.update(
            dict([(key, value) \
                for key, value in PyQt4.QtCore.__dict__.items() + PyQt4.QtGui.__dict__.items() \
                if hasattr(value, "__subclasses__") and issubclass(value, QObject)])
        )
    try:
        if not issubclass(value, QObject):
            return obj
    except TypeError: 
        # no class - no cast...
        return obj
    mo = obj.metaObject()
    while mo:
        cls = qtclasses.get(str(mo.className()))
        if cls:
            return sip.cast(obj, cls)
        mo = mo.superClass()
    # This should never be reached
    return obj
开发者ID:Fahad-Alsaidi,项目名称:scribus-svn,代码行数:27,代码来源:mikro.py


示例8: registerObject

 def registerObject(cls, obj):
     """
     Workaround for PyQt bug in qgraphicsscene.items()
     All subclasses of QGraphicsObject must register themselves with this function.
     (otherwise, mouse interaction with those objects will likely fail)
     """
     if HAVE_SIP and isinstance(obj, sip.wrapper):
         cls._addressCache[sip.unwrapinstance(sip.cast(obj, QtGui.QGraphicsItem))] = obj
开发者ID:Rareson,项目名称:LammpsRelated,代码行数:8,代码来源:GraphicsScene.py


示例9: __init__

    def __init__(self, brush, matrix, pdf, pixel_page_width, pixel_page_height):
        self.matrix = (matrix.m11(), matrix.m12(), matrix.m21(), matrix.m22(),
                       matrix.dx(), matrix.dy())
        gradient = sip.cast(brush.gradient(), QLinearGradient)

        start, stop, stops = self.spread_gradient(gradient, pixel_page_width,
                                                  pixel_page_height, matrix)

        # TODO: Handle colors with different opacities
        self.const_opacity = stops[0].color[-1]

        funcs = Array()
        bounds = Array()
        encode = Array()

        for i, current_stop in enumerate(stops):
            if i < len(stops) - 1:
                next_stop = stops[i+1]
                func = Dictionary({
                    'FunctionType': 2,
                    'Domain': Array([0, 1]),
                    'C0': Array(current_stop.color[:3]),
                    'C1': Array(next_stop.color[:3]),
                    'N': 1,
                })
                funcs.append(func)
                encode.extend((0, 1))
                if i+1 < len(stops) - 1:
                    bounds.append(next_stop.t)

        func = Dictionary({
            'FunctionType': 3,
            'Domain': Array([stops[0].t, stops[-1].t]),
            'Functions': funcs,
            'Bounds': bounds,
            'Encode': encode,
        })

        shader = Dictionary({
            'ShadingType': 2,
            'ColorSpace': Name('DeviceRGB'),
            'AntiAlias': True,
            'Coords': Array([start.x(), start.y(), stop.x(), stop.y()]),
            'Function': func,
            'Extend': Array([True, True]),
        })

        Dictionary.__init__(self, {
            'Type': Name('Pattern'),
            'PatternType': 2,
            'Shading': shader,
            'Matrix': Array(self.matrix),
        })

        self.cache_key = (self.__class__.__name__, self.matrix,
                          tuple(shader['Coords']), stops)
开发者ID:AEliu,项目名称:calibre,代码行数:56,代码来源:gradients.py


示例10: testCopyPaste

    def testCopyPaste(self):
        p = QgsProject()
        l = QgsLayout(p)

        # clear clipboard
        mime_data = QMimeData()
        mime_data.setData("text/xml", QByteArray())
        clipboard = QApplication.clipboard()
        clipboard.setMimeData(mime_data)

        # add an item
        item1 = QgsLayoutItemLabel(l)
        item1.setText('label 1')
        l.addLayoutItem(item1)
        item1.setSelected(True)
        item2 = QgsLayoutItemLabel(l)
        item2.setText('label 2')
        l.addLayoutItem(item2)
        item2.setSelected(True)

        view = QgsLayoutView()
        view.setCurrentLayout(l)
        self.assertFalse(view.hasItemsInClipboard())

        view.copySelectedItems(QgsLayoutView.ClipboardCopy)
        self.assertTrue(view.hasItemsInClipboard())

        pasted = view.pasteItems(QgsLayoutView.PasteModeCursor)
        self.assertEqual(len(pasted), 2)
        self.assertIn(pasted[0], l.items())
        self.assertIn(pasted[1], l.items())
        self.assertIn(sip.cast(pasted[0], QgsLayoutItemLabel).text(), ('label 1', 'label 2'))
        self.assertIn(sip.cast(pasted[1], QgsLayoutItemLabel).text(), ('label 1', 'label 2'))

        # copy specific item
        view.copyItems([item2], QgsLayoutView.ClipboardCopy)
        l2 = QgsLayout(p)
        view2 = QgsLayoutView()
        view2.setCurrentLayout(l2)
        pasted = view2.pasteItems(QgsLayoutView.PasteModeCursor)
        self.assertEqual(len(pasted), 1)
        self.assertIn(pasted[0], l2.items())
        self.assertEqual(sip.cast(pasted[0], QgsLayoutItemLabel).text(), 'label 2')
开发者ID:cz172638,项目名称:QGIS,代码行数:43,代码来源:test_qgslayoutview.py


示例11: itemChange

    def itemChange(self, change, value):
        if change == QtGui.QGraphicsItem.ItemPositionHasChanged and self.scene():
            self.parentItem().update()

        # itemChange and setParentItem causes error in PyQt4
        # TODO: Test with PySide and PyQt5
        # See http://www.riverbankcomputing.com/pipermail/pyqt/2012-August/031818.html
        result =  super(SegmentEndPointSceneItem, self).itemChange(change, value)
        if isinstance(result, QtGui.QGraphicsItem):
            result = sip.cast(result, QtGui.QGraphicsItem)
        return result
开发者ID:chrisbura,项目名称:pythoncad-qt,代码行数:11,代码来源:segment_scene_item.py


示例12: itemChange

 def itemChange(self, change, value):
     ret = GraphicsObject.itemChange(self, change, value)
         
     ## workaround for pyqt bug:
     ## http://www.riverbankcomputing.com/pipermail/pyqt/2012-August/031818.html
     if change == self.ItemParentChange and isinstance(ret, QtGui.QGraphicsItem):
         ret = sip.cast(ret, QtGui.QGraphicsItem)
     
     if change == self.ItemScenePositionHasChanged:
         self.setNewBounds()
     return ret
开发者ID:ZhuangER,项目名称:robot_path_planning,代码行数:11,代码来源:UIGraphicsItem.py


示例13: onViewChanged

 def onViewChanged(self):
     try:
       doc = sip.cast(kate.activeDocument(), KateDocument)
     except kate.api.NoActiveView:
       return
   
     self.act.blockSignals(True)
     if doc.property('AutoReload'):
         self.act.setChecked(True)
     else:
         self.act.setChecked(False)
     self.act.blockSignals(False)
开发者ID:LarsBV,项目名称:kate_reload,代码行数:12,代码来源:kate_reload.py


示例14: extension

    def extension(self, extension, info=None, errorPage=None):
        if extension == QWebPage.ErrorPageExtension:
            # catch the error, populate self.errorInfo and return an error page

            info = sip.cast(info, QWebPage.ErrorPageExtensionOption)

            domain = 'Unknown'
            if info.domain == QWebPage.QtNetwork:
                domain = 'Network'
            elif info.domain == QWebPage.Http:
                domain = 'HTTP'
            elif info.domain == QWebPage.WebKit:
                domain = 'WebKit'

            self.error_info = RenderErrorInfo(
                domain,
                int(info.error),
                unicode(info.errorString),
                unicode(info.url.toString())
            )

            # XXX: this page currently goes nowhere
            content = u"""
                <html><head><title>Failed loading page</title></head>
                <body>
                    <h1>Failed loading page ({0.text})</h1>
                    <h2>{0.url}</h2>
                    <p>{0.type} error #{0.code}</p>
                </body></html>""".format(self.error_info)

            errorPage = sip.cast(errorPage, QWebPage.ErrorPageExtensionReturn)
            errorPage.content = QByteArray(content.encode('utf-8'))
            return True

        # XXX: this method always returns True, even if we haven't
        # handled the extension. Is it correct? When can this method be
        # called with extension which is not ErrorPageExtension if we
        # are returning False in ``supportsExtension`` for such extensions?
        return True
开发者ID:brandontheis,项目名称:splash,代码行数:39,代码来源:qwebpage.py


示例15: pageTitleChanged

 def pageTitleChanged(self, title):
     widget = self.sender()
     if widget and isinstance(widget, PyMultiPageWidget):
         page = widget.widget(widget.getCurrentIndex())
         form = QtDesigner.QDesignerFormWindowInterface.findFormWindow(widget)
         if form:
             editor = form.core()
             manager = editor.extensionManager()
             sheet = manager.extension(page, Q_TYPEID["QPyDesignerPropertySheetExtension"])
             # This explicit cast is necessary here
             sheet = sip.cast(sheet, QtDesigner.QPyDesignerPropertySheetExtension)
             propertyIndex = sheet.indexOf("windowTitle")
             sheet.setChanged(propertyIndex, True)
开发者ID:RedEyedDog,项目名称:PyQt4,代码行数:13,代码来源:multipagewidgetplugin.py


示例16: itemChange

    def itemChange(self, change, value):
        ret = QtGui.QGraphicsObject.itemChange(self, change, value)
        if change in [self.ItemParentHasChanged, self.ItemSceneHasChanged]:
            self.parentChanged()
        if self.__inform_view_on_changes and change in [self.ItemPositionHasChanged, self.ItemTransformHasChanged]:
            self.informViewBoundsChanged()
            
        ## workaround for pyqt bug:
        ## http://www.riverbankcomputing.com/pipermail/pyqt/2012-August/031818.html
        if change == self.ItemParentChange and isinstance(ret, QtGui.QGraphicsItem):
            ret = sip.cast(ret, QtGui.QGraphicsItem)

        return ret
开发者ID:ZhuangER,项目名称:robot_path_planning,代码行数:13,代码来源:GraphicsObject.py


示例17: _handle_errorpage

    def _handle_errorpage(self, opt, out):
        """Display an error page if needed.

        Loosly based on Helpviewer/HelpBrowserWV.py from eric5
        (line 260 @ 5d937eb378dd)

        Args:
            opt: The QWebPage.ErrorPageExtensionOption instance.
            out: The QWebPage.ErrorPageExtensionReturn instance to write return
                 values to.

        Return:
            False if no error page should be displayed, True otherwise.
        """
        ignored_errors = [
            (QWebPage.QtNetwork, QNetworkReply.OperationCanceledError),
            (QWebPage.WebKit, 203),  # "Loading is handled by the media engine"
        ]
        info = sip.cast(opt, QWebPage.ErrorPageExtensionOption)
        errpage = sip.cast(out, QWebPage.ErrorPageExtensionReturn)
        errpage.baseUrl = info.url
        urlstr = info.url.toDisplayString()
        if (info.domain, info.error) in ignored_errors:
            log.webview.debug("Ignored error on {}: {} (error domain: {}, "
                              "error code: {})".format(
                                  urlstr, info.errorString, info.domain,
                                  info.error))
            return False
        log.webview.error("Error while loading {}: {}".format(
            urlstr, info.errorString))
        log.webview.debug("Error domain: {}, error code: {}".format(
            info.domain, info.error))
        title = "Error loading page: {}".format(urlstr)
        template = jinja.env.get_template('error.html')
        errpage.content = template.render(  # pylint: disable=maybe-no-member
            title=title, url=urlstr, error=info.errorString, icon='')
        return True
开发者ID:har5ha,项目名称:qutebrowser,代码行数:37,代码来源:webpage.py


示例18: _handle_multiple_files

    def _handle_multiple_files(self, opt, files):
        """Handle uploading of multiple files.

        Loosly based on Helpviewer/HelpBrowserWV.py from eric5.

        Args:
            opt: The ChooseMultipleFilesExtensionOption instance.
            files: The ChooseMultipleFilesExtensionReturn instance to write
                   return values to.

        Return:
            True on success, the superclass return value on failure.
        """
        info = sip.cast(opt, QWebPage.ChooseMultipleFilesExtensionOption)
        files = sip.cast(files, QWebPage.ChooseMultipleFilesExtensionReturn)
        if info is None or files is None:
            return super().extension(QWebPage.ChooseMultipleFilesExtension,
                                     opt, files)
        suggested_file = ""
        if opt.suggestedFileNames:
            suggested_file = opt.suggestedFileNames[0]
        files.fileNames, _ = QFileDialog.getOpenFileNames(None, None,
                                                          suggested_file)
        return True
开发者ID:har5ha,项目名称:qutebrowser,代码行数:24,代码来源:webpage.py


示例19: itemChange

    def itemChange(self, change, value):
        ret = QtGui.QGraphicsObject.itemChange(self, change, value)
        if change in [self.ItemParentHasChanged, self.ItemSceneHasChanged]:
            self.parentChanged()
        try:
            inform_view_on_change = self.__inform_view_on_changes
        except AttributeError:
            # It's possible that the attribute was already collected when the itemChange happened
            # (if it was triggered during the gc of the object).
            pass
        else:
            if inform_view_on_change and change in [self.ItemPositionHasChanged, self.ItemTransformHasChanged]:
                self.informViewBoundsChanged()
            
        ## workaround for pyqt bug:
        ## http://www.riverbankcomputing.com/pipermail/pyqt/2012-August/031818.html
        if not USE_PYSIDE and change == self.ItemParentChange and isinstance(ret, QtGui.QGraphicsItem):
            ret = sip.cast(ret, QtGui.QGraphicsItem)

        return ret
开发者ID:52-41-4d,项目名称:MoNTP-TG,代码行数:20,代码来源:GraphicsObject.py


示例20: __init__

  def __init__(self):
    QObject.__init__(self)
      
    ## Create Kate window
    self.kate_window    = kate.mainInterfaceWindow()
    self.tool_view      = self.kate_window.createToolView("preview", self.kate_window.Right, SmallIcon("okular"), "Okular")
    self.win            = QWidget(self.tool_view)
    
    ## Load okular part
    factory             = KPluginLoader("okularpart").factory()
    self.part           = factory.create(self, "OkularPart", ["ViewerWidgetout",])
    self.part           = sip.cast(self.part, Okular.Part)
    
    
    self.okular_actions = self.part.actionCollection()
    print("Okular actions: ", self.okular_actions)
      #print("Action: %s: %s, context: %s" % (
      #                         action.objectName(),
      #                         action.iconText(),
      #                         action.shortcutContext()))
    
    
    kate.configuration.root.clear()
    
    #Actions
    
    ''' Adds a shortcut using its stored, or its default shortcut. Takes a name-string as icon. '''
    def addAction(self, objectName, icon, text, shortcut = "", slot = None):
        act = KAction(KIcon(icon), text, self.win)
        act.setObjectName(objectName)
        
        if not act.objectName() in kate.configuration:
            kate.configuration[act.objectName()] = shortcut

        act.setShortcut(kate.configuration[act.objectName()])
        act.changed.connect( self.onActionChange )
        if slot != None:
            act.triggered.connect( slot )
        self.kate_window.window().actionCollection().addAction(act.objectName(), act)
        act.setEnabled(False)
        return act
        
        
    self.act_preview_file = addAction(self, 'preview-file',  'document-open', 'preview file', 'Ctrl+Alt+Shift+O', self.open )
    self.act_go_jump      = addAction(self, 'goto-shortcut', 'go-jump', 'Goto page', 'Ctrl+Alt+G', self.okular_actions.action('go_goto_page').trigger )
    
    self.act_preview_file.setEnabled(True)
    
    ## Build a toolbar 
    self.toolBar        = QToolBar(self.win)
    toolButtonAction    = QWidgetAction(self.win)
    toolButton          = QToolButton()
    self.toolMenu       = QMenu(toolButton)
        
    
    toolButton.setMenu(self.toolMenu)
    toolButton.setPopupMode(QToolButton.InstantPopup)
    toolButtonAction.setDefaultWidget(toolButton)

    # Update the buttons icon / main action when an action gets selected
    self.toolMenu.triggered.connect(toolButton.setDefaultAction)
    
    # toolButton provides a menu with actions
    for item in ['mouse_drag', 'mouse_zoom', 'mouse_select', 'mouse_textselect', 'mouse_tableselect']:
        act = self.okular_actions.action(item)
        if act:
            act = addAction(self, item, act.icon(), act.text(), act.shortcut().toString(), act.trigger)
            act.setEnabled(True)
            self.toolMenu.addAction(act)
            if item == 'mouse_drag':
                act.trigger()
    
    ## Arrange toolbar
    # self.toolBar.addAction(self.act_show_panel)
    self.toolBar.addAction(self.act_preview_file)
    self.toolBar.addAction(toolButtonAction)
    self.toolBar.addAction(self.act_go_jump)

    

    ## Disable okular's actions shortcut's, after we have used their default's as our own
    for action in self.okular_actions.actions():
      action.setShortcut(QKeySequence())


    ## Fit okular and toolbar together
    layout = QVBoxLayout()
    layout.addWidget(self.part.widget())
    layout.addWidget(self.toolBar)    
    self.win.setLayout(layout)
            
    ## Don't let us take focus, TODO check if this actually works and subwidgets can't grab the focus.
    self.win.setFocusPolicy(Qt.NoFocus)
    
    ## Test
    #for (name, value) in inspect.getmembers(self.part):
    #    print("Name: %s\nValue: %s\n" % (name,value))
    
    #print(self.part.staticMetaObject.superClass().superClass().superClass().className())
        
#.........这里部分代码省略.........
开发者ID:LarsBV,项目名称:kate_okular,代码行数:101,代码来源:okular_plugin.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python sip.delete函数代码示例发布时间:2022-05-27
下一篇:
Python singleton_store.Screen类代码示例发布时间: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