Ejemplo n.º 1
0
    def onOpen(self, event): # wxGlade: AddPhasePanel.<event_handler>
        """Add a the new phase to the tree.

        The phase is added as a child of entryfit, right after the
        entryphase, if it exists. If entryphase is None, the new phase is
        appended to the end of the children of entryfit.
        """
        import os.path
        newnode = None
        dir, filename = os.path.split(self.fullpath)
        if not dir:
            dir = self.mainFrame.workpath
        matchstring = "|".join((
            "Structure file",
            "*.cif;*CIF;*.stru;*.STRU;*.pdb;*.PDB;*.xyz;*.XYZ",
            "Crystallographic Information File (*.cif)", "*.cif;*.CIF",
            "PDFfit structure files (*.stru)", "*.stru;*.STRU",
            "Protein Data Bank files (*.pdb)", "*.pdb;*.PDB",
            "Coordinate files (*.xyz)", "*.xyz;*.XYZ",
            "All Files", "*",
            ))
        d = wx.FileDialog(None, "Choose a file", dir, "", matchstring)
        if d.ShowModal() == wx.ID_OK:
            self.fullpath = d.GetPath()
            self.mainFrame.workpath = os.path.dirname(self.fullpath)

            # Update the configuration
            self.updateConfiguration()

            # Add the item to the tree.
            name = os.path.basename(self.fullpath)

            # Check the name and alter it if necessary
            siblings = self.treeCtrlMain.GetChildren(self.entryfit)
            names = [self.treeCtrlMain.GetItemText(i) for i in siblings]
            name = incrementName(name, names)

            newnode = self.treeCtrlMain.AddPhase(self.entryfit, name,
                    insertafter=self.entryphase, filename=self.fullpath)

            self.mainFrame.setMode("fitting")
            self.treeCtrlMain.SetItemBold(self.entrypoint, False)
            self.treeCtrlMain.UnselectAll()
            self.mainFrame.makeTreeSelection(newnode)
            self.validateStructure(newnode)
        d.Destroy()
        return
Ejemplo n.º 2
0
    def onOpen(self, event): # wxGlade: AddPhasePanel.<event_handler>
        """Add a the new phase to the tree.

        The phase is added as a child of entryfit, right after the
        entryphase, if it exists. If entryphase is None, the new phase is
        appended to the end of the children of entryfit.
        """
        import os.path
        newnode = None
        dir, filename = os.path.split(self.fullpath)
        if not dir:
            dir = self.mainFrame.workpath
        matchstring = "|".join((
            "Structure file",
            "*.cif;*CIF;*.stru;*.STRU;*.pdb;*.PDB;*.xyz;*.XYZ",
            "Crystallographic Information File (*.cif)", "*.cif;*.CIF",
            "PDFfit structure files (*.stru)", "*.stru;*.STRU",
            "Protein Data Bank files (*.pdb)", "*.pdb;*.PDB",
            "Coordinate files (*.xyz)", "*.xyz;*.XYZ",
            "All Files", "*",
            ))
        d = wx.FileDialog(None, "Choose a file", dir, "", matchstring, wx.OPEN)
        if d.ShowModal() == wx.ID_OK:
            self.fullpath = d.GetPath()
            self.mainFrame.workpath = os.path.dirname(self.fullpath)

            # Update the configuration
            self.updateConfiguration()

            # Add the item to the tree.
            name = os.path.basename(self.fullpath)

            # Check the name and alter it if necessary
            siblings = self.treeCtrlMain.GetChildren(self.entryfit)
            names = [self.treeCtrlMain.GetItemText(i) for i in siblings]
            name = incrementName(name, names)

            newnode = self.treeCtrlMain.AddPhase(self.entryfit, name,
                    insertafter=self.entryphase, filename=self.fullpath)

            self.mainFrame.setMode("fitting")
            self.treeCtrlMain.SetItemBold(self.entrypoint, False)
            self.treeCtrlMain.UnselectAll()
            self.mainFrame.makeTreeSelection(newnode)
            self.validateStructure(newnode)
        d.Destroy()
        return
Ejemplo n.º 3
0
    def onNew(self, event): # wxGlade: ServerPanel.<event_handler>
        """Create a new server item and give it the default configuration."""
        # Get a name for the item
        name = "New Server"
        others = [server['name'] for server in self.servers]
        name = incrementName(name, others)

        # Add a new server to the servers dictionary.
        self.addServer(name)

        # Add this item to the list of servers and to the list
        import sys
        item = self.serverList.InsertStringItem(sys.maxint, name)
        self.setSelection(item)
        self.serverList.EditLabel(item)

        assert(len(self.servers) == self.serverList.GetItemCount())
        return
Ejemplo n.º 4
0
    def onNew(self, event): # wxGlade: AddPhasePanel.<event_handler>
        """Add a new item to be created from scratch."""
        # Set the name of the new phase
        siblings = self.treeCtrlMain.GetChildren(self.entryfit)
        names = [self.treeCtrlMain.GetItemText(i) for i in siblings]
        label = "New Phase"
        label = incrementName(label, names)

        # Create the phase
        newnode = self.treeCtrlMain.AddPhase(self.entryfit, label,
                insertafter=self.entryphase)

        # Go to the new node
        self.mainFrame.setMode("fitting")
        self.treeCtrlMain.SetItemBold(self.entrypoint, False)
        self.treeCtrlMain.UnselectAll()
        self.mainFrame.makeTreeSelection(newnode)
        self.treeCtrlMain.EditLabel(newnode)
        return
Ejemplo n.º 5
0
    def onNew(self, event): # wxGlade: AddPhasePanel.<event_handler>
        """Add a new item to be created from scratch."""
        # Set the name of the new phase
        siblings = self.treeCtrlMain.GetChildren(self.entryfit)
        names = [self.treeCtrlMain.GetItemText(i) for i in siblings]
        label = "New Phase"
        label = incrementName(label, names)

        # Create the phase
        newnode = self.treeCtrlMain.AddPhase(self.entryfit, label,
                insertafter=self.entryphase)

        # Go to the new node
        self.mainFrame.setMode("fitting")
        self.treeCtrlMain.SetItemBold(self.entrypoint, False)
        self.treeCtrlMain.UnselectAll()
        self.mainFrame.makeTreeSelection(newnode)
        self.treeCtrlMain.EditLabel(newnode)
        return
Ejemplo n.º 6
0
    def onOpen(self, event): # wxGlade: AddDataPanel.<event_handler>
        """Add a dataset to the tree from a file."""
        import os.path
        newnode = None
        dir, filename = os.path.split(self.fullpath)
        if not dir:
            dir = self.mainFrame.workpath
        matchstring = "|".join((
                "PDF files", "*.gr;*.fgr;*.fit;*.cgr;*.calc",
                "PDF data files (*.gr)", "*.gr",
                "PDF fit files (*.fgr)", "*.fgr",
                "PDF fit files (*.fit)", "*.fit",
                "PDF calculation files (*.cgr)", "*.cgr",
                "PDF calculation files (*.calc)", "*.calc",
                "All Files", "*"
                ))
        d = wx.FileDialog(None, "Choose a file", dir, "", matchstring, wx.OPEN)
        if d.ShowModal() == wx.ID_OK:
            self.fullpath = d.GetPath()
            self.mainFrame.workpath = os.path.dirname(self.fullpath)

            # Update the configuration
            self.updateConfiguration()

            # Add the item to the tree.
            name = os.path.basename(self.fullpath)

            # Check the name and alter it if necessary
            siblings = self.treeCtrlMain.GetChildren(self.entryfit)
            names = [self.treeCtrlMain.GetItemText(i) for i in siblings]
            name = incrementName(name, names)
            newnode = self.treeCtrlMain.AddDataSet(self.entryfit, name,
                    insertafter=self.entryset, filename=self.fullpath)

            self.mainFrame.setMode("fitting")
            self.treeCtrlMain.SetItemBold(self.entrypoint, False)
            self.treeCtrlMain.UnselectAll()
            self.mainFrame.makeTreeSelection(newnode)
        d.Destroy()
        return
Ejemplo n.º 7
0
    def onOpen(self, event):  # wxGlade: AddDataPanel.<event_handler>
        """Add a dataset to the tree from a file."""
        import os.path
        newnode = None
        dir, filename = os.path.split(self.fullpath)
        if not dir:
            dir = self.mainFrame.workpath
        matchstring = "|".join(
            ("PDF files", "*.gr;*.fgr;*.fit;*.cgr;*.calc",
             "PDF data files (*.gr)", "*.gr", "PDF fit files (*.fgr)", "*.fgr",
             "PDF fit files (*.fit)", "*.fit", "PDF calculation files (*.cgr)",
             "*.cgr", "PDF calculation files (*.calc)", "*.calc", "All Files",
             "*"))
        d = wx.FileDialog(None, "Choose a file", dir, "", matchstring)
        if d.ShowModal() == wx.ID_OK:
            self.fullpath = d.GetPath()
            self.mainFrame.workpath = os.path.dirname(self.fullpath)

            # Update the configuration
            self.updateConfiguration()

            # Add the item to the tree.
            name = os.path.basename(self.fullpath)

            # Check the name and alter it if necessary
            siblings = self.treeCtrlMain.GetChildren(self.entryfit)
            names = [self.treeCtrlMain.GetItemText(i) for i in siblings]
            name = incrementName(name, names)
            newnode = self.treeCtrlMain.AddDataSet(self.entryfit,
                                                   name,
                                                   insertafter=self.entryset,
                                                   filename=self.fullpath)

            self.mainFrame.setMode("fitting")
            self.treeCtrlMain.SetItemBold(self.entrypoint, False)
            self.treeCtrlMain.UnselectAll()
            self.mainFrame.makeTreeSelection(newnode)
        d.Destroy()
        return