[image: image.png] ``` """ Embedded Python Blocks: Each time this file is saved, GRC will instantiate the first class it finds to get ports and parameters of your block. The arguments to __init__ will be the parameters. All of them are required to have default values! """
import numpy as np from gnuradio import gr class blk(gr.sync_block): # other base classes are basic_block, decim_block, interp_block """Embedded Python Block example - a simple multiply const""" def __init__(self, example_param=1.0): # only default arguments here """arguments to this function show up as parameters in GRC""" gr.sync_block.__init__( self, name='Embedded Python Block', # will show up in GRC in_sig=[np.complex64], out_sig=[np.complex64] ) # if an attribute with the same name as a parameter is found, # a callback is registered (properties work, too). self.example_param = example_param def work(self, input_items, output_items): """example: multiply with constant""" output_items[0][:] = input_items[0] * self.example_param return len(output_items[0]) def set_example_param(self, asdf): print('here') ``` On Wed, Jun 19, 2024 at 12:12 PM Croizer Mathieu <croizer.math...@gmail.com> wrote: > Hello, > > Can you post the rest of the code and a snapshot of your project in > gnuradio? Because with only your function, it's hard to say what happens > in your python block :) > > Best Regards > > M. Croizer > > > Le mer. 19 juin 2024 à 14:52, Jameson Collins <jameson.coll...@gmail.com> > a écrit : > >> I'm trying to use a callback to set a variable in an embedded python >> block. Using the tutorial ( >> https://wiki.gnuradio.org/index.php/Embedded_Python_Block) as an example >> I added the function below. I've found that this callback never gets >> called when I update this value from a GUI. Should it be? >> >> def set_example_param(self, example_param): >> print("here") >> >> >> >> >>