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


Python QCursor.pos方法代码示例

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


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

示例1: getDetailInfo

# 需要导入模块: from PyQt5.QtGui import QCursor [as 别名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 别名]
def getDetailInfo(self):
        """点击后进行动画效果的: 显示某歌曲的详细信息。"""
        self.shortInfo.hide()
        self.detailInfo.show()

        self.showDetail = QPropertyAnimation(self, b"geometry")

        x = self.pos().x()
        y = self.pos().y()

        self.showDetail.setStartValue(QRect(x, y, self.width(), self.height()))
        # 获取顶层父窗口的长度。
        self.showDetail.setEndValue(QRect(0, self.grandparent.header.height()+3, self.grandparent.width(), self.grandparent.mainContent.height()))
        self.showDetail.setDuration(300)
        self.showDetail.setEasingCurve(QEasingCurve.InBack)

        self.showDetail.start(QAbstractAnimation.DeleteWhenStopped)
        # 将该组件显示在最前,默认会嵌入到父组件里面。
        self.raise_()

        self.setDetailInfo() 
开发者ID:HuberTRoy,项目名称:MusicBox,代码行数:23,代码来源:player.py

示例2: getShortInfo

# 需要导入模块: from PyQt5.QtGui import QCursor [as 别名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 别名]
def getShortInfo(self):
        """返回到原来的缩略图信息。"""
        self.detailInfo.hide()
        self.showShort = QPropertyAnimation(self, b"geometry")
        
        x = self.pos().x()
        y = self.pos().y()
        
        self.showShort.setStartValue(QRect(0, self.grandparent.header.height(), self.grandparent.width(), self.grandparent.mainContent.height()))
        self.showShort.setEndValue(QRect(0, self.grandparent.height()-64-self.parent.height(), self.grandparent.navigation.width(), 64))
        self.showShort.setDuration(300)
        self.showShort.setEasingCurve(QEasingCurve.InBack)
        
        self.showShort.start(QAbstractAnimation.DeleteWhenStopped)

        self.shortInfo.show()
        self.raise_() 
开发者ID:HuberTRoy,项目名称:MusicBox,代码行数:19,代码来源:player.py

示例3: downloadWidgetContext

# 需要导入模块: from PyQt5.QtGui import QCursor [as 别名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 别名]
def downloadWidgetContext(self, point):
        """downloadWidget right click menu
        """
        popMenu = QMenu()
        startAThread = QAction('开始', self)
        pauseAThread = QAction('暂停', self)
        clearAThread = QAction('删除', self)

        startAThread.triggered.connect(lambda: self.operateAThread(1, point))
        pauseAThread.triggered.connect(lambda: self.operateAThread(2, point))
        clearAThread.triggered.connect(lambda: self.operateAThread(3, point))

        popMenu.addAction(startAThread)
        popMenu.addAction(pauseAThread)
        popMenu.addAction(clearAThread)

        popMenu.exec_(QCursor.pos()) 
开发者ID:taseikyo,项目名称:PyQt5-Apps,代码行数:19,代码来源:main.py

示例4: contextMenuEvent

# 需要导入模块: from PyQt5.QtGui import QCursor [as 别名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 别名]
def contextMenuEvent(self, event: QContextMenuEvent) -> None:
        col = self.columnAt(event.pos().x())
        row = self.rowAt(event.pos().y())
        if col == 3:
            item = self.item(row, col)
            vtype = item.value_type
            if vtype != "unknown":
                menu = QMenu(self)
                as_int = QAction("repr as int", self)
                as_int.triggered.connect(lambda: self.repr_as_int(row, col))
                as_hex = QAction("repr as hex", self)
                as_hex.triggered.connect(lambda: self.repr_as_hex(row, col))
                as_flt = QAction("repr as floating", self)
                as_flt.triggered.connect(lambda: self.repr_as_floating(row, col))
                as_str = QAction("repr as str", self)
                as_str.triggered.connect(lambda: self.repr_as_str(row, col))
                as_bys = QAction("repr as bytes", self)
                as_bys.triggered.connect(lambda: self.repr_as_bytes(row, col))
                menu.addAction(as_int)
                menu.addAction(as_hex)
                menu.addAction(as_flt)
                menu.addAction(as_str)
                menu.addAction(as_bys)
                menu.popup(QCursor.pos()) 
开发者ID:hase-project,项目名称:hase,代码行数:26,代码来源:viewtable.py

示例5: mouseMoveEvent

# 需要导入模块: from PyQt5.QtGui import QCursor [as 别名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 别名]
def mouseMoveEvent(self, event):
        super(ChartView, self).mouseMoveEvent(event)
        # 把鼠标位置所在点转换为对应的xy值
        x = self._chart.mapToValue(event.pos()).x()
        y = self._chart.mapToValue(event.pos()).y()
        index = round((x - self.min_x) / self.step_x)
        #         print(x, pos_x, index, index * self.step_x + self.min_x)
        # 得到在坐标系中的所有series的类型和点
        points = [(serie, serie.at(index))
                  for serie in self._chart.series() if self.min_x <= x <= self.max_x and self.min_y <= y <= self.max_y]
        if points:
            # 跟随鼠标的黑线条
            self.lineItem.setLine(event.pos().x(), self.point_top.y(),
                                  event.pos().x(), self.point_bottom.y())
            self.lineItem.show()
            self.toolTipWidget.show("", points, event.pos() + QPoint(20, 20))
        else:
            self.toolTipWidget.hide()
            self.lineItem.hide() 
开发者ID:PyQt5,项目名称:PyQt,代码行数:21,代码来源:ToolTip2.py

示例6: mouseMoveEvent

# 需要导入模块: from PyQt5.QtGui import QCursor [as 别名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 别名]
def mouseMoveEvent(self, event):
        super(ChartView, self).mouseMoveEvent(event)
        # 把鼠标位置所在点转换为对应的xy值
        x = self._chart.mapToValue(event.pos()).x()
        y = self._chart.mapToValue(event.pos()).y()
        index = round((x - self.min_x) / self.step_x)
        pos_x = self._chart.mapToPosition(
            QPointF(index * self.step_x + self.min_x, self.min_y))
        #         print(x, pos_x, index, index * self.step_x + self.min_x)
        # 得到在坐标系中的所有series的类型和点
        points = [(serie, serie.at(index))
                  for serie in self._chart.series() if self.min_x <= x <= self.max_x and self.min_y <= y <= self.max_y]
        if points:
            # 永远在轴上的黑线条
            self.lineItem.setLine(pos_x.x(), self.point_top.y(),
                                  pos_x.x(), self.point_bottom.y())
            self.lineItem.show()
            self.toolTipWidget.show("", points, event.pos() + QPoint(20, 20))
        else:
            self.toolTipWidget.hide()
            self.lineItem.hide() 
开发者ID:PyQt5,项目名称:PyQt,代码行数:23,代码来源:ToolTip.py

示例7: paintEvent

# 需要导入模块: from PyQt5.QtGui import QCursor [as 别名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 别名]
def paintEvent(self, event):
        super(Label, self).paintEvent(event)
        # 中正间画十字
        painter = QPainter(self)
        painter.setPen(Qt.red)
        x = int(self.width() / 2)
        y = int(self.height() / 2)
        painter.drawLine(x, 0, x, self.height())
        painter.drawLine(0, y, self.width(), y)
        if self.ismd:
            # 画坐标点
            pos = QCursor.pos()
            ret = win32gui.GetPixel(win32gui.GetWindowDC(
                win32gui.GetDesktopWindow()), pos.x(), pos.y())
            r, g, b = ret & 0xff, (ret >> 8) & 0xff, (ret >> 16) & 0xff
            print(r, g, b)
            painter.setPen(Qt.white)
            painter.drawText(self.rect(), Qt.AlignLeft |
                             Qt.AlignBottom, '({}, {})\nRGB: ({}, {}, {})\n{}'.format(
                                 pos.x(), pos.y(), r, g, b, QColor(r, g, b).name())) 
开发者ID:PyQt5,项目名称:PyQt,代码行数:22,代码来源:ProbeWindow.py

示例8: startDrag

# 需要导入模块: from PyQt5.QtGui import QCursor [as 别名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 别名]
def startDrag(self, supportedActions):
        items = self.selectedItems()
        drag = QDrag(self)
        mimeData = self.mimeData(items)
        # 由于QMimeData只能设置image、urls、str、bytes等等不方便
        # 这里添加一个额外的属性直接把item放进去,后面可以根据item取出数据
        mimeData.setProperty('myItems', items)
        drag.setMimeData(mimeData)
        pixmap = QPixmap(self.viewport().visibleRegion().boundingRect().size())
        pixmap.fill(Qt.transparent)
        painter = QPainter()
        painter.begin(pixmap)
        for item in items:
            rect = self.visualRect(self.indexFromItem(item))
            painter.drawPixmap(rect, self.viewport().grab(rect))
        painter.end()
        drag.setPixmap(pixmap)
        drag.setHotSpot(self.viewport().mapFromGlobal(QCursor.pos()))
        drag.exec_(supportedActions) 
开发者ID:PyQt5,项目名称:PyQt,代码行数:21,代码来源:DragDrop.py

示例9: zoom

# 需要导入模块: from PyQt5.QtGui import QCursor [as 别名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 别名]
def zoom(self, factor, zoom_to_mouse_cursor=True, cursor_pos=None):
        if factor > 1 and self.view_rect().width() / factor < self.MINIMUM_VIEW_WIDTH:
            factor = self.view_rect().width() / self.MINIMUM_VIEW_WIDTH

        if zoom_to_mouse_cursor:
            pos = self.mapFromGlobal(QCursor.pos()) if cursor_pos is None else cursor_pos
        else:
            pos = None
        old_pos = self.mapToScene(pos) if pos is not None else None

        show_full = False
        if self.view_rect().width() / factor > self.sceneRect().width():
            self.show_full_scene()
            factor = 1
            show_full = True

        self.scale(factor, 1)
        if show_full:
            self.zoomed.emit(-1)
        else:
            self.zoomed.emit(factor)

        if pos is not None:
            move = self.mapToScene(pos) - old_pos
            self.translate(move.x(), 0) 
开发者ID:jopohl,项目名称:urh,代码行数:27,代码来源:ZoomableGraphicView.py

示例10: contextMenuEvent

# 需要导入模块: from PyQt5.QtGui import QCursor [as 别名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 别名]
def contextMenuEvent(self, event):
        """Pops up the context menu when the right button is clicked."""
        try:
            index = self._get_current_index
            menu = RCMenu(self)
            menu.popup(QCursor.pos())

            self.selected_indexes = menu.return_selected_row_indexes()
            menu.overall_hist_action.triggered.connect(
                self._compute_overall_histograms)
        except UnboundLocalError:
            pass 
开发者ID:MTG,项目名称:dunya-desktop,代码行数:14,代码来源:table.py

示例11: download_clicked

# 需要导入模块: from PyQt5.QtGui import QCursor [as 别名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 别名]
def download_clicked(self):
        click_me = qApp.focusWidget()
        index = self.indexAt(click_me.pos())
        if index.isValid():
            row = index.row()
            if sys.version_info[0] == 2:
                docid = convert_str(self.item(row, 1).text())
            else:
                docid = self.item(row, 1).text()

            self.set_status(row, 0)
            self.indexes[docid] = row
            self.added_new_doc.emit([docid]) 
开发者ID:MTG,项目名称:dunya-desktop,代码行数:15,代码来源:table.py

示例12: __add_items_to_plot

# 需要导入模块: from PyQt5.QtGui import QCursor [as 别名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 别名]
def __add_items_to_plot(self, len_plot, min_audio, max_audio):
        """
        Adds a region selector item and vertical line for to the waveform plot.

        :param len_plot: (int) Number of samples in plotted waveform array.
        :param min_audio: (float) The minimum value of plotted waveform array.
        :param max_audio: (float) The maximum value of plotted waveform array.
        """

        # Create a waveform region item and add it to waveform plot
        pos_wf_x_max = len_plot * 0.05  # Region item focuses on the 5% of
        # waveform plot.
        self.region_wf = WaveformRegionItem(values=[0, pos_wf_x_max],
                                            brush=WAVEFORM_BRUSH,
                                            bounds=[0., len_plot])

        # Creating a cursor with pyqtgraph.ROI
        self.vline_wf = pg.ROI(pos=[0, min_audio],
                               size=[0, max_audio - min_audio],
                               angle=0, pen=WAVEFORM_VLINE)

        # add items to waveform plot
        self.waveform.addItem(self.region_wf)
        self.waveform.addItem(self.vline_wf)

        # text item
        self.section_label = pg.TextItem(text='')
        self.waveform.addItem(self.section_label) 
开发者ID:MTG,项目名称:dunya-desktop,代码行数:30,代码来源:waveformwidget.py

示例13: update_wf_vline

# 需要导入模块: from PyQt5.QtGui import QCursor [as 别名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 别名]
def update_wf_vline(self, playback_pos_sample):
        """
        Updated the position of vertical line.

        :param playback_pos_sample: (int) Position of playback in samples.
        """
        pos = playback_pos_sample / self.ratio
        if pos <= 0:
            pos = 0
        elif pos >= self.len:
            pos = self.len

        self.vline_wf.setPos([pos, self.min]) 
开发者ID:MTG,项目名称:dunya-desktop,代码行数:15,代码来源:waveformwidget.py

示例14: contextMenuEvent

# 需要导入模块: from PyQt5.QtGui import QCursor [as 别名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 别名]
def contextMenuEvent(self, event):
        self.tablewidget_menu.popup(QCursor.pos())


# CategoryTreeView Class adds QMenu to QTreeView 
开发者ID:persepolisdm,项目名称:persepolis,代码行数:7,代码来源:mainwindow_ui.py

示例15: mousePressEvent

# 需要导入模块: from PyQt5.QtGui import QCursor [as 别名]
# 或者: from PyQt5.QtGui.QCursor import pos [as 别名]
def mousePressEvent(self, event):
        self.mousePos = QCursor.pos() 
开发者ID:HuberTRoy,项目名称:MusicBox,代码行数:4,代码来源:player.py


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