[PyQt] question about dip.ui MenuBar
Darren Dale
dsdale24 at gmail.com
Fri Sep 10 13:21:48 BST 2010
I have a question about the menubar example at
http://www.riverbankcomputing.co.uk/static/Docs/dip/ui_tutorial.html#menus
. The example includes the following:
-------------
# We need a toolkit to create the widgets.
toolkit = QtToolkit()
# Create the main window.
main_window = QMainWindow()
# Create the action.
exit_action = QAction("&Exit", None, triggered=app.quit)
# Define the action hierarchy.
action_collection = ActionCollection(title="&File", members=[exit_action])
# Create the factory that will create instances of the action hierarchy.
menu_bar = MenuBar(action_collection)
# Create an instance of the action hierarchy using QMenuBar and QMenu.
qmenubar = menu_bar(toolkit)
------------
Based on its function, it looks like MenuBar could be called
MenuBarFactoryFactory. Is this layer of abstraction important? Would
it be possible to instead do:
qmenubar = MenuBar(action_collection, toolkit=toolkit)
, and also to have the toolkit kwarg default to dip.ui.QtToolkit()?
Having ui factories default to QtToolkit would simplify the code for
the presumably most common use case.
Thanks,
Darren
More information about the PyQt
mailing list