Difference between revisions of "Summer of Code/2013/Turtle Blocks Python export project"

From Sugar Labs
Jump to navigation Jump to search
(add a decision on running unnamed stacks; defer the pending decision on the speed of execution)
(update decisions after meeting with Walter)
Line 47: Line 47:
 
* Code in named stacks will be put into functions with the same name. Blocks appended to the 'start' block will be put into a function called <code>start()</code>. Unnamed stacks will also be put into extra functions with auto-generated names (e.g., <code>unnamed_stack_1()</code>).
 
* Code in named stacks will be put into functions with the same name. Blocks appended to the 'start' block will be put into a function called <code>start()</code>. Unnamed stacks will also be put into extra functions with auto-generated names (e.g., <code>unnamed_stack_1()</code>).
 
* Run only the block stack that has a 'start' block at the top. If there is no 'start' block, notify the user, but don't execute unnamed stacks. (TA itself should show the same behavior.)
 
* Run only the block stack that has a 'start' block at the top. If there is no 'start' block, notify the user, but don't execute unnamed stacks. (TA itself should show the same behavior.)
 +
* Assume the generated code will be run in GNOME, but keep the <code>running_sugar</code> flag, so it can be ported to Sugar later.
  
 
=== Pending ===
 
=== Pending ===
Line 54: Line 55:
 
* Enable the user to control the speed of execution (e.g., by setting a global <code>step_time</code>)? ''deferred on 2013-06-14''
 
* Enable the user to control the speed of execution (e.g., by setting a global <code>step_time</code>)? ''deferred on 2013-06-14''
 
** How to implement this? E.g., call a <code>wait(step_time)</code> function in between two steps?
 
** How to implement this? E.g., call a <code>wait(step_time)</code> function in between two steps?
 +
* How to automatically determine the path to the TA installation (e.g., for finding the plugins)? ''deferred on 2013-06-14''
 +
** Either: check a list of standard paths.
 +
** Or: expect it to be in the <code>PYTHONPATH</code>.
 +
** Explain to the user what's wrong when the TA installation wasn't found.
 +
* Should the status bar be shown when the exported code is run?

Revision as of 11:53, 14 June 2013

This page tracks the progress of Marion Zepf's GSoC project, "Turtle Blocks Python export." An abstract and a motivational statement can be found on the project proposal page, along with other details.

The mentors for this project are Walter Bender and Claudia Urrea.

Repositories

I develop my project in a branch called gsoc-python-export on Gitorious. Design documents, sample code, etc. go into ta-python-export-dev on GitHub.

Timeline

The following timeline will be modified as the project evolves.

  • June 17 – June 30 (2 weeks): Determine what code needs to be shared by Turtle Blocks and the exported code. Restructure the modules to isolate this part, so it can easily be imported. Only cover the modules that are necessary to run blocks from the 'Turtle', 'Pen', and 'Pen colors' palettes. Deal with the other modules when implementing the corresponding blocks.
  • July 1 – July 21 (3 weeks): Implement the first transformations from blocks to Python code. Only cover the following blocks from the 'Turtle' palette: 'forward', 'back', 'left', and 'right'. Make sure the exported code imports the correct modules from Turtle Blocks and can be run on the command line (or in Pippy). Keep the implementation modular, so more blocks can be added easily.
  • July 22 – July 28 (1 week): Implement transformations of the rest of the 'Turtle' palette, and the complete 'Pen' and 'Pen colors' palettes. (These should be similar enough to the first four blocks that they can be implemented quickly.)
  • July 29 – August 2: Midterm evaluation: Block programs can be exported to Python code that can be run outside of Turtle Blocks. The export functionality is limited to blocks from the 'Turtle', 'Pen', and 'Pen colors' palette, but it can easily be extended to cover the other blocks.
  • August 3 – September 15 (6 weeks): Implement transformations of all other blocks to Python code:
    • August 3 – August 11 (1 week)
      • Numeric operations from the 'Numeric operators' palette and screen dimensions from the 'Presentation templates' palette[note 1]
      • Boolean operations from the 'Numeric operators' palette and conditionals from the 'Flow operators' palette
    • August 12 – August 18 (1 week)
      • Variables from the 'Action stacks' palette and heaps from the 'Extra options' palette
      • Loops from the 'Flow operators' palette and functions from the 'Action stacks' palette
    • August 19 – August 25 (1 week)
      • Runtime control (e.g., exit, suspension) from the 'Flow operators' palette
      • External functions (chr, int, mathematical function, tamyblock.py) from the 'Extra options' palette[note 1]
    • August 26 – September 1 (1 week)
      • Comments from the 'Extra options' palette: This is especially difficult because Python's ast module does not support comments natively.
    • September 2 – September 8 (1 week)
      • Events and user input from the 'Sensors' palette[note 1]
      • Sounds and sprites from the 'Media' palette and presentation templates from the 'Presentation templates' palette[note 1]
    • September 9 – September 15 (1 week)
      • Multiple turtles and custom turtle shells from the 'Extra options' palette[note 1]
      • Display management (hide/ show blocks, toggle full screen) from the 'Presentation templates' palette, and printing and loading blocks and palettes from the 'Extra options' palette:[note 1]
  • September 16 – September 23 (1 week): Test exporting different kinds of blocks in combination. Fix the last bugs. Clean up.

Notes

  1. 1.0 1.1 1.2 1.3 1.4 1.5 This may require importing additional modules from Turtle Blocks.

Decisions

This section lists important design decisions.

  • The generated Python code will setup a window without menus and palettes. It will only be a plain canvas. Turtles will be visible with their (default or custom) sprites because this is the only way to make sprites move in TA.
  • Code in named stacks will be put into functions with the same name. Blocks appended to the 'start' block will be put into a function called start(). Unnamed stacks will also be put into extra functions with auto-generated names (e.g., unnamed_stack_1()).
  • Run only the block stack that has a 'start' block at the top. If there is no 'start' block, notify the user, but don't execute unnamed stacks. (TA itself should show the same behavior.)
  • Assume the generated code will be run in GNOME, but keep the running_sugar flag, so it can be ported to Sugar later.

Pending

The following design issues have yet to be decided:

  • Enable the user to control the speed of execution (e.g., by setting a global step_time)? deferred on 2013-06-14
    • How to implement this? E.g., call a wait(step_time) function in between two steps?
  • How to automatically determine the path to the TA installation (e.g., for finding the plugins)? deferred on 2013-06-14
    • Either: check a list of standard paths.
    • Or: expect it to be in the PYTHONPATH.
    • Explain to the user what's wrong when the TA installation wasn't found.
  • Should the status bar be shown when the exported code is run?