{qti{qti's插件有一个没有背景的qti图形。我正在尝试设置背景色,它只在我用QGIS插件重新加载插件后加载(这个插件是为开发插件的人设计的,所以在代码发生任何更改后,您可以刷新并将一个新的插件加载到QGIS中。普通用户不使用它。在
我的代码如下:
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
pyqtgraph documentation说明了
setConfigOption
设置,即:在我的密码里
这就是我认为的“之前”的地方,但这是一个对象的创建,而不是小部件。应该在类中编写
setConfigOption
,该类负责存储pyqtgraph
对象。在我的例子中,__init__
函数在一个单独的文件中创建了一个单独的对话框:从PyQt4导入QtGui,QtCore 从plugin4“绘图”窗口小部件“导入Ui”对话框 从plugin4_对话框导入plugin4Dialog 导入pyqtgraph
^{pr2}$相关问题 更多 >
编程相关推荐