Beispiel #1
0
def main():
    import sys
    from openalea.oalab.shell import get_shell_class
    from openalea.core.service.ipython import interpreter
    from openalea.oalab.editor.highlight import Highlighter
    app = QtGui.QApplication(sys.argv)

    edit = TextEditor()
    Highlighter(edit)
    interp = interpreter()
    shell = get_shell_class()(interp)

    win = QtGui.QMainWindow()
    win.setCentralWidget(edit)

    dock_widget = QtGui.QDockWidget("IPython", win)
    interp.locals['mainwindow'] = win
    interp.locals['editor'] = edit
    interp.locals['shell'] = shell
    interp.locals['interpreter'] = interp

    dock_widget.setWidget(shell)
    win.addDockWidget(QtCore.Qt.BottomDockWidgetArea, dock_widget)

    win.show()
    win.raise_()
    app.exec_()
Beispiel #2
0
    def __init__(self, session, parent=None, args=None):
        super(QtGui.QMainWindow, self).__init__()
        self.session = session
        interp = interpreter()
        interp.locals['mainwindow'] = self

        self.areas = {}
        for area_name in ('inputs', 'outputs', 'shell'):
            self.areas[area_name] = QtGui.QTabWidget()

        self.dockWidget("Inputs", self.areas['inputs'], name="Inputs",
                        position=QtCore.Qt.LeftDockWidgetArea)
        self.dockWidget("Outputs", self.areas['outputs'], name="Outputs",
                        position=QtCore.Qt.RightDockWidgetArea)
        self.dockWidget("Shell", self.areas['shell'], name="Shell, log and history",
                        position=QtCore.Qt.BottomDockWidgetArea)

        self.split = QtGui.QSplitter()
        self.setCentralWidget(self.split)

        menu_names = ('Project', 'Edit', 'Viewer', 'Help')

        # Classic menu
        self.menu_classic = {}
        menubar = QtGui.QMenuBar()

        for menu_name in menu_names:
            self.menu_classic[menu_name] = menubar.addMenu(menu_name)

        self.setMenuBar(menubar)

        # PanedMenu
        self.menu_paned = {}
        self.menu = PanedMenu()

        # Organize order of tabs
        for menu_name in menu_names:
            self.menu_paned[menu_name] = self.menu.addSpecialTab(menu_name)

        dock_menu = self.dockWidget("Menu", self.menu, position=QtCore.Qt.TopDockWidgetArea)
        dock_menu.setFeatures(QtGui.QDockWidget.NoDockWidgetFeatures)
        dock_menu.setContentsMargins(0, 0, 0, 0)
        widget = QtGui.QLabel()
        dock_menu.setTitleBarWidget(widget)

        size_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Maximum)
        dock_menu.setSizePolicy(size_policy)

        # Shell
        self.shell = get_shell_class()(interp)
        interp.locals['shell'] = self.shell
        self.add_applet(self.shell, 'Shell', area='shell')

        self.applets = self._plugins = {}
if __name__ == '__main__':
    instance = QtGui.QApplication.instance()
    if instance is None:
        app = QtGui.QApplication([])
    else:
        app = instance

    from openalea.oalab.shell import get_shell_class

    # Set interpreter
    interp.locals.update(locals())

    # Set Shell Widget
    widget = QtGui.QWidget()
    layout = QtGui.QHBoxLayout(widget)

    shellwdgt = get_shell_class()(interp)
    interp.locals['layout'] = layout

#    layout.addWidget(editor)
    layout.addWidget(shellwdgt)

    layout.setSpacing(0)
    layout.setContentsMargins(0, 0, 0, 0)
    widget.show()
    widget.raise_()

    if instance is None:
        app.exec_()
Beispiel #4
0
    def __init__(self, session, parent=None):
        """
        @param session : user session
        @param parent : parent window
        """
        qt.QtGui.QMainWindow.__init__(self, parent)
        SignalSlotListener.__init__(self)
        ui_mainwindow.Ui_MainWindow.__init__(self)
        self.setupUi(self)
        self.setAcceptDrops(True)
        self.setAttribute(qt.QtCore.Qt.WA_QuitOnClose)

        self.tabWorkspace.removeTab(0)
        self.tabWorkspace.setTabsClosable(True)
        self.ws_cpt = 0

        if hasattr(AbstractEvaluation, "__provenance__"):
            self._prov = AbstractEvaluation.__provenance__
        else:
            self._prov = False

        #last opened nodes
        self._last_opened = []

        #lower tab pane : python shell, logger...
        self.lowerpane = qt.QtGui.QTabWidget()
        self.splitter.addWidget(self.lowerpane)

        # python interpreter
        try:
            interpreter = get_interpreter()
        except NameError:
            InterpreterClass = get_interpreter_class()
            interpreter = InterpreterClass()

        # interpreter init defered after session init
        shellclass = get_shell_class()
        self.interpreterWidget = shellclass(interpreter,
                                            cli.get_welcome_msg())

        GraphOperator.globalInterpreter = interpreter
        self.lowerpane.addTab(self.interpreterWidget, "Python Shell")

        if logger.QT_LOGGING_MODEL_AVAILABLE:
            # openalea logger
            model = logger.LoggerOffice().get_handler("qt")
            view = LoggerView(parent=self.lowerpane, model=model)
            self.lowerpane.addTab(view, "Logging")

        # search list view
        self.search_model = SearchModel()
        self.searchListView = \
            SearchListView(self, self.searchview)
        self.searchListView.setModel(self.search_model)
        self.vboxlayout3.addWidget(self.searchListView)
        self.searchListView.clicked.connect(self.on_package_manager_focus_change)

        # help widget
        self.helpWidget = helpwidget.HelpWidget()
        css = pj(misc.__path__[0], "..", "..", "..",
                 "share", "_static", "openalea.css")
        self.helpWidget.set_stylesheet_file(css)
        self.poolTabWidget.addTab(self.helpWidget, "Help")

        # Widgets
        self.connect(self.tabWorkspace, qt.QtCore.SIGNAL("contextMenuEvent(QContextMenuEvent)"),
                     self.contextMenuEvent)
        self.tabWorkspace.currentChanged.connect(self.ws_changed)
        self.search_lineEdit.editingFinished.connect(self.search_node)
        self.tabWorkspace.tabCloseRequested.connect(self.close_tab_workspace)

        # Help Menu
        self.action_About.triggered.connect(self.about)
        self.actionOpenAlea_Web.triggered.connect(self.web)
        self.action_Help.triggered.connect(self.help)

        # File Menu
        self.action_New_Session.triggered.connect(self.new_session)
        self.action_Open_Session.triggered.connect(self.open_session)
        self.action_Save_Session.triggered.connect(self.save_session)
        self.actionSave_as.triggered.connect(self.save_as)
        self.action_Quit.triggered.connect(self.quit)

        self.action_Image.triggered.connect(self.export_image)
        self.action_Svg.triggered.connect(self.export_image_svg)

        # Package Manager Menu
        self.action_Auto_Search.triggered.connect(self.reload_all)
        self.action_Add_File.triggered.connect(self.add_pkgdir)
        self.actionFind_Node.triggered.connect(self.find_node)
        self.action_New_Network.triggered.connect(self.new_graph)
        self.actionNew_Python_Node.triggered.connect(self.new_python_node)
        self.actionNew_Package.triggered.connect(self.new_package)
        self.action_Data_File.triggered.connect(self.new_data)

        # DataPool Menu
        self.actionClear_Data_Pool.triggered.connect(self.clear_data_pool)

        # Python Menu
        self.action_Execute_script.triggered.connect(
            self.exec_python_script)
        self.actionOpen_Console.triggered.connect(
            self.open_python_console)
        self.actionClea_r_Console.triggered.connect(
            self.clear_python_console)

        # WorkspaceMenu
        self.__operatorAction = dict([(self.action_Run, "graph_run"),
                                      (self.actionInvalidate, "graph_invalidate"),
                                      (self.actionReset, "graph_reset"),
                                      (self.actionConfigure_I_O, "graph_configure_io"),
                                      (self.actionGroup_Selection, "graph_group_selection"),
                                      (self.action_Copy, "graph_copy"),
                                      (self.action_Paste, "graph_paste"),
                                      (self.action_Cut, "graph_cut"),
                                      (self.action_Delete_2, "graph_remove_selection"),
                                      (self.action_Close_current_workspace, "graph_close"),
                                      (self.action_Export_to_Factory, "graph_export_to_factory"),
                                      (self.actionReload_from_Model, "graph_reload_from_factory"),
                                      (self.actionExport_to_Application, "graph_export_application"),
                                      (self.actionPreview_Application, "graph_preview_application"),
                                      (self.actionAlignHorizontally, "graph_align_selection_horizontal"),
                                      (self.actionAlignLeft, "graph_align_selection_left"),
                                      (self.actionAlignRight, "graph_align_selection_right"),
                                      (self.actionAlignMean, "graph_align_selection_mean"),
                                      (self.actionDistributeHorizontally, "graph_distribute_selection_horizontally"),
                                      (self.actionDistributeVertically, "graph_distribute_selection_vertically"),
                                      (self.actionSetCustomColor, "graph_set_selection_color"),
                                      (self.actionUseCustomColor, "graph_use_user_color")])

        self._last_open_action_group = qt.QtGui.QActionGroup(self)
        self.connect(self._last_open_action_group,
                     qt.QtCore.SIGNAL("triggered(QAction*)"),
                     self.reopen_last)
        self.action_New_Empty_Workspace.triggered.connect(self.new_workspace)
        self.menu_Workspace.aboutToShow.connect(self.__wsMenuShow)
        self.menu_Workspace.aboutToShow.connect(self.__wsMenuHide)
        for ac, fname in self.__operatorAction.iteritems():
            f = self.__make_operator_action_connector(ac, fname)
            ac.triggered.connect(f)

        self.actionTo_script.triggered.connect(self.to_python_script)

        # Window Mneu
        self.actionPreferences.triggered.connect(self.open_preferences)
        self.actionDisplay_Package_Manager.toggled.connect(self.display_leftpanel)
        self.actionDisplay_Workspaces.toggled.connect(self.display_rightpanel)

        #load personnal GUI settings
        self.read_settings()

        #############
        # Provenance
        #############
        if PROVENANCE:
            self.menu_provenance = qt.QtGui.QMenu(self.menubar)
            self.menu_provenance.setObjectName("menu_provenance")
            self.menu_provenance.setTitle(qt.QtGui.QApplication.translate("MainWindow", "&Provenance", None, qt.QtGui.QApplication.UnicodeUTF8))

            self.action_activ_prov = qt.QtGui.QAction(self)
            self.action_activ_prov.setCheckable(True)
            prov = self.get_provenance()
            self.action_activ_prov.setChecked(prov)
            self.action_activ_prov.setObjectName("action_activ_prov")
            self.action_activ_prov.setText(qt.QtGui.QApplication.translate("MainWindow", "Connect/Disconnect Provenance", None, qt.QtGui.QApplication.UnicodeUTF8))

            self.action_show_prov = qt.QtGui.QAction(self)
            self.action_show_prov.setCheckable(False)
            self.action_show_prov.setObjectName("action_show_prov")
            self.action_show_prov.setText(qt.QtGui.QApplication.translate("MainWindow", "Show Provenance", None, qt.QtGui.QApplication.UnicodeUTF8))

            self.menu_provenance.addAction(self.action_activ_prov)
            self.menu_provenance.addAction(self.action_show_prov)

            self.menubar.addAction(self.menu_provenance.menuAction())

            self.action_activ_prov.toggled.connect(self.set_provenance)
            self.action_show_prov.triggered.connect(self.show_provenance)
Beispiel #5
0
def initDocks(lpywidget):
    prevdock = None
    st = lpywidget.statusBar()
    for i,dock in enumerate([lpywidget.materialDock, lpywidget.scalarDock, lpywidget.descriptionDock, lpywidget.parametersDock]):
        lpywidget.addDockWidget(qt.QtCore.Qt.LeftDockWidgetArea,dock)
        #lpywidget.menuView.addAction(dock.toggleViewAction())
        dock.statusBar = st
        dock.showMessage = showMessage
        if not prevdock is None:
            lpywidget.tabifyDockWidget(prevdock,dock)
        prevdock = dock
    lpywidget.menuView.addAction(lpywidget.materialDock.toggleViewAction())
    lpywidget.menuView.addAction(lpywidget.scalarDock.toggleViewAction())
    lpywidget.vparameterView = lpywidget.menuView.addMenu("Graphical Parameters")
    lpywidget.menuView.addSeparator()
    lpywidget.menuView.addAction(lpywidget.descriptionDock.toggleViewAction())
    lpywidget.menuView.addAction(lpywidget.parametersDock.toggleViewAction())
   
    lpywidget.addDockWidget(qt.QtCore.Qt.LeftDockWidgetArea,lpywidget.helpDock)
    action = lpywidget.helpDock.toggleViewAction()
    action.setShortcut(qt.QtGui.QApplication.translate("MainWindow", "F1", None, qt.QtGui.QApplication.UnicodeUTF8))
    lpywidget.helpDock.hide()
    lpywidget.helpDock.setFloating(True)
    icon = qt.QtGui.QIcon()
    icon.addPixmap(qt.QtGui.QPixmap(":/images/icons/book.png"),qt.QtGui.QIcon.Normal,qt.QtGui.QIcon.Off)
    action.setIcon(icon)
    lpywidget.menuHelp.addSeparator()
    lpywidget.menuHelp.addAction(action)
    lpywidget.tabifyDockWidget(lpywidget.materialDock,lpywidget.parametersDock)
    lpywidget.tabifyDockWidget(lpywidget.parametersDock,lpywidget.descriptionDock)
    # debug dock
    lpywidget.debugDock = qt.QtGui.QDockWidget("Debugger",lpywidget)
    lpywidget.debugDock.setObjectName("LpyDebugger")
    lpywidget.debugWidget = qt.QtGui.QSplitter(qt.QtCore.Qt.Horizontal,lpywidget)
    lpywidget.debugWidget.left = DebugLeftWidget(lpywidget.debugWidget)
    lpywidget.debugWidget.addWidget(lpywidget.debugWidget.left)
    lpywidget.debugWidget.right = DebugRightWidget(lpywidget.debugWidget)
    lpywidget.debugWidget.addWidget(lpywidget.debugWidget.right)
    lpywidget.debugWidget.setEnabled(False)
    lpywidget.debugDock.setWidget(lpywidget.debugWidget)
    lpywidget.addDockWidget(qt.QtCore.Qt.BottomDockWidgetArea,lpywidget.debugDock)    
    action = lpywidget.debugDock.toggleViewAction()
    lpywidget.menuView.addSeparator()
    lpywidget.menuView.addAction(action)
    lpywidget.debugDock.hide()
    #profiler dock
    lpywidget.addDockWidget(qt.QtCore.Qt.BottomDockWidgetArea,lpywidget.profilerDock)    
    action = lpywidget.profilerDock.toggleViewAction()
    lpywidget.menuView.addAction(action)
    lpywidget.profilerDock.hide()
    #interpreter dock
    if lpywidget.withinterpreter :
        shellclass = get_shell_class()
        interpreterclass = get_interpreter_class()
        lpywidget.interpreter = interpreterclass()
        lpywidget.shell = shellclass(lpywidget.interpreter, parent=lpywidget.interpreterDock)    
        lpywidget.interpreterDock.setWidget(lpywidget.shell)
        action = lpywidget.interpreterDock.toggleViewAction()
        action.setShortcut(qt.QtGui.QApplication.translate("MainWindow", "Ctrl+P", None, qt.QtGui.QApplication.UnicodeUTF8))
        lpywidget.menuView.addSeparator()
        lpywidget.menuView.addAction(action)
        lpywidget.interpreter.locals['window'] = lpywidget
        lpywidget.interpreter.locals['clear'] = lpywidget.shell.clear
        try:
            exec('from openalea.plantgl.all import *',lpywidget.interpreter.locals,lpywidget.interpreter.locals)
            exec('from openalea.lpy import *',lpywidget.interpreter.locals,lpywidget.interpreter.locals)
            #lpywidget.interpreter.loadcode('from openalea.plantgl.all import *' )
            #lpywidget.interpreter.loadcode('from openalea.lpy import *')
            # lpywidget.interpreter.runcode('from openalea.plantgl.all import *')
            # lpywidget.interpreter.runcode('from openalea.lpy import *')
        except:
            lpywidget.interpreter.runcode('from openalea.plantgl.all import *')
            lpywidget.interpreter.runcode('from openalea.lpy import *')
        lpywidget.addDockWidget(qt.QtCore.Qt.BottomDockWidgetArea,lpywidget.interpreterDock)
        lpywidget.tabifyDockWidget(lpywidget.debugDock,lpywidget.interpreterDock)
    else:
        lpywidget.interpreter = None