How to trigger onchange from python class

I wanna do an onchange calculating total hours when in and out time is entered.

You, can do it in a very simple way.

Examples please.