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.app
¶
Mu - a "micro" Python editor for beginner programmers.
Copyright (c) 2015-2017 Nicholas H.Tollervey and others (see the AUTHORS file).
Based upon work done for Puppy IDE by Dan Pope, Nicholas Tollervey and Damien George.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
AnimatedSplash
¶
Bases: QSplashScreen
An animated splash screen for gifs. Includes a text area for logging output.
Source code in mu/app.py
__init__(animation, parent=None)
¶
Ensure signals are connected and start the animation.
Source code in mu/app.py
draw_log(text)
¶
Draw the log entries onto the splash screen. Will only display the last self.log_lines number of log entries. The logs will be displayed at the bottom of the splash screen, justified left.
Source code in mu/app.py
draw_text(text)
¶
failed(text)
¶
Something has gone wrong during start-up, so signal this, display a helpful message along with instructions for what to do.
Source code in mu/app.py
set_frame()
¶
SharedMemoryMutex
¶
Bases: object
Simple wrapper around the QSharedMemory object, adding a context handler which uses the built in Semaphore as a locking mechanism and raises an error if the shared memory object is already in use
TODO: The *nix implementation doesn't release the shared memory if a process attached to it crashes. There is code to attempt to detect this but it doesn't seem worth implementing for the moment: we're only talking about a page at most.
Source code in mu/app.py
StartupWorker
¶
Bases: QObject
A worker class for running blocking tasks on a separate thread during application start-up.
The animated splash screen will be shown until this thread is finished.
Source code in mu/app.py
run()
¶
Blocking and long running tasks for application startup should be called from here.
Source code in mu/app.py
check_only_running_once()
¶
If the application is already running log the error and exit
crash_details(exc_type, exc_value, exc_traceback)
¶
The text a user can copy into a bug report after a crash: versions, platform, where the log is, and the traceback.
Source code in mu/app.py
excepthook(*exc_args)
¶
Log the exception, show the details to the user, and exit -- unless it came from a plugin, in which case it's reported to the user and Nu carries on.
Source code in mu/app.py
is_linux_wayland()
¶
Checks environmental variables to try to determine if Mu is running on wayland.
Source code in mu/app.py
run()
¶
Creates all the top-level assets for the application, sets things up and then runs the application. Specific tasks include:
- set up logging
- set up global exception handler
- check that another instance of the app isn't already running (exit if so)
- create an application object
- create an editor window and status bar
- display a splash screen while starting
- close the splash screen after startup timer ends
Source code in mu/app.py
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 | |
setup_exception_handler()
¶
setup_logging()
¶
Configure logging.
Source code in mu/app.py
setup_modes(editor, view)
¶
Create a dictionary of the available modes, keyed by short name.
The built-in modes are registered through a plugin Host, then every installed or dropped-in plugin that is switched on is loaded into it. A plugin that fails to load is logged and skipped.
Source code in mu/app.py
show_crash_dialog(details)
¶
Show the crash details so the user can copy them. Nothing is sent anywhere. Skipped if there's no QApplication yet (a crash during start-up) or MU_SUPPRESS_CRASH_REPORT_FORM is set (tests and CI).
Source code in mu/app.py
mu.logic¶
Most of the fundamental logic for Mu is in this module.
mu.logic
¶
Copyright (c) 2015-2017 Nicholas H.Tollervey and others (see the AUTHORS file).
Based upon work done for Puppy IDE by Dan Pope, Nicholas Tollervey and Damien George.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Device
¶
Device object, containing both information about the connected device, the port it's connected through and the mode it works with.
Source code in mu/logic.py
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 | |
name
property
¶
Returns the device name.
__eq__(other)
¶
Equality on devices. Comparison on vid, pid, and serial_number, and most importantly also matches on which port the device is connected to. That is, if two identical devices are connected to separate ports they are considered different.
Source code in mu/logic.py
__ge__(other)
¶
__gt__(other)
¶
__hash__()
¶
Hash is the hash of the string representation, includes the same elements in the hash as in equality testing.
__le__(other)
¶
__lt__(other)
¶
__ne__(other)
¶
__str__()
¶
String representation of devices includes name, port, and VID/PID
DeviceList
¶
Bases: QAbstractListModel
Source code in mu/logic.py
635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 | |
__getitem__(i)
¶
__iter__()
¶
__len__()
¶
add_device(new_device)
¶
Add a new device to the device list, maintains alphabetical ordering
Source code in mu/logic.py
check_usb()
¶
Ensure connected USB devices are polled. If there's a change and a new recognised device is attached, inform the user via a status message. If a single device is found and Mu is in a different mode ask the user if they'd like to change mode.
Source code in mu/logic.py
data(index, role)
¶
Reimplements QAbstractListModel.data(): returns data for the specified index and role. In this case only implemented for ToolTipRole and DisplayRole
Source code in mu/logic.py
remove_device(device)
¶
Remove the given device from the device list
Source code in mu/logic.py
Editor
¶
Bases: QObject
Application logic for the editor itself.
Source code in mu/logic.py
764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 | |
ask_to_change_mode(new_mode, mode_name, heading)
¶
Open a dialog asking the user, whether to change mode from mode_name to new_mode. The dialog can be customized by the heading-parameter.
Source code in mu/logic.py
autosave()
¶
Cycles through each tab and, if changed, saves it to the filesystem.
Source code in mu/logic.py
change_mode(mode)
¶
Given the name of a mode, will make the necessary changes to put the editor into the new mode.
Source code in mu/logic.py
1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 | |
check_code()
¶
Uses PyFlakes and PyCodeStyle to gather information about potential problems with the code in the current tab.
Source code in mu/logic.py
check_for_shadow_module(path)
¶
Check if the filename in the path is a shadow of a module already in the Python path. For example, many learners will save their first turtle based script as turtle.py, thus causing Python to never find the built in turtle module because of the name conflict.
If the filename shadows an existing module, return True, otherwise, return False.
Source code in mu/logic.py
connect_to_status_bar(status_bar)
¶
Connect the editor with the Window-statusbar. Should be called after Editor.setup(), to ensure modes are initialized
Source code in mu/logic.py
debug_toggle_breakpoint(margin, line, modifiers)
¶
How to handle the toggling of a breakpoint.
Source code in mu/logic.py
device_changed(device)
¶
Slot for receiving signals that the current device has changed. If the device change requires mode change, the user will be asked through a dialog.
Source code in mu/logic.py
direct_load(path)
¶
find_again(forward=True)
¶
Handle find again (F3 and Shift+F3) functionality.
Source code in mu/logic.py
find_again_backward(forward=False)
¶
find_replace()
¶
Handle find / replace functionality.
If find/replace dialog is dismissed, do nothing.
Otherwise, check there's something to find, warn if there isn't.
If there is, find (and, optionally, replace) then confirm outcome with a status message.
Source code in mu/logic.py
get_dialog_directory(default=None)
¶
Return the directory folder which a load/save dialog box should open into. In order of precedence this function will return:
0) If not None, the value of default. 1) The last location used by a load/save dialog. 2) The directory containing the current file. 3) The mode's reported workspace directory.
Source code in mu/logic.py
get_tab(path)
¶
Given a path, returns either an existing tab for the path or creates / loads a new tab for the path.
Source code in mu/logic.py
has_python_extension(filename)
¶
Check whether the given filename matches recognized Python extensions.
load(*args, default_path=None)
¶
Loads a Python (or other supported) file from the file system or extracts a Python script from a hex file.
Source code in mu/logic.py
load_cli(paths)
¶
Given a set of paths, passed in by the user when Mu starts, this method will attempt to load them and log / report a problem if Mu is unable to open a passed in path.
Source code in mu/logic.py
new()
¶
Adds a new tab to the editor.
quit(*args, **kwargs)
¶
Exit the application.
Source code in mu/logic.py
rename_tab(tab_id=None)
¶
How to handle double-clicking a tab in order to rename the file. If activated by the shortcut, activate against the current tab.
Source code in mu/logic.py
restore_session(paths=None)
¶
Attempts to recreate the tab state from the last time the editor was run. If paths contains a collection of additional paths specified by the user, they are also "restored" at the same time (duplicates will be ignored).
Source code in mu/logic.py
save(*args, default=None)
¶
Save the content of the currently active editor tab.
Source code in mu/logic.py
save_tab_to_file(tab, show_error_messages=True)
¶
Given a tab, will attempt to save the script in the tab to the path associated with the tab. If there's a problem this will be logged and reported and the tab status will continue to show as Modified.
Source code in mu/logic.py
select_mode(event=None)
¶
Select the mode that editor is supposed to be in.
Source code in mu/logic.py
setup(modes)
¶
Define the available modes and ensure there's a default working directory.
Source code in mu/logic.py
show_admin(event=None)
¶
Cause the editor's admin dialog to be displayed to the user.
Ensure any changes to the envars is updated.
Source code in mu/logic.py
show_help()
¶
show_status_message(message, duration=5)
¶
sync_package_state(old_packages, new_packages)
¶
Given the state of the old third party packages, compared to the new third party packages, ensure that pip uninstalls and installs the packages so the currently available third party packages reflects the new state.
Source code in mu/logic.py
tidy_code()
¶
Prettify code with Black.
Source code in mu/logic.py
toggle_comments()
¶
toggle_theme()
¶
Switches between themes (night, day or high-contrast).
Source code in mu/logic.py
zoom_in()
¶
MuFlakeCodeReporter
¶
The class instantiates a reporter that creates structured data about code quality for Mu. Used by the PyFlakes module.
Source code in mu/logic.py
__init__()
¶
flake(message)
¶
PyFlakes found something wrong with the code.
Source code in mu/logic.py
syntaxError(filename, message, line_no, column, source)
¶
Records a syntax error in the file called filename.
The message argument contains an explanation of the syntax error, line_no indicates the line where the syntax error occurred, column indicates the column on which the error occurred and source is the source code containing the syntax error.
Source code in mu/logic.py
unexpectedError(filename, message)
¶
Called if an unexpected error occurred while trying to process the file called filename. The message parameter contains a description of the problem.
Source code in mu/logic.py
check_flake(filename, code, builtins=None)
¶
Given a filename and some code to be checked, uses the PyFlakesmodule to return a dictionary describing issues of code quality per line. See:
https://github.com/PyCQA/pyflakes
If a list symbols is passed in as "builtins" these are assumed to be additional builtins available when run by Mu.
Source code in mu/logic.py
check_pycodestyle(code, config_file=False)
¶
Given some code, uses the PyCodeStyle module (was PEP8) to return a list of items describing issues of coding style. See:
https://pycodestyle.readthedocs.io/en/latest/intro.html
Source code in mu/logic.py
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | |
extract_envars(raw)
¶
Returns a list of environment variables given a string containing NAME=VALUE definitions on separate lines.
Source code in mu/logic.py
read_and_decode(filepath)
¶
Read the contents of a file,
Source code in mu/logic.py
save_and_encode(text, filepath, newline=os.linesep)
¶
Detect the presence of an encoding cookie and use that encoding; if none is present, do not add one and use the Mu default encoding. If the codec is invalid, log a warning and fall back to the default.
Source code in mu/logic.py
sniff_encoding(filepath)
¶
Determine the encoding of a file:
- If there is a BOM, return the appropriate encoding
- If there is a PEP 263 encoding cookie, return the appropriate encoding
- Otherwise return None for read_and_decode to attempt several defaults
Source code in mu/logic.py
sniff_newline_convention(text)
¶
Determine which line-ending convention predominates in the text.
Windows usually has U+000D U+000A Posix usually has U+000A But editors can produce either convention from either platform. And a file which has been copied and edited around might even have both!
Source code in mu/logic.py
write_and_flush(fileobj, content)
¶
Write content to the fileobj then flush and fsync to ensure the data is, in fact, written.
This is especially necessary for USB-attached devices
Source code in mu/logic.py
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.client
¶
A debug client for the Mu editor.
Copyright (c) 2015-2017 Nicholas H.Tollervey and others (see the AUTHORS file).
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Breakpoint
¶
Represents a breakpoint, identified by a breakpoint number (bpnum). Users set breakpoints to stop the debugger at a certain line (potentially in a named function) in a file.
Source code in mu/debugger/client.py
CommandBufferHandler
¶
Bases: QObject
Represents the work to be done on a separate thread for connecting and processing incoming messages.
Emits signals to indicate when messages are receievd or the connection fails at appropriate moments during the lifetime of a debug session.
Source code in mu/debugger/client.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
__init__(debugger)
¶
Receive the debugger object containing the configuration attributes and socket for inter-process communication with the debug runner.
worker()
¶
Buffer input from a socket, emit complete debugger commands as signals.
Source code in mu/debugger/client.py
ConnectionNotBootstrapped
¶
Debugger
¶
Bases: QObject
Represents the networked debugger client.
Source code in mu/debugger/client.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | |
__init__(host, port, proc=None)
¶
Instantiate given a host, port and process for the debug runner.
Source code in mu/debugger/client.py
breakpoint(breakpoint)
¶
Given a breakpoint number or (filename, line), return an object representing the referenced breakpoint.
Source code in mu/debugger/client.py
breakpoints(filename)
¶
Return all the breakpoints associated with the referenced file.
clear_breakpoint(breakpoint)
¶
create_breakpoint(filename, line, temporary=False)
¶
Create a new, enabled breakpoint at the specified line of the given file.
disable_breakpoint(breakpoint)
¶
do_next()
¶
do_return()
¶
do_run()
¶
do_step()
¶
enable_breakpoint(breakpoint)
¶
ignore_breakpoint(breakpoint, count)
¶
Ignore an existing breakpoint for "count" iterations.
(N.B. Use a count of 0 to restore the breakpoint.
on_bootstrap(breakpoints)
¶
The runner has finished setting up.
Source code in mu/debugger/client.py
on_breakpoint_clear(bpnum)
¶
on_breakpoint_create(**bp_data)
¶
The runner has created a breakpoint.
Source code in mu/debugger/client.py
on_breakpoint_disable(bpnum)
¶
The runner has disabled a breakpoint referenced by breakpoint number.
on_breakpoint_enable(bpnum)
¶
The runner has enabled the breakpoint referenced by breakpoint number.
on_breakpoint_ignore(bpnum, count)
¶
The runner will ignore the referenced breakpoint "count" iterations.
on_call(args)
¶
on_command(command)
¶
Handle a command emitted by the client thread.
on_error(message)
¶
on_exception(name, value)
¶
The runner has encountered a named exception with an associated value.
Source code in mu/debugger/client.py
on_fail(message)
¶
on_finished()
¶
on_info(message)
¶
on_line(filename, line)
¶
on_postmortem(*args, **kwargs)
¶
on_restart()
¶
on_return(retval)
¶
on_stack(stack)
¶
on_warning(message)
¶
output(event, **data)
¶
Send a command to the debug runner.
Source code in mu/debugger/client.py
start()
¶
Start the debugger session.
Source code in mu/debugger/client.py
stop()
¶
Shut down the debugger session.
Source code in mu/debugger/client.py
mu.debugger.runner¶
The runner code controls the debug process.
mu.debugger.runner
¶
A debug runner for the Mu editor.
Copyright (c) 2015-2017 Nicholas H.Tollervey and others (see the AUTHORS file).
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
ClientClose
¶
DebugState
¶
Debugger
¶
Bases: Bdb
Instances of this class represent and drive the debugging process.
Source code in mu/debugger/runner.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | |
do_break(filename, line, temporary=False)
¶
Set a breakpoint.
Source code in mu/debugger/runner.py
do_clear(bpnum)
¶
Handle how a breakpoint must be removed when it is a temporary one.
Source code in mu/debugger/runner.py
do_close()
¶
Respond to a closed socket (not a user command, but needs handling).
do_continue()
¶
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.
Source code in mu/debugger/runner.py
do_disable(bpnum)
¶
Disable the breakpoint referenced by its breakpoint number (bpnum).
Source code in mu/debugger/runner.py
do_enable(bpnum)
¶
Enables the breakpoint referenced by its breakpoint number (bpnum).
Source code in mu/debugger/runner.py
do_ignore(bpnum, count)
¶
Ignore the breakpoint referenced by its breakpoint number (bpnum), count number of times.
Source code in mu/debugger/runner.py
do_next()
¶
do_quit()
¶
Set the quitting attribute to True. This raises BdbQuit in the next call to one of the dispatch_*() methods.
do_restart()
¶
do_return()
¶
do_step()
¶
interact(frame, traceback)
¶
Contains the loop processing interactions with the debugger.
Source code in mu/debugger/runner.py
output(event, **data)
¶
Dumps data related to a referenced event to the socket.
Source code in mu/debugger/runner.py
output_stack()
¶
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.
Source code in mu/debugger/runner.py
reset()
¶
setup(frame, traceback)
¶
user_call(frame, argument_list)
¶
This method is called from dispatch_call() when there is the possibility that a break might be necessary anywhere inside the called function.
Source code in mu/debugger/runner.py
user_exception(frame, exc_info)
¶
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.
Source code in mu/debugger/runner.py
user_line(frame)
¶
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.
Source code in mu/debugger/runner.py
user_return(frame, return_value)
¶
This method is called from dispatch_return() when stop_here() yields True.
For when a return trap is set here.
Source code in mu/debugger/runner.py
Restart
¶
command_buffer(debugger)
¶
Buffer input from a socket, yield complete debugger commands.
Source code in mu/debugger/runner.py
run(hostname, port, filename, args)
¶
Run a Python script identified by "filename" with the specified arguments in a debugger session that's listening at hostname/port.
Source code in mu/debugger/runner.py
mu.plugin¶
The public API for plugins. See Writing a Nu plugin.
mu.plugin.base
¶
The plugin base classes and API versioning for Nu.
Copyright (c) 2026 the Nu contributors (see the AUTHORS file).
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
ModePlugin
¶
Bases: Plugin
A plugin whose only job is to contribute modes.
Set mode to a single Mode subclass, or modes to several, and they are
registered for you.
Source code in mu/plugin/base.py
Plugin
¶
Base class for a Nu plugin.
Subclasses set name and api_version, then do all their wiring in
register, using only the Host they are given.
Source code in mu/plugin/base.py
check_compatible(api_version, core_version=PLUGIN_API_VERSION)
¶
Return None if a plugin targeting api_version can run on a core
providing core_version, otherwise a short reason why it can't.
A plugin is compatible when it targets the same MAJOR version and a MINOR version no newer than the core's. While MAJOR is 0 the MINOR versions must match exactly, since 0.x releases are allowed to break the API.
Source code in mu/plugin/base.py
mu.plugin.host
¶
The Host: the façade the core hands to plugins.
Copyright (c) 2026 the Nu contributors (see the AUTHORS file).
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Host
¶
The only supported way for a plugin to reach the editor.
The core is free to change behind this class; a plugin should never need
mu.logic, mu.interface or mu.modes internals. One Host is created per
editor window and handed to every plugin's register/unregister.
Source code in mu/plugin/host.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
modes
property
¶
The registered modes, as a {short_name: mode} dict (a copy).
plugins
property
¶
The successfully loaded plugins, in load order (a copy).
confirm(message, information=None, icon=None)
¶
Ask the learner to confirm with OK/Cancel; return True for OK. icon
is as for show_message.
Source code in mu/plugin/host.py
current_path()
¶
current_text()
¶
load_plugin(plugin)
¶
Check plugin is compatible and call its register. Return True if
it loaded.
This never raises: an incompatible plugin, or one whose register
fails, is logged and skipped, and any modes it registered before
failing are removed again.
Source code in mu/plugin/host.py
logger(name)
¶
open_directory(path)
¶
register_mode(mode_class)
¶
Create an instance of mode_class (a mu.plugin.Mode subclass) and
make it available in the editor. Its short_name must be unique.
Returns the new mode instance, whose host attribute is this Host.
Source code in mu/plugin/host.py
settings(namespace)
¶
show_message(message, information=None, icon=None)
¶
Show a modal message. icon is one of "NoIcon", "Question",
"Information", "Warning" (the default) or "Critical".
show_status(message, duration=5)
¶
unload_plugin(plugin)
¶
Call plugin.unregister and remove the modes it registered. Errors in
unregister are logged, not raised.
Source code in mu/plugin/host.py
PluginSettings
¶
A plugin's own corner of the user settings, persisted with them.
Values live under settings["plugins"][namespace], so plugins can't clash
with each other or with the core's keys. Values must be JSON-serialisable.
Source code in mu/plugin/host.py
get(key, default=None)
¶
set(key, value)
¶
Store value under key; it is saved with the user's settings.
Source code in mu/plugin/host.py
mu.plugin.loader
¶
Finding and loading plugins: installed packages and the drop-in folder.
Copyright (c) 2026 the Nu contributors (see the AUTHORS file).
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
PluginRecord
dataclass
¶
PluginSource
dataclass
¶
A plugin that has been found but not yet imported.
id is the stable name used to enable/disable it: the entry point name,
or the module name in the drop-in folder. origin says where it came from
for logs and the (future) Plugins tab. Calling load() imports it and
returns a Plugin instance, or raises.
Source code in mu/plugin/loader.py
disabled_plugins(store=None)
¶
discover(dropin_dir=None)
¶
Every plugin Nu can see: installed packages first, then the drop-in folder. Nothing is imported yet.
Source code in mu/plugin/loader.py
dropin_sources(dirpath=None)
¶
Plugins dropped into dirpath: each name.py file or name/ package
(with an __init__.py) is one plugin, with id name. The folder is
created if it doesn't exist, so it's there for learners to find.
Defaults to DROPIN_DIR.
Source code in mu/plugin/loader.py
entry_point_sources(group=ENTRY_POINT_GROUP)
¶
Plugins installed as packages in the environment Nu runs from, found
through their mu.plugins entry points.
Source code in mu/plugin/loader.py
load_plugins(host, sources=None, store=None)
¶
Load every discovered, enabled plugin into host and return a
PluginRecord for each one found.
This never raises. A plugin that is switched off, shares an id with one
already found, fails to import, targets an incompatible API version or
fails in register is recorded (and logged) as skipped, and Nu carries
on without it.
Source code in mu/plugin/loader.py
set_plugin_enabled(plugin_id, enabled, store=None)
¶
Switch a plugin on or off; takes effect the next time Nu starts.
Source code in mu/plugin/loader.py
mu.plugin.errors
¶
Keeping Nu running when a plugin has an error.
Copyright (c) 2026 the Nu contributors (see the AUTHORS file).
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
A plugin's code runs in two ways, and both are covered:
- The core calls a plugin mode's methods (
activate,actions,api, ...).PluginErrorHandler.guard_modewraps those methods: an error is reported and a safe fallback is returned, so e.g. a mode whoseapi()fails just has no autocomplete. - Qt calls the plugin's button handlers, timers and signal handlers. An error
there reaches
sys.excepthook;app.excepthookfirst askshandle_uncaught, which recognises plugin code in the traceback and reports the error instead of letting Nu exit.
Either way the learner sees a dialog naming the plugin (rate limited, so a failing timer can't bury them in dialogs), the details go to the log, and a plugin that keeps failing is offered to be switched off.
PluginError
¶
Bases: Exception
Raise this from plugin code for an expected problem the learner can
fix, e.g. "Plug in your micro:bit first". Nu shows message (and the
optional information) as is, rather than reporting a bug in the plugin.
Source code in mu/plugin/errors.py
PluginErrorHandler
¶
Reports errors in plugin code to the learner and the log, so Nu keeps running. There is one per Host.
Source code in mu/plugin/errors.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | |
error_count(plugin)
¶
guard_mode(mode, plugin)
¶
Wrap mode's core-called methods so errors are reported.
Source code in mu/plugin/errors.py
handle_uncaught(exc_type, exc, tb)
¶
Called from app.excepthook. If plugin code raised the exception,
report it and return True (Nu carries on); otherwise return False.
Source code in mu/plugin/errors.py
owner(tb)
¶
The plugin whose code appears in traceback tb (the innermost one,
if several), or None if it's all core code. A frame counts as the
plugin's if it's in the plugin's modules, or is a method called on
one of the plugin's modes (e.g. inherited MicroPythonMode code).
Source code in mu/plugin/errors.py
report(plugin, exc, tb=None, where=None)
¶
Tell the learner (and the log) that plugin raised exc. This never
raises.
Source code in mu/plugin/errors.py
handle_uncaught(exc_type, exc, tb)
¶
For app.excepthook: return True if the exception came from a plugin
and has been reported, so Nu should carry on.
Source code in mu/plugin/errors.py
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.main
¶
Contains the main Window definition for Mu's UI.
Copyright (c) 2015-2017 Nicholas H.Tollervey and others (see the AUTHORS file).
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
ButtonBar
¶
Bases: QToolBar
Represents the bar of buttons across the top of the editor and defines their behaviour.
Source code in mu/interface/main.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
addAction(name, display_name, tool_text)
¶
Creates an action associated with an icon and name and adds it to the widget's slots.
Source code in mu/interface/main.py
connect(name, handler, shortcut=None)
¶
Connects a named slot to a handler function and optional hot-key shortcuts.
Source code in mu/interface/main.py
reset()
¶
set_responsive_mode(width, height)
¶
Compact button bar for when window is very small.
Source code in mu/interface/main.py
FileTabs
¶
Bases: QTabWidget
Extend the base class so we can override the removeTab behaviour.
Source code in mu/interface/main.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | |
addTab(widget, title)
¶
Add a new tab to the switcher
Source code in mu/interface/main.py
change_tab(tab_id)
¶
Update the application title to reflect the name of the file in the currently selected tab.
Source code in mu/interface/main.py
removeTab(tab_id)
¶
Ask the user before closing the file.
Source code in mu/interface/main.py
StatusBar
¶
Bases: QStatusBar
Defines the look and behaviour of the status bar along the bottom of the UI.
Source code in mu/interface/main.py
1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 | |
connect_logs(handler, shortcut)
¶
Connect the mouse press event and keyboard shortcut for the log widget to the referenced handler function.
Source code in mu/interface/main.py
connect_mode(handler, shortcut)
¶
Connect the mouse press event and keyboard shortcut for the mode widget to the referenced handler function.
Source code in mu/interface/main.py
device_connected(device)
¶
Show a tooltip whenever a new device connects
Source code in mu/interface/main.py
set_message(message, pause=5000)
¶
Window
¶
Bases: QMainWindow
Defines the look and characteristics of the application's main window.
Source code in mu/interface/main.py
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 | |
current_tab
property
¶
Returns the currently focussed tab.
modified
property
¶
Returns a boolean indication if there are any modified tabs in the editor.
tab_count
property
¶
Returns the number of active tabs.
widgets
property
¶
Returns a list of references to the widgets representing tabs in the editor.
add_debug_inspector()
¶
Display a debug inspector to view the call stack.
Source code in mu/interface/main.py
add_jupyter_repl(kernel_manager, kernel_client)
¶
Adds a Jupyter based REPL pane to the application.
Source code in mu/interface/main.py
add_micropython_plotter(name, connection, data_flood_handler)
¶
Adds a plotter that reads data from a serial connection.
Source code in mu/interface/main.py
add_micropython_repl(name, connection)
¶
Adds a MicroPython based REPL pane to the application.
Source code in mu/interface/main.py
add_plotter(plotter_pane, name)
¶
Adds the referenced plotter pane to the application.
Source code in mu/interface/main.py
add_python3_plotter(mode)
¶
Add a plotter that reads from either the REPL or a running script. Since this function will only be called when either the REPL or a running script are running (but not at the same time), it'll just grab data emitted by the REPL or script via data_received.
Source code in mu/interface/main.py
add_python3_runner(interpreter, script_name, working_directory, interactive=False, debugger=False, command_args=None, envars=None, python_args=None)
¶
Display console output for the interpreter with the referenced pythonpath running the referenced script.
The script will be run within the workspace_path directory.
If interactive is True (default is False) the Python process will run in interactive mode (dropping the user into the REPL when the script completes).
If debugger is True (default is False) the script will be run within a debug runner session. The debugger overrides the interactive flag (you cannot run the debugger in interactive mode).
If there is a list of command_args (the default is None) then these will be passed as further arguments into the command run in the new process.
If envars is given, these will become part of the environment context of the new child process.
If python_args is given, these will be passed as arguments to the Python runtime used to launch the child process.
Source code in mu/interface/main.py
654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 | |
add_repl(repl_pane, name)
¶
Adds the referenced REPL pane to the application.
Source code in mu/interface/main.py
add_tab(path, text, api, newline)
¶
Adds a tab with the referenced path and text to the editor.
Source code in mu/interface/main.py
annotate_code(feedback, annotation_type)
¶
Given a list of annotations about the code in the current tab, add the annotations to the editor window so the user can make appropriate changes.
Source code in mu/interface/main.py
change_mode(mode)
¶
Given a an object representing a mode, recreates the button bar with the expected functionality.
Source code in mu/interface/main.py
connect_find_again(handlers, shortcut)
¶
Create keyboard shortcuts and associate them with handlers for doing a find again in forward or backward direction. Any given shortcut will be used for forward find again, while Shift+shortcut will find again backwards.
Source code in mu/interface/main.py
connect_find_replace(handler, shortcut)
¶
Create a keyboard shortcut and associate it with a handler for doing a find and replace.
Source code in mu/interface/main.py
connect_tab_rename(handler, shortcut)
¶
Connect the double-click event on a tab and the keyboard shortcut to the referenced handler (causing the Save As dialog).
Source code in mu/interface/main.py
connect_toggle_comments(handler, shortcut)
¶
Create a keyboard shortcut and associate it with a handler for toggling comments on highlighted lines.
Source code in mu/interface/main.py
connect_zoom(widget)
¶
Connects a referenced widget to the zoom related signals and sets the zoom of the widget to the current zoom level.
Source code in mu/interface/main.py
copy_to_repl()
¶
Copies currently selected text in the editor, into the active REPL widget and sets focus to the REPL widget. The final line pasted into the REPL waits for RETURN to be pressed by the user (this appears to be the default behaviour for pasting into the REPL widget).
Source code in mu/interface/main.py
focus_tab(tab)
¶
get_load_path(folder, extensions='*', allow_previous=True)
¶
Displays a dialog for selecting a file to load. Returns the selected path. Defaults to start in the referenced folder unless a previous folder has been used and the allow_previous flag is True (the default behaviour)
Source code in mu/interface/main.py
get_save_path(folder)
¶
Displays a dialog for selecting a file to save. Returns the selected path. Defaults to start in the referenced folder.
Source code in mu/interface/main.py
hide_device_selector()
¶
highlight_text(target_text, forward=True)
¶
Highlight the first match from the current position of the cursor in the current tab for the target_text. Returns True if there's a match.
Source code in mu/interface/main.py
on_context_menu()
¶
Called when a user right-clicks on an editor pane.
If the REPL is active AND there is selected text in the current editor pane, modify the default context menu to include a paste to REPL option. Otherwise, just display the default context menu.
Source code in mu/interface/main.py
on_stdout_write(data)
¶
open_directory_from_os(path)
¶
Given the path to a directory, open the OS's built in filesystem explorer for that path. Works with Windows, OSX and Linux.
Source code in mu/interface/main.py
remove_debug_inspector()
¶
Removes the debug inspector pane from the application.
Source code in mu/interface/main.py
remove_plotter()
¶
Removes the plotter pane from the application.
Source code in mu/interface/main.py
remove_python_runner()
¶
Removes the runner pane from the application.
Source code in mu/interface/main.py
remove_repl()
¶
Removes the REPL pane from the application.
Source code in mu/interface/main.py
replace_text(target_text, replace, global_replace)
¶
Given target_text, replace the first instance after the cursor with "replace". If global_replace is true, replace all instances of "target". Returns the number of times replacement has occurred.
Source code in mu/interface/main.py
reset_annotations()
¶
resizeEvent(resizeEvent)
¶
Respond to window getting too small for the button bar to fit well.
screen_size()
¶
Returns an (width, height) tuple with the screen geometry.
select_mode(modes, current_mode)
¶
Display the mode selector dialog and return the result.
Source code in mu/interface/main.py
set_checker_icon(icon)
¶
Set the status icon to use on the check button
Source code in mu/interface/main.py
set_read_only(is_readonly)
¶
set_theme(theme)
¶
Sets the theme for the REPL and editor tabs.
Source code in mu/interface/main.py
set_timer(duration, callback)
¶
Set a repeating timer to call "callback" every "duration" seconds.
Source code in mu/interface/main.py
set_usb_checker(duration, callback)
¶
Sets up a timer that polls for USB changes via the "callback" every "duration" seconds.
Source code in mu/interface/main.py
set_zoom()
¶
setup(breakpoint_toggle, theme)
¶
Sets up the window.
Defines the various attributes of the window and defines how the user interface is laid out.
Source code in mu/interface/main.py
show_admin(log, settings, packages, mode, device_list)
¶
Display the administrative dialog with referenced content of the log and settings. Return a dictionary of the settings that may have been changed by the admin dialog.
Source code in mu/interface/main.py
show_annotations()
¶
show_confirmation(message, information=None, icon=None)
¶
Displays a modal message to the user to which they need to confirm or cancel.
If information is passed in this will be set as the additional informative text in the modal dialog.
Since this mechanism will be used mainly for warning users that something is awry the default icon is set to "Warning". It's possible to override the icon to one of the following settings: NoIcon, Question, Information, Warning or Critical.
Source code in mu/interface/main.py
show_device_selector()
¶
show_find_replace(find, replace, global_replace)
¶
Display the find/replace dialog. If the dialog's OK button was clicked return a tuple containing the find term, replace term and global replace flag.
Source code in mu/interface/main.py
show_message(message, information=None, icon=None)
¶
Displays a modal message to the user.
If information is passed in this will be set as the additional informative text in the modal dialog.
Since this mechanism will be used mainly for warning users that something is awry the default icon is set to "Warning". It's possible to override the icon to one of the following settings: NoIcon, Question, Information, Warning or Critical.
Source code in mu/interface/main.py
size_window(x=None, y=None, w=None, h=None)
¶
Makes the editor 80% of the width*height of the screen and centres it when none of x, y, w and h is passed in; otherwise uses the passed in values to position and size the editor window.
If the X or Y value will be off the screen, these are reset to None (thus stopping the window being drawn in a hard-to-reach place). See issue #1613 for context.
Source code in mu/interface/main.py
stop_timer()
¶
sync_packages(to_remove, to_add)
¶
Display a modal dialog that indicates the status of the add/remove package management operation.
Source code in mu/interface/main.py
toggle_comments()
¶
Toggle comments on/off for all selected line in the currently active tab.
update_debug_inspector(locals_dict)
¶
Given the contents of a dict representation of the locals in the current stack frame, update the debug inspector with the new values.
Source code in mu/interface/main.py
update_title(filename=None)
¶
Updates the title bar of the application. If a filename (representing the name of the file currently the focus of the editor) is supplied, append it to the end of the title.
Source code in mu/interface/main.py
wheelEvent(event)
¶
Trap a CTRL-scroll event so the user is able to zoom in and out.
Source code in mu/interface/main.py
zoom_in()
¶
mu.interface.dialogs¶
Bespoke modal dialogs required by Mu.
mu.interface.dialogs
¶
UI related code for dialogs used by Mu.
Copyright (c) 2015-2017 Nicholas H.Tollervey and others (see the AUTHORS file).
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
AdminDialog
¶
Bases: QDialog
Displays administrative related information and settings (logs, environment variables, third party packages etc...).
Source code in mu/interface/dialogs.py
settings()
¶
Return a dictionary representation of the raw settings information generated by this dialog. Such settings will need to be processed / checked in the "logic" layer of Mu.
Source code in mu/interface/dialogs.py
CrashDialog
¶
Bases: QDialog
Shown when Nu hits an error it can't recover from. It shows the crash details and lets the user copy them (e.g. into a bug report); nothing is sent anywhere.
Source code in mu/interface/dialogs.py
EnvironmentVariablesWidget
¶
Bases: QWidget
Used for editing and displaying environment variables used with Python 3 mode.
Source code in mu/interface/dialogs.py
FindReplaceDialog
¶
Bases: QDialog
Display a dialog for getting:
- A term to find,
- An optional value to replace the search term,
- A flag to indicate if the user wishes to replace all.
Source code in mu/interface/dialogs.py
LocaleWidget
¶
Bases: QWidget
Used for manually setting the locale (and thus the language) used by Mu.
Source code in mu/interface/dialogs.py
LogWidget
¶
Bases: QWidget
Used to display Mu's logs.
Source code in mu/interface/dialogs.py
ModeItem
¶
Bases: QListWidgetItem
Represents an available mode listed for selection.
Source code in mu/interface/dialogs.py
ModeSelector
¶
Bases: QDialog
Defines a UI for selecting the mode for Mu.
Source code in mu/interface/dialogs.py
get_mode()
¶
Return details of the newly selected mode.
PackageDialog
¶
Bases: QDialog
Display the output of the pip commands needed to remove or install packages.
Because the QProcess mechanism we're using is asynchronous, we have to
manage the pip requests via pip_queue. When one request is signalled
as finished we start the next.
Source code in mu/interface/dialogs.py
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 | |
finish()
¶
next_pip_command()
¶
Run the next pip command, finishing if there is none.
run_pip(command, packages)
¶
Run a pip command in a subprocess and pipe the output to the dialog's text area.
Source code in mu/interface/dialogs.py
setup(to_remove, to_add)
¶
Create the UI for the dialog.
Source code in mu/interface/dialogs.py
PackagesWidget
¶
Bases: QWidget
Used for editing and displaying 3rd party packages installed via pip to be used with Python 3 mode.
Source code in mu/interface/dialogs.py
mu.interface.editor¶
Contains the customised Scintilla based editor used for textual display and entry.
mu.interface.editor
¶
UI related capabilities for the text editor widget embedded in each tab in Mu.
Copyright (c) 2015-2017 Nicholas H.Tollervey and others (see the AUTHORS file).
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
CssLexer
¶
Bases: QsciLexerCSS
Fixes problems with comments in CSS.
Source code in mu/interface/editor.py
description(style)
¶
Ensures "Comment" is returned when the lexer encounters a comment (this is due to a bug in the base class, for which this is a work around).
Source code in mu/interface/editor.py
EditorPane
¶
Bases: QsciScintilla
Represents the text editor.
Source code in mu/interface/editor.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 | |
label
property
¶
The label associated with this editor widget (usually the filename of the script we're editing).
title
property
¶
The title associated with this editor widget (usually the filename of the script we're editing).
If the script has been modified since it was last saved, the label will end with an asterisk.
annotate_code(feedback, annotation_type='error')
¶
Given a list of annotations add them to the editor pane so the user can act upon them.
Source code in mu/interface/editor.py
configure()
¶
Set up the editor component.
Source code in mu/interface/editor.py
connect_margin(func)
¶
Connect clicking the margin to the passed in handler function, via a filtering handler that ignores clicks on margin 4.
Source code in mu/interface/editor.py
contextMenuEvent(event)
¶
debugger_at_line(line)
¶
Set the line to be highlighted with the DEBUG_INDICATOR.
Source code in mu/interface/editor.py
dropEvent(event)
¶
Run by Qt when something is dropped on this editor
Source code in mu/interface/editor.py
find_next_match(text, from_line=-1, from_col=-1, case_sensitive=True, wrap_around=True)
¶
Finds the next text match from the current cursor, or the given position, and selects it (the automatic selection is the only available QsciScintilla behaviour). Returns True if match found, False otherwise.
Source code in mu/interface/editor.py
highlight_selected_matches()
¶
Checks the current selection, if it is a single word it then searches and highlights all matches.
Since we're interested in exactly one word: * Ignore an empty selection * Ignore anything which spans more than one line * Ignore more than one word * Ignore anything less than one word
Source code in mu/interface/editor.py
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 | |
range_from_positions(start_position, end_position)
¶
Given a start-end pair, such as are provided by a regex match, return the corresponding Scintilla line-offset pairs which are used for searches, indicators etc.
NOTE: Arguments must be byte offsets into the underlying text bytes.
Source code in mu/interface/editor.py
reset_annotations()
¶
Clears all the assets (indicators, annotations and markers).
reset_check_indicators()
¶
Clears all the text indicators related to the check code functionality.
Source code in mu/interface/editor.py
reset_debugger_highlight()
¶
Reset all the lines so the DEBUG_INDICATOR is no longer displayed.
We need to check each line since there's no way to tell what the currently highlighted line is. This approach also has the advantage of resetting the whole editor pane.
Source code in mu/interface/editor.py
reset_search_indicators()
¶
Clears all the text indicators from the search functionality.
Source code in mu/interface/editor.py
selection_change_listener()
¶
Runs every time the text selection changes. This could get triggered multiple times while the mouse click is down, even if selection has not changed in itself. If there is a new selection is passes control to highlight_selected_matches.
Source code in mu/interface/editor.py
set_api(api_definitions)
¶
Sets the API entries for tooltips, calltips and the like.
set_theme(theme=DayTheme)
¶
Connect the theme to a lexer and return the lexer for the editor to apply to the script text.
Source code in mu/interface/editor.py
set_zoom(size='m')
¶
Sets the font zoom to the specified base point size for all fonts given a t-shirt size.
Source code in mu/interface/editor.py
show_annotations()
¶
Display all the messages to be annotated to the code.
Source code in mu/interface/editor.py
toggle_comments()
¶
Iterate through the selected lines and toggle their comment/uncomment state. So, lines that are not comments become comments and vice versa.
Source code in mu/interface/editor.py
toggle_line(raw_line)
¶
Given a raw_line, will return the toggled version of it.
Source code in mu/interface/editor.py
wheelEvent(event)
¶
PythonLexer
¶
Bases: QsciLexerPython
A Python specific "lexer" that's used to identify keywords of the Python language so the editor can do syntax highlighting.
Source code in mu/interface/editor.py
keywords(flag)
¶
Returns a list of Python keywords.
mu.interface.panes¶
Contains code used to populate the various panes found in the user interface (REPL, file list, debug inspector etc...).
mu.interface.panes
¶
Contains the UI classes used to populate the various panes used by Mu.
Copyright (c) 2015-2017 Nicholas H.Tollervey and others (see the AUTHORS file).
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
DebugInspector
¶
Bases: QTreeView
Presents a tree like representation of the current state of the call stack to the user.
Source code in mu/interface/panes.py
record_collapsed(index)
¶
Remove collapsed dicts from set, so they render collapsed.
Source code in mu/interface/panes.py
record_expanded(index)
¶
Keep track of expanded dicts for displaying in debugger.
set_font_size(new_size=DEFAULT_FONT_SIZE)
¶
Sets the font size for all the textual elements in this pane.
Source code in mu/interface/panes.py
JupyterREPLPane
¶
Bases: RichJupyterWidget
REPL = Read, Evaluate, Print, Loop.
Displays a Jupyter iPython session.
Source code in mu/interface/panes.py
setFocus()
¶
set_font_size(new_size=DEFAULT_FONT_SIZE)
¶
Sets the font size for all the textual elements in this pane.
set_theme(theme)
¶
Sets the theme / look for the REPL pane.
Source code in mu/interface/panes.py
MicroPythonREPLPane
¶
Bases: QTextEdit
REPL = Read, Evaluate, Print, Loop.
This widget represents a REPL client connected to a device running MicroPython.
The device MUST be flashed with MicroPython for this to work.
Source code in mu/interface/panes.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | |
clear()
¶
context_menu()
¶
Creates custom context menu with just copy and paste.
Source code in mu/interface/panes.py
delete_selection()
¶
Returns true if deletion happened, returns false if there was no selection to delete.
Source code in mu/interface/panes.py
insertFromMimeData(source)
¶
Insert mime data by sending it to the REPL
Source code in mu/interface/panes.py
keyPressEvent(data)
¶
Called when the user types something in the REPL.
Correctly encodes it and sends it to the connected device.
Source code in mu/interface/panes.py
mouseReleaseEvent(mouseEvent)
¶
Called whenever a user have had a mouse button pressed, and releases it. We pass it through to the normal way Qt handles button pressed, but also sends as cursor movement signal to the device (except if a selection is made, for selections we first move the cursor on deselection)
Source code in mu/interface/panes.py
move_cursor_to(new_position)
¶
Move the cursor, by sending vt100 left/right signals through serial. The Qt cursor is first returned to the known location of the device cursor. Then the appropriate number of move left or right signals are send. The Qt cursor is not moved to the new_position here, but will be moved once receiving a response (in process_tty_data).
Source code in mu/interface/panes.py
process_tty_data(data)
¶
Given some incoming bytes of data, work out how to handle / display them in the REPL widget. If received input is incomplete, stores remainder in self.unprocessed_input.
Updates the self.device_cursor_position to match that of the device for every input received.
Source code in mu/interface/panes.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 | |
set_devicecursor_to_qtcursor()
¶
Call this whenever the cursor has been moved by the user, to send the cursor movement to the device.
set_font_size(new_size=DEFAULT_FONT_SIZE)
¶
Sets the font size for all the textual elements in this pane.
set_qtcursor_to_devicecursor()
¶
Resets the Qt TextCursor to where we know the device has the cursor placed.
PlotterPane
¶
Bases: QChartView
This plotter widget makes viewing sensor data easy!
This widget represents a chart that will look for tuple data from the MicroPython REPL, Python 3 REPL or Python 3 code runner and will auto-generate a graph.
Source code in mu/interface/panes.py
1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 | |
add_data(values)
¶
Given a tuple of values, ensures there are the required number of line series, add the data to the line series, update the range of the chart so the chart displays nicely.
Source code in mu/interface/panes.py
1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 | |
process_tty_data(data)
¶
Takes raw bytes and, if a valid tuple is detected, adds the data to the plotter.
The the length of the bytes data > 1024 then a data_flood signal is emitted to ensure Mu can take action to remain responsive.
Source code in mu/interface/panes.py
set_theme(theme)
¶
Sets the theme / look for the plotter pane.
Source code in mu/interface/panes.py
PythonProcessPane
¶
Bases: QTextEdit
Handles / displays a Python process's stdin/out with working command history and simple buffer editing.
Source code in mu/interface/panes.py
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 | |
append(msg)
¶
Append text to the text area.
Source code in mu/interface/panes.py
backspace()
¶
Removes a character from the current buffer -- to the left of cursor.
Source code in mu/interface/panes.py
clear_input_line()
¶
Remove all the characters currently in the input buffer line.
Source code in mu/interface/panes.py
context_menu()
¶
Creates custom context menu with just copy and paste.
Source code in mu/interface/panes.py
delete()
¶
Removes a character from the current buffer -- to the right of cursor.
finished(code, status)
¶
Handle when the child process finishes.
Source code in mu/interface/panes.py
history_back()
¶
Replace the current input line with the next item BACK from the current history position.
Source code in mu/interface/panes.py
history_forward()
¶
Replace the current input line with the next item FORWARD from the current history position.
Source code in mu/interface/panes.py
insert(msg)
¶
Insert text to the text area at the current cursor position.
Source code in mu/interface/panes.py
insertFromMimeData(source)
¶
Insert mime data by sending it to the REPL
Source code in mu/interface/panes.py
keyPressEvent(data)
¶
Called when the user types something in the REPL.
on_process_halt()
¶
Called when the the user has manually halted a running process. Ensures that the remaining data from the halted process's stdout is handled properly.
When the process is halted the user is dropped into the Python prompt and this method ensures the UI is updated in a clean, non-blocking way.
Source code in mu/interface/panes.py
parse_input(key, text, modifiers)
¶
Correctly encodes user input and sends it to the connected process.
The key is a Qt.Key.Key_Something value, text is the textual representation of the input, and modifiers are the control keys (shift, CTRL, META, etc) also used.
Source code in mu/interface/panes.py
773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 | |
parse_paste(text)
¶
Recursively takes characters from text to be parsed as input. We do this so the event loop has time to respond to output from the process to which the characters are sent (for example, when a newline is sent).
Yes, this is a quick and dirty hack, but ensures the pasted input is also evaluated in an interactive manner rather than as a single-shot splurge of data. Essentially, it's simulating someone typing in the characters of the pasted text really fast but in such a way that the event loop cycles.
Source code in mu/interface/panes.py
read_from_stdout()
¶
Process incoming data from the process's stdout.
Source code in mu/interface/panes.py
replace_input_line(text)
¶
set_font_size(new_size=DEFAULT_FONT_SIZE)
¶
Sets the font size for all the textual elements in this pane.
set_start_of_current_line()
¶
Set the flag to indicate the start of the current line (used before waiting for input).
This flag is used to discard the preceding text in the text entry field when Mu parses new input from the user (i.e. any text beyond the self.start_of_current_line).
Source code in mu/interface/panes.py
set_zoom(size)
¶
start_process(interpreter, script_name, working_directory, interactive=True, debugger=False, command_args=None, envars=None, python_args=None)
¶
Start the child Python process.
Will use the referenced interpreter to run the Python script_name within the context of the working directory.
If interactive is True (the default) the Python process will run in interactive mode (dropping the user into the REPL when the script completes).
If debugger is True (the default is False) then the script will run within a debug runner session.
If there is a list of command_args (the default is None), then these will be passed as further arguments into the script to be run.
If there is a list of environment variables, these will be part of the context of the new child process.
If python_args is given, these are passed as arguments to the Python interpreter used to launch the child process.
Source code in mu/interface/panes.py
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 | |
try_read_from_stdout()
¶
Ensure reading from stdout only happens if there is NOT already current attempts to read from stdout.
mu.interface.themes¶
Theme related code so Qt changes for each pre-defined theme.
mu.interface.themes
¶
Theme and presentation related code for the Mu editor.
Copyright (c) 2015-2017 Nicholas H.Tollervey and others (see the AUTHORS file).
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
ContrastTheme
¶
Bases: Theme
Defines a Python related theme including the various font colours for syntax highlighting.
This is the high contrast theme.
Source code in mu/interface/themes.py
DayTheme
¶
Bases: Theme
Defines a Python related theme including the various font colours for syntax highlighting.
This is a light theme.
Source code in mu/interface/themes.py
Font
¶
Utility class that makes it easy to set font related values within the editor.
Source code in mu/interface/themes.py
stylename
property
¶
Map the bold and italic boolean flags here to a relevant font style name.
get_database()
classmethod
¶
Register Mu's builtin fonts with Qt's font database.
Qt6's QFontDatabase is entirely static (it can no longer be instantiated), so this simply ensures the application fonts are loaded exactly once for the lifetime of the process.
Source code in mu/interface/themes.py
load(size=DEFAULT_FONT_SIZE)
¶
Load the font from the font database, using the correct size and style
NightTheme
¶
Bases: Theme
Defines a Python related theme including the various font colours for syntax highlighting.
This is the dark theme.
Source code in mu/interface/themes.py
Theme
¶
Defines a font and other theme specific related information.
Source code in mu/interface/themes.py
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.base
¶
Contains the base classes for Mu editor modes.
Copyright (c) 2015-2017 Nicholas H.Tollervey and others (see the AUTHORS file).
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
BaseMode
¶
Bases: QObject
Represents the common aspects of a mode.
Source code in mu/modes/base.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | |
actions()
¶
Return an ordered list of actions provided by this module. An action is a name (also used to identify the icon) , description, and handler.
activate()
¶
add_plotter()
¶
Mode specific implementation of adding and connecting a plotter to incoming streams of data tuples.
api()
¶
assets_dir(asset_type)
¶
Determine (and create) the directory for a set of assets
This supports the [Images] and [Sounds] &c. buttons in pygamezero mode and possibly other modes, too.
If a tab is current and has an active file, the assets directory is looked for under that path; otherwise the workspace directory is used.
If the assets directory does not exist it is created
Source code in mu/modes/base.py
deactivate()
¶
device_changed(new_device)
¶
ensure_state()
¶
Executed when the mode is finished setting up. Used to ensure button / UI state according to current state of settings.
on_data_flood()
¶
Handle when the plotter is being flooded by data (which usually causes Mu to become unresponsive). In this case, remove the plotter and display a warning dialog to explain what's happened and how to fix things (usually, put a time.sleep(x) into the code generating the data).
Source code in mu/modes/base.py
open_file(path)
¶
Some files are not plain text and each mode can attempt to decode them.
When overridden, should return the text and newline convention for the file.
remove_plotter()
¶
If there's an active plotter, hide it.
Save any data captured while the plotter was active into a directory called 'data_capture' in the workspace directory. The file contains CSV data and is named with a timestamp for easy identification.
Source code in mu/modes/base.py
return_focus_to_current_tab()
¶
After, eg, stopping the plotter or closing the REPL return the focus to the currently-active tab is there is one.
set_buttons(**kwargs)
¶
Given the names and boolean settings of buttons associated with actions for the current mode, toggles them into the boolean enabled state.
Source code in mu/modes/base.py
stop()
¶
Called if/when the editor quits when in this mode. Override in child classes to clean up state, stop child processes etc.
workspace_dir()
staticmethod
¶
Return the location on the filesystem for opening and closing files.
The default is to use a directory in the users home folder, however in some network systems this in inaccessible. This allows a key in the settings file to be used to set a custom path.
Source code in mu/modes/base.py
write_plotter_data_to_csv(csv_filepath)
¶
Write any plotter data out to a CSV file when the plotter is closed
Source code in mu/modes/base.py
MicroPythonMode
¶
Bases: BaseMode
Includes functionality that works with a USB serial based REPL.
Source code in mu/modes/base.py
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 | |
activate()
¶
add_plotter()
¶
Check if REPL exists, and if so, enable the plotter pane!
Source code in mu/modes/base.py
add_repl()
¶
Detect a connected MicroPython based device and, if found, connect to the REPL and display it to the user.
Source code in mu/modes/base.py
compatible_board(port)
¶
A compatible board must match on vendor ID, but only needs to match on product ID or manufacturer ID, if they are supplied in the list of valid boards (aren't None).
Source code in mu/modes/base.py
deactivate()
¶
Invoked whenever the mode is deactivated.
device_changed(new_device)
¶
Invoked when the user changes device.
Source code in mu/modes/base.py
find_devices(with_logging=True)
¶
Returns the port and serial number, and name for the first MicroPython-ish device found connected to the host computer. If no device is found, returns the tuple (None, None, None).
Source code in mu/modes/base.py
on_data_flood()
¶
remove_plotter()
¶
Remove plotter pane. Disconnects serial connection to device.
remove_repl()
¶
If there's an active REPL, disconnect and hide it.
toggle_plotter(event)
¶
Toggles the plotter on and off.
toggle_repl(event)
¶
REPLConnection
¶
Bases: QObject
Source code in mu/modes/base.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
close()
¶
Close and clean up the currently open serial link.
execute(commands)
¶
Execute a series of commands over a period of time (scheduling remaining commands to be run in the next iteration of the event loop).
Source code in mu/modes/base.py
open()
¶
Open the serial link
Source code in mu/modes/base.py
send_commands(commands)
¶
Send commands to the REPL via raw mode.
Source code in mu/modes/base.py
mu.modes.circuitpython¶
CircuitPython mode for Adafruit boards (and others).
mu.modes.circuitpython
¶
A mode for working with Circuit Python boards.
Copyright (c) 2015-2017 Nicholas H.Tollervey and others (see the AUTHORS file).
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
CircuitPythonMode
¶
Bases: MicroPythonMode
Represents the functionality required by the CircuitPython mode.
Source code in mu/modes/circuitpython.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | |
actions()
¶
Return an ordered list of actions provided by this module. An action is a name (also used to identify the icon) , description, and handler.
Source code in mu/modes/circuitpython.py
api()
¶
compatible_board(port)
¶
Use adafruit_board_toolkit to find out whether a board is running CircuitPython. The toolkit sees if the CDC Interface name is appropriate.
Source code in mu/modes/circuitpython.py
workspace_dir()
¶
Return the default location on the filesystem for opening and closing files.
Source code in mu/modes/circuitpython.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
mu.modes.debugger¶
The Python 3 debugger mode.
mu.modes.debugger
¶
The mode Mu is is when it's debugging a Python 3 script.
Copyright (c) 2015-2017 Nicholas H.Tollervey and others (see the AUTHORS file).
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
DebugMode
¶
Bases: BaseMode
Represents the functionality required by the Python 3 visual debugger.
Source code in mu/modes/debugger.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
actions()
¶
Return an ordered list of actions provided by this module. An action is a name (also used to identify the icon) , description, and handler.
Source code in mu/modes/debugger.py
api()
¶
button_continue(event)
¶
button_step_in(event)
¶
Button clicked to step into the current block of code.
button_step_out(event)
¶
Button clicked to step out of the current block of code.
button_step_over(event)
¶
Button clicked to step over the current line of code.
button_stop(event)
¶
debug_on_bootstrap()
¶
Once the debugger is bootstrapped ensure all the current breakpoints are set. Do not set breakpoints (and remove the marker) if:
- The marker is not visible (the line is -1)
- The marker is not a duplicate of an existing line.
- The line with the marker is not a valid breakpoint line.
Source code in mu/modes/debugger.py
debug_on_breakpoint_clear(breakpoint)
¶
Handle the clearing of the referenced breakpoint. Currently an unimplemented extra feature.
debug_on_breakpoint_disable(breakpoint)
¶
debug_on_breakpoint_enable(breakpoint)
¶
Handle when a breakpoint is enabled.
Source code in mu/modes/debugger.py
debug_on_breakpoint_ignore(breakpoint, count)
¶
Handle when a breakpoint is to be ignored by the debugger. Currently an unimplemented extra feature.
debug_on_call(args)
¶
Handle when the debugger has called a function with the referenced args. Make sure the debugger steps into the function.
debug_on_error(message)
¶
debug_on_exception(name, value)
¶
Handle when the debugger encounters a named exception with an associated value. Clear the highlighted line and allow the script to run until the end so the error message is printed to stdout.
Source code in mu/modes/debugger.py
debug_on_fail(message)
¶
Called when, for any reason, the debug client was unable to connect to the debug runner. On a Raspberry Pi this is usually because it's an underpowereed machine and it takes time to start the debug runner process. (However, the debug client waits for 10 seconds for the runner to start.)
Source code in mu/modes/debugger.py
debug_on_finished()
¶
debug_on_info(message)
¶
debug_on_line(filename, line)
¶
Handle when the debugger has moved to the referenced line in the file.
Source code in mu/modes/debugger.py
debug_on_postmortem(args, kwargs)
¶
Handle when something catastrophic happens to the debugger.
Source code in mu/modes/debugger.py
debug_on_restart()
¶
debug_on_return(return_value)
¶
Handle when the debugger returns from a function call with the referenced return value. Make sure the debugger steps out of the function to the caller.
debug_on_stack(stack)
¶
Handle when the debugger sends an updated stack.
Source code in mu/modes/debugger.py
debug_on_warning(message)
¶
disable_buttons()
¶
disable_buttons_later(*, milliseconds=100)
¶
enable_buttons()
¶
Enable all debug control buttons except 'stop': if the timer started
in disable_buttons_later is active, stops it and does nothing else.
Source code in mu/modes/debugger.py
finished()
¶
Called when the debugged Python process is finished.
Source code in mu/modes/debugger.py
start()
¶
Start debugging the current script.
Source code in mu/modes/debugger.py
stop()
¶
Stop the debug runner and reset the UI.
Source code in mu/modes/debugger.py
toggle_breakpoint(line, tab)
¶
Toggle a breakpoint in the debugger.
Source code in mu/modes/debugger.py
mu.modes.pygamezero¶
The Pygame Zero / pygame mode.
mu.modes.pygamezero
¶
The Pygame Zero mode for the Mu editor.
Copyright (c) 2015-2017 Nicholas H.Tollervey and others (see the AUTHORS file).
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
PyGameZeroMode
¶
Bases: BaseMode
Represents the functionality required by the PyGameZero mode.
Source code in mu/modes/pygamezero.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | |
actions()
¶
Return an ordered list of actions provided by this module. An action is a name (also used to identify the icon) , description, and handler.
Source code in mu/modes/pygamezero.py
api()
¶
Return a list of API specifications to be used by auto-suggest and call tips.
play_toggle(event)
¶
Handles the toggling of the play button to start/stop a script.
Source code in mu/modes/pygamezero.py
run_game()
¶
Run the current game.
Source code in mu/modes/pygamezero.py
show_fonts(event)
¶
Open the directory containing the font assets used by Pygame Zero.
This should open the host OS's file system explorer so users can drag new files into the opened folder.
Source code in mu/modes/pygamezero.py
show_images(event)
¶
Open the directory containing the image assets used by Pygame Zero.
This should open the host OS's file system explorer so users can drag new files into the opened folder.
Source code in mu/modes/pygamezero.py
show_music(event)
¶
Open the directory containing the music assets used by Pygame Zero.
This should open the host OS's file system explorer so users can drag new files into the opened folder.
Source code in mu/modes/pygamezero.py
show_sounds(event)
¶
Open the directory containing the sound assets used by Pygame Zero.
This should open the host OS's file system explorer so users can drag new files into the opened folder.
Source code in mu/modes/pygamezero.py
stop_game()
¶
mu.modes.python3¶
The Python 3 editing mode.
mu.modes.python3
¶
The Python3 mode for the Mu editor.
Copyright (c) 2015-2017 Nicholas H.Tollervey and others (see the AUTHORS file).
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
KernelRunner
¶
Bases: QObject
Used to control the iPython kernel in a non-blocking manner so the UI remains responsive.
Source code in mu/modes/python3.py
__init__(kernel_name, cwd, envars)
¶
Initialise the kernel runner with a name of a kernel specification, a target current working directory, any user-defined envars and the path for the currently active virtualenv's site-packages.
Source code in mu/modes/python3.py
start_kernel()
¶
Create the expected context, start the kernel, obtain a client and emit a signal when both are started.
Source code in mu/modes/python3.py
stop_kernel()
¶
Clean up the context, stop the client connections to the kernel, affect an immediate shutdown of the kernel and emit a "finished" signal.
Source code in mu/modes/python3.py
MuKernelManager
¶
Bases: QtKernelManager
Source code in mu/modes/python3.py
start_kernel(**kw)
¶
Starts a kernel on this host in a separate process.
Subclassed to allow checking that the kernel uses the same Python as Mu itself.
Source code in mu/modes/python3.py
PythonMode
¶
Bases: BaseMode
Represents the functionality required by the Python 3 mode.
Source code in mu/modes/python3.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | |
actions()
¶
Return an ordered list of actions provided by this module. An action is a name (also used to identify the icon) , description, and handler.
Source code in mu/modes/python3.py
add_plotter()
¶
Add a plotter pane.
Source code in mu/modes/python3.py
add_repl()
¶
Create a new Jupyter REPL session in a non-blocking way.
Source code in mu/modes/python3.py
api()
¶
debug(event)
¶
Debug the script using the debug mode.
on_data_flood()
¶
Ensure the process (REPL or runner) causing the data flood is stopped before the base on_data_flood is called to turn off the plotter and tell the user what to fix.
Source code in mu/modes/python3.py
on_kernel_start(kernel_manager, kernel_client)
¶
Handles UI update when the kernel runner has started the iPython kernel.
Source code in mu/modes/python3.py
on_kernel_stop()
¶
Handles UI updates for when the kernel runner has shut down the running iPython kernel.
Source code in mu/modes/python3.py
remove_plotter()
¶
remove_repl()
¶
Remove the Jupyter REPL session.
run_script()
¶
Run the current script.
Source code in mu/modes/python3.py
run_toggle(event)
¶
Handles the toggling of the run button to start/stop a script.
Source code in mu/modes/python3.py
stop_script()
¶
Stop the currently running script.
Source code in mu/modes/python3.py
toggle_plotter()
¶
Toggles the plotter on and off.
toggle_repl(event)
¶
Toggles the REPL on and off
Source code in mu/modes/python3.py
mu.resources¶
Contains utility functions for working with binary assets used by Mu (mainly images).
mu.resources
¶
Copyright (c) 2015-2017 Nicholas H.Tollervey and others (see the AUTHORS file).
Based upon work done for Puppy IDE by Dan Pope, Nicholas Tollervey and Damien George.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.