Exemplo n.º 1
0
    def SaveGrid(self, path):
        """
        Saves using the tables.TABLES object
        """

        controlgrid = tables.TABLES(self)
        controlgrid.grid_to_excel(path, [(self.m_grid3, "Control"),
                                         (self.m_grid2, "Dict"),
                                         (self.m_grid21, "Ranges")])
Exemplo n.º 2
0
    def FillDCData(self):
        """
        Loads data to create a report. Requires a results sheet named "Results".
        Uses tables.TABLES for a excel-to-grid object.
        """

        datagrid = tables.TABLES(self)
        self.data_grid = datagrid.excel_to_grid(self.DCdata_file, 'Sheet',
                                                self.m_grid41)
Exemplo n.º 3
0
    def OnAnalyse(self, event):
        """
        Reads the name of the file to analyse,
        and sends it to the analysis object analysis.Analyser
        """

        #read a text box to get the name of file to analyse
        #create analysis object, send it the name of the file
        #it updates the file, adding the ratios.
        #call fill grid to load the new file up and replace the old one.

        xcel_name = str(self.Analysis_file_name.GetValue())  #'Book1.xlsx'
        print(xcel_name)
        xcel_sheet = 'Sheet'

        analyser = analysis.Analyser(xcel_name, xcel_sheet)
        analyser.analysis()
        analyser.Save(xcel_name)
        controlgrid = tables.TABLES(self)
        printed_results = controlgrid.excel_to_grid(xcel_name, 'Results',
                                                    self.m_grid4)
        printed_results_ratios = controlgrid.excel_to_grid(
            xcel_name, 'Gain Ratios', self.m_grid4b)
Exemplo n.º 4
0
    def FillData(self):
        """
        Loads data to create a report. Requires a results sheet named "Results".
        Uses tables.TABLES for a excel-to-grid object.
        """

        datagrid = tables.TABLES(self)
        self.data_grid = datagrid.excel_to_grid(self.data_file, 'Results',
                                                self.m_grid44)
        self.data_grid = datagrid.excel_to_grid(self.data_file, 'Gain Ratios',
                                                self.m_grid42)
        self.data_grid = datagrid.excel_to_grid(self.data_file,
                                                'Linearity Ratios',
                                                self.m_grid43)
        meter_row = 0
        for i in range(0, self.m_grid42.GetNumberRows()):
            if self.m_grid42.GetCellValue(i, 0) == 'Meter Gain Ratios':
                meter_row = i
        if self.m_checkBox1.GetValue():
            self.m_grid42.DeleteRows(0, meter_row)

        else:
            self.m_grid42.DeleteRows(meter_row - 1,
                                     self.m_grid42.GetNumberRows() - 1)
Exemplo n.º 5
0
    def FillGrid(self):
        """
        Loads self.proj_file to the grid. Requires a dictionary sheet named "Dict" and
        a control sheet named "Sheet 1". Uses tables.TABLES for a excel-to-grid object.
        """

        controlgrid = tables.TABLES(self)

        self.filled_grid = controlgrid.excel_to_grid(self.proj_file, 'Control',
                                                     self.m_grid3)
        if self.filled_grid == True:
            grid = self.m_grid3
            if int(float(grid.GetCellValue(3, 3))) > int(grid.GetNumberRows()):
                #int(float(is needed as it cant seem to cast straight to an int
                print("Final row needed to be updated in grid")
                grid.SetCellValue(3, 3, str(grid.GetNumberRows()))
            self.m_grid3.Layout()
        else:
            print("no sheet named 'Control' found")

        self.loaded_dict = controlgrid.excel_to_grid(self.proj_file, 'Dict',
                                                     self.m_grid2)
        if self.loaded_dict == True:
            col_names = [
                'Key words', 'Meter', 'Key words', 'Source S', 'Key words',
                'Source X'
            ]
            for i in range(len(col_names)):
                self.m_grid2.SetColLabelValue(i, col_names[i])
            self.m_grid2.Layout()

        else:
            print("no sheet named 'Dict' found, can not run")

        self.loaded_ranges = controlgrid.excel_to_grid(self.proj_file,
                                                       'Ranges', self.m_grid21)

        if self.loaded_ranges == True:

            col_names = [
                'Min', 'Max', '# Readings', 'Pre-reading delay',
                'Inter-reading delay', '# Repetitions', '# steps'
            ]
            for i in range(len(col_names)):
                self.m_grid21.SetColLabelValue(i, col_names[i])
            self.m_grid21.Layout()
            #Copy ranges from m_grid21 to m_grid91
            rows = self.m_grid21.GetNumberRows()
            rows = range(0, int(rows))
            for x in rows:
                self.m_grid91.SetCellValue(x + 1, 0,
                                           self.m_grid21.GetCellValue(x, 1))
        else:
            print("no sheet named 'Ranges' found")

            #wip
        i = 0
        while (isinstance(self.m_grid21.GetCellValue(1, i),
                          (int, long, float))):
            self.m_grid91.SetCellValue(0, i, self.m_grid21.GetCellValue(1, i))
            i = i + 1