faqts : Computers : Programming : Languages : Python : Snippets

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

7 of 9 people (78%) answered Yes
Recently 5 of 6 people (83%) answered Yes

Entry

Simple xmgrace Python interface

Jul 5th, 2000 10:02
Nathan Wallace, Hans Nowak, Snippet 263, nbecker@fred.net


"""
Packages: interfaces
"""
import popen2
class grace:
    def __init__ (self):
        self.p = popen2.Popen3 ("xmgrace -noask -dpipe 0")
    def Command (self, cmd):
        if (cmd[-1] != '\n'):
            cmd = cmd + '\n'
        self.p.tochild.write (cmd)
    def Flush (self):
        self.p.tochild.flush()
    def Wait (self):
        return self.p.wait()
if (__name__ == "__main__"):
    g = grace()
    g.Command ("g0.s0 point 0,0")
    g.Command ("g0.s0 point 1,1")
    g.Flush()
    print "returned:", g.Wait()