我有一个pyQt应用程序,其中包含几个嵌入式matplotlib小部件(https://github.com/chipmuenk/pyFDA)。在
可以为每个绘图小部件关闭绘图的自动更新,以加快应用程序的速度(尤其是三维绘图可能需要相当长的时间)。在
不幸的是,我还没有完全禁用画布。我想做的是
class MplWidget(QWidget):
"""
Construct a subwidget with Matplotlib canvas and NavigationToolbar
"""
def __init__(self, parent):
super(MplWidget, self).__init__(parent)
# Create the mpl figure and construct the canvas with the figure
self.fig = Figure()
self.pltCanv = FigureCanvas(self.fig)
#-------------------------------------------------
self.mplwidget = MplWidget(self)
self.mplwidget.pltCanv.setEnabled(False) # <- this doesn't work
为了清楚地表明在这个小部件中没有什么可以交互的。有简单的解决方法吗?在
你可以在上面放一块灰色半透明的贴片,使它变灰。为此,您可以创建一个矩形,将其zorder设置得非常高,并对其进行图形转换。要将其添加到an轴,可以使用
ax.add_patch
;但是要将其添加到具有3D轴的图形中,这将不起作用,您需要通过fig.patches.extend
添加它。(见this answer)断开所有事件
您可以断开所有事件与画布的连接。这将阻止任何用户交互,但也是不可逆的;因此,如果您需要在稍后阶段返回这些事件,则解决方案将更加复杂。在
^{pr2}$相关问题 更多 >
编程相关推荐