How to write custom widgets? Looking for step by step tutorial

You might check my intesis widget as an example