1 # $Id: gp_cygwin.py 292 2006-03-03 09:49:04Z mhagger $
3 # Copyright (C) 1999-2003 Michael Haggerty <mhagger@alum.mit.edu>
5 # This file is licensed under the GNU Lesser General Public License
6 # (LGPL). See LICENSE.txt for details.
8 """gp_cygwin -- an interface to gnuplot for cygwin under Windows.
10 This is identical to gp_win32.py except that prefer_inline_data is
17 # ############ Configuration variables: ################################
20 """The configuration options for gnuplot under windows.
22 See gp_unix.py for details about the meaning of these options.
23 Please let me know if you know better choices for these settings.
27 # Command to start up the gnuplot program. Note that on windows
28 # the main gnuplot program cannot be used directly because it can
29 # not read commands from standard input. See README for more
32 # If pgnuplot is in a subdirectory with spaces in its name, extra
33 # quoting is required for windows for it to launch gnuplot.
34 # Moreover, any backslashes in the filename have to be escaped by
35 # writing them as "\\". Example:
37 # gnuplot_command = '"C:\\Program Files\\gp371w32\\pgnuplot.exe"'
38 gnuplot_command
= 'pgnuplot.exe'
40 # The '-persist' option is not supported on windows:
41 recognizes_persist
= 0
43 # As far as I know, gnuplot under windows can use binary data:
44 recognizes_binary_splot
= 1
46 # Apparently gnuplot on windows can use inline data, but we use
47 # non-inline data (i.e., temporary files) by default for no
49 prefer_inline_data
= 1
51 # os.mkfifo is apparently not supported under Windows.
55 # The default choice for the 'set term' command (to display on
57 default_term
= 'windows'
59 # According to the gnuplot help manual, the following can be used
60 # to print directly to a printer under windows. (Of course it
61 # won't help if your printer can't handle postscript!)
64 # Used the 'enhanced' option of postscript by default? Set to
65 # None (*not* 0!) if your version of gnuplot doesn't support
66 # enhanced postscript.
67 prefer_enhanced_postscript
= 1
69 # ############ End of configuration options ############################
73 from sys
import hexversion
77 if hexversion
>= 0x02000000:
78 # Apparently at least as of Python 2.0b1, popen support for
79 # windows is adequate. Give that a try:
82 # For earlier versions, you have to have the win32 extensions
83 # installed and we use the popen that it provides.
84 from win32pipe
import popen
87 # Mac doesn't recognize persist.
93 """Unsophisticated interface to a running gnuplot program.
95 See gp_unix.py for usage information.
99 def __init__(self
, persist
=0):
100 """Start a gnuplot process.
102 Create a 'GnuplotProcess' object. This starts a gnuplot
103 program and prepares to write commands to it.
107 'persist' -- the '-persist' option is not supported under
108 Windows so this argument must be zero.
113 raise Errors
.OptionError(
114 '-persist is not supported under Windows!')
116 self
.gnuplot
= popen(GnuplotOpts
.gnuplot_command
, 'w')
118 # forward write and flush methods:
119 self
.write
= self
.gnuplot
.write
120 self
.flush
= self
.gnuplot
.flush
123 if self
.gnuplot
is not None:
130 def __call__(self
, s
):
131 """Send a command string to gnuplot, followed by newline."""