Change icon in a Matplotlib figure window

前端 未结 5 1175
难免孤独
难免孤独 2020-12-11 05:18

Is it possible to change the icon of a Matplotlibe figure window? My application has a button that opens a Figure window with a graph (created with Matplotlib). I managed to

5条回答
  •  爱一瞬间的悲伤
    2020-12-11 05:51

    I found that under OS X with PyQT5, doing plt.get_current_fig_manager().window.setWindowIcon() has no effect. To get the dock icon to change you have to call setWindowIcon() on the QApplication instance, not on the window.

    What worked for me is:

    QApplication.instance().setWindowIcon(QtGui.QIcon(icon_path))
    

    Do mind that QApplication.instance() will be None until you have actually created a figure, so do that first.

提交回复
热议问题