Python qtpy.QtCore.QPoint() Examples
The following are 25
code examples of qtpy.QtCore.QPoint().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
qtpy.QtCore
, or try the search function
.
Example #1
Source File: test_datatree.py From spyder-unittest with MIT License | 6 votes |
def test_contextMenuEvent_calls_exec(view_and_model, monkeypatch): # test that a menu is displayed when clicking on an item mock_exec = Mock() monkeypatch.setattr('spyder_unittest.widgets.datatree.QMenu.exec_', mock_exec) view, model = view_and_model pos = view.visualRect(model.index(0, 0)).center() event = QContextMenuEvent(QContextMenuEvent.Mouse, pos) view.contextMenuEvent(event) assert mock_exec.called # test that no menu is displayed when clicking below the bottom item mock_exec.reset_mock() pos = view.visualRect(model.index(1, 0)).bottomRight() pos += QPoint(0, 1) event = QContextMenuEvent(QContextMenuEvent.Mouse, pos) view.contextMenuEvent(event) assert not mock_exec.called
Example #2
Source File: graph_view.py From pyflowgraph with BSD 3-Clause "New" or "Revised" License | 6 votes |
def getSelectedNodesCentroid(self): selectedNodes = self.getSelectedNodes() leftMostNode = None topMostNode = None for node in selectedNodes: nodePos = node.getGraphPos() if leftMostNode is None: leftMostNode = node else: if nodePos.x() < leftMostNode.getGraphPos().x(): leftMostNode = node if topMostNode is None: topMostNode = node else: if nodePos.y() < topMostNode.getGraphPos().y(): topMostNode = node xPos = leftMostNode.getGraphPos().x() yPos = topMostNode.getGraphPos().y() pos = QtCore.QPoint(xPos, yPos) return pos
Example #3
Source File: actions.py From Pyslvs-UI with GNU Affero General Public License v3.0 | 6 votes |
def canvas_context_menu(self, point: QPoint) -> None: """MainCanvas context menu.""" index = self.entities_tab.currentIndex() if index == 0: self.__enable_point_context() self.action_c_add_target.setVisible( self.main_panel.currentWidget() is self.synthesis_tab and self.synthesis_tab_widget.currentWidget() is self.dimensional_synthesis and self.dimensional_synthesis.has_target() ) self.pop_canvas_p.exec_(self.main_canvas.mapToGlobal(point)) self.action_new_link.setVisible(True) self.pop_point_m.clear() elif index == 1: self.__enable_link_context() self.pop_canvas_l.exec_(self.main_canvas.mapToGlobal(point)) self.pop_link_m.clear()
Example #4
Source File: actions.py From Pyslvs-UI with GNU Affero General Public License v3.0 | 5 votes |
def point_context_menu(self, point: QPoint) -> None: """EntitiesPoint context menu.""" self.__enable_point_context() self.pop_point.exec_(self.entities_point_widget.mapToGlobal(point)) self.action_new_link.setVisible(True) self.pop_point_m.clear()
Example #5
Source File: table.py From conda-manager with MIT License | 5 votes |
def mousePressEvent(self, event): """Override Qt method""" QTableView.mousePressEvent(self, event) self.current_index = self.currentIndex() column = self.current_index.column() if event.button() == Qt.LeftButton and column == const.COL_ACTION: pos = QPoint(event.x(), event.y()) index = self.indexAt(pos) self.action_pressed(index) self.context_menu_requested(event) elif event.button() == Qt.RightButton: self.context_menu_requested(event, right_click=True) self.update_visible_rows()
Example #6
Source File: pyrpl_widget.py From pyrpl with GNU General Public License v3.0 | 5 votes |
def click_menu_modules(self): self.menu_modules.popup(self.mapToGlobal(QtCore.QPoint(10,10)))
Example #7
Source File: schematics.py From pyrpl with GNU General Public License v3.0 | 5 votes |
def adjust(self): x1 = self.widget_start.item_x() + self.widget_start.item.width() / 2 x2 = self.widget_stop.item_x() + self.widget_stop.item.width() / 2 y1 = self.widget_start.item_y() + self.widget_start.item.height() / 2 y2 = self.widget_stop.item_y() + self.widget_stop.item.height() / 2 if self.h_first: self.line1.setLine(x1, y1, x1, y2) self.line2.setLine(x1, y2, x2, y2) else: self.line1.setLine(x1, y1, x2, y1) self.line2.setLine(x2, y1, x2, y2) if self.show_arrow: if self.h_first: x = x2 - self.widget_stop.width() / 2 y = y2 arrow = QtGui.QPolygonF( [QtCore.QPoint(x - self.margin, y - self.arrow_height / 2), QtCore.QPoint(x - self.margin, y + self.arrow_height / 2), QtCore.QPoint(x - self.margin + self.arrow_width, y)]) else: x = x2 y = y2 - self.widget_stop.height() / 2 if y2 < y1: margin = - self.margin arrow_width = - self.arrow_width y = y2 + self.widget_stop.height() / 2 else: margin = self.margin arrow_width = self.arrow_width arrow = QtGui.QPolygonF( [QtCore.QPoint(x - self.arrow_height / 2, y - margin), QtCore.QPoint(x + self.arrow_height / 2, y - margin), QtCore.QPoint(x, y - margin + arrow_width)]) if self.show_arrow: self.arrow.setPolygon(arrow)
Example #8
Source File: test_completion_widget.py From qtconsole with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_droplist_completer_mousepick(self): leftButton = QtCore.Qt.LeftButton w = CompletionWidget(self.console) w.show_items(self.text_edit.textCursor(), ["item1", "item2", "item3"]) QTest.mouseClick(w.viewport(), leftButton, pos=QtCore.QPoint(19, 8)) QTest.mouseRelease(w.viewport(), leftButton, pos=QtCore.QPoint(19, 8)) QTest.mouseDClick(w.viewport(), leftButton, pos=QtCore.QPoint(19, 8)) self.assertEqual(self.text_edit.toPlainText(), "item1") self.assertFalse(w.isVisible())
Example #9
Source File: test_00_console_widget.py From qtconsole with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_link_handling(self): noKeys = QtCore.Qt noButton = QtCore.Qt.MouseButton(0) noButtons = QtCore.Qt.MouseButtons(0) noModifiers = QtCore.Qt.KeyboardModifiers(0) MouseMove = QtCore.QEvent.MouseMove QMouseEvent = QtGui.QMouseEvent w = ConsoleWidget() cursor = w._get_prompt_cursor() w._insert_html(cursor, '<a href="http://python.org">written in</a>') obj = w._control tip = QtWidgets.QToolTip self.assertEqual(tip.text(), u'') # should be somewhere else elsewhereEvent = QMouseEvent(MouseMove, QtCore.QPoint(50,50), noButton, noButtons, noModifiers) w.eventFilter(obj, elsewhereEvent) self.assertEqual(tip.isVisible(), False) self.assertEqual(tip.text(), u'') # should be over text overTextEvent = QMouseEvent(MouseMove, QtCore.QPoint(1,5), noButton, noButtons, noModifiers) w.eventFilter(obj, overTextEvent) self.assertEqual(tip.isVisible(), True) self.assertEqual(tip.text(), "http://python.org") # should still be over text stillOverTextEvent = QMouseEvent(MouseMove, QtCore.QPoint(1,5), noButton, noButtons, noModifiers) w.eventFilter(obj, stillOverTextEvent) self.assertEqual(tip.isVisible(), True) self.assertEqual(tip.text(), "http://python.org")
Example #10
Source File: console_widget.py From qtconsole with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _custom_context_menu_requested(self, pos): """ Shows a context menu at the given QPoint (in widget coordinates). """ menu = self._context_menu_make(pos) menu.exec_(self._control.mapToGlobal(pos))
Example #11
Source File: console_widget.py From qtconsole with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _context_menu_make(self, pos): """ Creates a context menu for the given QPoint (in widget coordinates). """ menu = QtWidgets.QMenu(self) self.cut_action = menu.addAction('Cut', self.cut) self.cut_action.setEnabled(self.can_cut()) self.cut_action.setShortcut(QtGui.QKeySequence.Cut) self.copy_action = menu.addAction('Copy', self.copy) self.copy_action.setEnabled(self.can_copy()) self.copy_action.setShortcut(QtGui.QKeySequence.Copy) self.paste_action = menu.addAction('Paste', self.paste) self.paste_action.setEnabled(self.can_paste()) self.paste_action.setShortcut(QtGui.QKeySequence.Paste) anchor = self._control.anchorAt(pos) if anchor: menu.addSeparator() self.copy_link_action = menu.addAction( 'Copy Link Address', lambda: self.copy_anchor(anchor=anchor)) self.open_link_action = menu.addAction( 'Open Link', lambda: self.open_anchor(anchor=anchor)) menu.addSeparator() menu.addAction(self.select_all_action) menu.addSeparator() menu.addAction(self.export_action) menu.addAction(self.print_action) return menu
Example #12
Source File: main_abc.py From Pyslvs-UI with GNU Affero General Public License v3.0 | 5 votes |
def link_context_menu(self, point: QPoint) -> None: ...
Example #13
Source File: main_abc.py From Pyslvs-UI with GNU Affero General Public License v3.0 | 5 votes |
def canvas_context_menu(self, point: QPoint) -> None: ...
Example #14
Source File: canvas.py From Pyslvs-UI with GNU Affero General Public License v3.0 | 5 votes |
def grab_no_background(self) -> QPixmap: """Grab function without background.""" image = QImage(self.size(), QImage.Format_ARGB32_Premultiplied) image.fill(Qt.transparent) self.switch_grab() self.painter.begin(image) self.render(self.painter, QPoint(), QRegion(), QWidget.DrawChildren) self.switch_grab() return QPixmap.fromImage(image)
Example #15
Source File: actions.py From Pyslvs-UI with GNU Affero General Public License v3.0 | 5 votes |
def link_context_menu(self, point: QPoint) -> None: """EntitiesLink context menu.""" self.__enable_link_context() self.pop_link.exec_(self.entities_link_widget.mapToGlobal(point)) self.pop_link_m.clear()
Example #16
Source File: iconic_font.py From qtawesome with MIT License | 5 votes |
def pixmap(self, size, mode, state): pm = QPixmap(size) pm.fill(Qt.transparent) self.paint(QPainter(pm), QRect(QPoint(0, 0), size), mode, state) return pm
Example #17
Source File: test_qt_scrollbar.py From napari with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_modified_scrollbar_click(qtbot): w = ModifiedScrollBar(Qt.Horizontal) w.resize(100, 10) assert w.value() == 0 qtbot.mousePress(w, Qt.LeftButton, pos=QPoint(50, 5)) # the normal QScrollBar would have moved to "10" assert w.value() >= 40
Example #18
Source File: qt_modal.py From napari with BSD 3-Clause "New" or "Revised" License | 5 votes |
def show_right_of_mouse(self, *args): pos = QCursor().pos() # mouse position szhint = self.sizeHint() pos -= QPoint(-14, szhint.height() / 4) self.move(pos) self.show()
Example #19
Source File: qt_modal.py From napari with BSD 3-Clause "New" or "Revised" License | 5 votes |
def show_above_mouse(self, *args): """Show popup dialog above the mouse cursor position.""" pos = QCursor().pos() # mouse position szhint = self.sizeHint() pos -= QPoint(szhint.width() / 2, szhint.height() + 14) self.move(pos) self.show()
Example #20
Source File: qt_range_slider_popup.py From napari with BSD 3-Clause "New" or "Revised" License | 5 votes |
def update_position(self): """Update slider position.""" x = self.get_pos() - self.width() // 2 y = self.slider.handle_radius + 12 self.move(QPoint(x, -y) + self.slider.pos())
Example #21
Source File: test_vim.py From spyder-vim with MIT License | 5 votes |
def test_L_command(vim_bot): """Test L command (Cursor moves to the bottom of the screen).""" main, editor_stack, editor, vim, qtbot = vim_bot editor.resize(400, 800) editor.stdkey_backspace() cmd_line = vim.get_focus_widget() qtbot.keyClicks(cmd_line, 'ggVGy') qtbot.keyClicks(cmd_line, '100pgg') first_position = editor.cursorForPosition(QPoint(0, editor.viewport().height())).position() qtbot.keyClicks(cmd_line, 'L') position = editor.textCursor().position() assert first_position == position
Example #22
Source File: test_vim.py From spyder-vim with MIT License | 5 votes |
def test_H_command(vim_bot): """Test H command (Cursor moves to the top of the screen).""" main, editor_stack, editor, vim, qtbot = vim_bot editor.resize(400, 800) editor.stdkey_backspace() cmd_line = vim.get_focus_widget() qtbot.keyClicks(cmd_line, 'ggVGy') qtbot.keyClicks(cmd_line, '100pG') first_position = editor.cursorForPosition(QPoint(0,0)).position() qtbot.keyClicks(cmd_line, 'H') position = editor.textCursor().position() assert first_position == position
Example #23
Source File: vim_widget.py From spyder-vim with MIT License | 5 votes |
def M(self, repeat=1): """Move cursor to the middle of the page""" editor = self._widget.editor() position = editor.cursorForPosition(QPoint(0, int((editor.viewport().height())*0.5))).position() self._set_cursor(position, mode=QTextCursor.MoveAnchor)
Example #24
Source File: vim_widget.py From spyder-vim with MIT License | 5 votes |
def L(self, repeat=1): """Move cursor to the bottom of the page""" editor = self._widget.editor() position = editor.cursorForPosition(QPoint(0, editor.viewport().height())).position() self._set_cursor(position, mode=QTextCursor.MoveAnchor)
Example #25
Source File: vim_widget.py From spyder-vim with MIT License | 5 votes |
def H(self, repeat=1): """Move cursor to the top of the page""" editor = self._widget.editor() position = editor.cursorForPosition(QPoint(0, 0)).position() self._set_cursor(position, mode=QTextCursor.MoveAnchor)