示例#1
0
文件: gki.py 项目: jhunkeler/pyraf
def printPlot(window=None):
    """Print contents of window (default active window) to stdplot
    window must be a GkiKernel object (with a gkibuffer attribute.)
    """
    import gwm, gkiiraf
    if window is None:
        window = gwm.getActiveGraphicsWindow()
        if window is None: return
    gkibuff = window.gkibuffer.get()
    if len(gkibuff):
        graphcap = getGraphcap()
        stdplot = pyraf.iraf.envget('stdplot','')
        if not stdplot:
            msg = "No hardcopy device defined in stdplot"
        elif not stdplot in graphcap:
            msg = "Unknown hardcopy device stdplot=`%s'" % stdplot
        else:
            printer = gkiiraf.GkiIrafKernel(stdplot)
            printer.append(gkibuff)
            printer.flush()
            msg = "snap completed"
    stdout = kernel.getStdout(default=sys.stdout)
    stdout.write("%s\n" % msg)
示例#2
0
def printPlot(window=None):
    """Print contents of window (default active window) to stdplot
    window must be a GkiKernel object (with a gkibuffer attribute.)
    """
    import gwm, gkiiraf
    if window is None:
        window = gwm.getActiveGraphicsWindow()
        if window is None: return
    gkibuff = window.gkibuffer.get()
    if len(gkibuff):
        graphcap = getGraphcap()
        stdplot = pyraf.iraf.envget('stdplot', '')
        if not stdplot:
            msg = "No hardcopy device defined in stdplot"
        elif not stdplot in graphcap:
            msg = "Unknown hardcopy device stdplot=`%s'" % stdplot
        else:
            printer = gkiiraf.GkiIrafKernel(stdplot)
            printer.append(gkibuff)
            printer.flush()
            msg = "snap completed"
    stdout = kernel.getStdout(default=sys.stdout)
    stdout.write("%s\n" % msg)
示例#3
0
def imcur(displayname=None):

    """Read image cursor and return string expected for IRAF's imcur parameter

    If key pressed is colon, also prompts for additional string input.
    Raises EOFError if ^D or ^Z is typed and IrafError on other errors.
    The optional display argument specifies the name of the display to
    use (default is the display specified in stdimage).
    """

    try:
        # give kernel a chance to do anything it needs right before imcur
        gkrnl = gwm.getActiveGraphicsWindow()
        if gkrnl:
            gkrnl.pre_imcur()
        # get device
        device = _getDevice(displayname)
        # Read cursor position at keystroke
        result = device.readCursor()
        if Verbose>1:
            sys.__stdout__.write("%s\n" % (result,))
            sys.__stdout__.flush()
        if result == 'EOF':
            raise EOFError
        x, y, wcs, key = result.split()

        if key in [r'\004', r'\032']:
            # ctrl-D and ctrl-Z are treated as EOF
            # Should ctrl-C raise a KeyboardInterrupt?
            raise EOFError
        elif key == ':':
            sys.stdout.write(": ")
            sys.stdout.flush()
            result = result + ' ' + irafutils.tkreadline()[:-1]
        return result
    except IOError, error:
        raise IrafError(str(error))
示例#4
0
def imcur(displayname=None):
    """Read image cursor and return string expected for IRAF's imcur parameter

    If key pressed is colon, also prompts for additional string input.
    Raises EOFError if ^D or ^Z is typed and IrafError on other errors.
    The optional display argument specifies the name of the display to
    use (default is the display specified in stdimage).
    """

    try:
        # give kernel a chance to do anything it needs right before imcur
        gkrnl = gwm.getActiveGraphicsWindow()
        if gkrnl:
            gkrnl.pre_imcur()
        # get device
        device = _getDevice(displayname)
        # Read cursor position at keystroke
        result = device.readCursor()
        if Verbose > 1:
            sys.__stdout__.write("%s\n" % (result, ))
            sys.__stdout__.flush()
        if result == 'EOF':
            raise EOFError
        x, y, wcs, key = result.split()

        if key in [r'\004', r'\032']:
            # ctrl-D and ctrl-Z are treated as EOF
            # Should ctrl-C raise a KeyboardInterrupt?
            raise EOFError
        elif key == ':':
            sys.stdout.write(": ")
            sys.stdout.flush()
            result = result + ' ' + irafutils.tkreadline()[:-1]
        return result
    except IOError, error:
        raise IrafError(str(error))