Пример #1
0
def run():
    """
    Creates all the top-level assets for the application, sets things up and
    then runs the application.
    """
    # The app object is the application running on your computer.
    app = QApplication(sys.argv)
    app.setStyleSheet(load_stylesheet('mu.css'))
    # Display a friendly "splash" icon.
    splash = QSplashScreen(load_pixmap('icon'))
    splash.show()
    # Create the "window" we'll be looking at.
    editor_window = Window()
    # Create the "editor" that'll control the "window".
    editor = Editor(view=editor_window)
    # Setup the window.
    editor_window.setup()
    editor.restore_session()
    # Connect the various buttons in the window to the editor.
    button_bar = editor_window.button_bar
    button_bar.connect("new", editor.new, "Ctrl+N")
    button_bar.connect("load", editor.load, "Ctrl+O")
    button_bar.connect("save", editor.save, "Ctrl+S")
    button_bar.connect("flash", editor.flash)
    button_bar.connect("repl", editor.toggle_repl)
    button_bar.connect("zoom-in", editor.zoom_in)
    button_bar.connect("zoom-out", editor.zoom_out)
    button_bar.connect("quit", editor.quit)
    # Finished starting up the application, so hide the splash icon.
    splash.finish(editor_window)
    # Stop the program after the application finishes executing.
    sys.exit(app.exec_())
Пример #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)
Пример #3
0
Файл: app.py Проект: 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)