示例#1
0
  def __init__(self,**kargs):
    """
    Initialize. Redirect I/O to console.
    """
    ConsoleView.__init__(self)
    self.cout = StringIO()
    IterableIPShell.__init__(self, cout=self.cout,cerr=self.cout,
                             input_func=self.raw_input, **kargs)
#    self.connect('key_press_event', self.keyPress)
    self.execute()
    self.cout.truncate(0)
    self.showPrompt(self.prompt)
    self.interrupt = False
 def start(self):
     """ agent protocol """
     super(ChannelAgent,self).start()
     window = self.spawn_window
     vbox = self.vbox
     S = self.scrolled_window
     x = ConsoleView(); x.show()
     self.console_view = x
     S.add(x); S.show()
     vbox.pack_start(self.menu, gtk.FALSE, gtk.FALSE, 2)
     vbox.pack_end(S, True, True, 2); vbox.show()
     window.add(vbox); window.show()
     #window.add(S); window.show()
     self.buffer = x  # you can call .write('str') on this thing
class Console(App):
    def __init__(self, **kwargs):
        self.count = 0
        super(Console, self).__init__(**kwargs)

    def build(self):
        self.root = ConsoleView(script=script)
        self.root.__setattr__('stop', self.stop)
        # stdout -> textbox
        import sys
        sys.stdout = self.root
        return self.root

    def on_pause(self):
        return True
 def build(self):
     self.root = ConsoleView(script=script)
     self.root.__setattr__('stop', self.stop)
     # stdout -> textbox
     import sys
     sys.stdout = self.root
     return self.root
示例#5
0
from console_view import ConsoleView

if __name__ == '__main__':
    ConsoleView()
 def help_type():
     View.help_type()
 def help_quit():
     View.help_quit()
 def help_show():
     View.help_show()
    def do_type(self, line):
        """

        :param line:
        :return:
        """
        types = "-py", "-txt"
        args = list(arg.lower() for arg in str(line).split())

        try:
            if args[0] != types:
                raise ValueError("That is not a valid option")
            else:
                if args[0] == "-py":
                    try:
                        if len(args) == 1:
                            self._pc.type(args[0][1:], "test_code.py")
                            View.text_show("No file selected using text_code by default")
                        elif len(args) == 2:
                            self._pc.type(args[0][1], args[1])
                    except Exception as e:
                        (print(e))
                    else:
                        View.text_show("Python file selected")

                elif args[0] == "-txt":
                    try:
                        if len(args) == 1:
                            self._pc.type(args[0][1:], "test_code.txt")
                            View.text_show("No file selected using text_code by default")
                        elif len(args) == 2:
                            self._pc.type(args[0][1], args[1])
                    except Exception as e:
                        (print(e))
                    else:
                        View.text_show("Text file selected")

                else:
                    pass

        except ValueError as e:
            View.error_show(str(e) + "\n")
            View.help_select()
        except Exception as e:
            print(e)