def mousePressEvent(self, event: PySide2.QtGui.QMouseEvent): if not self.startFlag: return # event.pos() x = event.x() y = event.y() if x < 35 or x > 605: return if y < 35 or y > 605: return if self.chessmanboard[(y - 50 + 15) // 30][(x - 50 + 15) // 30]: return self.chessmanColor = not self.chessmanColor self.chessman = Chessman(self.chessmanColor, parent=self) x, y = self.chessman.getindex(x, y) self.chessmanboard[self.chessman.y_index][ self.chessman.x_index] = self.chessman # print(self.chessmanboard) self.chessman.move(x - 15, y - 15) self.chessman.show() self.record.append(self.chessman) self.regretFlag = True self.renjixiaqiFlag = True self.isWin(self.chessman) return True
def mouseReleaseEvent(self, event: PySide2.QtGui.QMouseEvent): if event.button() == Qt.LeftButton: p = event.pos() clip_panel = self.childAt(p) clipboard = QApplication.clipboard() if hasattr(clip_panel, 'text'): text = clip_panel.text() clipboard.setText(text)
def mousePressEvent(self, event: PySide2.QtGui.QMouseEvent) -> None: super().mousePressEvent(event) if event.button() == Qt.RightButton: menu = QMenu() menu.addAction("Delete", self.delete_layer) menu.addAction("Edit Layer", self.edit_layer) if isinstance(self._layer, AnnotationLayer): menu.addAction("Export .GeoJSON", self.export_path_json) menu.exec_(event.globalPos())
def mouseReleaseEvent(self, event: PySide2.QtGui.QMouseEvent): coord_x = event.x() # 获得鼠标X坐标 coord_y = event.y() # 获得鼠标Y坐标 # print('zuobiao{} {}'.format(coord_x,coord_y)) # 坐标转换位置 pos = self.reverse_to_position((coord_x, coord_y)) # 如果位置有效,发送落子信号 if pos is None: return else: self.position_signal.emit(pos)
def mousePressEvent(self, event: PySide2.QtGui.QMouseEvent) -> None: super().mousePressEvent(event) from seedpod_ground_risk.layers.pathfinding_layer import PathfindingLayer if event.button() == Qt.RightButton: menu = QMenu() menu.addAction("Delete", self.delete_layer) menu.addAction("Edit Layer", self.edit_layer) if isinstance(self._layer, AnnotationLayer): menu.addAction("Export .GeoJSON", self.export_path_json) if isinstance(self._layer, PathfindingLayer): menu.addAction("Show path data", self.path_data) menu.exec_(event.globalPos())
def mouseMoveEvent(self, event: PySide2.QtGui.QMouseEvent): if self.startFlag & self.doingFlag: self.show_widget.show() self.mouse_current_x = event.globalX() self.mouse_current_y = event.globalY() pointTopLeft = QPoint( min(self.mouse_start_x, self.mouse_current_x), min(self.mouse_start_y, self.mouse_current_y)) pointBottomRight = QPoint( max(self.mouse_start_x, self.mouse_current_x), max(self.mouse_start_y, self.mouse_current_y)) self.draw_signal.emit(pointTopLeft, pointBottomRight)
def mouseReleaseEvent(self, event: PySide2.QtGui.QMouseEvent): ''' 处理鼠标释放事件 ''' coord_x = event.x() # 获得鼠标x坐标 coord_y = event.y() # 坐标转换成位置 pos = self.reverse_to_position((coord_x, coord_y)) # 如果位置有效,则发送落子信号 if pos is None: return else: self.position_signal.emit(pos)
def mousePressEvent(self, event: PySide2.QtGui.QMouseEvent): x = event.x() y = event.y() self.chessman = Chessman(self.chessmanColor, parent=self) x, y = self.chessman.getindex(x, y) if self.chessboard[self.chessman.y_index][ self.chessman.x_index] == None: super().mousePressEvent(event) if self.xiaqiflag == True: if x < 50 - 15 or x > 590 + 15: return if y < 50 - 15 or y > 590 + 15: return # if self.chessboard[self.chessman.y_index][self.chessman.x_index]==None: self.autoPlay()
def mouseReleaseEvent(self, event: PySide2.QtGui.QMouseEvent): if event.button() == Qt.RightButton: index = self.indexAt(event.pos()) if index.isValid(): node = index.internalPointer() action = self.menu.exec_(self.mapToGlobal(event.pos())) if action == self.action_export_buffer: file_path, _ = QFileDialog.getSaveFileName( self, "Save file") file = open(file_path, "wb") file.write(node.buffer) file.close() else: super(ObjectTree, self).mouseReleaseEvent(event)
def mouseMoveEvent(self, event: PySide2.QtGui.QMouseEvent): if not self.is_grab: return self.check_screen() pos = event.screenPos().toPoint() if pos.x() < self.geometry().left(): self.move(self.pos() + QPoint(pos.x() - self.geometry().left(), 0)) elif pos.x() > self.geometry().right(): self.move(self.pos() + QPoint(pos.x() - self.geometry().right(), 0))
def mousePressEvent(self, event: PySide2.QtGui.QMouseEvent): # event.pos() x = event.x() y = event.y() if self.xiaqiflag == True: # 判断 - 如果超出返回,直接返回,不做任何操作 if x < 50 - 15 or x > 590 + 15: return if y < 50 - 15 or y > 590 + 15: return if self.chessboard[(y - 50 + 15) // 30][(x - 50 + 15) // 30]: return # chessmanColor 记录了当前棋子颜色,当前是白色,那么下一个棋子因为黑色 self.chessmanColor = not self.chessmanColor # 实例化一个棋子 self.chessman = Chessman(self.chessmanColor, parent=self) # 计算棋子棋盘坐标和数组索引,返回棋盘坐标 x, y = self.chessman.getindex(x, y) # 移动并显示棋子 self.chessman.move(x - 15, y - 15) self.chessman.show() # self.biaoshi.move(x,y) # self.biaoshi.show() # 棋子添加到二维数组中 # self.chessboard[self.chessman.y_index][self.chessman.x_index] = self.chessman if self.chessboard[self.chessman.y_index][ self.chessman.x_index] == None: self.chessboard[self.chessman.y_index][ self.chessman.x_index] = self.chessman self.record.append(self.chessman) else: self.chessman.deleteLater() self.chessmanColor = not self.chessmanColor # self.lastchessman = self.chessman # 判断输赢 self.isWin(self.chessman) return True
def mouseMoveEvent(self, event: PySide2.QtGui.QMouseEvent): return if event.button() & Qt.MouseButton.NoButton == Qt.MouseButton.NoButton: if self.ui.btnClose.underMouse() or self.ui.btnMinimize.underMouse( ): event.accept() return vec = event.globalPos() - self.mouse_pos self.parent_window.move(self.window_pos + vec) event.accept()
def mousePressEvent(self, e: PySide2.QtGui.QMouseEvent): QPushButton.mousePressEvent(self, e) if e.button() == Qt.LeftButton: print("Press")
def mouseReleaseEvent(self, event: PySide2.QtGui.QMouseEvent) -> None: super().mouseReleaseEvent(event) self.tablica_1.mouse_released(event.x(), event.y()) self.tablica_2.mouse_released(event.x(), event.y())
def mousePressEvent(self, event: PySide2.QtGui.QMouseEvent): if event.button() == Qt.LeftButton: self.mouse_pos = event.globalPos( ) #event.globalPos() - self.geometry().topLeft() - self.parent_window.geometry().topLeft() self.window_pos = self.parent_window.frameGeometry().topLeft() event.accept()
def mousePressEvent(self, ev: PySide2.QtGui.QMouseEvent): if ev.button() == Qt.LeftButton: if self.reward_count > 1: print(self.reward_text)