Reputation: 491
I found that matplotlib's NavigationToolbar2Tk
'configure plot' window is being pulled from widgets.py
for ref: https://matplotlib.org/2.0.2/mpl_examples/pylab_examples/subplot_toolbar_01.pdf
The title for this window is Click on slider to adjust subplot param
Please advice me how to change its icon from default tkinter
icon.
self.axleft = toolfig.add_subplot(711)
self.axleft.set_title('Click on slider to adjust subplot param')
self.icon = self.resource_path('icon.ico')
self.axleft.icon_bitmap = ImageTk.PhotoImage(Image.open(self.icon))
self.axleft.wm_iconbitmap(self.icon)
self.axleft.set_navigate(False)
I changed the above code starting in line 1115 in widgets.py
. Here self.resource_path
is a method I created to find the icon's path.
But getting error as subplots don't have the method wm_icon_bitmap
Upvotes: 0
Views: 529
Reputation: 491
As @ImportanceOfBeingErnest pointed out.. I had to modify the configure_subplots
method in _backend_tk.py. Used the wm_icon_bitmap method
for the Toplevel widget.
def configure_subplots(self):
toolfig = Figure(figsize=(6,3))
window = Tk.Toplevel()
icon = self.resource_path('icon.ico')
window.icon_bitmap = ImageTk.PhotoImage(Image.open(icon))
window.wm_iconbitmap(icon)
canvas = type(self.canvas)(toolfig, master=window)
toolfig.subplots_adjust(top=0.9)
canvas.tool = SubplotTool(self.canvas.figure, toolfig)
canvas.draw()
canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
window.grab_set()
Upvotes: 1