Adding external GUI panels with GANGA GUI Plugin System

The GANGA GUI Plugin System (GPS) has been designed to assist GANGA developers with the task of adding custom built GUI panels to the main GANGA GUI. Some familiarity with Qt and PyQt is required to create the external GUI panels using Qt Designer and subsequently subclassing the auto-generated Python code (the recommended approach for easy maintenance). With the GPS, development of the external GUI panels can be done independently of the main GANGA GUI as the latter's code does not need to be modified. This allows for the easy distribution of experiment-specific GUI panels. The GPS is available with GANGA v4.3.1.

External GUI panels can be invoked as modal (i.e. no access to other windows until panel is closed) or non-modal (i.e. can be used concurrently with other GUI windows) panels. Modal panels are invoked using custom GUI buttons of input widgets in the Job Building panel and are typically used to populate the calling widget. Non-modal panels are invoked from the menubar and/or toolbar of the main GANGA GUI and typically used for reference purposes only.

When using the GPS, there are some conventions to adhere to:

  • External GUI code must be placed in pre-designated locations.
    1. All code for external GUI panels must be placed in the corresponding gui/ directory of the runtime package that the panels are part of (e.g. GangaAtlas/gui).
    2. Create an file in the gui/ directory and add the file containing the GUI code to the __all__ list variable. E.g. To direct the GPS to access (and not any other ancillary code in the gui/ directory), the should simply be:
         __all__ = ['TestDialog']
  • Some code specifics
    1. External GUI panels should be subclasses of QDialog and have the get() method which will return a value to the calling widget when the panel is closed. In the trivial example below, TestDialog is a subclass of TestDialog_BASE (an auto-generated class using pyuic on the TestDialog_BASE.ui Qt Designer file).
            class TestDialog( TestDialog_BASE ):
               def __init__( self, parent = None, name = '' ):
                  TestDialog_BASE.__init__( self, parent, name )
               def get( self ):
                  return str( self.lineEdit1.text() )
      See (remove .txt from filename), (remove .txt from filename) and TestDialog.ui.
    2. Define a dictionary list describing to the GPS how to make use of the class(es). Each dictionary in the list describes a corresponding class. Each dictionary has a fixed set of key/value pairs:
      • 'guiclass' - [mandatory] The class being described,
      • 'arglist' - [mandatory] List of arguments needed to create an instance of the class,
      • 'menubar' - [optional] Location of the menu entry for TestDialog in the menubar. Possible values are menubar_job, menubar_folders, menubar_view and menubar_help. If undefined, there will be no corresponding entry in the menubar.
      • 'icon' - [optional] A QIcon object used by the menubar and the toolbar. If undefined, there will be no corresponding button in the toolbar.
      • 'label' - [optional] The text used for the corresponding entry in the menubar. If undefined, The string representation of the class is used.
      • 'action' - [optional] Custom QAction object. Create your own QAction object if more complex behaviour is required.
           GPS_LIST = [ { 'guiclass' : TestDialog, 'arglist' : [ None, 'My_Test_Dialog' ], 'menubar' : 'menubar_view', 'icon' : qt.QIconSet(icon), 'label' : 'My Test Dialog', 'action' : None },
                        { 'guiclass' : TestListDialog, 'arglist' : [ None, 'My_Test_List_Dialog' ], 'menubar' : 'menubar_view', 'icon' : None, 'label' : 'My Test List Dialog', 'action' : None } ]
  • Invoking external panels via GPS. Non-modal access to the external panels is made automatically (i.e. no further developer intervention required) available via the Menubar and toolbar. However, modal access via the custom GUI button on input widgets (from the Job Builder panel) will need an additional customgui dictionary entry in the _GUIPrefs of the GANGA plugin class concerned. By defining the customgui dictionary entry, the specified external panel will be invoked when the custom GUI button of an input widget is clicked. After the external panel is closed (i.e. Ok is clicked), a value is returned and used to populate the recipient sub-widget (typically the line edit or list view sub-component) of the input widget. An example _GUIPrefs for the Executable plugin:
        _GUIPrefs = [ { 'attribute' : 'exe', 'widget' : 'File', 'customgui' : 'TestDialog.TestDialog' },
                      { 'attribute' : 'args', 'widget' : 'String_List', 'customgui' : 'TestDialog.TestListDialog' },
                      { 'attribute' : 'env', 'widget' : 'DictOfString', 'customgui' : 'TestDialog.TestListDialog' } ]

-- AlvinTan - 08 May 2007

Topic attachments
I Attachment History Action Size Date Who Comment
Texttxt r1 manage 5.2 K 2007-05-08 - 21:44 AlvinTan There are two classes (TestDialog and TestListDialog) defined in See for example of GPS_LIST dictionary list used to describe the classes to the GPS. Note: Remove the .txt extension (added by TWiki) before use.
Texttxt r1 manage 1.7 K 2007-05-08 - 21:34 AlvinTan Auto-generated Python file using pyuic on TestDialog_BASE.ui. This Python file should not be modified by hand! Note: Remove the .txt extension (added by TWiki) before use.
Unknown file formatui TestDialog_BASE.ui r1 manage 2.2 K 2007-05-08 - 21:30 AlvinTan Qt Designer file for the TestDialog widget. Used to generate
Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r2 - 2007-05-09 - AlvinTan
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    ArdaGrid All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback