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.

The Mu application is created and configured in this module.


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


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.


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


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.


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


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


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.


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


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.


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


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


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


Stop when returning from the current frame.


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.


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 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.


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.


Buffer input from a socket, yield complete debugger commands., 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.


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.


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


Bespoke modal dialogs required by Mu.


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


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


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


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.


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.


Adafruit mode for CircuitPython.


The Python 3 debugger mode.


The original BBC micro:bit mode.


The Pygame Zero / pygame mode.


The Python 3 editing mode.


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