Python PyQt5.QtCore.QPoint() Examples
The following are 30 code examples for showing how to use PyQt5.QtCore.QPoint(). These examples are extracted from open source projects. 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 check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
PyQt5.QtCore
, or try the search function
.
Example 1
Project: screenshot Author: SeptemberHX File: screenshot.py License: GNU General Public License v3.0 | 7 votes |
def saveScreenshot(self, clipboard=False, fileName='screenshot.png', picType='png'): fullWindow = QRect(0, 0, self.width() - 1, self.height() - 1) selected = QRect(self.selected_area) if selected.left() < 0: selected.setLeft(0) if selected.right() >= self.width(): selected.setRight(self.width() - 1) if selected.top() < 0: selected.setTop(0) if selected.bottom() >= self.height(): selected.setBottom(self.height() - 1) source = (fullWindow & selected) source.setTopLeft(QPoint(source.topLeft().x() * self.scale, source.topLeft().y() * self.scale)) source.setBottomRight(QPoint(source.bottomRight().x() * self.scale, source.bottomRight().y() * self.scale)) image = self.screenPixel.copy(source) if clipboard: QGuiApplication.clipboard().setImage(QImage(image), QClipboard.Clipboard) else: image.save(fileName, picType, 10) self.target_img = image self.screen_shot_grabed.emit(QImage(image))
Example 2
Project: screenshot Author: SeptemberHX File: screenshot.py License: GNU General Public License v3.0 | 7 votes |
def drawSizeInfo(self): sizeInfoAreaWidth = 200 sizeInfoAreaHeight = 30 spacing = 5 rect = self.selected_area.normalized() sizeInfoArea = QRect(rect.left(), rect.top() - spacing - sizeInfoAreaHeight, sizeInfoAreaWidth, sizeInfoAreaHeight) if sizeInfoArea.top() < 0: sizeInfoArea.moveTopLeft(rect.topLeft() + QPoint(spacing, spacing)) if sizeInfoArea.right() >= self.screenPixel.width(): sizeInfoArea.moveTopLeft(rect.topLeft() - QPoint(spacing, spacing) - QPoint(sizeInfoAreaWidth, 0)) if sizeInfoArea.left() < spacing: sizeInfoArea.moveLeft(spacing) if sizeInfoArea.top() < spacing: sizeInfoArea.moveTop(spacing) self.items_to_remove.append(self.graphics_scene.addRect(QRectF(sizeInfoArea), Qt.white, QBrush(Qt.black))) sizeInfo = self.graphics_scene.addSimpleText( ' {0} x {1}'.format(rect.width() * self.scale, rect.height() * self.scale)) sizeInfo.setPos(sizeInfoArea.topLeft() + QPoint(0, 2)) sizeInfo.setPen(QPen(QColor(255, 255, 255), 2)) self.items_to_remove.append(sizeInfo)
Example 3
Project: simnibs Author: simnibs File: electrodeGUI.py License: GNU General Public License v3.0 | 6 votes |
def __init__(self, parent=None): super(GLElectrode, self).__init__(parent) self.electrode_object = 0 self.plug_object = 0 self.center_dir = 0 self.xRot = 3160 self.yRot = 5536 self.zRot = 0 self.zoom = 1.0 self.electrode_placeholder = sim_struct.ELECTRODE() self.electrode_placeholder.dimensions = [0.0, 0.0] self.electrode_placeholder.thickness = [0.0] self.lastPos = QtCore.QPoint()
Example 4
Project: simnibs Author: simnibs File: head_model_OGL.py License: GNU General Public License v3.0 | 6 votes |
def mouseDoubleClickEvent(self, event): if isinstance(self.skin_surf, surface.Surface): self.lastPos = QtCore.QPoint(event.pos()) x = float(self.lastPos.x()) y = float(self.view[3] - self.lastPos.y()) Near = GLU.gluUnProject( x, y, 0., self.model_matrix, self.projection_matrix, self.view) Far = GLU.gluUnProject( x, y, 1., self.model_matrix, self.projection_matrix, self.view) self.intersect_point, self.intersect_normal = self.skin_surf.interceptRay(Near, Far) if self.intersect_point is not None: self.indicator = self.drawIndicator(self.intersect_point, self.intersect_normal) self.update() self.windowClicked.emit(1)
Example 5
Project: qutebrowser Author: qutebrowser File: stubs.py License: GNU General Public License v3.0 | 6 votes |
def __init__(self, geometry=None, *, scroll=None, plaintext=None, html=None, parent=None, zoom=1.0): """Constructor. Args: geometry: The geometry of the frame as QRect. scroll: The scroll position as QPoint. plaintext: Return value of toPlainText html: Return value of tohtml. zoom: The zoom factor. parent: The parent frame. """ if scroll is None: scroll = QPoint(0, 0) self.geometry = mock.Mock(return_value=geometry) self.scrollPosition = mock.Mock(return_value=scroll) self.parentFrame = mock.Mock(return_value=parent) self.toPlainText = mock.Mock(return_value=plaintext) self.toHtml = mock.Mock(return_value=html) self.zoomFactor = mock.Mock(return_value=zoom)
Example 6
Project: qutebrowser Author: qutebrowser File: webkittab.py License: GNU General Public License v3.0 | 6 votes |
def load_items(self, items): if items: self._tab.before_load_started.emit(items[-1].url) stream, _data, user_data = tabhistory.serialize(items) qtutils.deserialize_stream(stream, self._history) for i, data in enumerate(user_data): self._history.itemAt(i).setUserData(data) cur_data = self._history.currentItem().userData() if cur_data is not None: if 'zoom' in cur_data: self._tab.zoom.set_factor(cur_data['zoom']) if ('scroll-pos' in cur_data and self._tab.scroller.pos_px() == QPoint(0, 0)): QTimer.singleShot(0, functools.partial( self._tab.scroller.to_point, cur_data['scroll-pos']))
Example 7
Project: persepolis Author: persepolisdm File: about.py License: GNU General Public License v3.0 | 6 votes |
def __init__(self, persepolis_setting): super().__init__(persepolis_setting) self.persepolis_setting = persepolis_setting # setting window size and position size = self.persepolis_setting.value( 'AboutWindow/size', QSize(545, 375)) position = self.persepolis_setting.value( 'AboutWindow/position', QPoint(300, 300)) # read translators.txt files. # this file contains all translators. f = QFile(':/translators.txt') f.open(QIODevice.ReadOnly | QFile.Text) f_text = QTextStream(f).readAll() f.close() self.translators_textEdit.insertPlainText(f_text) self.resize(size) self.move(position)
Example 8
Project: FAE Author: salan668 File: FeatureExtractionForm.py License: GNU General Public License v3.0 | 6 votes |
def __init__(self, parent=None): super(QWidget, self).__init__(parent) self.ui = Ui_FeatureExtraction() self._source_path = '' self._cur_pattern_item = 0 self.logger = eclog(os.path.split(__file__)[-1]).GetLogger() folder, _ = os.path.split(os.path.abspath(sys.argv[0])) self.radiomics_config_path = folder + '/RadiomicsParams.yaml' self.ui.setupUi(self) self.ui.buttonBrowseSourceFolder.clicked.connect(self.BrowseSourceFolder) self.ui.buttonBrowseRoiFile.clicked.connect(self.BrowseRoiFile) self.ui.buttonAdd.clicked.connect(self.onButtonAddClicked) self.ui.listWidgetImageFiles.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.ui.listWidgetImageFiles.customContextMenuRequested[QtCore.QPoint].connect( self.onListImageFilesContextMenuRequested) self.ui.buttonBrowseFile.clicked.connect(self.BrowsePatternFile) self.ui.buttonBrowseOutputFile.clicked.connect(self.BrowseOutputFile) self.radiomics_params = RadiomicsParamsConfig(self.radiomics_config_path) self.ui.buttonGo.clicked.connect(self.Go) self.InitUi() self.check_background_color = "background-color:rgba(255,0,0,64)" self.raw_background_color = "background-color:rgba(25,35,45,255)"
Example 9
Project: pychemqt Author: jjgomera File: widgets.py License: GNU General Public License v3.0 | 6 votes |
def __init__(self, parent=None): super(DragButton, self).__init__(parent) # def mouseMoveEvent(self, event): # self.startDrag() # QtWidgets.QToolButton.mouseMoveEvent(self, event) # def startDrag(self): # if self.icon().isNull(): # return # data = QtCore.QByteArray() # stream = QtCore.QDataStream(data, QtCore.QIODevice.WriteOnly) # stream << self.icon() # mimeData = QtCore.QMimeData() # mimeData.setData("application/x-equipment", data) # drag = QtGui.QDrag(self) # drag.setMimeData(mimeData) # pixmap = self.icon().pixmap(24, 24) # drag.setHotSpot(QtCore.QPoint(12, 12)) # drag.setPixmap(pixmap) # drag.exec_(QtCore.Qt.CopyAction)
Example 10
Project: Uranium Author: Ultimaker File: PointingRectangle.py License: GNU Lesser General Public License v3.0 | 6 votes |
def __init__(self, parent = None): super().__init__(parent) self.setFlag(QQuickItem.ItemHasContents) self._arrow_size = 0 self._color = QColor(255, 255, 255, 255) self._target = QPoint(0,0) self._border_width = 0 self._border_color = QColor(0, 0, 0, 255) self._geometry = None self._material = None self._node = None self._border_geometry = None self._border_material = None self._border_node = None
Example 11
Project: nanovna-saver Author: NanoVNA-Saver File: Polar.py License: GNU General Public License v3.0 | 6 votes |
def drawChart(self, qp: QtGui.QPainter): centerX = int(self.width()/2) centerY = int(self.height()/2) qp.setPen(QtGui.QPen(self.textColor)) qp.drawText(3, 15, self.name) qp.setPen(QtGui.QPen(self.foregroundColor)) qp.drawEllipse(QtCore.QPoint(centerX, centerY), int(self.chartWidth / 2), int(self.chartHeight / 2)) qp.drawEllipse(QtCore.QPoint(centerX, centerY), int(self.chartWidth / 4), int(self.chartHeight / 4)) qp.drawLine(centerX - int(self.chartWidth / 2), centerY, centerX + int(self.chartWidth / 2), centerY) qp.drawLine(centerX, centerY - int(self.chartHeight / 2), centerX, centerY + int(self.chartHeight / 2)) qp.drawLine(centerX + int(self.chartHeight / 2 * math.sin(math.pi / 4)), centerY + int(self.chartHeight / 2 * math.sin(math.pi / 4)), centerX - int(self.chartHeight / 2 * math.sin(math.pi / 4)), centerY - int(self.chartHeight / 2 * math.sin(math.pi / 4))) qp.drawLine(centerX + int(self.chartHeight / 2 * math.sin(math.pi / 4)), centerY - int(self.chartHeight / 2 * math.sin(math.pi / 4)), centerX - int(self.chartHeight / 2 * math.sin(math.pi / 4)), centerY + int(self.chartHeight / 2 * math.sin(math.pi / 4))) self.drawTitle(qp)
Example 12
Project: mhw_armor_edit Author: fre-sch File: suite.py License: The Unlicense | 6 votes |
def load_settings(self): self.settings = AppSettings() with self.settings.main_window() as group: size = group.get("size", QSize(1000, 800)) position = group.get("position", QPoint(300, 300)) with self.settings.application() as group: chunk_directory = group.get("chunk_directory", None) mod_directory = group.get("mod_directory", None) lang = group.get("lang", None) with self.settings.import_export() as group: self.import_export_default_attrs = { key: group.get(key, "").split(";") for key in group.childKeys() } # apply settings self.resize(size) self.move(position) if chunk_directory: self.chunk_directory.set_path(chunk_directory) if mod_directory: self.mod_directory.set_path(mod_directory) if lang: self.handle_set_lang_action(lang)
Example 13
Project: CustomWidgets Author: PyQt5 File: CDrawer.py License: GNU General Public License v3.0 | 6 votes |
def animationOut(self): """离开动画 """ self.animIn.stop() # 停止进入动画 geometry = self.widget.geometry() if self.direction == self.LEFT: # 左侧抽屉 self.animOut.setStartValue(geometry.topLeft()) self.animOut.setEndValue(QPoint(-self.widget.width(), 0)) self.animOut.start() elif self.direction == self.TOP: # 上方抽屉 self.animOut.setStartValue(QPoint(0, geometry.y())) self.animOut.setEndValue(QPoint(0, -self.widget.height())) self.animOut.start() elif self.direction == self.RIGHT: # 右侧抽屉 self.animOut.setStartValue(QPoint(geometry.x(), 0)) self.animOut.setEndValue(QPoint(self.width(), 0)) self.animOut.start() elif self.direction == self.BOTTOM: # 下方抽屉 self.animOut.setStartValue(QPoint(0, geometry.y())) self.animOut.setEndValue(QPoint(0, self.height())) self.animOut.start()
Example 14
Project: simnibs Author: simnibs File: electrodeGUI.py License: GNU General Public License v3.0 | 5 votes |
def mousePressEvent(self, event): self.lastPos = QtCore.QPoint(event.pos())
Example 15
Project: simnibs Author: simnibs File: electrodeGUI.py License: GNU General Public License v3.0 | 5 votes |
def mouseMoveEvent(self, event): dx = event.x() - self.lastPos.x() dy = event.y() - self.lastPos.y() if event.buttons() & QtCore.Qt.LeftButton: self.setXRotation(self.xRot - 8 * dy) self.setYRotation(self.yRot - 8 * dx) elif event.buttons() & QtCore.Qt.RightButton: self.setXRotation(self.xRot - 8 * dy) self.setZRotation(self.zRot - 8 * dx) self.lastPos = QtCore.QPoint(event.pos())
Example 16
Project: simnibs Author: simnibs File: head_model_OGL.py License: GNU General Public License v3.0 | 5 votes |
def mousePressEvent(self,event): self.lastPos = QtCore.QPoint(event.pos()) #Rotates / translates model
Example 17
Project: qutebrowser Author: qutebrowser File: test_webkitelem.py License: GNU General Public License v3.0 | 5 votes |
def test_scrolled(self, geometry, visible, stubs): scrolled_frame = stubs.FakeWebFrame(QRect(0, 0, 100, 100), scroll=QPoint(10, 10)) elem = get_webelem(geometry, scrolled_frame) assert elem._is_visible(scrolled_frame) == visible
Example 18
Project: qutebrowser Author: qutebrowser File: test_webkitelem.py License: GNU General Public License v3.0 | 5 votes |
def test_iframe_scrolled(self, objects): """Scroll iframe down so elem3 gets visible and elem1/elem2 not.""" objects.iframe.scrollPosition.return_value = QPoint(0, 100) assert not objects.elems[0]._is_visible(objects.frame) assert not objects.elems[1]._is_visible(objects.frame) assert objects.elems[2]._is_visible(objects.frame) assert objects.elems[3]._is_visible(objects.frame)
Example 19
Project: qutebrowser Author: qutebrowser File: test_webkitelem.py License: GNU General Public License v3.0 | 5 votes |
def test_mainframe_scrolled_iframe_visible(self, objects): """Scroll mainframe down so iframe is partly visible but elem1 not.""" objects.frame.scrollPosition.return_value = QPoint(0, 50) geom = objects.frame.geometry().translated( objects.frame.scrollPosition()) assert not geom.contains(objects.iframe.geometry()) assert geom.intersects(objects.iframe.geometry()) assert not objects.elems[0]._is_visible(objects.frame) assert objects.elems[1]._is_visible(objects.frame) assert not objects.elems[2]._is_visible(objects.frame) assert objects.elems[3]._is_visible(objects.frame)
Example 20
Project: qutebrowser Author: qutebrowser File: test_webkitelem.py License: GNU General Public License v3.0 | 5 votes |
def test_mainframe_scrolled_iframe_invisible(self, objects): """Scroll mainframe down so iframe is invisible.""" objects.frame.scrollPosition.return_value = QPoint(0, 110) geom = objects.frame.geometry().translated( objects.frame.scrollPosition()) assert not geom.contains(objects.iframe.geometry()) assert not geom.intersects(objects.iframe.geometry()) assert not objects.elems[0]._is_visible(objects.frame) assert not objects.elems[1]._is_visible(objects.frame) assert not objects.elems[2]._is_visible(objects.frame) assert objects.elems[3]._is_visible(objects.frame)
Example 21
Project: qutebrowser Author: qutebrowser File: webpage.py License: GNU General Public License v3.0 | 5 votes |
def on_restore_frame_state_requested(self, frame): """Restore scroll position and zoom from history. Args: frame: The QWebFrame which gets restored. """ if frame != self.mainFrame(): return data = self.history().currentItem().userData() if data is None: return if 'zoom' in data: frame.page().view().tab.zoom.set_factor(data['zoom']) if 'scroll-pos' in data and frame.scrollPosition() == QPoint(0, 0): frame.setScrollPosition(data['scroll-pos'])
Example 22
Project: qutebrowser Author: qutebrowser File: webengineelem.py License: GNU General Public License v3.0 | 5 votes |
def _click_editable(self, click_target: usertypes.ClickTarget) -> None: # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-58515 ev = QMouseEvent(QMouseEvent.MouseButtonPress, QPoint(0, 0), QPoint(0, 0), QPoint(0, 0), Qt.NoButton, Qt.NoButton, Qt.NoModifier, Qt.MouseEventSynthesizedBySystem) self._tab.send_event(ev) # This actually "clicks" the element by calling focus() on it in JS. self._js_call('focus') self._move_text_cursor()
Example 23
Project: qutebrowser Author: qutebrowser File: webelem.py License: GNU General Public License v3.0 | 5 votes |
def _mouse_pos(self) -> QPoint: """Get the position to click/hover.""" # Click the center of the largest square fitting into the top/left # corner of the rectangle, this will help if part of the <a> element # is hidden behind other elements # https://github.com/qutebrowser/qutebrowser/issues/1005 rect = self.rect_on_view() if rect.width() > rect.height(): rect.setWidth(rect.height()) else: rect.setHeight(rect.width()) pos = rect.center() if pos.x() < 0 or pos.y() < 0: raise Error("Element position is out of view!") return pos
Example 24
Project: screenshot Author: SeptemberHX File: screenshot.py License: GNU General Public License v3.0 | 5 votes |
def mouseReleaseEvent(self, event): """ :type event: QMouseEvent :param event: :return: """ if event.button() != Qt.LeftButton: return if self.mousePressed: self.mousePressed = False self.endX, self.endY = event.x(), event.y() if self.action == ACTION_SELECT: self.selected_area.setBottomRight(QPoint(event.x(), event.y())) self.selectedAreaRaw = QRect(self.selected_area) self.action = ACTION_MOVE_SELECTED self.redraw() elif self.action == ACTION_MOVE_SELECTED: self.selectedAreaRaw = QRect(self.selected_area) self.redraw() # self.action = None elif self.action == ACTION_RECT: self.drawRect(self.startX, self.startY, event.x(), event.y(), True) self.redraw() elif self.action == ACTION_ELLIPSE: self.drawEllipse(self.startX, self.startY, event.x(), event.y(), True) self.redraw() elif self.action == ACTION_ARROW: self.drawArrow(self.startX, self.startY, event.x(), event.y(), True) self.redraw() elif self.action == ACTION_LINE: self.drawLine(self.startX, self.startY, event.x(), event.y(), True) self.redraw() elif self.action == ACTION_FREEPEN: self.drawFreeLine(self.pointPath, True) self.redraw()
Example 25
Project: screenshot Author: SeptemberHX File: screenshot.py License: GNU General Public License v3.0 | 5 votes |
def detect_mouse_position(self, point): """ :type point: QPoint :param point: the mouse position you want to check :return: """ if self.selected_area == QRect(): self.mousePosition = MousePosition.OUTSIDE_AREA return if self.selected_area.left() - ERRORRANGE <= point.x() <= self.selected_area.left() and ( self.selected_area.top() - ERRORRANGE <= point.y() <= self.selected_area.top()): self.mousePosition = MousePosition.ON_THE_TOP_LEFT_CORNER elif self.selected_area.right() <= point.x() <= self.selected_area.right() + ERRORRANGE and ( self.selected_area.top() - ERRORRANGE <= point.y() <= self.selected_area.top()): self.mousePosition = MousePosition.ON_THE_TOP_RIGHT_CORNER elif self.selected_area.left() - ERRORRANGE <= point.x() <= self.selected_area.left() and ( self.selected_area.bottom() <= point.y() <= self.selected_area.bottom() + ERRORRANGE): self.mousePosition = MousePosition.ON_THE_BOTTOM_LEFT_CORNER elif self.selected_area.right() <= point.x() <= self.selected_area.right() + ERRORRANGE and ( self.selected_area.bottom() <= point.y() <= self.selected_area.bottom() + ERRORRANGE): self.mousePosition = MousePosition.ON_THE_BOTTOM_RIGHT_CORNER elif -ERRORRANGE <= point.x() - self.selected_area.left() <= 0 and ( self.selected_area.topLeft().y() < point.y() < self.selected_area.bottomLeft().y()): self.mousePosition = MousePosition.ON_THE_LEFT_SIDE elif 0 <= point.x() - self.selected_area.right() <= ERRORRANGE and ( self.selected_area.topRight().y() < point.y() < self.selected_area.bottomRight().y()): self.mousePosition = MousePosition.ON_THE_RIGHT_SIDE elif -ERRORRANGE <= point.y() - self.selected_area.top() <= 0 and ( self.selected_area.topLeft().x() < point.x() < self.selected_area.topRight().x()): self.mousePosition = MousePosition.ON_THE_UP_SIDE elif 0 <= point.y() - self.selected_area.bottom() <= ERRORRANGE and ( self.selected_area.bottomLeft().x() < point.x() < self.selected_area.bottomRight().x()): self.mousePosition = MousePosition.ON_THE_DOWN_SIDE elif not self.selected_area.contains(point): self.mousePosition = MousePosition.OUTSIDE_AREA else: self.mousePosition = MousePosition.INSIDE_AREA
Example 26
Project: screenshot Author: SeptemberHX File: screenshot.py License: GNU General Public License v3.0 | 5 votes |
def drawEllipse(self, x1, x2, y1, y2, result): rect = self.selected_area.normalized() tmpRect = QRect(QPoint(x1, x2), QPoint(y1, y2)).normalized() resultRect = rect & tmpRect tmp = [ACTION_ELLIPSE, resultRect.topLeft().x(), resultRect.topLeft().y(), resultRect.bottomRight().x(), resultRect.bottomRight().y(), QPen(QColor(self.penColorNow), int(self.penSizeNow))] if result: self.drawListResult.append(tmp) else: self.drawListProcess = tmp
Example 27
Project: screenshot Author: SeptemberHX File: screenshot.py License: GNU General Public License v3.0 | 5 votes |
def textChange(self): if self.textPosition is None: return self.text = self.textInput.getText() self.drawListProcess = [ACTION_TEXT, str(self.text), QFont(self.fontNow), QPoint(self.textPosition), QColor(self.penColorNow)] self.redraw()
Example 28
Project: screenshot Author: SeptemberHX File: screenshot.py License: GNU General Public License v3.0 | 5 votes |
def okInput(self): self.text = self.textInput.getText() self.drawListResult.append( [ACTION_TEXT, str(self.text), QFont(self.fontNow), QPoint(self.textPosition), QColor(self.penColorNow)]) self.textPosition = None self.textRect = None self.textInput.hide() self.textInput.clearText() self.redraw()
Example 29
Project: qhangups Author: xmikos File: conversationwidget.py License: GNU General Public License v3.0 | 5 votes |
def scroll_messages(self, position=None): """Scroll list of messages to given position (or to the bottom if not specified)""" frame = self.messagesWebView.page().mainFrame() if position is None: position = frame.scrollBarMaximum(QtCore.Qt.Vertical) frame.setScrollPosition(QtCore.QPoint(0, position))
Example 30
Project: Lector Author: BasioMeusPuga File: metadatadialog.py License: GNU General Public License v3.0 | 5 votes |
def generate_display_position(self, mouse_cursor_position): size = self.size() desktop_size = QtWidgets.QDesktopWidget().screenGeometry() display_x = mouse_cursor_position.x() display_y = mouse_cursor_position.y() if display_x + size.width() > desktop_size.width(): display_x = desktop_size.width() - size.width() if display_y + size.height() > desktop_size.height(): display_y = desktop_size.height() - size.height() return QtCore.QPoint(display_x, display_y)