def __init__(self, layout=None, **kwds): """ tests: list of function runnable in shell (name changed to run_<funcname>) layout_file """ OALabMainWin.__init__(self, layout=layout, **kwds) self.interp = interpreter() self.interp.user_ns['mainwin'] = self self.interp.user_ns['splittable'] = self.splittable self.interp.user_ns['debug'] = self.debug self.interp.user_ns['QtCore'] = QtCore self.interp.user_ns['QtGui'] = QtGui def applet(name): return plugin_instance('oalab.applet', name) def applets(name): return plugin_instances('oalab.applet', name) self.interp.user_ns['applet'] = applet self.interp.user_ns['applets'] = applets print 'VARIABLES AVAILABLE IN SHELL ...' print '\nAPPLICATION:' print ' - mainwin' print ' - splittable' print ' - QtCore' print ' - QtGui' print '\nAPPLETS:' for plugin in plugins('oalab.applet'): if plugin_instance_exists('oalab.applet', plugin.name): varname = camel_case_to_lower(plugin.name) self.interp.user_ns['plugin_%s' % varname] = plugin self.interp.user_ns[varname] = plugin_instance('oalab.applet', plugin.name) print ' -', varname print '\nFUNCTIONS:' for f in kwds.pop('tests', []): self.interp.user_ns['run_%s' % f.__name__] = f f.func_globals['ns'] = self.interp.user_ns print ' - run_%s' % f.__name__ self.resize(QtCore.QSize(800, 600))
def launch_lab(plugin_class): from openalea.oalab.widget.splittablewindow import OALabMainWin from openalea.core.settings import get_openalea_home_dir from openalea.core.path import path as Path from openalea.core.service.introspection import label from openalea.oalab.utils import qicon plugin = plugin_class() lab_class = plugin() layout_path = Path(get_openalea_home_dir()) / '%s.oaui' % lab_class.name OALabMainWin.DEFAULT_LAYOUT_PATH = layout_path OALabMainWin.DEFAULT_LAYOUT = lab_class.layout OALabMainWin.DEFAULT_MENU_NAMES = lab_class.menu_names OALabMainWin.LAB = lab_class if hasattr(lab_class, "start"): lab_class.start() win = OALabMainWin(lab=lab_class, autosave=True) win.setWindowIcon(qicon(lab_class.icon)) if hasattr(lab_class, 'connect_applet'): win.appletSet.connect(lab_class.connect_applet) win.emit_applet_set() win.initialize() if hasattr(lab_class, "initialize"): lab_class.initialize() win.setWindowTitle('OpenAleaLab "%s"' % label(plugin)) win.showMaximized() win.raise_() return win