10000 matplotlib/matplotlib@cba39f4 · GitHub
[go: up one dir, main page]

Skip to content

Commit cba39f4

Browse files
committed
* Fixed embedding_in_wx and dynamic_demo_wx examples * Ported build to darwin * Tk: removed default figman=None from nav toolbar since it needs the figman fixed close bug small changes to aid darwin build svn path=/trunk/matplotlib/; revision=174
1 parent a5d42bf commit cba39f4

File tree

9 files changed

+107
-118
lines changed

9 files changed

+107
-118
lines changed

DEVNOTES

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ http://matplotlib.sourceforge.net
2828

2929
0) Turn off all the build flags
3030

31-
0) when building the win installer, comment out the import ttfquery in
32-
build_fonttools
31+
0) when building the win installer, make sure you specify
32+
--install-script postinstall.py
3333

3434
0) Run examples/batch_figs.py w/o errors; run the backend specific
3535
demos (object_picker, anim , embedding*)

MANIFEST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff li D7AE ne numberDiff line change
@@ -14,6 +14,7 @@ Makefile
1414
README
1515
TODO
1616
__init__.py
17+
postinstall.py
1718
setup.py
1819
setupext.py
1920
FontTools/__init__.py

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ include LICENSE LICENSE_PAINT API_CHANGES CHANGELOG KNOWN_BUGS GOALS INSTALL
22
include INTERACTIVE TODO
33
include Makefile MANIFEST.in MANIFEST
44
include .matplotlibrc
5-
include __init__.py setupext.py setup.py
5+
include __init__.py setupext.py setup.py postinstall.py
66
include examples/data/*
77
include images/*
88
include test/*.py

TODO

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,4 +262,6 @@
262262

263263
-- DONE 2004-03-02 - fix ft2font clipping on agg
264264

265-
-- DONE 2004-03-02 - why are aliased lines of varying widths on agg?
265+
-- DONE 2004-03-02 - why are aliased lines of varying widths on agg?
266+
267+
-- update dynamic_demo_wx

examples/dynamic_demo_wx.py

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,52 +19,65 @@
1919
2020
Modification History:
2121
$Log$
22+
Revision 1.3 2004/03/08 22:17:20 jdh2358
23+
* Fixed embedding_in_wx and dynamic_demo_wx examples
24+
25+
* Ported build to darwin
26+
27+
* Tk:
28+
29+
removed default figman=None from nav toolbar since it needs the
30+
figman
31+
32+
fixed close bug
33+
34+
small changes to aid darwin build
35+
2236
Revision 1.2 2004/02/26 20:22:58 jaytmiller
2337
Added the "numerix" Numeric/numarray selector module enabling matplotlib
2438
to work with either numarray or Numeric. See matplotlib.numerix.__doc__.
2539
2640
Revision 1.1 2003/12/30 17:22:09 jodonoghue
2741
First version of dynamic_demo for backend_wx
28-
2942
"""
3043

44+
3145
import matplotlib
3246
matplotlib.use('WX')
47+
from matplotlib.backends.backend_wx import Toolbar, FigureCanvasWx,\
48+
FigureManager
3349

34-
from matplotlib.backends import Figure, Toolbar, FigureManager
50+
from matplotlib.figure import Figure
3551
from matplotlib.axes import Subplot
3652
import matplotlib.numerix as numpy
37-
38-
from matplotlib.matlab import *
3953
from wxPython.wx import *
4054

55+
4156
TIMER_ID = wxNewId()
4257

4358
class PlotFigure(wxFrame):
59+
4460
def __init__(self):
4561
wxFrame.__init__(self, None, -1, "Test embedded wxFigure")
46-
self.fig = Figure(self, -1, (5,4), 75)
47-
self.toolbar = Toolbar(self.fig)
62+
63+
self.fig = Figure((5,4), 75)
64+
self.canvas = FigureCanvasWx(self, -1, self.fig)
65+
self.toolbar = Toolbar(self.canvas)
4866
self.toolbar.Realize()
4967

50-
# On Windows, default frame size behaviour is incorrect
68+
# On Windows, default frame size behaviour is incorrect
5169
# you don't need this under Linux
5270
tw, th = self.toolbar.GetSizeTuple()
53-
fw, fh = self.fig.GetSizeTuple()
71+
fw, fh = self.canvas.GetSizeTuple()
5472
self.toolbar.SetSize(wxSize(fw, th))
55-
73+
5674
# Create a figure manager to manage things
57-
self.figmgr = FigureManager(self.fig, 1, self)
58-
75+
self.figmgr = FigureManager(self.canvas, 1, self)
5976
# Now put all into a sizer
6077
sizer = wxBoxSizer(wxVERTICAL)
61-
# This way of adding to sizer prevents resizing
62-
#sizer.Add(self.fig, 0, wxLEFT|wxTOP)
63-
64-
# This way of adding to sizer allows resizing
65-
sizer.Add(self.fig, 1, wxLEFT|wxTOP|wxGROW)
66-
67-
# Best to allow the toolbar to resize!
78+
# This way of adding to sizer allows resizing
79+
sizer.Add(self.canvas, 1, wxLEFT|wxTOP|wxGROW)
80+
# Best to allow the toolbar to resize!
6881
sizer.Add(self.toolbar, 0, wxGROW)
6982
self.SetSizer(sizer)
7083
self.Fit()
@@ -89,18 +102,18 @@ def onTimer(self, evt):
89102
self.count += 1
90103
if self.count > 99: self.count = 0
91104
self.lines[0].set_data(self.ind, self.X[:,self.count])
92-
self.fig.draw()
93-
self.fig.gui_repaint()
105+
self.canvas.draw()
106+
self.canvas.gui_repaint()
94107

95108
if __name__ == '__main__':
96109
app = wxPySimpleApp()
97110
frame = PlotFigure()
98111
frame.init_plot_data()
99112

100113
# Initialise the timer - wxPython requires this to be connected to the
101-
# receiving event handler
114+
# receivicng event handler
102115
t = wxTimer(frame, TIMER_ID)
103-
t.Start(500)
116+
t.Start(100)
104117

105118
frame.Show()
106119
app.MainLoop()

examples/embedding_in_wx.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
figure resizable or not.
3737
"""
3838

39-
39+
import matplotlib
40+
matplotlib.use('WX')
4041
from matplotlib.backends.backend_wx import Toolbar, FigureCanvasWx,\
4142
FigureManager
4243

@@ -72,6 +73,7 @@ def __init__(self):
7273
sizer.Add(self.toolbar, 0, wxGROW)
7374
self.SetSizer(sizer)
7475
self.Fit()
76+
7577
def plot_data(self):
7678
# Use ths line if using a toolbar
7779
a = self.figmgr.add_subplot(111)

setup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
data.extend(glob.glob('fonts/ttf/*.ttf'))
4646
data.extend(glob.glob('images/*.xpm'))
4747
data.extend(glob.glob('images/*.ppm'))
48-
data.append('.matplotlibrc')
48+
if sys.platform != 'win32': # win32 uses postinstaller for conditional install
49+
data.append('.matplotlibrc')
4950

5051
data_files=[('share/matplotlib', data),]
5152

@@ -91,7 +92,7 @@
9192

9293

9394
setup(name="matplotlib",
94-
version= '0.52a',
95+
version= '0.52c',
9596
description = "Matlab style python plotting package",
9697
author = "John D. Hunter",
9798
author_email="jdhunter@ace.bsd.uchicago.edu",
@@ -106,4 +107,5 @@
106107
platforms='any',
107108
ext_modules = ext_modules,
108109
data_files = data_files,
110+
scripts=['postinstall.py'],
109111
)

setupext.py

Lines changed: 52 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,40 @@
11
"""
22
Some helper functions for building the C extensions
33
4-
BUILDING ON WIN32
4+
you may need to edit basedir to point to the default location of your
5+
required libs, eg, png, z, freetype
56
6-
* You need to make the cygwin import library. Assuming you have a
7-
typical cygwin and python install, run the script importlib22.bat or
8-
importlib23.bat to build the python2.2 or 2.3 import libs
7+
DARWIN
98
10-
* You need to following libraries (saved in win32_static):
9+
I have installed all of the backends on OSX.
1110
12-
http://gnuwin32.sourceforge.net/downlinks/freetype.php
13-
http://gnuwin32.sourceforge.net/downlinks/zlib.php
14-
http://gnuwin32.sourceforge.net/downlinks/libgw32c.php
15-
http://gnuwin32.sourceforge.net/downlinks/libpng.php
16-
http://www.activestate.com/Products/Download/Download.plex?id=ActiveTcl
11+
Tk: If you want to install TkAgg, I recommend the "batteries included"
12+
binary build of Tcl/Tk at
13+
http://www.apple.com/downloads/macosx/unix_open_source/tcltkaqua.html
1714
18-
* To install the gtk packages, you need pkg-config. This is
19-
included in the GTK development lib. You should have the GTK
20-
runtime and development libs installed to C:\GTK and make sure
21-
c:\GTK\lib and c:\GTK\bin are in your PATH. Also, copy
22-
win32_static/pygtk-2.0.pc to c:\GTK\lib\pkgconfig
23-
24-
* You must patch distutils for python23 or python22 to build agg
25-
with g++. See
26-
http://mail.python.org/pipermail/distutils-sig/2004-January/003553.html.
27-
Edit c:/Python23/lib/distutils/cygwinccompiler.py and add the line
28-
to the two set_executables calls
15+
GTK: I installed GTK from src as described at
16+
http://www.macgimp.org/index.php?topic=gtk. There are several
17+
packages, but all configure/make/make install w/o problem. In
18+
addition to the packages listed there, You will also need libpng,
19+
libjpeg, and libtiff if you want output to these formats from GTK.
2920
30-
compiler_cxx='g++ -mcygwin -O -Wall',
21+
WIN32
3122
32-
* build command
23+
If you are sufficiently masochistic that you want to build this
24+
yourself, contact me and I'll send you win32_static as a zip file.
3325
34-
> python setup.py build --compiler=mingw32 > build23.out
26+
python setup.py build --compiler=mingw32 bdist_wininst --install-script postinstall.py > build23.out
3527
36-
* make the windows installer
37-
38-
> python setup.py bdist_wininst
39-
40-
Note on some systems this fails with a "extensions need to be
41-
built with the same version of the compiler" message. The
42-
following workaround helps
28+
"""
4329

44-
> python setup.py build --compiler=mingw32 bdist_wininst > build23.out
45-
46-
See for details http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=mailman.1060311735.32666.python-list%40python.org&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26q%3Dpython%2B%2522extensions%2Bneed%2Bto%2Bbe%2Bbuilt%2Bwith%2Bthe%2Bsame%2Bversion%2Bof%2Bthe%2Bcompiler%2522
30+
basedir = {
4731

32+
'win32' : 'win32_static',
33+
'linux2' : '/usr',
34+
'linux' : '/usr',
35+
'darwin' : '/usr/local',
36+
}
4837

49-
Note building for python22. Delete c:\python22\lib\distutils and copy
50-
the (patched) python23 version into this folder. Delete all the
51-
*.pyc in c:\python22\lib\distutils and the command subdir. Should work
52-
53-
54-
"""
5538
import sys, os
5639
from distutils.core import Extension
5740
import glob
@@ -81,18 +64,12 @@ def getoutput(s):
8164
def add_agg_flags(module):
8265
'Add the module flags to build extensions which use agg'
8366

84-
module.include_dirs.extend(['src','agg2/include'])
85-
module.libraries.extend(['freetype', 'png', 'z'])
86-
if sys.platform == 'win32':
87-
module.include_dirs.extend(
88-
['win32_static/include', ] )
89-
module.library_dirs.append('win32_static')
90-
module.libraries.append('gw32c')
67+
# before adding the freetype flags since -z comes later
68+
module.libraries.append('png')
9169

92-
else:
93-
module.include_dirs.extend(
94-
['/usr/include/freetype2',]
95-
)
70+
add_ft2font_flags(module)
71+
72+
module.include_dirs.extend(['src','agg2/include'])
9673

9774
# put these later for correct link order
9875
module.libraries.extend(['stdc++', 'm'])
@@ -106,17 +83,14 @@ def add_gd_flags(module):
10683
def add_ft2font_flags(module):
10784
'Add the module flags to build extensions which use gd'
10885
module.libraries.extend(['freetype', 'z'])
86+
87+
inc = os.path.join(basedir[sys.platform], 'include')
88+
module.include_dirs.append(inc)
89+
module.include_dirs.append(os.path.join(inc, 'freetype2'))
90+
module.library_dirs.append(os.path.join(basedir[sys.platform], 'lib'))
91+
10992
if sys.platform == 'win32':
110-
module.include_dirs.extend(
111-
[ 'win32_static/include', # for ft2build.h
112-
'win32_static/include/freetype', # renamed from freetype2
113-
]
114-
)
115-
module.library_dirs.append('win32_static')
11693
module.libraries.append('gw32c')
117-
else:
118-
module.include_dirs.extend(
119-
['/usr/include', '/usr/include/freetype2',])
12094

12195
# put this last for library link order
12296
module.libraries.append('m')
@@ -131,44 +105,31 @@ def add_pygtk_flags(module):
131105
module.library_dirs.extend(
132106
['C:/GTK/bin', 'C:/GTK/lib'])
133107

134-
135108
module.include_dirs.extend(
136109
['win32_static/include/pygtk-2.0',
137110
'C:/GTK/include',
138-
'C:/GTK/include/glib-2.0',
139-
'C:/GTK/lib/glib-2.0/include',
140-
'C:/GTK/include/gtk-2.0',
141-
'C:/GTK/lib/gtk-2.0/include',
142-
'C:/GTK/include/atk-1.0',
143-
'C:/GTK/include/pango-1.0',
144111
])
145-
146-
module.libraries.extend([
147-
'gtk-win32-2.0', 'gdk-win32-2.0', 'atk-1.0',
148-
'gdk_pixbuf-2.0', 'pangowin32-1.0', 'gdi32',
149-
'pango-1.0', 'gobject-2.0', 'gmodule-2.0',
150-
'glib-2.0', 'intl', 'iconv'])
151112

152-
else:
153-
pygtkIncludes = getoutput('pkg-config --cflags-only-I pygtk-2.0').split()
154-
gtkIncludes = getoutput('pkg-config --cflags-only-I gtk+-2.0').split()
155-
includes = pygtkIncludes + gtkIncludes
156-
module.include_dirs.extend([include[2:] for include in includes])
157113

158-
pygtkLinker = getoutput('pkg-config --libs pygtk-2.0').split()
159-
gtkLinker = getoutput('pkg-config --libs gtk+-2.0').split()
160-
linkerFlags = pygtkLinker + gtkLinker
114+
pygtkIncludes = getoutput('pkg-config --cflags-only-I pygtk-2.0').split()
115+
gtkIncludes = getoutput('pkg-config --cflags-only-I gtk+-2.0').split()
116+
includes = pygtkIncludes + gtkIncludes
117+
module.include_dirs.extend([include[2:] for include in includes])
161118

162-
module.libraries.extend(
163-
[flag[2:] for flag in linkerFlags if flag.startswith('-l')])
119+
pygtkLinker = getoutput('pkg-config --libs pygtk-2.0').split()
120+
gtkLinker = getoutput('pkg-config --libs gtk+-2.0').split()
121+
linkerFlags = pygtkLinker + gtkLinker
164122

165-
module.library_dirs.extend(
166-
[flag[2:] for dir in linkerFlags if flag.startswith('-L')])
123+
module.libraries.extend(
124+
[flag[2:] for flag in linkerFlags if flag.startswith('-l')])
125+
126+
module.library_dirs.extend(
127+
[flag[2:] for dir in linkerFlags if flag.startswith('-L')])
167128

168129

169-
module.extra_link_args.extend(
170-
[flag for flag in linkerFlags if not
171-
(flag.startswith('-l') or flag.startswith('-L'))])
130+
module.extra_link_args.extend(
131+
[flag for flag in linkerFlags if not
132+
(flag.startswith('-l') or flag.startswith('-L'))])
172133

173134

174135
def add_tk_flags(module):
@@ -178,6 +139,9 @@ def add_tk_flags(module):
178139
module.include_dirs.extend(['win32_static/include/tcl'])
179140
module.library_dirs.extend(['C:/Python23/dlls'])
180141
module.libraries.extend(['tk84', 'tcl84'])
142+
elif sys.platform == 'darwin':
143+
module.extra_link_args.extend(['-framework','Tcl'])
144+
module.extra_link_args.extend(['-framework','Tk'])
181145
else:
182146
module.libraries.extend(['tk', 'tcl'])
183147

src/_tkagg.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313
#include <stdlib.h>
1414

1515
extern "C" {
16-
#include <tk.h>
16+
#ifdef __APPLE__
17+
# include <Tcl/tcl.h>
18+
# include <Tk/tk.h>
19+
#else
20+
# include <tk.h>
21+
#endif
1722
};
1823

1924
#include "_backend_agg.h"

0 commit comments

Comments
 (0)
0