Creating a widget is not enough. You also have to make it appear on the screen. In order to do this use the show() or show_all() methods. There is a difference between these methods if the widget is a container.

This will display the window, but not any of its contained children:

<?php $window->show(); ?>
This will display the window and all of its contained children:

<?php $window->show_all(); ?>
If a widget is inside a container and you call show() on it, it will not appear on screen until the container itself has been shown. This is useful for visibility display of the main window, for example.

Corresponding functions for hiding a widget are hide() and hide_all().