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


Python QMimeData.setText方法代码示例

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


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

示例1: mousePressEvent

# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setText [as 别名]
	def mousePressEvent( self, event ):
		# handle an internal move
		from PyQt4.QtCore import Qt

		# start a drag event
		if ( event.button() == Qt.LeftButton and self.dragDropRect().contains( event.pos() ) ):
			from PyQt4.QtCore import QMimeData
			from PyQt4.QtGui import QDrag, QPixmap

			# create the pixmap
			pixmap = QPixmap.grabWidget( self, self.rect() )

			# create the mimedata
			mimeData = QMimeData()
			mimeData.setText( 'ItemTitle::%s' % (self.title()) )

			# create the drag
			drag = QDrag(self)
			drag.setMimeData( mimeData )
			drag.setPixmap( pixmap )
			drag.setHotSpot( event.pos() )

			if ( not drag.exec_() ):
				self._accordianWidget.emitItemDragFailed(self)

			event.accept()

		# determine if the expand/collapse should occur
		elif ( event.button() == Qt.LeftButton and self.expandCollapseRect().contains( event.pos() ) ):
			self._clicked = True
			event.accept()

		else:
			event.ignore()
开发者ID:skarone,项目名称:PipeL,代码行数:36,代码来源:collapsable_groupbox.py

示例2: eventFilter

# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setText [as 别名]
 def eventFilter( self, object, event ):
     if event.type() == event.MouseButtonPress:
         if self.isLocked():
             return False
             
         if event.button() == Qt.MidButton or \
            (event.button() == Qt.LeftButton and \
             event.modifiers() == Qt.ShiftModifier):
             index = self.tabBar().tabAt(event.pos())
             view  = self.widget(index)
             pixmap = QPixmap.grabWidget(view)
             drag = QDrag(self)
             data = QMimeData()
             data.setText('move view:{}'.format(index))
             drag.setMimeData(data)
             drag.setPixmap(pixmap)
             drag.exec_()
             
             return True
         return False
         
     elif event.type() == event.DragEnter:
         if ( str(event.mimeData().text()).startswith('move view:') and
              event.source() != self ):
             event.acceptProposedAction()
         return True
     
     elif event.type() == event.Drop:
         text = str(event.mimeData().text())
         splt = text.split(':')
         self.snagViewFromPanel(event.source(), int(splt[1]))
         return True
     
     return False
开发者ID:satishgoda,项目名称:DPS_PIPELINE,代码行数:36,代码来源:xviewpanel.py

示例3: startDrag

# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setText [as 别名]
 def startDrag(self, dropActions):
     """Reimplement Qt Method - handle drag event"""
     mimeData = QMimeData()
     mimeData.setText(self.get_filename())
     drag = QDrag(self)
     drag.setMimeData(mimeData)
     drag.exec_()
开发者ID:Brainsciences,项目名称:luminoso,代码行数:9,代码来源:explorer.py

示例4: copy

# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setText [as 别名]
 def copy(self):
     """Copy to the clipboard"""
     data = QMimeData()
     text = "\n".join([cursor.selectedText() for cursor in self.cursors()])
     data.setText(text)
     data.setData(self.MIME_TYPE, text.encode("utf8"))
     QApplication.clipboard().setMimeData(data)
开发者ID:kcrossen,项目名称:qutepart,代码行数:9,代码来源:rectangularselection.py

示例5: _copy

# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setText [as 别名]
 def _copy(self, index):
     doc = QTextDocument()
     doc.setHtml(index.data(Qt.DisplayRole).toString())
     clipboard = QApplication.clipboard()
     richTextData = QMimeData()
     richTextData.setHtml(index.data(Qt.DisplayRole).toString())
     richTextData.setText(doc.toPlainText())
     clipboard.setMimeData(richTextData)
开发者ID:hannesrauhe,项目名称:lunchinator,代码行数:10,代码来源:chat_widget.py

示例6: on_menuSelections_mouseMoved

# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setText [as 别名]
 def on_menuSelections_mouseMoved(self, event):
     if event.buttons() & Qt.LeftButton and self.seldrag_start_pos:
         if ((event.pos() - self.seldrag_start_pos).manhattanLength() >=
             QApplication.startDragDistance()):
             drag = QDrag(self.menuSelections)
             data = QMimeData()
             data.setText(self.seldrag_selection.name)
             drag.setMimeData(data)
             drag.exec_()
             self.seldrag_start_pos = None
             self.seldrag_selection = None
             self.seldrag_target = None
     QMenu.mouseMoveEvent(self.menuSelections, event)
开发者ID:neurodebian,项目名称:spykeviewer,代码行数:15,代码来源:main_window.py

示例7: copyColoredHtml

# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setText [as 别名]
 def copyColoredHtml(self):
     cursor = self.textCursor()
     if not cursor.hasSelection():
         return
     number_lines = QSettings().value("source_export/number_lines", False, bool)
     inline_style = QSettings().value("source_export/inline_copy", True, bool)
     as_plain_text = QSettings().value("source_export/copy_html_as_plain_text", False, bool)
     document_body_only = QSettings().value("source_export/copy_document_body_only", False, bool)
     import highlight2html
     html = highlight2html.html_inline(cursor, inline=inline_style, number_lines=number_lines,
         full_html=not document_body_only)
     data = QMimeData()
     data.setText(html) if as_plain_text else data.setHtml(html)
     QApplication.clipboard().setMimeData(data)
开发者ID:proski,项目名称:frescobaldi,代码行数:16,代码来源:mainwindow.py

示例8: mouseMoveEvent

# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setText [as 别名]
    def mouseMoveEvent(self, mouseEvent):
        #        if mouseEvent.button() != Qt.LeftButton:
        #            return
        if not self._selectedExperiment():
            return
        if not self.dragStartPosition:
            return
        if (mouseEvent.pos() - self.dragStartPosition).manhattanLength() < QApplication.startDragDistance():
            return

        drag = QDrag(self)
        mimeData = QMimeData()
        mimeData.setText(self._selectedExperiment().__name__)
        drag.setMimeData(mimeData)
        drag.exec_()
开发者ID:houssem21,项目名称:emctestbench,代码行数:17,代码来源:experimenttreewidget.py

示例9: start_drag

# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setText [as 别名]
    def start_drag(self, info_id):
        _logger.info( "started dragging" )
        mimeData = QMimeData()
        mimeData.data =("/" + info_id.partition("/")[2].partition("/")[0], moose.element(info_id))
        mimeData.setText(info_id)
        drag = QDrag(self)
        drag.setMimeData(mimeData)
        pixmap = QPixmap("")

        drag.setPixmap(pixmap)
        # drag.setHotSpot(e.pos() - self.rect().topLeft())
        dropAction = drag.start(QtCore.Qt.MoveAction)
        print((" => ", dropAction))
        self.select_info.set_event_type(0)
        self._timer.start(0)
        return
开发者ID:dilawar,项目名称:moose-gui,代码行数:18,代码来源:NeuroKitVisualizer.py

示例10: mouseMoveEvent

# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setText [as 别名]
 def mouseMoveEvent(self, event):
     """
     Protected method to handle mouse move events.
     
     @param event reference to the mouse move event (QMouseEvent)
     """
     if event.buttons() == Qt.MouseButtons(Qt.LeftButton) and \
        (event.pos() - self.__dragStartPos).manhattanLength() > \
             QApplication.startDragDistance():
         drag = QDrag(self)
         mimeData = QMimeData()
         index = self.tabAt(event.pos())
         mimeData.setText(self.tabText(index))
         mimeData.setData("action", "tab-reordering")
         mimeData.setData("tabbar-id", str(id(self)))
         drag.setMimeData(mimeData)
         drag.exec_()
     E4WheelTabBar.mouseMoveEvent(self, event)
开发者ID:usc-bbdl,项目名称:R01_HSC_cadaver_system,代码行数:20,代码来源:E4TabWidget.py

示例11: start_drag

# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setText [as 别名]
    def start_drag(self, info_id):
        # pixmap = QPixmap()
        # painter = QPainter( pixmap )
        # painter.setFont( QFont("Arial") );
        # painter.drawText( QPoint(100, 100), info_id );
        mimeData = QMimeData()
        mimeData.data =("/" + info_id.partition("/")[2].partition("/")[0], moose.element(info_id))
        mimeData.setText(info_id)
        drag = QDrag(self)
        drag.setMimeData(mimeData)
        pixmap = QPixmap("")

        drag.setPixmap(pixmap)
        # drag.setHotSpot(e.pos() - self.rect().topLeft())
        dropAction = drag.start(QtCore.Qt.MoveAction)
        print(" => ", dropAction)
        self.select_info.set_event_type(0)
        self._timer.start(0)
        return
开发者ID:NeuroArchive,项目名称:moose,代码行数:21,代码来源:NeuroKitVisualizer.py

示例12: mouseMoveEvent

# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setText [as 别名]
    def mouseMoveEvent(self, e):
        if self.drag_start is None:
            pass
        x = e.x() - self.drag_start.x()
        y = e.y() - self.drag_start.y()
        dist = QApplication.startDragDistance()
        if not self.draggable or x > dist or y > dist:
            return

        drag = QDrag(self)
        mime = QMimeData()
        mime.setText(self.__class__.__name__)
        mime.part = self
        drag.setMimeData(mime)
        pixmap = QPixmap.grabWidget(self)
        pixmap.setAlphaChannel(pixmap)
        drag.setPixmap(pixmap)
        drag.setHotSpot(QPoint(drag.pixmap().width() / 2,
                               drag.pixmap().height()))
        drag.start(Qt.CopyAction)
开发者ID:patrickkidd,项目名称:pksampler,代码行数:22,代码来源:parts.py

示例13: mouseMoveEvent

# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setText [as 别名]
    def mouseMoveEvent(self, e):
        if self.drag_start is None:
            pass
        x = e.x() - self.drag_start[0]
        y = e.y() - self.drag_start[1]
        dist = QApplication.startDragDistance()
        if (self.draggable is False) or (abs(x) < dist and abs(y) < dist):
            return

        drag = QDrag(self)
        mime = QMimeData()
        mime.setText(self.__class__.__name__)
        mime.part = self
        drag.setMimeData(mime)
        pixmap = QPixmap.grabWidget(self)
        pixmap.setAlphaChannel(pixmap)
        drag.setPixmap(pixmap)
        drag.setHotSpot(QPoint(drag.pixmap().width() / 2,
                               drag.pixmap().height()))
        self.dragging = True
        drag.start(Qt.CopyAction)
开发者ID:RikVerschueren,项目名称:AccordionMega,代码行数:23,代码来源:parts.py

示例14: copyColoredHtml

# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setText [as 别名]
    def copyColoredHtml(self):
        cursor = self.textCursor()
        if not cursor.hasSelection():
            return

        s = QSettings()
        s.beginGroup("source_export")
        number_lines = s.value("number_lines", False, bool)
        inline_style = s.value("inline_copy", True, bool)
        as_plain_text = s.value("copy_html_as_plain_text", False, bool)
        wrap_tag = s.value("wrap_tag", "pre", str)
        wrap_attrib = s.value("wrap_attrib", "id", str)
        wrap_attrib_name = s.value("wrap_attrib_name", "document", str)
        document_body_only = s.value("copy_document_body_only", False, bool)
        import highlight2html
        html = highlight2html.html_inline(cursor, inline=inline_style, number_lines=number_lines,
            full_html=not document_body_only, wrap_tag=wrap_tag, wrap_attrib=wrap_attrib,
            wrap_attrib_name=wrap_attrib_name)
        data = QMimeData()
        data.setText(html) if as_plain_text else data.setHtml(html)
        QApplication.clipboard().setMimeData(data)
开发者ID:elmamyra,项目名称:frescobaldi,代码行数:23,代码来源:mainwindow.py

示例15: mouseMoveEvent

# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setText [as 别名]
    def mouseMoveEvent(self, event):
        drag = QDrag(event.widget())
        data = QMimeData()
        data.setText(self.commit.name())

        drag.setMimeData(data)

        #data.setColorData(GREEN)
        pixmap = QPixmap(COMMIT_WIDTH, COMMIT_HEIGHT)
        pixmap.fill(WHITE)
        painter = QPainter(pixmap)
        painter.translate(0, 0)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.setPen(Qt.NoPen)
        painter.setBrush(QBrush(self.color))
        painter.drawPath(self.setup_display(0, 0))
        painter.end()

        pixmap.setMask(pixmap.createHeuristicMask())
        drag.setPixmap(pixmap)
        drag.setHotSpot(QPoint(0, 0))
        drag.start()
开发者ID:mike-perdide,项目名称:gitbuster,代码行数:24,代码来源:graphics.py


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