Exemplo n.º 1
0
    def getKey(self, event):

        import gkicmd
        # The main character handling routine where no special keys
        # are used (e.g., arrow keys)
        key = event.char
        if not key:
            # ignore keypresses of non printable characters
            return
        elif key == '\004':
            # control-D causes immediate EOF
            self.eof = "EOF from `^D'"
            self.top.quit()
        elif key == '\003':
            # control-C causes interrupt
            self.window.gcurTerminate("interrupted by `^C'")

        x,y = self.getNDCCursorPos()
        if self.markcur and key not in 'q?:=UR':
            metacode = gkicmd.markCross(x,y)
            self.appendMetacode(metacode)
        if key == ':':
            colonString = self.readString(prompt=": ")
            if colonString:
                if colonString[0] == '.':
                    if colonString[1:] == 'markcur+':
                        self.markcur = 1
                    elif colonString[1:] == 'markcur-':
                        self.markcur = 0
                    elif colonString[1:] == 'markcur':
                        self.markcur = not self.markcur
                    else:
                        self.writeString("Unimplemented CL gcur `:%s'" % colonString)
                else:
                    self._setRetString(key,x,y,colonString)
        elif key == '=':
            # snap command - print the plot
            import gki
            gki.printPlot(self.window)
        elif key in string.ascii_uppercase:
            if key == 'I':
                # I is equivalent to keyboard interrupt
                self.window.gcurTerminate("interrupted by `I' keyboard command")
            elif key == 'R':
                self.window.redrawOriginal()
            elif key == 'T':
                textString = self.readString(prompt="Annotation string: ")
                metacode = gkicmd.text(textString,x,y)
                self.window.forceNextDraw() # we can afford a perf hit here,
                                            # a human just typed in text
                self.appendMetacode(metacode)
            elif key == 'U':
                self.window.undoN()
            elif key == 'C':
                wx,wy,gwcs = self._convertXY(x,y)
                self.writeString("%g %g" % (wx,wy))
            else:
                self.writeString("Unimplemented CL gcur command `%s'" % key)
        else:
            self._setRetString(key,x,y,"")
Exemplo n.º 2
0
    def doprint(self):

        stdout = sys.stdout
        sys.stdout = self.StatusLine
        try:
            gki.printPlot(self)
        finally:
            sys.stdout = stdout
Exemplo n.º 3
0
    def doprint(self):

        stdout = sys.stdout
        sys.stdout = self.StatusLine
        try:
            gki.printPlot(self)
        finally:
            sys.stdout = stdout
Exemplo n.º 4
0
    def getKey(self, event):

        import gkicmd
        # The main character handling routine where no special keys
        # are used (e.g., arrow keys)
        key = event.char
        if not key:
            # ignore keypresses of non printable characters
            return
        elif key == '\004':
            # control-D causes immediate EOF
            self.eof = "EOF from `^D'"
            self.top.quit()
        elif key == '\003':
            # control-C causes interrupt
            self.window.gcurTerminate("interrupted by `^C'")

        x, y = self.getNDCCursorPos()
        if self.markcur and key not in 'q?:=UR':
            metacode = gkicmd.markCross(x, y)
            self.appendMetacode(metacode)
        if key == ':':
            colonString = self.readString(prompt=": ")
            if colonString:
                if colonString[0] == '.':
                    if colonString[1:] == 'markcur+':
                        self.markcur = 1
                    elif colonString[1:] == 'markcur-':
                        self.markcur = 0
                    elif colonString[1:] == 'markcur':
                        self.markcur = not self.markcur
                    else:
                        self.writeString("Unimplemented CL gcur `:%s'" %
                                         colonString)
                else:
                    self._setRetString(key, x, y, colonString)
        elif key == '=':
            # snap command - print the plot
            import gki
            gki.printPlot(self.window)
        elif key in string.ascii_uppercase:
            if key == 'I':
                # I is equivalent to keyboard interrupt
                self.window.gcurTerminate(
                    "interrupted by `I' keyboard command")
            elif key == 'R':
                self.window.redrawOriginal()
            elif key == 'T':
                textString = self.readString(prompt="Annotation string: ")
                metacode = gkicmd.text(textString, x, y)
                self.window.forceNextDraw()  # we can afford a perf hit here,
                # a human just typed in text
                self.appendMetacode(metacode)
            elif key == 'U':
                self.window.undoN()
            elif key == 'C':
                wx, wy, gwcs = self._convertXY(x, y)
                self.writeString("%g %g" % (wx, wy))
            else:
                self.writeString("Unimplemented CL gcur command `%s'" % key)
        else:
            self._setRetString(key, x, y, "")