Python Editor

The Python Editor is where you can create, edit and save Python programs.

Adding a Python Editor page

To add a new Python Editor page in the current problem, press b and select Add Python > New.

You can create a blank program, or you can select a template.

Blank program

 

Template

After creating the program, the Python Editor is displayed. If you selected a template, the necessary import statements are automatically added (see below).

Note: You can have multiple programs in a single TNS file just like other apps. If the Python program is intended to be used as a module, the TNS file can be saved in the PyLib folder. That module can then be used in other programs and documents.

Math Calculations

 

Random Simulations

 

Geometry Graphics

 

Image Processing

 

Plotting (x,y) & Text

 

Data Sharing

 

TI-Innovator Hub Project

 

TI-Rover Coding

Opening a Python Program

To open an existing Python program, press ~ and select Insert > Add Python > Open. This will display a list of programs that have been saved in the TNS file.

If the Editor page used to create the program has been deleted, the program is still available in the TNS file.

Working in the Python Editor

Pressing b displays the Document Tools menu. With these menu options you can add, move, and copy blocks of code for your program.

Document Tools menu

 

 

Items selected from the module menus will automatically add a code template to the Editor with inline prompts for each part of the function. You can navigate from one argument to the next by pressing e (forward) or g+e (backward). Tooltips or pop-up lists will appear when available to help you select the proper values.

Inline prompts

 

Tooltips

Pop-up lists

   

The numbers to the right of the program name reflect the current line number of the cursor and the total number of lines in the program.

Global functions and variables defined in the lines above the current cursor position can be inserted by pressing h and selecting from the list.

As you add code to your program, the Editor displays keywords, operators, comments, strings and indents in different colors to aid in identifying the different elements.

Saving and running programs

When your are finished with your program, press b and select Run > Check Syntax & Save. This will check the syntax of the Python program and save it to the TNS file.

Note: If you have unsaved changes in your program, an asterisk will display next to the program name.

To run the program, press b and select Run > Run. This will run the current program in the next Python Shell page or a new one if the next page is not a Shell.

Note: Running the program automatically checks the syntax and saves the program.