Just wanted to share something very irritating that just have happened to me.
Compiled and ran this, and everything just stoped working. The instant I called:
Program just stopped doing anything. (and it took me some time to realize that it is not doing anything, and not only failing to show the widget)
I went on to discover what the problem is - commenting out parts of the code (obviously, the snippet above is not the whole code) to see what is causing the issue, and nothing seemed to be the problem.