# Python methods for a custom c++ plugin

**URL:** https://discourse.paraview.org/t/python-methods-for-a-custom-c-plugin/3326
**Category:** Development
**Tags:** python
**Created:** [January 13, 2020, 12:52pm UTC](https://discourse.paraview.org/t/python-methods-for-a-custom-c-plugin/3326 "2020-01-13T12:52:25Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![siver](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/7ba0ec/32.png) [@siver](https://discourse.paraview.org/u/siver)
#### Post date: [January 13, 2020, 12:52pm UTC](https://discourse.paraview.org/t/python-methods-for-a-custom-c-plugin/3326/1 "2020-01-13T12:52:25Z")

</div>

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

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [January 13, 2020, 12:54pm UTC](https://discourse.paraview.org/t/python-methods-for-a-custom-c-plugin/3326/2 "2020-01-13T12:54:26Z")

</div>

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

---

<div class="post-metadata">

### Author: ![siver](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/7ba0ec/32.png) [@siver](https://discourse.paraview.org/u/siver)
#### Post date: [January 13, 2020, 1:01pm UTC](https://discourse.paraview.org/t/python-methods-for-a-custom-c-plugin/3326/3 "2020-01-13T13:01:27Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [January 14, 2020, 11:36am UTC](https://discourse.paraview.org/t/python-methods-for-a-custom-c-plugin/3326/4 "2020-01-14T11:36:05Z")

</div>

Do these operations are done server side or client side ?

---

<div class="post-metadata">

### Author: ![siver](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/7ba0ec/32.png) [@siver](https://discourse.paraview.org/u/siver)
#### Post date: [January 21, 2020, 3:03pm UTC](https://discourse.paraview.org/t/python-methods-for-a-custom-c-plugin/3326/5 "2020-01-21T15:03:19Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [January 22, 2020, 2:55am UTC](https://discourse.paraview.org/t/python-methods-for-a-custom-c-plugin/3326/6 "2020-01-22T02:55:57Z")

</div>

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

---

<div class="post-metadata">

### Author: ![siver](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/7ba0ec/32.png) [@siver](https://discourse.paraview.org/u/siver)
#### Post date: [January 22, 2020, 9:12am UTC](https://discourse.paraview.org/t/python-methods-for-a-custom-c-plugin/3326/7 "2020-01-22T09:12:33Z")

</div>

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

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [January 23, 2020, 2:19am UTC](https://discourse.paraview.org/t/python-methods-for-a-custom-c-plugin/3326/8 "2020-01-23T02:19:44Z")

</div>

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>
```
