Python methods for a custom c++ plugin

Hello dear PV-coders,

In my quest for making a custom PV plugin, I’m currently trying to press a (qt) button in my C++ plugin via the PV python console.

I guess, I am looking for a functionality, similar to Q_PROPERTY, which would add a python method to a C++ plugin, enabling one to write plugin.Function() in a console.

Though it sounds complicated, all I need is to emit a signal, which would trigger another C++ function and do what I need.

What is the correct way to achieve this? Thank you.

Best wishes,
Art

I’m not sure why do you need a python method here. could you elaborate the need ?

I have a preprocessing step and it is currently triggered by a button. Now, I want to do these actions from the python console:

plugin.parameters = [1, 2, 3]
plugin.Preprocess()
plugin.Apply()

But as I said, all I need is just to send a signal. I don’t need complex python code.

Do these operations are done server side or client side ?

Sorry, for a delay.

I’m not sure what is the difference. The Preprocess() function is defined in the body of a C++ plugin, i.e. it is plugin’s method.

is Preprocess() a method of a VTK filter? does it needs access to the data ?

It is not a filter in the VTK sense, but it indeed accesses the data and updates them, yes.

Then you should use a Property to trigger the call in the proxy controlling this class.

  <Property command="Preprocess"
            name="preprocess"
            panel_widget="command_button"
            panel_visibility="always">
    <Documentation> A convenient way to trigger a call server side </Documentation>
  </Property>