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)
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)
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))
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))