Creating Your First Block: Difference between revisions

From GNU Radio
Jump to navigation Jump to search
No edit summary
Line 30: Line 30:


There are three important sections in the Python block code:
There are three important sections in the Python block code:
# The ''import'' statements in <span style="color:green">green</span>
# ''import'' statements in <span style="color:green">green</span>
# ''__init__'' function in <span style="color:orange">orange</span>
# ''__init__'' function in <span style="color:red">red</span>


[[File:PythonBlockCodeFunctions.png|500px]]
[[File:PythonBlockCodeFunctions.png|500px]]

Revision as of 15:41, 7 January 2022

This tutorial will guide you through creating your first block with the Embedded Python Block.

Embedded Python Block

The Embedded Python Block is a tool to quickly prototype a block within a flowgraph. Search for the Python Block and add it to the workspace:

AddPythonBlockToWorkspace.png


Double-click the box to edit the properties. The Embedded Python Block has two properties,

  1. Code, a click-box which contains a link to the Python code for the block and
  2. Example_Param, an input parameter to the block.


Click on Open in Editor to edit the Python code:

EmbeddedPythonBlockProperties.png


You will be prompted with another choice for which editor to use to write the Python code. Click Use Default:

ClickUseDefault.png


An editor window will then display the Python code for the Embedded Python Block:

PythonCodeGedit.png


Editing Python Block Code

There are three important sections in the Python block code:

  1. import statements in green
  2. __init__ function in orange
  3. __init__ function in red

PythonBlockCodeFunctions.png