Commits

Alain Leufroy committed a4c937e

[gui.qt] add a command line option to choose the UI

Note: The qt ui is empty for now.

  • Participants
  • Parent commits d8e011c

Comments (0)

Files changed (3)

config/conffile.py

     parser.add_option('-r', '--remove-data',
                       action='store_true', default=False,
                       help='Purge existing persistent data.')
+    parser.add_option('-i', '--interface',
+                      type='choice', choices=['console', 'qt'],
+                      default='console',
+                      help='interface to use ("qt" or "console") [%default]')
     opts, _ = parser.parse_args()
     return dict((('command-line', key), value)
                 for key, value in vars(opts).items())
 import shutil
 import logging
 
-from limma.ui.console.console_ui import ConsoleUI
 from limma.config.conffile import get_configuration
 from limma.config.logger import configure_logging
 
 CONF_FILENAME = 'limma.conf'
 
+def get_interface(conf):
+    """Return the ui interface requested by the user."""
+    # import from within the switch case in order to prevent
+    # import error with non required interface
+    interface_name = conf[('command-line', 'interface')]
+    if interface_name == 'console':
+        from limma.ui.console.console_ui import ConsoleUI
+        return ConsoleUI(conf)
+    elif interface_name == 'qt':
+        from limma.ui.gui.qt.qt_ui import QtUI
+        return QtUI(conf)
+
 def main():
     # pylint: disable=C0103
     # C0103: Invalid name (allow 'ui')
             data_dir = conf[('main', 'data_directory')]
             if os.path.exists(data_dir):
                 shutil.rmtree(data_dir)
-        ui = ConsoleUI(conf)
+        ui = get_interface(conf)
         ui.loop()
     except:
         logger.exception("Got exception on main handler")

ui/gui/qt/qt_ui.py

+# -*- coding: utf-8 -*-
+"""
+This module contains the Qt user interface controller.
+"""
+import sys
+from PyQt4 import QtGui
+from limma.structure.structure import Structure
+from limma.ui.ui import AbstractUI
+from limma.ui.gui.qt.mainwindow import MainWindow
+
+class QtUI(AbstractUI):
+    """UI controller that synchronize data and the Qt UI"""
+
+    def __init__(self, conf):
+        AbstractUI.__init__(self, conf)
+        self._struct = Structure(conf)
+
+    def loop(self):
+        app = QtGui.QApplication(sys.argv)
+        mainwindow = MainWindow()
+        mainwindow.show()
+        app.exec_()