How to create and edit a custom widget?