1
# $Id: gp_win32.py,v 2.9 2001/01/07 21:35:14 mhagger Exp $
3
# Copyright (C) 1999 Michael Haggerty <mhagger@alum.mit.edu>
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version. This program is distributed in
9
# the hope that it will be useful, but WITHOUT ANY WARRANTY; without
10
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11
# PARTICULAR PURPOSE. See the GNU General Public License for more
12
# details; it is available at <http://www.fsf.org/copyleft/gpl.html>,
13
# or by writing to the Free Software Foundation, Inc., 59 Temple Place
14
# - Suite 330, Boston, MA 02111-1307, USA.
16
"""gp_win32 -- an interface to gnuplot for Windows.
20
__cvs_version__ = '$Revision: 2.9 $'
23
# ############ Configuration variables: ################################
26
"""The configuration options for gnuplot under windows.
28
See gp_unix.py for details about the meaning of these options.
29
Please let me know if you know better choices for these settings.
33
# Command to start up the gnuplot program. Note that on windows
34
# the main gnuplot program cannot be used directly because it can
35
# not read commands from standard input. See README for more
37
gnuplot_command = 'pgnuplot.exe'
39
# The '-persist' option is not supported on windows:
40
recognizes_persist = 0
42
# As far as I know, gnuplot under windows can use binary data:
43
recognizes_binary_splot = 1
45
# Apparently gnuplot on windows can use inline data, but we use
46
# non-inline data (i.e., temporary files) by default for no
48
prefer_inline_data = 0
50
# The default choice for the 'set term' command (to display on
52
default_term = 'windows'
54
# According to the gnuplot help manual, the following can be used
55
# to print directly to a printer under windows. (Of course it
56
# won't help if your printer can't handle postscript!)
59
# Used the 'enhanced' option of postscript by default? Set to
60
# None (*not* 0!) if your version of gnuplot doesn't support
61
# enhanced postscript.
62
prefer_enhanced_postscript = 1
64
# ############ End of configuration options ############################
68
from sys import hexversion
72
if hexversion >= 0x02000000:
73
# Apparently at least as of Python 2.0b1, popen support for
74
# windows is adequate. Give that a try:
77
# For earlier versions, you have to have the win32 extensions
78
# installed and we use the popen that it provides.
79
from win32pipe import popen
82
# Mac doesn't recognize persist.
88
"""Unsophisticated interface to a running gnuplot program.
90
See gp_unix.py for usage information.
94
def __init__(self, persist=0):
95
"""Start a gnuplot process.
97
Create a 'GnuplotProcess' object. This starts a gnuplot
98
program and prepares to write commands to it.
102
'persist' -- the '-persist' option is not supported under
103
Windows so this argument must be zero.
107
assert not persist, '-persist is not supported under Windows!'
109
self.gnuplot = popen(GnuplotOpts.gnuplot_command, 'w')
111
# forward write and flush methods:
112
self.write = self.gnuplot.write
113
self.flush = self.gnuplot.flush
115
def __call__(self, s):
116
"""Send a command string to gnuplot, followed by newline."""