Contents
About PyLogo
PyLogo is a Logo interpreter written in Python. Its implementation is small, and is based on the language as implemented by UCBLogo. The Logo language is a learning language, intended for children for which more “complete” languages aren’t appropriate. Many of Logos language design choices are driven by this, and differ from Python.
PyLogo is a Python implementation of elements of NetLogo.
- The
core
directory contains the NetLogo implementation. - The
models
directory contains a number of example models. Each example can be run by running the file.
PyLogo uses pygame and pySimpleGui, two very nice libraries. It also makes minimal use of NumPy. All three libraries must be installed.
Features:
User-Friendly Interface: One of the standout features of Pylogo is its intuitive and user-friendly interface. Users can easily navigate through various menus and options to find what they need without feeling overwhelmed. The interface also includes helpful tooltips and prompts to guide users as they learn how to use the platform. This makes Pylogo an excellent choice for beginners who may be intimidated by more complicated programming environments.
Real-Time Feedback: Another notable feature of Pylogo is its ability to provide real-time feedback as users type their code. As soon as users enter a command, the program will immediately display the resulting image or animation. This instant feedback helps users understand the relationship between their code and the resulting visual output. It also encourages experimentation since users can quickly try out different ideas and adjust their code accordingly.
Built-In Tools and Resources: Pylogo comes equipped with a wide range of built-in tools and resources to help users create visually stunning graphics and animations. These include pre-defined shapes such as circles, squares, and triangles, as well as color pickers, font selectors, and gradient generators. Pylogo also includes tutorials, sample projects, and other resources to help users get started and stay motivated.
Extensibility and Customization: While Pylogo offers many built-in tools and resources, one of its most powerful features is its extensibility and customizability. Users can import external libraries, modules, and functions to extend the capabilities of the platform beyond its default offerings. They can also modify and customize existing code snippets or create their own from scratch. This flexibility makes Pylogo suitable for both beginner and advanced users, allowing them to tailor the platform to meet their specific needs and interests.
Download
You can download from the Cheese Shop Page, or if you use easy_install with easy_install PyLogo.
The subversion repository is available with:svn co http://svn.colorstudy.com/PyLogo/trunk PyLogo
Or with easy_install PyLogo==dev
API: Embedding PyLogo
This document describes how you can use PyLogo in your Python application.
Usually there is a single “master” interpreter, called pylogo.Logo. This is the object you will interact with.
Running Logo
To read a Logo file into Logo, use:
>>> Logo.import_logo('filename.logo')
>>> Logo.import_logo_stream(file_like_object)
You should try to give your file_like_object a .name attribute, which will be used in tracebacks as the filename.
When you get a pylogo.common.LogoError exception, typically you can just print exc.description, ‘:’, exc to give the proper error message. Other exceptions should be displayed with whatever your normal Python exception display routine is.
To do a REPL (read-eval-print-loop) use:
>>> Logo.input_loop(input_stream, output_stream)
Interacting With Logo
If you have Python code you want to make available, you can use:
>>> Logo.import_function(python_function, name_override=['foo'])
>>> Logo.import_module(python_module)
The first form imports a single function. It will use the function’s name unless you provide name_override, a list of the name/aliases of the function. The second form searches a Python module for functions to add to logo. pylogo.builtins is an example of this kind of module, and Adding Primitives with Python section describes how you can do this.