Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 889a360

Browse files
author
James Evans
committed
Added the ability for the following in the various GUI backends:
>>> import pylab >>> fig = pylab.figure() >>> fig.canvas.set_window_title("My Plot Window") svn path=/trunk/matplotlib/; revision=3833
1 parent 7894bf9 commit 889a360

7 files changed

Lines changed: 32 additions & 0 deletions

File tree

lib/matplotlib/backend_bases.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,14 @@ def print_figure(self, filename, dpi=None, facecolor='w', edgecolor='w',
12051205
def get_default_filetype(self):
12061206
raise NotImplementedError
12071207

1208+
def set_window_title(self, title):
1209+
"""
1210+
Set the title text of the window containing the figure. Note that
1211+
this has no effect if there is no window (eg, a PS backend).
1212+
"""
1213+
if hasattr(self, "manager"):
1214+
self.manager.set_window_title(title)
1215+
12081216
def switch_backends(self, FigureCanvasClass):
12091217
"""
12101218
instantiate an instance of FigureCanvasClass
@@ -1317,6 +1325,13 @@ def show_popup(self, msg):
13171325
"""
13181326
pass
13191327

1328+
def set_window_title(self, title):
1329+
"""
1330+
Set the title text of the window containing the figure. Note that
1331+
this has no effect if there is no window (eg, a PS backend).
1332+
"""
1333+
pass
1334+
13201335
# cursors
13211336
class Cursors: #namespace
13221337
HAND, POINTER, SELECT_REGION, MOVE = range(4)

lib/matplotlib/backends/backend_fltkagg.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@ def show(self):
299299
self.canvas.draw()
300300
self.window.redraw()
301301

302+
def set_window_title(self, title):
303+
self.window_title=title
304+
self.window.label(title)
302305

303306
class AxisMenu:
304307
def __init__(self, toolbar):

lib/matplotlib/backends/backend_gtk.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,8 @@ def _get_toolbar(self, canvas):
460460
toolbar = None
461461
return toolbar
462462

463+
def set_window_title(self, title):
464+
self.window.set_title(title)
463465

464466
def resize(self, width, height):
465467
'set the canvas size in pixels'

lib/matplotlib/backends/backend_qt.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ def destroy( self, *args ):
247247
if DEBUG: print "destroy figure manager"
248248
self.window.close(True)
249249

250+
def set_window_title(self, title):
251+
self.window.setCaption(title)
252+
250253
class NavigationToolbar2QT( NavigationToolbar2, qt.QWidget ):
251254
# list of toolitems to add to the toolbar, format is:
252255
# text, tooltip_text, image_file, callback(str)

lib/matplotlib/backends/backend_qt4.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ def destroy( self, *args ):
249249
if DEBUG: print "destroy figure manager"
250250
self.window.close()
251251

252+
def set_window_title(self, title):
253+
self.window.setWindowTitle(title)
254+
252255
class NavigationToolbar2QT( NavigationToolbar2, QtGui.QWidget ):
253256
# list of toolitems to add to the toolbar, format is:
254257
# text, tooltip_text, image_file, callback(str)

lib/matplotlib/backends/backend_tkagg.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,9 @@ def destroy(self, *args):
349349
pass
350350
self.window = None
351351

352+
def set_window_title(self, title):
353+
self.window.wm_title(title)
354+
352355
class AxisMenu:
353356
def __init__(self, master, naxes):
354357
self._master = master

lib/matplotlib/backends/backend_wx.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,6 +1399,9 @@ def destroy(self, *args):
13991399
#wx.GetApp().ProcessIdle()
14001400
wx.WakeUpIdle()
14011401

1402+
def set_window_title(self, title):
1403+
self.window.SetTitle(title)
1404+
14021405
# Identifiers for toolbar controls - images_wx contains bitmaps for the images
14031406
# used in the controls. wxWindows does not provide any stock images, so I've
14041407
# 'stolen' those from GTK2, and transformed them into the appropriate format.

0 commit comments

Comments
 (0)