Virtually pressing button to run code

I have a button that contains a great deal of code and custom properties so I would prefer not to re-write it all. Is there a way to programmatically ‘press’ the button to execute the code in the “Action Performed” event handler?

try:

event.source.parent.getComponent("Button").doClick()

This did not seem to work. I am trying to do this in the extension function onCellEdited in a power table. Here is the code. No errors just no DB updates.

import system
self.data = system.dataset.setValue(self.data, rowIndex, colIndex, newValue)
event.source.parent.getComponent('btnHome 6').doClick()

My preferred method of handling this situation is to put the script in a timer with an initial delay of 0.

Then you can start the timer from your button’s action performed event and also from anywhere else you want.

You can copy and paste the script into the timer but you will probably need to correct some references.

Try this:

import system
self.data = system.dataset.setValue(self.data, rowIndex, colIndex, newValue)
self.parent.getComponent('btnHome 6').doClick()

Best,

2 Likes

Worked perfectly. Thank you!