Python console
Introduction
The Python console is a panel that's part of the LabRPS user interface. It runs an instance of the Python interpreter which can be used to control LabRPS processes, and create and modify objects and their properties.
It can be made visible/hidden through the View → Panels → Python console drop-down menu.
The Python console in LabRPS has basic syntax highlighting, able to differentiate with various styles and colors, comments, strings, numeric values, built in functions, printed text output, and delimiters like parentheses and commas. These properties of the console can be configured in the Preferences editor.
The Python console showing messages when LabRPS has just started.
Scripting
For absolute beginners, see: Introduction to Python, and Python scripting tutorial.
See also: LabRPS scripting basics, and Scripted objects.
The Python console can perform basic code completion when a dot is written after an object; it will show public methods and attributes (variables) of the current object (class), for example, obj.
The console is also able to show the documentation string of a particular function when the opening parenthesis is written, for example, function(
Example Python code that produces objects in the 3D view.
The LabRPS initialization scripts automatically load some modules, and define some aliases. Therefore, in the Python console these are available
App = LabRPS Gui = LabRPSGui
Therefore these are equal
App.newDocument() LabRPS.newDocument()
Note: these pre-loaded modules and aliases are only available from the Python console embedded inside the LabRPS program. If you use LabRPS as a library in an external program, you must remember to load the LabRPS
and LabRPSGui
modules and define the necessary aliases if you wish.
Actions
Right click on the Python console shows some commands:
- Copy: stores the selected text in the clipboard for later pasting; it is disabled if nothing is selected.
- Copy command: stores the selected command in the clipboard for later pasting; it is disabled if nothing is selected.
- Copy history: copy the entire history of Python commands entered in this session.
- Save history as: save the entire history of Python commands entered in this session to a text file.
- Paste: paste previously copied text in the clipboard to the Python console.
- Select all: selects all text in the Python console.
- Clear console: erases all commands entered into the Python console. This is useful if the Python console is full of messages and previously entered commands that may be distracting when testing a new function. This is merely aesthetic, as this command doesn't delete existing variables nor clears the imported modules in the session.
- Insert file name: opens a dialog to search for a file in the system, then it inserts the full path of the file. This is useful to test functions that process an input file, without having to write the entire name in the console, which is error prone. This command does not run the file, and does not import it as a Python module, it just returns the full path of that file.
- Word wrap: wrap very long lines that exceed the horizontal dimension of the Python console.
Notes
- One has the ability to scroll the API in the Python console. Example:
- In the console type:
LabRPS.
- A dialog box will display with optional classes/functions to choose from
- Scroll through the list to read the description of each class/function
- By choosing a function and following it with a
.
one can repeat steps 2 and 3 to traverse deeper in to the API
- In the console type:
- Tab/Word completion is supported using the Ctrl+Space shortcut
- File: New document, New Table, New Matrix, New Graph, New 2D Plot, New 3D Plot, Open..., Open Recent, Close, Close All, Save, Save As..., Save a Copy..., Save All, Revert, Import..., Export..., Merge project..., Document information..., Print..., Print preview..., Export PDF...Exit
- Edit: Undo, Redo, Cut, Copy, Paste, Duplicate selection, Refresh, Select All, Delete, Preferences...
- View: Fullscreen, Workbench, Sync view, Record selection, Single document, Multi document, Collapse/Expand, Initiate dragging, Go to selection, Selection back, Selection forward, Status bar
- Tools: Edit parameters..., Export dependency graph..., Project utility..., Alphaplot, Line, Scatter, Scatter, Scatter With X Err, Scatter With Y Err, Scatter With XY Err, Line + Symbol, Special Line + Symbol, Vertical Drop Lines, Spline, Vertical Steps, Horizontal Steps, Vertical Bars, Vertical Stacked Bars, Vertical Grouped Bars ,Horizontal Bars, Horizontal Stacked Bars, Horizontal Grouped Bars, Area, Channel Fil, Pie, Half Pie, Vectors XYXY, Vectors XYAM, Statistical Graph, Box Plot, Histogram, Stacked Histogram, 3D Plot, Bar, Scatter, Layout Grids, Vertical 2 Layouts, Horizontal 2 Layouts, 4(2x2) Layouts, 3D Wire Frame, 3D Surface, 3D Wire Frame Surface, Bar, Scatter, Contour + Color Fill, Countour Lines, Gray Scale Map, 3D Wire Frame Polar, 3D Surface Polar, 3D Wire Frame Surface Polar, 3D Scatter Polar, Polar spectrogram, Graph, Add/Remove Plot xy/xy..., Add Function..., Add Error Bars..., Add/Remove Other Plots..., Add/Remove Plot y..., Add/Remove Vector Plot..., Add Axis..., Add Left Axis, Add Bottom Axis, Add Right Axis, Add Top Axis, Legend Reorder, Add Text, Add Time Stamp, Add Image, Draw Line, Draw Arrow, Draw Ellipse, Add Nested Layout, Add Layout, Add Up, Add Down, Add Left, Add Right, Remove Layout, Swap Layouts..., Graph Tolls, Disable Tools, Data Rearder, Screen Reader, Select Data Range, Move Data Points, Remove Bad Data Points..., Drag Range, Zoom Range, Rescale To Show All, Table, Set Column(s) As, X, Y, Z, X Error, Y Error, None, Fill Selection With, Row Numbers, , Random Values, Custom Random, Show Comments, Show Controls, Formula Edit Mode, Edit Column Description, Change Type & Format, Clear Table, Sort Table, Assign Formula, Recalculate, Add Column, Go To Cell, Export ASCII..., Convert To Matrix, Matrix, Hide Controls, Set Coordinates, Set Display Format, Assign Formula, Recalculate, Clear Matrix, Transpose, Mirror Horizontally, Mirror Vertically, Import Image, Go To Cell, Invert, Determinant, Convert To Table, Add text document, Group, Units Calculator,Customize..., RPS Features..., Addon manager
- Macro: Macro recording, Macros, Recent macros, Execute macro, Attach to remote debugger, Debug macro, Stop debugging, Step over, Step into, Toggle breakpoint
- Help: Help, LabRPS Website, Donate, Users documentation, Python scripting documentation, Automatic Python modules documentation, LabRPS Forum, LabRPS FAQ, Report a bug, About LabRPS, What's This
- Getting started
- Installation: Download, Windows, Linux, Mac, Additional components, AppImage
- Basics: About LabRPS, Interface, RPS Objects, Object name, Preferences, Workbenches, Document structure, Properties, Help LabRPS, Donate
- Hubs: User hub, Power users hub, Developer hub