示例#1
0
    def valid_ui(self):
        """ Valid UI Parameters """

        d = [
            ["run", "open"],
            ["run"],
            ["open"],
        ]
        index = self.dbclickBox.currentIndex()

        styles = ["Spline", "Polyline", "Line"]
        edge_style_index = self.comboBox.currentIndex()
        edge_style = styles[edge_style_index]

        config = Settings()
        config.set("UI", "DoubleClick", repr(d[index]))
        config.set("UI", "EdgeStyle", edge_style)
        config.set("UI", "EvalCue",
                   str(self.evalCue.checkState() == qt.QtCore.Qt.Checked))
        config.write()

        if edge_style != self.edge_style:
            self.edge_style = edge_style
            session = self.session
            session.notify_listeners()
            ws = session.workspaces
            for cn in ws:
                cn.notify_listeners(('graph_modified', ))
示例#2
0
 def writeSettings(self):
     """
     Register current settings (geometry and window state)
     in a setting file
     """
     if self.pm.cproject:
         from openalea.core.settings import Settings
         last_proj = self.pm.cproject.name
         config = Settings()
         config.set("ProjectManager", "Last Project", last_proj)
         config.write()
示例#3
0
    def writeSettings(self):
        """
        Register current settings (geometry and window state)
        in a setting file
        """
        if self.session.project:
            last_proj = self.session.project.name
            config = Settings()

            config.set("ProjectManager", "Last Project", last_proj)
            config.write()
def test_write_config():

    pkgman = PackageManager()
    pkgman.load_directory("./")
    pkgman.write_config()
    p = pkgman.user_wralea_path

    s = Settings()
    path = s.get("pkgmanager", "path")
    paths = list(eval(path)) # path is a string

    assert set(paths) == set(p)
示例#5
0
def get_editor():
    """ Return the editor class """
    
    editor = PythonCodeEditor

    s = Settings()
    try:
        str = s.get('editor', 'use_external')
        l = eval(str)
        if(l): editor = ExternalCodeEditor
        
    except:
        pass

    return editor
示例#6
0
    def valid_editor(self):
        """ Valid editor parameter """
        use_ext = bool(self.externalBool.checkState() == qt.QtCore.Qt.Checked)
        command = str(self.commandStr.text())

        config = Settings()
        config.set("editor", "use_external", repr(use_ext))
        config.set("editor", "command", command)
        config.write()
示例#7
0
文件: vertex.py 项目: gbaty/openalea
    def mouseDoubleClickEvent(self, event):
        if event.button() == qt.QtCore.Qt.LeftButton:
            # Read settings
            try:
                localsettings = Settings()
                str = localsettings.get("UI", "DoubleClick")
            except:
                str = "['open']"

            operator = GraphOperator(graph=self.graph(),
                                     graphScene=self.scene())
            operator.set_vertex_item(self)

            if('open' in str):
                operator(fName="vertex_open")()
            elif('run' in str):
                operator(fName="vertex_run")()
示例#8
0
    def get_command(self):
        """ Return command to execute """
        s = Settings()
        cmd = ""
        try:
            cmd = s.get('editor', 'command')
            
        except:
            cmd = ""
            
        if(not cmd):
            if('posix' in os.name):
                return "/usr/bin/vim"
            else:
                return "C:\\windows\\notepad.exe"

        return cmd
示例#9
0
    def mouseDoubleClickEvent(self, event):
        if event.button() == qt.QtCore.Qt.LeftButton:
            # Read settings
            try:
                localsettings = Settings()
                str = localsettings.get("UI", "DoubleClick")
            except:
                str = "['open']"

            operator = GraphOperator(graph=self.graph(),
                                     graphScene=self.scene())
            operator.set_vertex_item(self)

            if ('open' in str):
                operator(fName="vertex_open")()
            elif ('run' in str):
                operator(fName="vertex_run")()
示例#10
0
    def read_settings(self):
        """Read application settings.
        """
        settings = Settings()

        #main window
        try:
            size = eval(settings.get("MainWindow", "size"))
            self.resize(qt.QtCore.QSize(*size))
        except NoSectionError:
            pass
        except NoOptionError:
            pass
        try:
            pos = eval(settings.get("MainWindow", "pos"))
            self.move(qt.QtCore.QPoint(*pos))
        except NoSectionError:
            pass
        except NoOptionError:
            pass
        try:
            sizes = eval(settings.get("MainWindow", "splitter_2"))
            self.splitter_2.setSizes(sizes)
        except NoSectionError:
            pass
        except NoOptionError:
            pass
        try:
            sizes = eval(settings.get("MainWindow", "splitter_3"))
            self.splitter_3.setSizes(sizes)
        except NoSectionError:
            pass
        except NoOptionError:
            pass
        #workspace
        try:
            last_open = eval(settings.get("WorkSpace", "last"))
            last_open.reverse()
            for item in last_open:
                gr = item.split(".")
                pkgid = ".".join(gr[:-1])
                name = gr[-1]
                self.add_last_open(pkgid, name)
        except NoSectionError:
            pass
        except NoOptionError:
            pass

        try:
            prov = eval(settings.get("Provenance", "enable"))
            self.set_provenance(bool(prov))
        except NoSectionError:
            pass
        except NoOptionError:
            pass
示例#11
0
    def notify(self, sender, event):
        """ Notification sent by the vertex associated to the item """
        if event is None:
            return

        try:
            refresh = eval(Settings().get("UI", "EvalCue"))
        except:
            refresh = True

        eventTopKey = event[0]
        if eventTopKey == "close":
            if self.__editor:
                self.__editor.close()
        elif eventTopKey == "data_modified":
            key = event[1]
            if key == "caption":
                self.set_graphical_caption(event[2])
        elif eventTopKey == "internal_state_changed":
            key = event[1]
            if key == "delay":
                self.update_delay_item()
            elif key == "lazy" or key == "blocked" or key == "user_application":
                self.update_colors()
        elif eventTopKey == "metadata_changed":
            if event[1] == "userColor":
                if event[2] is None:
                    self.store_view_data(useUserColor=False)
                else:
                    self.update_colors()
            elif event[1] == "useUserColor":
                self.update_colors()
        elif eventTopKey == "exception_state_changed":
            self.update_colors()
        elif eventTopKey == "hiddenPortChange":
            self.update_hidden_port_item()
        elif (eventTopKey == "tooltip_modified"):
            self.set_graphical_tooltip(event[1])
        if refresh:
            if (eventTopKey == "start_eval"):
                self._busyItem.setVisible(self.isVisible())
                qt.QtGui.QApplication.processEvents()
            elif (eventTopKey == "stop_eval"):
                self._busyItem.setVisible(False)
                qt.QtGui.QApplication.processEvents()
        elif (eventTopKey == "input_port_added"):
            self.add_port(event[1])
        elif (eventTopKey == "output_port_added"):
            self.add_port(event[1])
        elif (eventTopKey == "cleared_input_ports"):
            self.remove_ports(lambda x: isinstance(x.port(), InputPort))
        elif (eventTopKey == "cleared_output_ports"):
            self.remove_ports(lambda x: isinstance(x.port(), OutputPort))
        self.update()
        qtgraphview.Vertex.notify(self, sender, event)
示例#12
0
    def __init__(self, parent):

        qt.QtGui.QDialog.__init__(self, parent)
        ui_preferences.Ui_Preferences.__init__(self)
        self.setupUi(self)

        # Read config
        config = Settings()
        self.session = parent.session

        # pkgmanager
        try:
            str = config.get("pkgmanager", "path")
            l = eval(str)

            for p in l:
                self.pathList.addItem(p)
        except:
            pass


#        try:
#str = config.get("pkgmanager", "include_namespace")
#enabled = bool(eval(str))

#            if(enabled):
#                self.includenmspace.setCheckState(qt.QtCore.Qt.Checked)
#            else:
#                self.includenmspace.setCheckState(qt.QtCore.Qt.Unchecked)
#        except:
#            pass

# Editor
        try:
            str = config.get("editor", "use_external")
            l = eval(str)
            if (l):
                self.externalBool.setCheckState(qt.QtCore.Qt.Checked)
            else:
                self.externalBool.setCheckState(qt.QtCore.Qt.Unchecked)
        except Exception, e:
            print e
示例#13
0
    def valid_editor(self):
        """ Valid editor parameter """
        use_ext = bool(self.externalBool.checkState() == qt.QtCore.Qt.Checked)
        command = str(self.commandStr.text())

        config = Settings()
        config.set("editor", "use_external", repr(use_ext))
        config.set("editor", "command", command)
        config.write()
示例#14
0
    def __init__(self, parent):

        qt.QtGui.QDialog.__init__(self, parent)
        ui_preferences.Ui_Preferences.__init__(self)
        self.setupUi(self)

        # Read config
        config = Settings()
        self.session = parent.session

        # pkgmanager
        try:
            str = config.get("pkgmanager", "path")
            l = eval(str)

            for p in l:
                self.pathList.addItem(p)
        except:
            pass

        #        try:
        # str = config.get("pkgmanager", "include_namespace")
        # enabled = bool(eval(str))

        #            if(enabled):
        #                self.includenmspace.setCheckState(qt.QtCore.Qt.Checked)
        #            else:
        #                self.includenmspace.setCheckState(qt.QtCore.Qt.Unchecked)
        #        except:
        #            pass

        # Editor
        try:
            str = config.get("editor", "use_external")
            l = eval(str)
            if l:
                self.externalBool.setCheckState(qt.QtCore.Qt.Checked)
            else:
                self.externalBool.setCheckState(qt.QtCore.Qt.Unchecked)
        except Exception, e:
            print e
示例#15
0
    def write_config(self):
        """ Write user config """

        config = Settings()
        config.set("pkgmanager", "path", repr(list(self.user_wralea_path)))
#        config.set("pkgmanager", "include_namespace", repr(self.include_namespace))
        config.write()
示例#16
0
    def read_settings(self):
        """Read application settings.
        """
        settings = Settings()

        #main window
        try:
            size = eval(settings.get("MainWindow", "size"))
            self.resize(qt.QtCore.QSize(*size))
        except NoSectionError:
            pass
        except NoOptionError:
            pass
        try:
            pos = eval(settings.get("MainWindow", "pos"))
            self.move(qt.QtCore.QPoint(*pos))
        except NoSectionError:
            pass
        except NoOptionError:
            pass
        try:
            sizes = eval(settings.get("MainWindow", "splitter_2"))
            self.splitter_2.setSizes(sizes)
        except NoSectionError:
            pass
        except NoOptionError:
            pass
        try:
            sizes = eval(settings.get("MainWindow", "splitter_3"))
            self.splitter_3.setSizes(sizes)
        except NoSectionError:
            pass
        except NoOptionError:
            pass
        #workspace
        try:
            last_open = eval(settings.get("WorkSpace", "last"))
            last_open.reverse()
            for item in last_open:
                gr = item.split(".")
                pkgid = ".".join(gr[:-1])
                name = gr[-1]
                self.add_last_open(pkgid, name)
        except NoSectionError:
            pass
        except NoOptionError:
            pass

        try:
            prov = eval(settings.get("Provenance", "enable"))
            self.set_provenance(bool(prov))
        except NoSectionError:
            pass
        except NoOptionError:
            pass
示例#17
0
    def write_settings(self):
        """
        Register current settings (geometry and window state)
        in a setting file
        """
        cproject = self.project()
        from openalea.core.settings import Settings
        config = Settings()
        if cproject:
            last_proj = cproject.name
            config.set("ProjectManager", "Last Project", last_proj)
        else:
            config.set("ProjectManager", "Last Project", "")

        config.write()
示例#18
0
    def writeSettings(self):
        """
        Register current settings (geometry and window state)
        in a setting file
        """
        if self.session.project:
            last_proj = self.session.project.name
            config = Settings()

            config.set("ProjectManager", "Last Project", last_proj)
            config.write()
示例#19
0
    def set_user_wralea_path(self):
        """ Read user config """

        if self.user_wralea_path:
            return
        if not SEARCH_OUTSIDE_ENTRY_POINTS:
            return

        self.user_wralea_path = set()
        config = Settings()
        l = []
        # wralea path
        try:
            s = config.get("pkgmanager", "path")
            l = eval(s)
        except NoSectionError:
            config.add_section("pkgmanager")
            config.add_option("pkgmanager", "path", str([]))
        except NoOptionError:
            config.add_option("pkgmanager", "path", str([]))
        for p in l:
            self.add_wralea_path(os.path.abspath(p), self.user_wralea_path)
示例#20
0
 def writeSettings(self):
     """
     Register current settings (geometry and window state)
     in a setting file
     """
     if self.pm.cproject:
         from openalea.core.settings import Settings
         last_proj = self.pm.cproject.name
         config = Settings()
         config.set("ProjectManager", "Last Project", last_proj)
         config.write()
示例#21
0
    def write_settings(self):
        """
        Register current settings (geometry and window state)
        in a setting file
        """
        cproject = self.project()
        from openalea.core.settings import Settings
        config = Settings()
        if cproject:
            last_proj = cproject.name
            config.set("ProjectManager", "Last Project", last_proj)
        else:
            config.set("ProjectManager", "Last Project", "")

        config.write()
示例#22
0
    def valid_ui(self):
        """ Valid UI Parameters """

        d = [["run", "open"], ["run"], ["open"]]
        index = self.dbclickBox.currentIndex()

        styles = ["Spline", "Polyline", "Line"]
        edge_style_index = self.comboBox.currentIndex()
        edge_style = styles[edge_style_index]

        config = Settings()
        config.set("UI", "DoubleClick", repr(d[index]))
        config.set("UI", "EdgeStyle", edge_style)
        config.set("UI", "EvalCue", str(self.evalCue.checkState() == qt.QtCore.Qt.Checked))
        config.write()

        if edge_style != self.edge_style:
            self.edge_style = edge_style
            session = self.session
            session.notify_listeners()
            ws = session.workspaces
            for cn in ws:
                cn.notify_listeners(("graph_modified",))
示例#23
0
    def write_settings(self):
        """Save application settings.
        """
        settings = Settings()

        #main window
        settings.set("MainWindow", "size",
                     "(%d,%d)" % (self.width(), self.height()))
        settings.set("MainWindow", "pos", "(%d,%d)" % (self.x(), self.y()))

        sizes = "[%s]" % ",".join("%d" % val
                                  for val in self.splitter_2.sizes())
        settings.set("MainWindow", "splitter_2", sizes)
        sizes = "[%s]" % ",".join("%d" % val
                                  for val in self.splitter_3.sizes())
        settings.set("MainWindow", "splitter_3", sizes)

        #tree view
        settings.set("TreeView", "open", "[]")

        #workspace
        last_open = "[%s]" % ",".join("'%s'" % item
                                      for item in self._last_opened)
        settings.set("WorkSpace", "last", last_open)

        #provenance
        prov = self.get_provenance()
        settings.set("Provenance", "enable", str(prov))

        settings.write()
示例#24
0
    def write_settings(self):
        """Save application settings.
        """
        settings = Settings()

        #main window
        settings.set("MainWindow", "size", "(%d,%d)" % (self.width(), self.height()))
        settings.set("MainWindow", "pos", "(%d,%d)" % (self.x(), self.y()))

        sizes = "[%s]" % ",".join("%d" % val for val in self.splitter_2.sizes())
        settings.set("MainWindow", "splitter_2", sizes)
        sizes = "[%s]" % ",".join("%d" % val for val in self.splitter_3.sizes())
        settings.set("MainWindow", "splitter_3", sizes)

        #tree view
        settings.set("TreeView", "open", "[]")

        #workspace
        last_open = "[%s]" % ",".join("'%s'" % item for item in self._last_opened)
        settings.set("WorkSpace", "last", last_open)

        #provenance
        prov = self.get_provenance()
        settings.set("Provenance", "enable", str(prov))

        settings.write()