Fix positioning of qgritems

master
LEdoian 2 years ago
parent 999f6988cb
commit 6c91be573e

@ -140,9 +140,14 @@ def create_qgritems(at):
x = pos.x x = pos.x
y = pos.y y = pos.y
shape = QtWidgets.QGraphicsRectItem(x, y, size, size) shape = QtWidgets.QGraphicsRectItem(-size/2, -size/2, size, size)
shape.setBrush(brush) shape.setBrush(brush)
shape.setPos(x, y)
label = QtWidgets.QGraphicsSimpleTextItem(rk, parent=shape) label = QtWidgets.QGraphicsSimpleTextItem(rk, parent=shape)
label.setY(size*0.8)
# Centering:
text_width = label.boundingRect().width()
label.setX(-text_width/2)
at.router_annotations[rk].append(shape) at.router_annotations[rk].append(shape)
for nk, n in topo.networks.items(): for nk, n in topo.networks.items():
@ -160,9 +165,14 @@ def create_qgritems(at):
x = pos.x x = pos.x
y = pos.y y = pos.y
shape = QtWidgets.QGraphicsRectItem(x, y, size, size) shape = QtWidgets.QGraphicsRectItem(-size/2, -size/2, size, size)
shape.setBrush(brush) shape.setBrush(brush)
shape.setPos(x, y)
label = QtWidgets.QGraphicsSimpleTextItem(nk, parent=shape) label = QtWidgets.QGraphicsSimpleTextItem(nk, parent=shape)
label.setY(size*0.8)
# Centering:
text_width = label.boundingRect().width()
label.setX(-text_width/2)
at.network_annotations[nk].append(shape) at.network_annotations[nk].append(shape)
for lk, l in topo.links.items(): for lk, l in topo.links.items():

Loading…
Cancel
Save