コード例 #1
0
ファイル: Labs2-ui.py プロジェクト: AmineId/Labs-Python
    def onCLicked_Plot(self):
        self.statusBar().showMessage('Plotting ID: ' +
                                     str(self.ids.currentText() + ' ...'))
        X = []
        Y = []
        color = list(np.random.choice(range(256), size=3))
        pen = pg.mkPen(color=color, width=2)
        brush = pg.mkBrush(color=color)
        global df_filtered, id_str, plotted
        temp = [str(s) for s in self.ids.currentText() if s.isdigit()]
        id_str = str("".join(temp))
        if process == "csv":
            X, Y, df_filtered = Lab1.Filtering_Data(df, id_str)
        elif process == "sql":
            cursor = connection.cursor()
            cursor.execute("SELECT latitude FROM TAB WHERE id LIKE " + id_str)
            X = cursor.fetchall()
            X = list(itertools.chain(*X))
            cursor.execute("SELECT longitude FROM TAB WHERE id LIKE " + id_str)
            Y = cursor.fetchall()
            Y = list(itertools.chain(*Y))

        plotted.append(id_str)

        self.tb_id.addItem(id_str)
        self.tb_id.setCurrentIndex(self.tb_id.findData(id_str))
        self.graphPlot.plot(X,
                            Y,
                            pen=pen,
                            symbol='o',
                            symbolSize=4,
                            symbolBrush=brush)
        self.statusBar().showMessage('Ready.')
コード例 #2
0
 def onChangedVal(self):
     global df_filtered
     if self.tb_id.currentText() != '':
         if process == "csv":
             df_filtered = Lab1.Filtering_Data(df, self.tb_id.currentText(), mode=True)
         elif process == "sql":
             cursor = connection.cursor()
             cursor.execute("SELECT * FROM TAB WHERE id LIKE " + self.tb_id.currentText())
             df_filtered = cursor.fetchall()
         self.TableFill()