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


Python QPoint.isNull方法代码示例

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


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

示例1: Window

# 需要导入模块: from PyQt4.QtCore import QPoint [as 别名]
# 或者: from PyQt4.QtCore.QPoint import isNull [as 别名]
class Window(QMainWindow):

    def __init__(self, parent=None):

        super(Window, self).__init__(parent)
        self.setWindowFlags(Qt.FramelessWindowHint)
        self.rubberBand = QRubberBand(QRubberBand.Rectangle, self)
        self.origin = QPoint()
        self.repaint()
    def mousePressEvent(self, event):

        if event.button() == Qt.LeftButton:

            self.origin = QPoint(event.pos())
            self.rubberBand.setGeometry(QRect(self.origin, QSize()))
            self.rubberBand.show()

    def mouseMoveEvent(self, event):

        if not self.origin.isNull():
            self.rubberBand.setGeometry(QRect(self.origin, event.pos()).normalized())

    def mouseReleaseEvent(self, event):

        if event.button() == Qt.LeftButton:
            self.rubberBand.hide()
开发者ID:Shadoukun,项目名称:Yomi,代码行数:28,代码来源:bbox.py

示例2: ClickReportingInterpreter

# 需要导入模块: from PyQt4.QtCore import QPoint [as 别名]
# 或者: from PyQt4.QtCore.QPoint import isNull [as 别名]
class ClickReportingInterpreter(QObject):
    rightClickReceived = pyqtSignal(object, QPoint) # list of indexes, global window coordinate of click
    leftClickReceived = pyqtSignal(object, QPoint)  # ditto
    leftClickReleased = pyqtSignal(object, object)
    
    def __init__(self, navigationInterpreter, positionModel, editor):
        QObject.__init__(self)
        self.baseInterpret = navigationInterpreter
        self.posModel      = positionModel
        self.rubberBand = QRubberBand(QRubberBand.Rectangle, editor)
        self.origin = QPoint()
        self.originpos = object()

    def start( self ):
        self.baseInterpret.start()

    def stop( self ):
        self.baseInterpret.stop()

    def eventFilter( self, watched, event ):
        if event.type() == QEvent.MouseButtonPress:
            pos = [int(i) for i in self.posModel.cursorPos]
            pos = [self.posModel.time] + pos + [self.posModel.channel]

            if event.button() == Qt.LeftButton:
                self.origin = QPoint(event.pos())
                self.originpos = pos
                self.rubberBand.setGeometry(QRect(self.origin, QSize()))
                self.rubberBand.show()
                gPos = watched.mapToGlobal( event.pos() )
                self.leftClickReceived.emit( pos, gPos )
            if event.button() == Qt.RightButton:
                gPos = watched.mapToGlobal( event.pos() )
                self.rightClickReceived.emit( pos, gPos )                
        if event.type() == QEvent.MouseMove:
            if not self.origin.isNull():
                self.rubberBand.setGeometry(QRect(self.origin,
                                                  event.pos()).normalized())
        if event.type() == QEvent.MouseButtonRelease:
            pos = [int(i) for i in self.posModel.cursorPos]
            pos = [self.posModel.time] + pos + [self.posModel.channel]
            if event.button() == Qt.LeftButton:
                self.rubberBand.hide()
                self.leftClickReleased.emit( self.originpos,pos )                

    

        # Event is always forwarded to the navigation interpreter.
        return self.baseInterpret.eventFilter(watched, event)
开发者ID:bheuer,项目名称:ilastik,代码行数:51,代码来源:counting3dGui.py

示例3: ScreenshotWindow

# 需要导入模块: from PyQt4.QtCore import QPoint [as 别名]
# 或者: from PyQt4.QtCore.QPoint import isNull [as 别名]
class ScreenshotWindow(QLabel):
    screenshot_close = pyqtSignal(Fotbalek)
    main_handler = None

    def __init__(self, parent = None):

        QLabel.__init__(self, parent)
        self.rubberBand = QRubberBand(QRubberBand.Rectangle, self)
        self.origin = QPoint()
        self.setWindowFlags(Qt.FramelessWindowHint)
        self.setGeometry(100,100,100,100)
        self.setAutoFillBackground(True)

        self.screenshot_close.connect(Fotbalek.load_pix)

    def mousePressEvent(self, event):

        if event.button() == Qt.LeftButton:

            self.origin = QPoint(event.pos())
            self.rubberBand.setGeometry(QRect(self.origin, QSize()))
            self.rubberBand.show()

    def mouseMoveEvent(self, event):

        if not self.origin.isNull():
            self.rubberBand.setGeometry(QRect(self.origin, event.pos()).normalized())

    def mouseReleaseEvent(self, event):
        self.rubberBand.hide()
        currentQrect = self.rubberBand.geometry()
        cropPixmap = self.pixmap().copy(currentQrect)
        cropPixmap.save('letters.bmp')
        self.close()

    def closeEvent(self, event):
        self.screenshot_close.emit(self.main_handler)
开发者ID:svob,项目名称:slovni-fotbal,代码行数:39,代码来源:Screenshot.py

示例4: BoxInterpreter

# 需要导入模块: from PyQt4.QtCore import QPoint [as 别名]
# 或者: from PyQt4.QtCore.QPoint import isNull [as 别名]

#.........这里部分代码省略.........

        QObject.__init__(self)


        self.baseInterpret = navigationInterpreter
        self._posModel      = positionModel
        self.rubberBand = RedRubberBand(QRubberBand.Rectangle, widget)

        self.boxController=BoxContr

        self.leftClickReleased.connect(BoxContr.addNewBox)
        self.rightClickReceived.connect(BoxContr.onChangedPos)
        #self.deleteSelectedItemsSignal.connect(BoxContr.deleteSelectedItems)


        self.origin = QPoint()
        self.originpos = object()

    def start( self ):
        self.baseInterpret.start()

    def stop( self ):
        self.baseInterpret.stop()

    def eventFilter( self, watched, event ):
        pos = [int(i) for i in self._posModel.cursorPos]
        pos = [self._posModel.time] + pos + [self._posModel.channel]

        #Rectangles under the current point
        items=watched.scene().items(QPointF(*pos[1:3]))
        items=filter(lambda el: isinstance(el, QGraphicsResizableRect),items)


        #Keyboard interaction
        if event.type()==QEvent.KeyPress:
            #Switch selection
            if event.key()==Qt.Key_Space :
                #assert items[0]._hovering
                #items[0].setZValue(1)
                #for el in items:
                #    print el.zValue()

                if len(items)>1:
                    items[-1].setZValue(items[0].zValue()+1)
                    items[0].setSelected(False)
                    items[-1].setSelected(True)
                    #items[0].setZero()

            if event.key()==Qt.Key_Control :
                QApplication.setOverrideCursor(QtCore.Qt.OpenHandCursor)

            # #Delete element
            # if event.key()==Qt.Key_Delete:
            #     self.deleteSelectedItemsSignal.emit()
        if event.type()==QEvent.KeyRelease:
            if event.key()==Qt.Key_Control :
                QApplication.restoreOverrideCursor()


        #Pressing mouse and menaging rubber band
        if event.type() == QEvent.MouseButtonPress:
            if event.button() == Qt.LeftButton:
                self.origin = QPoint(event.pos())
                self.originpos = pos
                self.rubberBand.setGeometry(QRect(self.origin, QSize()))

                itemsall=watched.scene().items(QPointF(*pos[1:3]))
                itemsall =filter(lambda el: isinstance(el, ResizeHandle), itemsall)

#                 if len(itemsall)==0: #show rubber band only if there is no rubbber band
#                     self.rubberBand.show()

                modifiers=QApplication.keyboardModifiers()
                if modifiers != Qt.ControlModifier and modifiers != Qt.ShiftModifier and len(itemsall)==0: #show rubber band if Ctrl is not pressed
                    self.rubberBand.show()


                gPos = watched.mapToGlobal( event.pos() )
                self.leftClickReceived.emit( pos, gPos )

            if event.button() == Qt.RightButton:
                gPos = watched.mapToGlobal( event.pos() )
                self.rightClickReceived.emit( pos, gPos )

        if event.type() == QEvent.MouseMove:
            self.cursorPositionChanged.emit(event.pos())
            if not self.origin.isNull():
                self.rubberBand.setGeometry(QRect(self.origin,
                                                  event.pos()).normalized())
        #Relasing the button
        if event.type() == QEvent.MouseButtonRelease:
            pos = [int(i) for i in self._posModel.cursorPos]
            pos = [self._posModel.time] + pos + [self._posModel.channel]
            if self.rubberBand.isVisible():
                if event.button() == Qt.LeftButton:
                    self.rubberBand.hide()
                    self.leftClickReleased.emit( self.originpos,pos )

        # Event is always forwarded to the navigation interpreter.
        return self.baseInterpret.eventFilter(watched, event)
开发者ID:cjaques,项目名称:ilastik,代码行数:104,代码来源:countingGuiBoxesInterface.py

示例5: VisionneurImagePourEKD

# 需要导入模块: from PyQt4.QtCore import QPoint [as 别名]
# 或者: from PyQt4.QtCore.QPoint import isNull [as 别名]

#.........这里部分代码省略.........
		# Si une image est en paramètre de classe, on l'affiche directement
		# sinon on pourra toujours l'afficher plus tard en appelant la
		# méthode setImage(), le moment venu
		if img:
			self.setImage(img)
			self.setToolTip(img)
		else:
			# image par défaut
			self.setImage("Icones" + os.sep + "avant-image.png")
			self.setToolTip(_(u"image d'accueil"))
			self.setTailleReelle()
	
	def mousePressEvent(self, event):
		"Menu contextuel et enregistrement de données préparant le déplacement de l'image par pincement"
		
		# Menu contextuel
		if event.button() == Qt.RightButton: 
			self.menuZoom.popup(event.globalPos())
		
		# On enregistre la position du curseur et de la barre de défilement au moment du clic
		elif event.button() == Qt.LeftButton:
			self.positionPresseeSourisIni = QPoint(event.pos())
			self.positionBarrePresseeSourisIni.setX(self.horizontalScrollBar().value())
			self.positionBarrePresseeSourisIni.setY(self.verticalScrollBar().value())
			if PYQT_VERSION_STR >= "4.1.0": 
				# curseur main fermée
				self.setCursor(Qt.ClosedHandCursor)
			else: self.setCursor(Qt.SizeAllCursor)
			event.accept()
	
	def mouseMoveEvent(self, event):
		"Déplacement de l'image dans le QScrollArea quand la souris est pressée"
		
		if self.positionPresseeSourisIni.isNull():
			event.ignore()
			return
		
		# Nouvelles positions de la barre de défilement (selon x et y)
		self.horizontalScrollBar().setValue(self.positionBarrePresseeSourisIni.x() + (self.positionPresseeSourisIni.x() - event.pos().x()))
		self.verticalScrollBar().setValue(self.positionBarrePresseeSourisIni.y() + (self.positionPresseeSourisIni.y() - event.pos().y()))
		self.horizontalScrollBar().update()
		self.verticalScrollBar().update()
		event.accept()
	
	def mouseReleaseEvent(self, event):
		"Réaffichage du curseur classique de la souris"
		self.setCursor(Qt.ArrowCursor)
		event.accept()
	
	def setScaleMode(self, mode):
		"Choix du mode de redimensionnement"
		# Mise à jour du paramètre
		self.modeTransformation=mode
	
	def setTailleFenetre(self):
		"Affichage taille fenetre"
		
		# Gestion de la taille
		#- Si l'image rentre
		##- Si l'image est trop grande
		# On retaille l'image en gardant le ratio entre 
		# le min (si l'image ne rentre pas dans le cadre), le max (sinon) de :
		#         * La largeur de la fenetre
		#         * La largeur de l'image
		#         * La hauteur de la fenetre
		#         * La hauteur de l'image
开发者ID:Ptaah,项目名称:Ekd,代码行数:70,代码来源:afficheurImage.py


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