Advertisement
Vladlslav

Untitled

Aug 25th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. class MyRect(QGraphicsRectItem):
  2.  
  3. def mousePressEvent(self, event):
  4. event.accept() if MainScreen.click1 else event.ignore()
  5.  
  6.  
  7. def mouseReleaseEvent(self, event):
  8. coord = event.buttonDownScenePos(Qt.LeftButton)
  9. obj=MyEllipse.last_click[2]
  10. x1=MyEllipse.last_click[0]
  11. y1=MyEllipse.last_click[1]
  12. x2 = coord.x()
  13. y2 = coord.y()
  14. MainScreen.moving(obj,x1,x2,y1,y2)
  15.  
  16.  
  17. class MainScreen():
  18. click1 = False
  19. click2 = False
  20.  
  21. @staticmethod
  22. def moving(obj,x1,x2,y1,y2):
  23. '''moving figure from one place to another
  24. we must know figure which is on the x2 y2 coord, then
  25. we must kmow its normal coord ... and after it replace ellipse'''
  26. item = get_scene().itemAt(x2,y2)
  27. print(item)
  28. obj.setRect(x2,y2,50,50)
  29.  
  30.  
  31. def get_scene(self):
  32. return self.scene
  33.  
  34. def setupMS(self,MainWindow):
  35.  
  36. self.scene=QGraphicsScene()
  37. self.scene.setSceneRect(0,0,600,600)
  38. self.create_icons()
  39. self.create_checkers()
  40. self.labels_create()
  41.  
  42. checkers = self.object_checkers()
  43. white_checkers = checkers[:13]
  44. black_checkers = checkers[13:]
  45. white_checkers[0].hide()
  46. print(type(white_checkers[0]))
  47.  
  48. self.view = QGraphicsView(self.scene)
  49.  
  50. self.view.centerOn(0,0)
  51.  
  52. self.view.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement