Python PyQt5.QtCore.QPoint() Examples
The following are 30
code examples of PyQt5.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
PyQt5.QtCore
, or try the search function
.
Example #1
Source File: screenshot.py From screenshot with GNU General Public License v3.0 | 20 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
Source File: mpv_opengl.py From kawaii-player with GNU General Public License v3.0 | 11 votes |
def send_fake_event(self, val): self.fake_mousemove_event = ("libmpv", True) pos = self.cursor().pos() if not self.pointer_moved: new_point = QtCore.QPoint(pos.x() + 1, pos.y()) self.pointer_moved = True else: new_point = QtCore.QPoint(pos.x() - 1, pos.y()) self.pointer_moved = False self.cursor().setPos(new_point) if val == "mouse_release": event = QtGui.QMouseEvent( QtCore.QEvent.MouseButtonRelease, new_point, QtCore.Qt.LeftButton, QtCore.Qt.LeftButton, QtCore.Qt.NoModifier, ) elif val == "mouse_move": event = QtGui.QMouseEvent( QtCore.QEvent.MouseMove, new_point, QtCore.Qt.NoButton, QtCore.Qt.NoButton, QtCore.Qt.NoModifier, ) self.ui.gui_signals.mouse_move_method((self, event))
Example #3
Source File: screenshot.py From screenshot with GNU General Public License v3.0 | 8 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 #4
Source File: electrodeGUI.py From simnibs with 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 #5
Source File: FeatureExtractionForm.py From FAE with 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 #6
Source File: head_model_OGL.py From simnibs with 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 #7
Source File: stubs.py From qutebrowser with 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 #8
Source File: suite.py From mhw_armor_edit with 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 #9
Source File: CDrawer.py From CustomWidgets with 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 #10
Source File: about.py From persepolis with 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 #11
Source File: webkittab.py From qutebrowser with 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 #12
Source File: widgets.py From pychemqt with 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 #13
Source File: Polar.py From nanovna-saver with 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 #14
Source File: PointingRectangle.py From Uranium with 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 #15
Source File: visual.py From stytra with GNU General Public License v3.0 | 5 votes |
def paint(self, p, w, h): x, y = ( (np.arange(d) - d / 2) * self._experiment.calibrator.mm_px for d in (w, h) ) self.image = np.round( np.sin( np.sqrt((x[None, :] ** 2 + y[:, None] ** 2) * (2 * np.pi / self.period)) + self.phase ) * 127 + 127 ).astype(np.uint8) p.drawImage(QPoint(0, 0), qimage2ndarray.array2qimage(self.image))
Example #16
Source File: plugin.py From FeelUOwn with GNU General Public License v3.0 | 5 votes |
def paintEvent(self, e): super().paintEvent(e) painter = QPainter(self) font = painter.font() pen = painter.pen() font.setPointSize(8) pen.setColor(QColor('grey')) painter.setFont(font) painter.setPen(pen) painter.setRenderHint(QPainter.Antialiasing) x = self.width() - 20 y = self.height() - 5 bottomright = QPoint(x, y) text = '{}/{}'.format(self._enabled_count, self._total_count) painter.drawText(bottomright, text)
Example #17
Source File: visual.py From stytra with GNU General Public License v3.0 | 5 votes |
def draw_block(self, p, point, w, h): # Painting settings: p.setPen(Qt.NoPen) p.setRenderHint(QPainter.Antialiasing) # Here for changing black with another color (to be debugged) # p.setBrush(QBrush(QColor(*self.color_2))) # # p.drawRect(QRect(-1, -1, (w + 2)*1.5, (h + 2)*1.5)) p.setBrush(QBrush(QColor(*self.color))) # To draw a windmill, a set of consecutive triangles will be painted: mid_x = int(w / 2) # calculate image center mid_y = int(h / 2) # calculate angles for each triangle: angles = np.arange(0, np.pi * 2, (np.pi * 2) / self.n_arms) angles += np.pi / 2 + np.pi / (2 * self.n_arms) # angular width of the white arms, by default equal to dark ones size = np.pi / self.n_arms # radius of triangles (much larger than frame) rad = (w ** 2 + h ** 2) ** (1 / 2) # loop over angles and draw consecutive triangles for deg in np.array(angles): polyg_points = [ QPoint(mid_x, mid_y), QPoint(int(mid_x + rad * np.cos(deg)), int(mid_y + rad * np.sin(deg))), QPoint( int(mid_x + rad * np.cos(deg + size)), int(mid_y + rad * np.sin(deg + size)), ), ] polygon = QPolygon(polyg_points) p.drawPolygon(polygon)
Example #18
Source File: CFontIcon.py From CustomWidgets with GNU General Public License v3.0 | 5 votes |
def pixmap(self, size, mode, state): pixmap = QPixmap(size) pixmap.fill(Qt.transparent) self.paint(QPainter(pixmap), QRect(QPoint(0, 0), size), mode, state) return pixmap
Example #19
Source File: CColorPanel.py From CustomWidgets with GNU General Public License v3.0 | 5 votes |
def reset(self): self.blockSignals(True) self._color = QColor(Qt.red) self._pointerPos = self.rect().topRight() - QPoint(6, 6) self.update() self.blockSignals(False)
Example #20
Source File: CColorPanel.py From CustomWidgets with GNU General Public License v3.0 | 5 votes |
def mousePressEvent(self, event): # 鼠标按下更新小圆环位置 super(CColorPanel, self).mousePressEvent(event) self._pointerPos = event.pos() if self._image: self.colorChanged.emit(self._image.pixelColor( max(min(self._pointerPos.x(), self.width() - 1), 0), max(min(self._pointerPos.y(), self.height() - 1), 0) )) self._pointerPos -= QPoint(6, 6) self.update()
Example #21
Source File: Chart.py From nanovna-saver with GNU General Public License v3.0 | 5 votes |
def drawTitle(self, qp: QtGui.QPainter, position: QtCore.QPoint = None): if self.sweepTitle != "": qp.setPen(self.textColor) if position is None: qf = QtGui.QFontMetricsF(self.font()) width = qf.boundingRect(self.sweepTitle).width() position = QtCore.QPointF(self.width()/2 - width/2, 15) qp.drawText(position, self.sweepTitle)
Example #22
Source File: visual.py From stytra with GNU General Public License v3.0 | 5 votes |
def clip(self, p, w, h): """Clip image before painting Parameters ---------- p : QPainter object used for painting w : image width h : image height Returns ------- """ if self.clip_mask is not None: if isinstance(self.clip_mask, float): # centered circle a = QRegion( w / 2 - self.clip_mask * w, h / 2 - self.clip_mask * h, self.clip_mask * w * 2, self.clip_mask * h * 2, type=QRegion.Ellipse, ) p.setClipRegion(a) elif isinstance(self.clip_mask[0], tuple): # polygon points = [QPoint(int(w * x), int(h * y)) for (x, y) in self.clip_mask] p.setClipRegion(QRegion(QPolygon(points))) else: p.setClipRect( self.clip_mask[0] * w, self.clip_mask[1] * h, self.clip_mask[2] * w, self.clip_mask[3] * h, )
Example #23
Source File: stimulus_display.py From stytra with GNU General Public License v3.0 | 5 votes |
def paintEvent(self, QPaintEvent): p = QPainter(self) p.setBrush(QBrush(QColor(0, 0, 0))) w = self.width() h = self.height() if self.display_state: if self.protocol_runner is not None: if self.protocol_runner.running: try: self.protocol_runner.current_stimulus.paint(p, w, h) except AttributeError: pass else: p.drawRect(QRect(-1, -1, w + 2, h + 2)) p.setRenderHint(QPainter.SmoothPixmapTransform, 1) if self.img is not None: p.drawImage(QPoint(0, 0), self.img) if self.calibrator is not None: if self.calibrator.enabled: self.calibrator.paint_calibration_pattern(p, h, w) p.end()
Example #24
Source File: stimulus_display.py From stytra with GNU General Public License v3.0 | 5 votes |
def paintEvent(self, QPaintEvent): """Generate the stimulus that will be displayed. A QPainter object is defined, which is then passed to the current stimulus paint function for drawing the stimulus. Parameters ---------- QPaintEvent : Returns ------- """ p = QPainter(self) p.setBrush(QBrush(QColor(0, 0, 0))) w = self.width() h = self.height() if self.protocol_runner is not None: if self.protocol_runner.running: try: self.protocol_runner.current_stimulus.paint(p, w, h) except AttributeError: pass else: p.drawRect(QRect(-1, -1, w + 2, h + 2)) p.setRenderHint(QPainter.SmoothPixmapTransform, 1) if self.img is not None: p.drawImage(QPoint(0, 0), self.img) if self.calibrator is not None: if self.calibrator.enabled: self.calibrator.paint_calibration_pattern(p, h, w) p.end()
Example #25
Source File: __init__.py From stytra with GNU General Public License v3.0 | 5 votes |
def paint_calibration_pattern(self, p, h, w, draw=True): """ Parameters ---------- p : h : w : draw : (Default value = True) Returns ------- """ assert isinstance(p, QPainter) d2h = self.triangle_length // 2 d2w = int(self.triangle_length * math.sqrt(3) // 2) ch = h // 2 cw = w // 2 # the three points sorted in ascending angle order (30, 60, 90) centres = [(cw - d2h, ch + d2w), (cw + d2h, ch + d2w), (cw - d2h, ch - d2w)] centres = np.array(centres) self.points = centres[np.argsort(CircleCalibrator._find_angles(centres)), :] if draw: p.setPen(QPen(QColor(255, 0, 0))) p.setBrush(QBrush(QColor(255, 0, 0))) for centre in centres: p.drawEllipse(QPoint(*centre), self.r, self.r)
Example #26
Source File: __init__.py From stytra with GNU General Public License v3.0 | 5 votes |
def paint_calibration_pattern(self, p, h, w): """ Parameters ---------- p : h : w : Returns ------- """ p.setPen(QPen(QColor(255, 0, 0))) if self.transparent: p.setBrush(QBrush(QColor(0, 0, 0, 0))) else: p.setBrush(QBrush(QColor(0, 0, 0, 255))) p.drawRect(QRect(1, 1, w - 2, h - 2)) l2 = self.length_px / 2 cw = w // 2 ch = h // 2 # draw the cross and the axis labels p.drawLine(cw - l2, ch, cw + l2, h // 2) p.drawText(w * 3 // 4, ch - 5, "x") p.drawLine(cw, h // 2 + l2, cw, ch - l2) p.drawText(cw + 5, h * 3 // 4, "y") # draw the "fish outline" p.drawEllipse(cw - 5, ch - 8, 3, 5) p.drawEllipse(cw + 2, ch - 8, 3, 5) p.drawPolygon( QPolygon( [QPoint(cw - 3, ch + 2), QPoint(cw + 3, ch + 2), QPoint(cw, ch + 20)] ) )
Example #27
Source File: base.py From pdfdir with GNU General Public License v3.0 | 5 votes |
def base_pos(self): """ If this class is inherited by a child widget, you should set instance.base_pos = parent.pos() """ if self.parents: self._base_pos = QPoint() for p in self.parents: self._base_pos += p.pos() return self._base_pos
Example #28
Source File: main_window.py From Blender-Version-Manager with GNU General Public License v3.0 | 5 votes |
def mouseMoveEvent(self, event): if self.pressing: delta = QPoint(event.globalPos() - self.old_pos) self.move(self.x() + delta.x(), self.y() + delta.y()) self.old_pos = event.globalPos()
Example #29
Source File: thread_fun_dlg.py From dash-masternode-tool with MIT License | 5 votes |
def centerByWindow(self, center_by_window: QDialog): """ Centers this window by window given by attribute 'center_by_window' :param center_by_window: Reference to (parent) window by wich this window will be centered. :return: None """ if self.center_by_window: pg: QPoint = center_by_window.frameGeometry().topLeft() size_diff = center_by_window.rect().center() - self.rect().center() pg.setX( pg.x() + int((size_diff.x()))) pg.setY( pg.y() + int((size_diff.y()))) self.move(pg)
Example #30
Source File: player.py From MusicBox with MIT License | 5 votes |
def moveEvent(self, event): # self.emit(SIGNAL("lyricmoved(QPoint)"), event.pos() - event.oldPos()) self.lyricmoved.emit(QPoint(event.pos() - event.oldPos()))