Beispiel #1
0
 def add_repl(self):
     """
     Detect a connected BBC micro:bit and if found, connect to the
     MicroPython REPL and display it to the user.
     """
     if self.repl is not None:
         raise RuntimeError("REPL already running")
     mb_port = find_microbit()
     if mb_port:
         try:
             self.repl = REPL(port=mb_port)
             self._view.add_repl(self.repl)
         except IOError as ex:
             self.repl = None
             information = "Click the device's reset button, wait a few" " seconds and then try again."
             self._view.show_message(str(ex), information)
     else:
         message = "Could not find an attached BBC micro:bit."
         information = (
             "Please make sure the device is plugged into this"
             " computer.\n\nThe device must have MicroPython flashed onto it"
             " before the REPL will work.\n\nFinally, press the device's"
             " reset button and wait a few seconds before trying again."
         )
         self._view.show_message(message, information)
Beispiel #2
0
 def setup(self):
     """
     Sets up the application.
     """
     ed = Editor(self, None)
     mb_port = find_microbit()
     if mb_port:
         port = '/dev/{}'.format(mb_port)
         print(port)
         replpane = REPLPane(port=port, parent=ed)
         ed.add_repl(replpane)
     self.addWidget(ed)
     self.setCurrentWidget(ed)
Beispiel #3
0
Datei: app.py Projekt: inglesp/mu
 def setup_editor(self):
     """
     Adds the editor to the window.
     """
     ed = Editor(self, None)
     mb_port = find_microbit()
     if mb_port:
         port = '/dev/{}'.format(mb_port)
         print(port)
         replpane = REPLPane(port=port, parent=ed)
         ed.add_pane(replpane)
     self.addWidget(ed)
     self.setCurrentWidget(ed)