Ejemplo n.º 1
0
    def dislpayCsDetails(self):  #display the selected curve set (xls) details
        """called when a curve set is selected"""

        #=======================================================================
        # #get the selection
        #=======================================================================
        fileName, filePath = self._get_cset_selection()

        #=======================================================================
        # build data for this
        #=======================================================================
        #=======================================================================
        # assert self.libName in self.vdata_d, self.libName
        # assert fileName in self.vdata_d[self.libName]['curves_d'], 'requested filename not found: %s'%filePath
        #
        # data = self.vdata_d[self.libName]['curves_d'][fileName]
        #=======================================================================

        data = self._load_cs(filePath)

        df = pd.Series(data, name='values').to_frame().reset_index().rename(
            columns={'index': 'var'})

        self.dfModel3 = pandasModel(df)

        #=======================================================================
        # send to the widget
        #=======================================================================
        self.tableView_bottomRight.setModel(self.dfModel3)

        #adjust columns
        header = self.tableView_bottomRight.horizontalHeader()
        for lindex in [0]:  #resize specific columns to contents
            header.setSectionResizeMode(lindex, QHeaderView.ResizeToContents)
        header.setStretchLastSection(True)
Ejemplo n.º 2
0
    def displayDetails(self):  #display details on the selected library
        #log = self.logger.getChild('displayDetails')

        #=======================================================================
        # retrieve selection
        #=======================================================================
        #check we have a selection
        if len(self.tableView.selectionModel().selectedRows()) == 0:
            return

        #get the selection index
        """should only allow 1 row.. but taking the first regardless"""
        sindex = self.tableView.selectionModel().selectedRows()[0]
        row = sindex.row()

        #get this value
        libName = self.dfModel.data(self.dfModel.index(row, 0))
        #log.debug('user selected \'%s\''%libName)
        self.libName = libName  #set for retrieving curve details
        #=======================================================================
        # build data for this
        #=======================================================================
        df = self.vdetails_d[libName]
        self.dfModel2 = pandasModel(df)

        #=======================================================================
        # send to the widget
        #=======================================================================
        self.tableView_right.setModel(self.dfModel2)
Ejemplo n.º 3
0
    def displayFiles(
            self
    ):  #show the xls files on the treeview for the selected library
        """
        called when a library is selected
        """
        #check we have a selection
        if len(self.tableView.selectionModel().selectedRows()) == 0:
            return
        log = self.logger.getChild('displayFiles')
        #=======================================================================
        # retrieve selection
        #=======================================================================
        #get the selection index
        """should only allow 1 row.. but taking the first regardless"""
        sindex = self.tableView.selectionModel().selectedRows()[0]
        row = sindex.row()

        #get this value
        libName = self.dfModel.data(self.dfModel.index(row, 0))
        #log.debug('user selected \'%s\''%libName)

        #=======================================================================
        # data setup
        #=======================================================================
        focus_dir = self.vdata_d[libName]['basedir']
        #focus_dir = r'C:\LS\03_TOOLS\CanFlood\_git\canflood\_pars\vfunc'

        #=======================================================================
        # #build the model
        #=======================================================================
        assert os.path.exists(focus_dir)
        fsModel = QFileSystemModel()
        fsModel.setRootPath(focus_dir)
        fsModel.setNameFilters(['*.xls'])
        self.fsModel = fsModel

        #=======================================================================
        # #tree view
        #=======================================================================
        self.treeView.setModel(fsModel)
        self.treeView.setRootIndex(fsModel.index(focus_dir))
        log.debug('connected treeView to QFileSystemModel w/: \n    %s' %
                  focus_dir)

        #adjust columns
        header = self.treeView.header()
        header.setSectionResizeMode(0, QHeaderView.ResizeToContents)
        header.setStretchLastSection(False)
        #self.treeView.resizeColumnToContents(0)

        #=======================================================================
        # connect it
        #=======================================================================
        self.treeView.selectionModel().selectionChanged.connect(
            self.dislpayCsDetails)
        """
        if not self.dfModel3 is None:
            self.dfModel3.clear()
        #self.tableView_bottomRight.clearSpans() #clear the table view until next trigger
        
        """

        try:  #cleanup the model
            self.tableView_bottomRight.setModel(pandasModel(
                pd.DataFrame()))  #set a dummy model
            del self.dfModel3
        except:
            pass
Ejemplo n.º 4
0
    def connect_slots(self):
        """
        called on launch
        """
        log = self.logger.getChild('connect_slots')

        #======================================================================
        # pull project data
        #======================================================================

        #=======================================================================
        # general----------------
        #=======================================================================

        #ok/cancel buttons
        self.buttonBox.accepted.connect(self.reject)  #back out of the dialog
        self.buttonBox.rejected.connect(self.reject)

        self.logger.statusQlab = self.progressText  #connect to the progress text
        #=======================================================================
        # library meta table------
        #=======================================================================
        #=======================================================================
        # build model
        #=======================================================================
        vdata_d = self.vdata_d
        assert len(vdata_d) > 0

        #build a df of what we want to display
        df = pd.DataFrame.from_dict({
            k: v['meta.d']
            for k, v in vdata_d.items()
        }).T.reset_index(drop=True).sort_values('name')

        #lModel = QStringListModel(list(vdata_d.keys()))
        self.dfModel = pandasModel(df)

        #=======================================================================
        # setup  view
        #=======================================================================
        self.tableView.setModel(self.dfModel)

        #adjust columns
        header = self.tableView.horizontalHeader()
        for lindex in [0, 1]:  #resize specific columns to contents
            header.setSectionResizeMode(lindex, QHeaderView.ResizeToContents)
        header.setStretchLastSection(False)

        #=======================================================================
        # connections
        #=======================================================================
        #connect selection
        self.tableView.selectionModel().selectionChanged.connect(
            self.displayDetails)
        self.tableView.selectionModel().selectionChanged.connect(
            self.displayFiles)

        #=======================================================================
        # connect buttons------
        #=======================================================================
        self.pushButton_copy.clicked.connect(self.copy_vfuncs)
        self.pushButton_PlotSet.clicked.connect(self.plot_set)