Mu API Reference

This API reference is automatically generated from the docstrings found within the source code. It’s meant as an easy to use and easy to share window into the code base.

Take a look around! The code is simple and short.

mu.app

The Mu application is created and configured in this module.

mu.logic

Most of the fundamental logic for Mu is in this module.

mu.debugger

The debugger consists of two parts:

  • Client - used by Mu to process messages from the process being debugged.
  • Runner - created in a new process to run the code to be debugged.

Messages are passed via inter-process communication.

mu.debugger.client

Code used by the Mu application to communicate with the process being debugged.

mu.debugger.runner

The runner code controls the debug process.

exception mu.debugger.runner.ClientClose[source]

Cause the debugger to wait for a new client to connect.

class mu.debugger.runner.DebugState[source]

Enumerates the three possible states of a debugging session.

class mu.debugger.runner.Debugger(socket, host, port, skip=None)[source]

Instances of this class represent and drive the debugging process.

do_break(filename, line, temporary=False)[source]

Set a breakpoint.

do_clear(bpnum)[source]

Handle how a breakpoint must be removed when it is a temporary one.

do_close()[source]

Respond to a closed socket (not a user commend, but needs handling).

do_continue()[source]

Stop only at breakpoints or when finished. If there are no breakpoints on script start, do a set_trace to stop at the first available line. However, use the continue_flag to ensure set_continue is always called thereafter.

do_disable(bpnum)[source]

Disable the breakpoint referenced by its breakpoint number (bpnum).

do_enable(bpnum)[source]

Enables the breakpoint referenced by its breakpoint number (bpnum).

do_ignore(bpnum, count)[source]

Ignore the breakpoint referenced by its breakpoint number (bpnum), count number of times.

do_next()[source]

Stop on the next line in or below the given frame.

do_quit()[source]

Set the quitting attribute to True. This raises BdbQuit in the next call to one of the dispatch_*() methods.

do_restart()[source]

Restart the program by raising an exception to be caught by the debugger.

do_return()[source]

Stop when returning from the current frame.

do_step()[source]

Stop after one line of code.

interact(frame, traceback)[source]

Contains the loop processing interactions with the debugger.

output(event, **data)[source]

Dumps data related to a referenced event to the socket.

output_stack()[source]

Dump the current stack.

If this is a normal situation, the top two frames are BDB and the runner executing the program. If there is an exception, there are two further extra frames. All these frames can be ignored.

reset()[source]

Reset state.

setup(frame, traceback)[source]

Start state should be set correctly.

user_call(frame, argument_list)[source]

This method is called from dispatch_call() when there is the possibility that a break might be necessary anywhere inside the called function.

user_exception(frame, exc_info)[source]

This method is called from dispatch_exception() when stop_here() yields True.

For when an exception occurs, but only if we are to stop at or just below this level.

user_line(frame)[source]

This method is called from dispatch_line() when either stop_here() or break_here() yields True.

For when we stop or break at this line.

user_return(frame, return_value)[source]

This method is called from dispatch_return() when stop_here() yields True.

For when a return trap is set here.

exception mu.debugger.runner.Restart[source]

Cause the debugger to restart for the target Python program.

mu.debugger.runner.command_buffer(debugger)[source]

Buffer input from a socket, yield complete debugger commands.

mu.debugger.runner.run(hostname, port, filename, *args)[source]

Run a Python script identified by “filename” with the specified arguments in a debugger session that’s listening at hostname/port.

mu.interface

This module contains all the PyQt related code needed to create the user interface for Mu. All interaction with the user interface is done via the Window class in mu.interface.main.

All the other sub-modules contain different bespoke aspects of the user interface.

mu.interface.main

Contains the core user interface assets used by other parts of the application.

mu.interface.dialogs

Bespoke modal dialogs required by Mu.

mu.interface.editor

Contains the customised Scintilla based editor used for textual display and entry.

mu.interface.panes

Contains code used to populate the various panes found in the user interface (REPL, file list, debug inspector etc…).

mu.interface.themes

Theme related code so Qt changes for each pre-defined theme.

mu.modes

Contains the definitions of the various modes Mu into which Mu can be put. All the core functionality is in the mu.modes.base module.

mu.modes.base

Core functionality and base classes for all Mu’s modes. The definitions of API autocomplete and call tips can be found in the mu.modes.api namespace.

mu.modes.adafruit

Adafruit mode for CircuitPython.

mu.modes.debugger

The Python 3 debugger mode.

mu.modes.microbit

The original BBC micro:bit mode.

mu.modes.pygamezero

The Pygame Zero / pygame mode.

mu.modes.python3

The Python 3 editing mode.

mu.resources

Contains utility functions for working with binary assets used by Mu (mainly images).