1
# $Id: gp_mac.py,v 2.8 2001/01/07 21:35:13 mhagger Exp $
1
# $Id: gp_mac.py,v 2.17 2003/04/21 09:44:09 mhagger Exp $
3
# Copyright (C) 1999 Michael Haggerty <mhagger@alum.mit.edu>
3
# Copyright (C) 1999-2003 Michael Haggerty <mhagger@alum.mit.edu>
4
4
# Thanks to Tony Ingraldi and Noboru Yamamoto for their contributions.
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2 of the License, or (at
9
# your option) any later version. This program is distributed in the
10
# hope that it will be useful, but WITHOUT ANY WARRANTY; without even
11
# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12
# PURPOSE. See the GNU General Public License for more details; it is
13
# available at <http://www.fsf.org/copyleft/gpl.html>, or by writing to
14
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
15
# Boston, MA 02111-1307, USA.
6
# This file is licensed under the GNU Lesser General Public License
7
# (LGPL). See LICENSE.txt for details.
17
9
"""gp_mac -- an interface to gnuplot for the Macintosh.
21
__cvs_version__ = '$Revision: 2.8 $'
13
__cvs_version__ = '$Revision: 2.17 $'
24
20
# ############ Configuration variables: ################################
38
34
# Apparently the Mac can not use inline data:
39
35
prefer_inline_data = 0
41
# The default choice for the 'set term' command (to display on screen):
42
default_term = 'macintosh'
37
# os.mkfifo is not supported on the Mac.
41
# The default choice for the 'set term' command (to display on screen).
42
# Terminal types are different in Gnuplot 3.7.1c.
43
# For earlier versions, this was default_term = 'macintosh'
44
46
# I don't know how to print directly to a printer on the Mac:
47
49
# Used the 'enhanced' option of postscript by default? Set to
48
50
# None (*not* 0!) if your version of gnuplot doesn't support
74
76
"""Start a gnuplot program and emulate a pipe to it."""
76
78
def __init__(self):
77
aetools.TalkTo.__init__(self, 'GPSE', start=1)
79
aetools.TalkTo.__init__(self, '{GP}', start=1)
80
82
class GnuplotProcess:
81
83
"""Unsophisticated interface to a running gnuplot program.
83
See gp.GnuplotProcess for usage information.
85
See gp_unix.GnuplotProcess for usage information.
100
assert not persist, \
101
OptionException('-persist is not supported on the Macintosh!')
103
raise Errors.OptionError(
104
'-persist is not supported on the Macintosh!')
103
106
self.gnuplot = _GNUPLOT()
105
# forward write and flush methods:
106
self.write = self.gnuplot.gnuexec
108
# forward close method:
107
109
self.close = self.gnuplot.quit
112
"""Mac gnuplot apparently requires '\r' to end statements."""
114
self.gnuplot.gnuexec(string.replace(s, '\n', os.linesep))
112
119
def __call__(self, s):
113
"""Send a command string to gnuplot, followed by newline."""
120
"""Send a command string to gnuplot, for immediate execution."""
122
# Apple Script doesn't seem to need the trailing '\n'.