예제 #1
0
파일: grid.py 프로젝트: bopopescu/relax
    def event_left_dclick(self, event):
        """Handle the left mouse double click.

        @param event:   The wx event.
        @type event:    wx event
        """

        # The row and column.
        col = self.grid.GetGridCursorCol()
        row = self.grid.GetGridCursorRow()

        # File selection.
        if col == 0:
            # The dialog.
            dialog = RelaxFileDialog(parent=self, style=wx.FD_OPEN)

            # Show the dialog and catch if no file has been selected.
            if status.show_gui and dialog.ShowModal() != wx.ID_OK:
                # Don't do anything.
                return

            # The files.
            filename = dialog.get_file()

            # Set the file name.
            self.grid.SetCellValue(row, col, str(filename))

        # Skip the event to allow for normal operation.
        event.Skip()
예제 #2
0
파일: grid.py 프로젝트: bopopescu/relax
    def load_delay(self, event, vc=False):
        """The variable delay list loading GUI element.

        @param event:   The wx event.
        @type event:    wx event
        """

        # VD

        # VC time is not a number
        if vc:
            try:
                vc_factor = float(self.vc_time.GetValue())
            except:
                error_message('VC time is not a number.')
                return

        # VD
        else:
            vc_factor = 1

        # The dialog.
        dialog = RelaxFileDialog(parent=self, style=wx.FD_OPEN)

        # Show the dialog and catch if no file has been selected.
        if status.show_gui and dialog.ShowModal() != wx.ID_OK:
            # Don't do anything.
            return

        # The files.
        filename = dialog.get_file()

        # Open the file
        file = open(filename, 'r')

        # Read entries
        index = 0
        for line in file:
            # Evaluate if line is a number
            try:
                t = float(line.replace('/n', ''))
            except:
                continue

            # Write delay to peak list grid
            self.grid.SetCellValue(index, 1, str(t*vc_factor))

            # Next peak list
            index = index + 1

            # Too many entries in VD list
            if index == self.num_rows:
                error_message('Too many entries in list.')
                return
예제 #3
0
파일: grid.py 프로젝트: tlinnet/relax
    def load_peaklist(self, event):
        """Function to load peak lists to data grid.

        @param event:   The wx event.
        @type event:    wx event
        """

        # The dialog.
        dialog = RelaxFileDialog(parent=self,
                                 message='Select the %s peak list file' %
                                 self.label,
                                 style=wx.FD_OPEN | wx.FD_MULTIPLE)

        # Show the dialog and catch if no file has been selected.
        if status.show_gui and dialog.ShowModal() != wx.ID_OK:
            # Don't do anything.
            return

        # The files.
        files = dialog.get_file()

        # Fill values in data grid
        index = 0
        for i in range(self.num_rows):
            # Add entry if nothing is filled in already
            if str(self.grid.GetCellValue(i, 0)) == '':
                # Write peak file
                self.grid.SetCellValue(i, 0, str(files[index]))

                # Next file
                index = index + 1

                # Stop if no files left
                if index == len(files):
                    break

        # Error message if not all files were loaded
        if index < (len(files) - 1):
            error_message('Not all files could be loaded.')