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

Skip to content

Commit 365a0a2

Browse files
committed
Merged revisions 3831-3835 via svnmerge from
http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib ........ r3832 | dsdale | 2007-09-11 14:46:47 -0400 (Tue, 11 Sep 2007) | 3 lines removed MANIFEST from revision control. It is generated by MANIFEST.in when building source distribution archives ........ r3833 | jrevans | 2007-09-11 15:40:27 -0400 (Tue, 11 Sep 2007) | 5 lines Added the ability for the following in the various GUI backends: >>> import pylab >>> fig = pylab.figure() >>> fig.canvas.set_window_title("My Plot Window") ........ r3834 | jouni | 2007-09-12 03:04:38 -0400 (Wed, 12 Sep 2007) | 3 lines Further development of dviread. It now attempts to read virtual fonts, but the positioning is still somewhat off. ........ svn path=/branches/transforms/; revision=3836
1 parent 634c7bc commit 365a0a2

10 files changed

Lines changed: 249 additions & 1447 deletions

File tree

MANIFEST

Lines changed: 0 additions & 1398 deletions
This file was deleted.

lib/matplotlib/backend_bases.py

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

1212+
def set_window_title(self, title):
1213+
"""
1214+
Set the title text of the window containing the figure. Note that
1215+
this has no effect if there is no window (eg, a PS backend).
1216+
"""
1217+
if hasattr(self, "manager"):
1218+
self.manager.set_window_title(title)
1219+
12121220
def switch_backends(self, FigureCanvasClass):
12131221
"""
12141222
instantiate an instance of FigureCanvasClass
@@ -1321,6 +1329,13 @@ def show_popup(self, msg):
13211329
"""
13221330
pass
13231331

1332+
def set_window_title(self, title):
1333+
"""
1334+
Set the title text of the window containing the figure. Note that
1335+
this has no effect if there is no window (eg, a PS backend).
1336+
"""
1337+
pass
1338+
13241339
# cursors
13251340
class Cursors: #namespace
13261341
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_pdf.py

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ def _write_afm_font(self, filename):
491491
return fontdictObject
492492

493493
def embedType1(self, filename, fontinfo):
494+
# TODO: font effects such as SlantFont
494495
fh = open(filename, 'rb')
495496
matplotlib.verbose.report(
496497
'Embedding Type 1 font ' + filename, 'debug')
@@ -520,8 +521,15 @@ def embedType1(self, filename, fontinfo):
520521

521522
if fontinfo.encodingfile is not None:
522523
enc = dviread.Encoding(fontinfo.encodingfile)
523-
widths = [ afmdata.get_width_from_char_name(ch)
524-
for ch in enc ]
524+
widths = []
525+
for ch in enc:
526+
try:
527+
widths.append(afmdata.get_width_from_char_name(ch))
528+
except KeyError:
529+
matplotlib.verbose.report(
530+
'No width for %s in %s' % (ch, fullname), 'debug')
531+
widths.append(0)
532+
525533
differencesArray = [ Name(ch) for ch in enc ]
526534
differencesArray = [ 0 ] + differencesArray
527535
firstchar = 0
@@ -538,11 +546,24 @@ def embedType1(self, filename, fontinfo):
538546
firstchar = not_None.next()
539547
lastchar = max(not_None)
540548
widths = widths[firstchar:lastchar+1]
549+
for i,w in enumerate(widths):
550+
if w is None: widths[i] = 0
541551

542-
differencesArray = [ firstchar ]
552+
differencesArray = [ ]
553+
need_idx = True
543554
for ch in range(firstchar, lastchar+1):
544-
differencesArray.append(Name(
545-
afmdata.get_name_char(ch, isord=True)))
555+
try:
556+
name = afmdata.get_name_char(ch, isord=True)
557+
if need_idx:
558+
differencesArray.append(ch)
559+
need_idx = False
560+
differencesArray.append(Name(name))
561+
except KeyError:
562+
matplotlib.verbose.report(
563+
'No name for glyph %d in %s' % (ch, fullname),
564+
'debug')
565+
need_idx = True
566+
546567

547568
fontdict = {
548569
'Type': Name('Font'),
@@ -1448,17 +1469,16 @@ def mytrans(x1, y1, x=x, y=y, a=angle / 180.0 * pi):
14481469

14491470
# Gather font information and do some setup for combining
14501471
# characters into strings.
1451-
oldfontnum, seq = None, []
1452-
for x1, y1, fontnum, glyph, width in page.text:
1453-
if fontnum != oldfontnum:
1454-
texname, fontsize = dvi.fontinfo(fontnum)
1455-
fontinfo = self.tex_font_mapping(texname)
1472+
oldfont, seq = None, []
1473+
for x1, y1, dvifont, glyph, width in page.text:
1474+
if dvifont != oldfont:
1475+
fontinfo = self.tex_font_mapping(dvifont.texname)
14561476
pdfname = self.file.fontName(fontinfo.filename)
14571477
self.file.fontInfo[pdfname] = Bunch(
14581478
encodingfile=fontinfo.encoding,
14591479
afmfile=fontinfo.afm)
1460-
seq += [['font', pdfname, fontsize]]
1461-
oldfontnum = fontnum
1480+
seq += [['font', pdfname, dvifont.size]]
1481+
oldfont = dvifont
14621482
seq += [['text', x1, y1, [chr(glyph)], x1+width]]
14631483
seq += [('end',)]
14641484

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
@@ -350,6 +350,9 @@ def destroy(self, *args):
350350
pass
351351
self.window = None
352352

353+
def set_window_title(self, title):
354+
self.window.wm_title(title)
355+
353356
class AxisMenu:
354357
def __init__(self, master, naxes):
355358
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)