我看到我不是the only one在pyqtgraph中有一个背景颜色问题 - 我正在编写一个QGIS软件插件,它带有一个带有图形的附加对话框。我试图设置背景颜色,并且只在使用QGIS Plugin Reloader插件重新加载插件之后才加载(这个插件是为开发插件的人制作的,所以在代码发生任何更改后,刷新并加载一个新插件到QGIS中,它不被普通用户使用)。pyqtgraph - 仅在重新加载后才加载背景颜色
我的下面这段代码:
import pyqtgraph
...
def prepareGraph(self): # loads on button click
self.graphTitle = 'Graph one'
# prepare data - simplified, but data display correctly
self.y = something
self.x = something_else
self.buildGraph()
def buildGraph(self):
""" Add data to the graph """
pyqtgraph.setConfigOption('background', (230,230,230))
pyqtgraph.setConfigOption('foreground', (100,100,100))
dataColor = (102,178,255)
dataBorderColor = (180,220,255)
barGraph = self.graph.graphicsView
barGraph.clear()
barGraph.addItem(pyqtgraph.BarGraphItem(x=range(len(self.x)), height=self.y, width=0.5, brush=dataColor, pen=dataBorderColor))
barGraph.addItem(pyqtgraph.GridItem())
barGraph.getAxis('bottom').setTicks([self.x])
barGraph.setTitle(title=self.graphTitle)
self.showGraph()
def showGraph(self):
self.graph.show()
有趣的是,没有任何问题,(即使前景色!)所有buildGraph()
负荷的零件只有背景颜色不会。
这是一个已知的错误还是设置前景色和背景色有区别?链接的问题并没有帮助我解决这个问题。
pyqtgraph==0.9.10 PyQt4==4.11.4 Python 2.7.3