Exemple #1
0
    def __init__(self, DIext='Aux2'):
        """
        Initialize the graphical user interface
        """
        QMainWindow.__init__(self)
        # Set up the user interface from Designer.
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        # Setup the ploting widgets
        self.canvas = self.ui.mpl.canvas
        self.fig = self.ui.mpl.canvas.fig
        self.canvas.mpl_connect('pick_event', self.on_pick)
        
        self.save = False

        self.DIext = DIext

        # Setup the plotting layout
        self.initPlotLayout()

        # Ask for the directory containing the matrix files
        if len(sys.argv) < 2:
            self.path = QFileDialog.getExistingDirectory()
        else:
            # If an argument is sent to the script, the first argument will be used as a Path. Very usefull for debugging the script without having to selectr the folder each time with window dialog
            self.path = sys.argv[1]
        
        # Read the Matrix file
        self.M = pyO.Matrix(self.path)

        # Looking for a Table of Content file (called toc.txt or ToC.txt)
        self.ToC = None
        f = False
        if os.path.exists(self.path+"/toc.txt"):
            f = open(self.path+"/toc.txt", "r")
        elif os.path.exists(self.path+"/ToC.txt"):
            f = open(self.path+"/ToC.txt", "r")
        if f:
            self.ToC = {int(z[0]):z[1] for z in [x.split() for x in f.readlines()]}
            f.close()
        val = 200 # value used for the colors
        # colors used for the plot lines
        self.colors = [(0, 0, val), (0, val, 0), (val, 0, 0),\
            (val, val, 0), (val, 0, val), (0, val, val)]
        
        # Add the found data to the combo box
        self.populateUI()


        # QT: SIGNALS -> SLOTS
        # This set which function is called when buttons, checkboxes, etc. are clicked
        self.ui.comboBox.currentIndexChanged.connect(self.updateSTSid)
        self.ui.listWidget.itemChanged.connect(self.plotUpdate)
        self.ui.DV.valueChanged.connect(self.plotUpdate)
        self.ui.statCB.stateChanged.connect(self.plotUpdate)
        self.ui.normCB.stateChanged.connect(self.plotUpdate)
        self.ui.pushButton.clicked.connect(self.InfoShowHideToggle)
        self.ui.saveBT.clicked.connect(self.export)
        self.InfoShowHideToggle('Hide')
        
        self.updateSTSid()
        
        if len(sys.argv) > 2:
            ID = sys.argv[2]
            self.ui.comboBox.setCurrentIndex(\
                self.ui.comboBox.findText(ID,QtCore.Qt.MatchStartsWith))

        self.plotUpdate()