A good starting point for app development with quickly and python is here: http://developer.ubuntu.com/resources/tutorials/all/diy-media-player-with-pygtk/
In general, you can see how quickly handles other .ui files in your code in the lines
from test.AboutTestDialog import AboutTestDialog
from test.PreferencesTestDialog import PreferencesTestDialog
[...]
self.AboutDialog = AboutTestDialog
self.PreferencesDialog = PreferencesTestDialog
You would add your new window the same way:
Create a new file for your menu window under your test directory, such that your code could look like this:
from test.AboutTestDialog import AboutTestDialog
from test.PreferencesTestDialog import PreferencesTestDialog
from test.MenuTestWindow import MenuTestWindow
[...]
self.AboutDialog = AboutTestDialog
self.PreferencesDialog = PreferencesTestDialog
self.MenuWindow = MenuTestWindow
Then you can show the Window in your on_button1_clicked method like this:
def on_button1_clicked(self, widget, data=None):
print "Loading Menu!"
self.MenuWindow.show()
Now the only question remaining is, what does your MenuTestWindow class look like? I would simply look into the quickly created classes and write something like this:
import gettext
from gettext import gettext as _
gettext.textdomain('test')
import logging
logger = logging.getLogger('test')
from test_lib.MenuWindow import MenuWindow
# See test_lib.MenuWindow for more details about how this class works.
class MenuTestWindow():
__gtype_name__ = "MenuTestWindow"
def finish_initializing(self, builder): # pylint: disable=E1002
"""Set up the about dialog"""
super(MenuTestWindow, self).finish_initializing(builder)
# Code for other initialization actions should be added here.
which leaves us with the test_lib.MenuWindow file and class (also stolen from the quickly defaults):
import gtk
import logging
logger = logging.getLogger('test_lib')
from . helpers import get_builder, show_uri, get_help_uri
from . preferences import preferences
# This class is meant to be subclassed by MenuWindow. It provides
# common functions and some boilerplate.
class Window(gtk.Window):
__gtype_name__ = "Window"
# To construct a new instance of this method, the following notable
# methods are called in this order:
# __new__(cls)
# __init__(self)
# finish_initializing(self, builder)
# __init__(self)
#
# For this reason, it's recommended you leave __init__ empty and put
# your initialization code in finish_initializing
def __new__(cls):
"""Special static method that's automatically called by Python when
constructing a new instance of this class.
Returns a fully instantiated MenuTestWindow object.
"""
builder = get_builder('MenuWindow')
new_object = builder.get_object("menu_window")
new_object.finish_initializing(builder)
return new_object
def finish_initializing(self, builder):
"""Called while initializing this instance in __new__
finish_initializing should be called after parsing the UI definition
and creating a TestWindow object with it in order to finish
initializing the start of the new TestWindow instance.
"""
# Get a reference to the builder and set up the signals.
self.builder = builder
self.ui = builder.get_ui(self, True)
(I hope I didn't miss anything... :-)
This should be all.
However: If I would be writing this application, I would probably not use a different .ui file, but place every additional gui/window in the main window ui file (lets call the new window MenuWindow) and access it via something like this:
def on_button1_clicked(self, widget, data=None):
mw = self.builder.get_object("MenuWindow")
mw.show()
This way you don't have to create all those other classes and files. But it is your app and you have to know yourself, if a separate .ui file is needed in your case.