【发布时间】:2018-06-12 13:36:41
【问题描述】:
我有一个包含多个节点的图表。一旦用户单击任何节点,图形应该以这样的方式双曲线化,即单击的节点应该位于图形的中心(通常是 2D 坐标系原点的位置)。当我单击时,图中没有更新,但是节点(散点)的新坐标值会在本地保存的文件中更新。下面是用于渲染和更新的函数。
# Function to render the H2 tree map embedded in Poincare disc
def render_h2_tree(positions):
global adj
global nodeText
# Configuring the PyQt graphic window
pg.setConfigOption('background', 'k')
pg.setConfigOption('foreground', 'w')
pg.setConfigOptions(antialias=True)
w = pg.GraphicsWindow() # creating an instance of the PyQt GraphicsWindow
w.setWindowTitle('H2 tree for Emails') # set the title of the graphic window
v = w.addViewBox() # add a view box to the graphic window
v.setAspectLocked()
g = Graph() # create an instance of the class Graph
v.addItem(g) # add the created graph instance to the view box
g.setData(pos=positions, adj=adj, size=0.01, pxMode=False, text=nodeText) # set the node in the graphic window
# Start Qt event loop unless running in interactive mode or using pyside.
import sys
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
QtGui.QApplication.instance().exec_()
我在这里做错了什么?谢谢。
【问题讨论】: