TACTIC Open Source
Can i access spt.alert using python? - Printable Version

+- TACTIC Open Source (http://forum.southpawtech.com)
+-- Forum: TACTIC Open Source (http://forum.southpawtech.com/forumdisplay.php?fid=3)
+--- Forum: TACTIC Discussion (http://forum.southpawtech.com/forumdisplay.php?fid=4)
+--- Thread: Can i access spt.alert using python? (/showthread.php?tid=240)



Can i access spt.alert using python? - listy - 08-10-2021

I am running some python triggers when tasks are created. Is there a solution to throw warnings or question dialogs during it's execution with feedback? Example: If user change something, tactic will warn or ask question.


RE: Can i access spt.alert using python? - listy - 08-11-2021

I found that i can use raise Exception('Alldone!') and this will throw error, but can it be somehow customized?


RE: Can i access spt.alert using python? - remkonoteboom - 08-11-2021

This completely depends on the action that caused the trigger to be called, because it controls the action that occur in the interface.

Usually, what happens is that a UI element from a user action causes a callback to the server to occur. This callback handles some actions which may cause a trigger to be called.

So, the UI element calls an callback, generally like this:

server.p_execute_cmd( cbk, kwargs )
.then( ret => {
// handle success
} )
.catch( e => {
// handle error
spt.alert("Error: " + e);
} )

So depending on what the cbk does (either ret or eror handling), the UI will determine what the user sees. The default behavior is that an exception will have the above.

If it is your own button, then you can handle it anyway you wish. If it is a preexisting TACTIC button, then that can get a little more complicated, depending on which one is actually being used to call the callback.


RE: Can i access spt.alert using python? - listy - 08-11-2021

(08-11-2021, 06:06 PM)remkonoteboom Wrote: If it is your own button, then you can handle it anyway you wish.  If it is a preexisting TACTIC button, then that can get a little more complicated, depending on which one is actually being used to call the callback.
Python trigger fired by the TaskElementWidget changes


RE: Can i access spt.alert using python? - remkonoteboom - 08-14-2021

I looked at this a little bit. Because it's not your widget, you would have to rely on some kind of a callback. In the code, there was an attempt to do something like this using a listen event on save that gets called, but it's not implemented very well and I couldn't make it work satisfactorily.

I would have to look at it deeper. Could you create an issue on Github for this?