python - How to animate a graph I've drawn in PyQt? -


So I have been able to get a graph that is ready on my screen like this:

  Class window (QWidget): #stuff graphicsView = QGraphicsView (own) view = QGraphicsScene (self) #dodo I limit our nodes and edges (0, len (MAIN_WORLD.currentMax.tour) - 1): node = QGraphicsRectItem (MAIN_WORLD.currentMax.tour [i] [0] / 3, MAIN_WORLD.currentMax.tour [i] [1] / 3, 5, 5) edge = QGraphicsLineItem (MAIN_WORLD.currentMax.tour [i] [0] / 3 , Man_warldkkarrentmaksktur [e] [1] / 3, Man_warldkkarrentmaksktur [e + 1] [0] / 3, Man_warldkkarrentmaksktur [e + 1] [1] / 3) Sinekadditem (Node) scene.addItem (edge) # now Apas go and drag our connecting edge. Ends Home node connectingEdge = QGraphicsLineItem (MAIN_WORLD.currentMax.tour [0] [0] / 3, MAIN_WORLD.currentMax.tour [0] [1] / 3, MAIN_WORLD.currentMax.tour [Lane (MAIN_WORLD.currentMax. Tour) - 1] [0] / 3, MAIN_WORLD.currentMax.tour [LAN (MAIN_WORLD.currentMax.tour) - 1] [1] / 3) scene.addItem (connectingEdge) graphicsView.setScene (view) hbox = QVBoxLayout ( Self) #some more content .. hbox.addWidget (graphicsView) self.setLayout (hbox)  

Now, the edges are going to be constantly updated, so I remove those edges and delete them Want to be able to create. How can I do this?

QGraphicsScene manages the drawing of the items you it is added if it went to change verses or lines of position, so you can update them if you are old at:

  i (category): nodes [i] = node = QGraphicsRectItem () Scene.add (node ​​[i])  

Later, you can update the status of a node:

  nodes [j] .setRect (Newx, newy, newwidth, newheight  

for lines similar.

Remove, you

  scene.removeItem (using nodes [22] are])  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -