Beispiel #1
0
 def QmFLt(self):
     self.tripop = QmFLt(df=self.model._df)
     try:
         self.tripop.Tri()
         self.tripop.show()
     except (KeyError):
         self.ErrorEvent()
Beispiel #2
0
class Ui_MainWindow(QtWidgets.QWidget):
    # raw=0
    raw = pd.DataFrame(index=[],
                       columns=[])  # raw is initialized as a blank dataframe

    def setupUi(
        self,
        MainWindow,
    ):

        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(800, 500)

        self.model = PandasModel(self.raw)

        self.main_widget = QWidget(self)

        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        MainWindow.setCentralWidget(self.centralwidget)

        self.tableView = CustomQTableView(self.centralwidget)
        self.tableView.setGeometry(QtCore.QRect(10, 10, 780, 384))
        self.tableView.setObjectName("tableView")
        self.tableView.setSortingEnabled(True)

        self.pushButtonOpen = QtWidgets.QPushButton(self.centralwidget)
        self.pushButtonOpen.setGeometry(QtCore.QRect(20, 404, 110, 32))
        self.pushButtonOpen.setObjectName("pushButtonOpen")

        self.pushButtonSave = QtWidgets.QPushButton(self.centralwidget)
        self.pushButtonSave.setGeometry(QtCore.QRect(150, 404, 110, 32))
        self.pushButtonSave.setObjectName("pushButtonSave")

        self.pushButtonSort = QtWidgets.QPushButton(self.centralwidget)
        self.pushButtonSort.setGeometry(QtCore.QRect(280, 404, 110, 32))
        self.pushButtonSort.setObjectName("pushButtonSort")

        self.pushButtonQuit = QtWidgets.QPushButton(self.centralwidget)
        self.pushButtonQuit.setGeometry(QtCore.QRect(410, 404, 110, 32))
        self.pushButtonQuit.setObjectName("pushButtonQuit")

        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 22))
        self.menubar.setNativeMenuBar(False)
        self.menubar.setObjectName("menubar")

        self.menuFile = QtWidgets.QMenu(self.menubar)
        self.menuFile.setObjectName("menuFile")

        self.menuGeoChem = QtWidgets.QMenu(self.menubar)
        self.menuGeoChem.setObjectName("menuGeoChem")

        self.menuStructure = QtWidgets.QMenu(self.menubar)
        self.menuStructure.setObjectName("menuStructure")

        self.menuCalc = QtWidgets.QMenu(self.menubar)
        self.menuCalc.setObjectName("menuCalc")

        self.menuMore = QtWidgets.QMenu(self.menubar)
        self.menuMore.setObjectName("menuMore")

        self.menuHelp = QtWidgets.QMenu(self.menubar)
        self.menuHelp.setObjectName("menuHelp")

        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.actionOpen = QtWidgets.QAction(MainWindow)
        self.actionOpen.setObjectName("actionOpen")
        self.actionOpen.setShortcut('Ctrl+O')

        self.actionSave = QtWidgets.QAction(MainWindow)
        self.actionSave.setObjectName("actionSave")
        self.actionSave.setShortcut('Ctrl+S')

        self.actionInstruction = QtWidgets.QAction(MainWindow)
        self.actionInstruction.setObjectName("actionInstruction")

        self.actionWebsite = QtWidgets.QAction(MainWindow)
        self.actionWebsite.setObjectName("actionWebsite")

        self.actionTAS = QtWidgets.QAction(MainWindow)
        self.actionTAS.setObjectName("actionTAS")

        self.actionTrace = QtWidgets.QAction(MainWindow)
        self.actionTrace.setObjectName("actionTrace")

        self.actionRee = QtWidgets.QAction(MainWindow)
        self.actionRee.setObjectName("actionRee")

        self.actionPearce = QtWidgets.QAction(MainWindow)
        self.actionPearce.setObjectName("actionPearce")

        self.actionHarker = QtWidgets.QAction(MainWindow)
        self.actionHarker.setObjectName("actionHarker")

        self.actionStereo = QtWidgets.QAction(MainWindow)
        self.actionStereo.setObjectName("actionStereo")

        self.actionRose = QtWidgets.QAction(MainWindow)
        self.actionRose.setObjectName("actionRose")

        self.actionQFL = QtWidgets.QAction(MainWindow)
        self.actionQFL.setObjectName("actionQFL")

        self.actionQmFLt = QtWidgets.QAction(MainWindow)
        self.actionQmFLt.setObjectName("actionQmFLt")

        self.actionCIPW = QtWidgets.QAction(MainWindow)
        self.actionCIPW.setObjectName("actionCIPW")

        self.actionZirconCe = QtWidgets.QAction(MainWindow)
        self.actionZirconCe.setObjectName("actionZirconCe")

        self.actionQAPF = QtWidgets.QAction(MainWindow)
        self.actionQAPF.setObjectName("actionQAPF")

        self.actionMudStone = QtWidgets.QAction(MainWindow)
        self.actionMudStone.setObjectName("actionMudStone")

        self.actionXY = QtWidgets.QAction(MainWindow)
        self.actionXY.setObjectName("actionXY")

        self.actionXYZ = QtWidgets.QAction(MainWindow)
        self.actionXYZ.setObjectName("actionXYZ")

        self.actionMagic = QtWidgets.QAction(MainWindow)
        self.actionMagic.setObjectName("actionMagic")

        self.menuFile.addAction(self.actionOpen)
        self.menuFile.addAction(self.actionSave)

        self.menuGeoChem.addAction(self.actionTAS)
        self.menuGeoChem.addAction(self.actionTrace)
        self.menuGeoChem.addAction(self.actionRee)
        self.menuGeoChem.addAction(self.actionPearce)
        self.menuGeoChem.addAction(self.actionHarker)

        self.menuStructure.addAction(self.actionStereo)
        self.menuStructure.addAction(self.actionRose)
        self.menuStructure.addAction(self.actionQFL)
        self.menuStructure.addAction(self.actionQmFLt)

        self.menuCalc.addAction(self.actionCIPW)
        self.menuCalc.addAction(self.actionZirconCe)

        self.menuMore.addAction(self.actionMudStone)
        self.menuMore.addAction(self.actionQAPF)
        self.menuMore.addAction(self.actionXY)
        self.menuMore.addAction(self.actionXYZ)
        self.menuMore.addAction(self.actionMagic)

        self.menuHelp.addAction(self.actionInstruction)
        self.menuHelp.addAction(self.actionWebsite)

        self.menubar.addAction(self.menuFile.menuAction())
        self.menubar.addSeparator()

        self.menubar.addAction(self.menuGeoChem.menuAction())
        self.menubar.addSeparator()

        self.menubar.addAction(self.menuStructure.menuAction())
        self.menubar.addSeparator()

        self.menubar.addAction(self.menuCalc.menuAction())
        self.menubar.addSeparator()

        self.menubar.addAction(self.menuMore.menuAction())
        self.menubar.addSeparator()

        self.menubar.addAction(self.menuHelp.menuAction())
        self.menubar.addSeparator()

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

        self.actionTAS.triggered.connect(self.TAS)
        self.actionTrace.triggered.connect(self.Trace)
        self.actionRee.triggered.connect(self.REE)
        self.actionPearce.triggered.connect(self.Pearce)
        self.actionHarker.triggered.connect(self.Harker)
        self.actionQAPF.triggered.connect(self.QAPF)

        self.actionStereo.triggered.connect(self.Stereo)
        self.actionRose.triggered.connect(self.Rose)
        self.actionQFL.triggered.connect(self.QFL)
        self.actionQmFLt.triggered.connect(self.QmFLt)

        self.actionCIPW.triggered.connect(self.CIPW)
        self.actionZirconCe.triggered.connect(self.Zircon)

        self.actionOpen.triggered.connect(self.getDataFile)
        self.actionSave.triggered.connect(self.saveDataFile)

        self.actionWebsite.triggered.connect(self.gowebsite)

        self.actionXY.triggered.connect(self.XY)
        self.actionXYZ.triggered.connect(self.XYZ)
        self.actionMagic.triggered.connect(self.Magic)
        self.actionMudStone.triggered.connect(self.Mud)

        self.pushButtonOpen.clicked.connect(self.getDataFile)
        self.pushButtonSave.clicked.connect(self.saveDataFile)
        self.pushButtonSort.clicked.connect(self.SetUpDataFile)
        self.pushButtonQuit.clicked.connect(qApp.quit)

        self.actionQuit = QtWidgets.QAction('Quit', self)
        self.actionQuit.setShortcut('Ctrl+Q')
        self.actionQuit.setObjectName("actionQuit")
        self.actionQuit.triggered.connect(qApp.quit)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "GeoPython"))

        self.pushButtonOpen.setText(_translate("MainWindow", "Open"))
        self.pushButtonSave.setText(_translate("MainWindow", "Save"))
        self.pushButtonSort.setText(_translate("MainWindow", "Set"))
        self.pushButtonQuit.setText(_translate("MainWindow", "Quit"))

        self.menuFile.setTitle(_translate("MainWindow", "Data File"))

        self.menuGeoChem.setTitle(_translate("MainWindow", "Geochemistry"))

        self.menuStructure.setTitle(_translate("MainWindow", "Structure"))

        self.menuCalc.setTitle(_translate("MainWindow", "Calculation"))

        self.menuMore.setTitle(_translate("MainWindow", "More Functions"))

        self.menuHelp.setTitle(_translate("MainWindow", "Get Help"))

        self.actionOpen.setText(_translate("MainWindow", "Open Data"))
        self.actionSave.setText(_translate("MainWindow", "Save Data"))

        self.actionTAS.setText(_translate("MainWindow", "TAS"))
        self.actionTrace.setText(_translate("MainWindow", "Trace"))
        self.actionRee.setText(_translate("MainWindow", "REE"))
        self.actionPearce.setText(_translate("MainWindow", "Pearce"))
        self.actionHarker.setText(_translate("MainWindow", "Harker"))

        self.actionQAPF.setText(_translate("MainWindow", "QAPF"))

        self.actionStereo.setText(_translate("MainWindow", "Stereo"))
        self.actionRose.setText(_translate("MainWindow", "Rose"))
        self.actionQFL.setText(_translate("MainWindow", "QFL"))
        self.actionQmFLt.setText(_translate("MainWindow", "QmFLt"))

        self.actionCIPW.setText(_translate("MainWindow", "CIPW"))

        self.actionZirconCe.setText(_translate("MainWindow", "ZirconCe"))

        self.actionXY.setText(_translate("MainWindow", "X-Y plot"))
        self.actionXYZ.setText(_translate("MainWindow", "X-Y-Z plot"))

        self.actionMagic.setText(_translate("MainWindow", "Testing Functions"))

        self.actionMudStone.setText(_translate("MainWindow", "Sand-Silt-Mud"))

        self.actionInstruction.setText(_translate("MainWindow", "Instruction"))
        self.actionWebsite.setText(_translate("MainWindow", "Website"))

    def getfile(self):
        fileName, filetype = QFileDialog.getOpenFileName(
            self, "选取文件", "~/",
            "All Files (*);;Text Files (*.txt)")  # 设置文件扩展名过滤,注意用双分号间隔

    def gowebsite(self):
        webbrowser.open(
            'https://github.com/chinageology/GeoPython/blob/master/README.md')

    def getDataFile(self):
        DataFileInput, filetype = QFileDialog.getOpenFileName(
            self, "选取文件", "~/",
            "Excel Files (*.xlsx);;Excel 2003 Files (*.xls);;CSV Files (*.csv)"
        )  # 设置文件扩展名过滤,注意用双分号间隔

        # print(DataFileInput,filetype)

        if ("csv" in DataFileInput):
            self.raw = pd.read_csv(DataFileInput)
        elif ("xls" in DataFileInput):
            self.raw = pd.read_excel(DataFileInput)
        # print(self.raw)

        self.model = PandasModel(self.raw)
        self.tableView.setModel(self.model)

        flag = 0
        ItemsAvalibale = self.model._df.columns.values.tolist()
        ItemsToTest = [
            'Label', 'Marker', 'Color', 'Size', 'Alpha', 'Style', 'Width'
        ]

        ItemsToAdd = []

        Sentecne = 'You need to add '

        print(ItemsAvalibale, '\n', ItemsToTest)

        for i in ItemsToTest:
            if i not in ItemsAvalibale:
                ItemsToAdd.append(i)
                Sentecne = Sentecne + i + ', '
                flag = flag + 1

        Sentecne = Sentecne + " to your data, set up now?"

        if flag != 0:

            buttonReply = QMessageBox.question(
                self, 'Message', Sentecne, QMessageBox.Yes | QMessageBox.No,
                QMessageBox.No)
            if buttonReply == QMessageBox.Yes:
                self.SetUpDataFile()
            else:
                reply = QMessageBox.warning(
                    self, 'Warning',
                    "Data can't be used without setting up Label,Color,Size and so on."
                )

    def saveDataFile(self):

        if self.model._changed == True:
            print("changed")
            print(self.model._df)

        DataFileOutput, ok2 = QFileDialog.getSaveFileName(
            self, "文件保存", "C:/",
            "Excel Files (*.xlsx);;CSV Files (*.csv)")  # 数据文件保存输出

        if (DataFileOutput != ''):

            if ("csv" in DataFileOutput):
                self.model._df.to_csv(DataFileOutput,
                                      sep=',',
                                      encoding='utf-8')

            elif ("xls" in DataFileOutput):
                self.model._df.to_excel(DataFileOutput, encoding='utf-8')

    def CIPW(self):
        self.cipwpop = CIPW(df=self.model._df)
        try:
            self.cipwpop.CIPW()
            self.cipwpop.show()
        except (KeyError):
            self.ErrorEvent()

    def TAS(self):

        self.pop = TAS(df=self.model._df)
        try:
            self.pop.TAS()
            self.pop.show()
        except (KeyError):
            self.ErrorEvent()

    def REE(self):
        self.reepop = REE(df=self.model._df)
        try:
            self.reepop.REE()
            self.reepop.show()
        except (KeyError):
            self.ErrorEvent()

    def Trace(self):
        self.tracepop = Trace(df=self.model._df)
        try:
            self.tracepop.Trace()
            self.tracepop.show()
        except (KeyError):
            self.ErrorEvent()

    def Pearce(self):
        self.pearcepop = Pearce(df=self.model._df)
        try:
            self.pearcepop.Pearce()
            self.pearcepop.show()
        except (KeyError):
            self.ErrorEvent()

    def Harker(self):
        self.harkerpop = Harker(df=self.model._df)
        try:
            self.harkerpop.Harker()
            self.harkerpop.show()
        except (KeyError):
            self.ErrorEvent()

    def Stereo(self):
        self.stereopop = Stereo(df=self.model._df)
        try:
            self.stereopop.Stereo()
            self.stereopop.show()
        except (KeyError):
            self.ErrorEvent()

    def Rose(self):
        self.rosepop = Rose(df=self.model._df)
        try:
            self.rosepop.Rose()
            self.rosepop.show()
        except (KeyError):
            self.ErrorEvent()

    def QFL(self):
        self.tripop = QFL(df=self.model._df)
        try:
            self.tripop.Tri()
            self.tripop.show()
        except (KeyError):
            self.ErrorEvent()

    def QmFLt(self):
        self.tripop = QmFLt(df=self.model._df)
        try:
            self.tripop.Tri()
            self.tripop.show()
        except (KeyError):
            self.ErrorEvent()

    def QAPF(self):
        self.qapfpop = QAPF(df=self.model._df)
        try:
            self.qapfpop.QAPF()
            self.qapfpop.show()
        except (KeyError):
            self.ErrorEvent()

    def Mud(self):
        self.mudpop = MudStone(df=self.model._df)
        try:
            self.mudpop.Tri()
            self.mudpop.show()
        except (KeyError):
            self.ErrorEvent()

    def Zircon(self):
        print("Opening a new popup window...")
        self.zirconpop = Zircon(df=self.model._df)
        try:
            self.zirconpop.MultiBallard()
            self.zirconpop.show()
        except (KeyError):
            self.ErrorEvent()

    def XY(self):
        print("Opening a new popup window...")
        # self.w = MyPopup(xlabel = r'$SiO_2 wt\%$', ylabel = r'$Na_2O + K_2O wt\%$', xlim = (30,90), ylim = (0, 20))
        # self.w.setGeometry(QtCore.QRect(100, 100, 532, 600))

        self.xypop = XY(df=self.model._df)
        try:
            self.xypop.Magic()
            self.xypop.show()
        except (KeyError):
            self.ErrorEvent()

    def XYZ(self):
        print("Opening a new popup window...")
        # self.w = MyPopup(xlabel = r'$SiO_2 wt\%$', ylabel = r'$Na_2O + K_2O wt\%$', xlim = (30,90), ylim = (0, 20))
        # self.w.setGeometry(QtCore.QRect(100, 100, 532, 600))

        self.xyzpop = XYZ(df=self.model._df)
        try:
            self.xyzpop.Magic()
            self.xyzpop.show()
        except (KeyError):
            self.ErrorEvent()

    def Magic(self):
        print("Opening a new popup window...")
        # self.w = MyPopup(xlabel = r'$SiO_2 wt\%$', ylabel = r'$Na_2O + K_2O wt\%$', xlim = (30,90), ylim = (0, 20))
        # self.w.setGeometry(QtCore.QRect(100, 100, 532, 600))

        self.magicpop = Magic(df=self.model._df)
        try:
            self.magicpop.Magic()
            self.magicpop.show()
        except (KeyError):
            self.ErrorEvent()

    def Tri(self):
        pass

    def Auto(self):
        pass

    def ErrorEvent(self):

        reply = QMessageBox.warning(self, 'Warning',
                                    "Your Data mismatch this Plot.")

    def SetUpDataFile(self):

        if self.model._changed == True:
            print("changed")
            print(self.model._df)

        flag = 0
        ItemsAvalibale = self.model._df.columns.values.tolist()

        Len = self.model._df.index.values.tolist()

        ItemsToTest = [
            'Label', 'Marker', 'Color', 'Size', 'Alpha', 'Style', 'Width'
        ]

        olddata = {
            'Label': ['group1', 'group2', 'group3', 'group4', 'group5'],
            'Marker': ['o', 's', 'd', '*', '^'],
            'Color': ['red', 'blue', 'black', 'green', 'yellow'],
            'Size': ['10', '10', '10', '10', '10'],
            'Alpha': ['0.6', '0.6', '0.6', '0.6', '0.6'],
            'Style': ['-', '--', ':', '--', '-'],
            'Width': ['1', '1', '1', '1', '1']
        }

        LabelList = []
        MarkerList = []
        ColorList = []
        SizeList = []
        AlphaList = []
        StyleList = []
        WidthList = []
        for i in range(len(self.model._df)):
            LabelList.append('Group1')
            MarkerList.append('o')
            ColorList.append('red')
            SizeList.append('10')
            AlphaList.append('0.6')
            StyleList.append('-')
            WidthList.append('1')

        data = {
            'Label': LabelList,
            'Marker': MarkerList,
            'Color': ColorList,
            'Size': SizeList,
            'Alpha': AlphaList,
            'Style': StyleList,
            'Width': WidthList
        }

        print('\n', data, '\n')

        for i in ItemsToTest:
            if i not in ItemsAvalibale:
                print(i)
                flag = flag + 1
                tmpdata = {i: data[i]}
                tmpdftoadd = pd.DataFrame(tmpdata)

                print('\n', tmpdftoadd, '\n')
                self.model._df = pd.concat([tmpdftoadd, self.model._df],
                                           axis=1)

        if flag == 0:
            reply = QMessageBox.warning(
                self, 'Ready', "Everything fine and no need to set up.")

        else:
            reply = QMessageBox.warning(
                self, 'Ready',
                "Items added, Modify in the Table to set up details.")
Beispiel #3
0
 def QmFLt(self):
     self.tripop = QmFLt(df=self.model._df)
     self.tripop.Tri()
     self.tripop.show()
Beispiel #4
0
class Ui_MainWindow(QtWidgets.QWidget):

    #raw=0
    raw = pd.DataFrame(index=[], columns=[])  # raw is initialized as a blank dataframe


    def setupUi(self, MainWindow,):

        self.w = MyPopup()
        self.w.setGeometry(QtCore.QRect(100, 100, 532, 600))

        self.zirconpop=Zircon()

        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(800, 800)

        self.model = PandasModel(self.raw)

        self.main_widget = QWidget(self)

        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")


        self.tableView = CustomQTableView(self.centralwidget)
        self.tableView.setGeometry(QtCore.QRect(10, 10, 780, 384))
        self.tableView.setObjectName("tableView")
        self.tableView.setSortingEnabled(True)

        self.pushButtonOpen = QtWidgets.QPushButton(self.centralwidget)
        self.pushButtonOpen.setGeometry(QtCore.QRect(30, 404, 110, 32))
        self.pushButtonOpen.setObjectName("pushButtonOpen")
        self.pushButtonSave = QtWidgets.QPushButton(self.centralwidget)
        self.pushButtonSave.setGeometry(QtCore.QRect(30, 444, 110, 32))
        self.pushButtonSave.setObjectName("pushButtonSave")



        self.pushButtonTAS = QtWidgets.QPushButton(self.centralwidget)
        self.pushButtonTAS.setGeometry(QtCore.QRect(150, 404, 110, 32))
        self.pushButtonTAS.setObjectName("pushButtonTAS")


        self.pushButtonZircon = QtWidgets.QPushButton(self.centralwidget)
        self.pushButtonZircon.setGeometry(QtCore.QRect(150, 444, 110, 32))
        self.pushButtonZircon.setObjectName("pushButtonZircon")


        self.pushButtonCIPW = QtWidgets.QPushButton(self.centralwidget)
        self.pushButtonCIPW.setGeometry(QtCore.QRect(150, 484, 110, 32))
        self.pushButtonCIPW.setObjectName("pushButtonCIPW")


        self.pushButtonStereo = QtWidgets.QPushButton(self.centralwidget)
        self.pushButtonStereo.setGeometry(QtCore.QRect(410, 404, 110, 32))
        self.pushButtonStereo.setObjectName("pushButtonStereo")


        self.pushButtonTrace = QtWidgets.QPushButton(self.centralwidget)
        self.pushButtonTrace.setGeometry(QtCore.QRect(280, 444, 110, 32))
        self.pushButtonTrace.setObjectName("pushButtonTrace")
        self.pushButtonTrace2 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButtonTrace2.setGeometry(QtCore.QRect(280, 484, 110, 32))
        self.pushButtonTrace2.setObjectName("pushButtonTrace2")

        self.pushButtonREE = QtWidgets.QPushButton(self.centralwidget)
        self.pushButtonREE.setGeometry(QtCore.QRect(280, 404, 110, 32))
        self.pushButtonREE.setObjectName("pushButtonREE")


        self.pushButtonRose = QtWidgets.QPushButton(self.centralwidget)
        self.pushButtonRose.setGeometry(QtCore.QRect(410, 444, 110, 32))
        self.pushButtonRose.setObjectName("pushButtonRose")


        self.pushButtonMudStone = QtWidgets.QPushButton(self.centralwidget)
        self.pushButtonMudStone.setGeometry(QtCore.QRect(540, 404, 110, 32))
        self.pushButtonMudStone.setObjectName("pushButtonMudStone")



        self.pushButtonQFL= QtWidgets.QPushButton(self.centralwidget)
        self.pushButtonQFL.setGeometry(QtCore.QRect(540, 444, 110, 32))
        self.pushButtonQFL.setObjectName("pushButtonQFL")


        self.pushButtonQmFLt= QtWidgets.QPushButton(self.centralwidget)
        self.pushButtonQmFLt.setGeometry(QtCore.QRect(540, 484, 110, 32))
        self.pushButtonQmFLt.setObjectName("pushButtonQmFLt")


        self.pushButtonQAPF= QtWidgets.QPushButton(self.centralwidget)
        self.pushButtonQAPF.setGeometry(QtCore.QRect(540, 524, 110, 32))
        self.pushButtonQAPF.setObjectName("pushButtonQAPF")



        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 22))
        self.menubar.setNativeMenuBar(False)
        self.menubar.setObjectName("menubar")
        self.menuFile = QtWidgets.QMenu(self.menubar)
        self.menuFile.setObjectName("menuFile")
        self.menuHelp = QtWidgets.QMenu(self.menubar)
        self.menuHelp.setObjectName("menuHelp")
        self.menuPlot = QtWidgets.QMenu(self.menubar)
        self.menuPlot.setObjectName("menuPlot")
        self.menuCalc = QtWidgets.QMenu(self.menubar)
        self.menuCalc.setObjectName("menuCalc")
        self.menuDIY = QtWidgets.QMenu(self.menubar)
        self.menuDIY.setObjectName("menuDIY")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.actionOpen = QtWidgets.QAction(MainWindow)
        self.actionOpen.setObjectName("actionOpen")
        self.actionSave = QtWidgets.QAction(MainWindow)
        self.actionSave.setObjectName("actionSave")
        self.actionInstruction = QtWidgets.QAction(MainWindow)
        self.actionInstruction.setObjectName("actionInstruction")
        self.actionWebsite = QtWidgets.QAction(MainWindow)
        self.actionWebsite.setObjectName("actionWebsite")



        self.menuFile.addAction(self.actionOpen)
        self.menuFile.addAction(self.actionSave)
        self.menuHelp.addAction(self.actionInstruction)
        self.menuHelp.addAction(self.actionWebsite)

        self.menubar.addAction(self.menuFile.menuAction())
        self.menubar.addAction(self.menuHelp.menuAction())

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)


        self.pushButtonOpen.clicked.connect(self.getDataFile)
        self.actionOpen.triggered.connect(self.getDataFile)

        self.pushButtonSave.clicked.connect(self.saveDataFile)
        self.actionSave.triggered.connect(self.saveDataFile)

        self.pushButtonZircon.clicked.connect(self.Zircon)

        self.pushButtonTAS.clicked.connect(self.TAS)

        self.pushButtonREE.clicked.connect(self.REE)

        self.pushButtonTrace.clicked.connect(self.Trace)

        self.pushButtonTrace2.clicked.connect(self.Trace2)

        self.pushButtonStereo.clicked.connect(self.Stereo)

        self.pushButtonRose.clicked.connect(self.Rose)

        self.pushButtonMudStone.clicked.connect(self.Mud)

        self.pushButtonQFL.clicked.connect(self.QFL)

        self.pushButtonQmFLt.clicked.connect(self.QmFLt)

        self.pushButtonCIPW.clicked.connect(self.CIPW)

        self.pushButtonQAPF.clicked.connect(self.QAPF)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "GeoPython"))
        self.pushButtonOpen.setText(_translate("MainWindow", "Open"))
        self.pushButtonSave.setText(_translate("MainWindow", "Save"))
        self.pushButtonTAS.setText(_translate("MainWindow", "TAS"))
        self.pushButtonZircon.setText(_translate("MainWindow", "Zircon Ce"))
        self.pushButtonCIPW.setText(_translate("MainWindow", "CIPW"))
        self.pushButtonStereo.setText(_translate("MainWindow", "Stereo"))
        self.pushButtonRose.setText(_translate("MainWindow", "Rose"))
        self.pushButtonTrace.setText(_translate("MainWindow", "Trace CS-Lu"))
        self.pushButtonTrace2.setText(_translate("MainWindow", "Trace Rb-Lu"))
        self.pushButtonREE.setText(_translate("MainWindow", "REE"))

        self.pushButtonMudStone.setText(_translate("MainWindow", "Sand-Silt-Mud"))
        self.pushButtonQFL.setText(_translate("MainWindow", "QFL"))
        self.pushButtonQmFLt.setText(_translate("MainWindow", "QmFLt"))

        self.pushButtonQAPF.setText(_translate("MainWindow", "QAPF"))

        self.menuFile.setTitle(_translate("MainWindow", "File"))
        self.menuHelp.setTitle(_translate("MainWindow", "Help"))

        self.actionOpen.setText(_translate("MainWindow", "Open"))
        self.actionSave.setText(_translate("MainWindow", "Save"))
        self.actionInstruction.setText(_translate("MainWindow", "Instruction"))
        self.actionWebsite.setText(_translate("MainWindow", "Website"))


    def getfile(self):
        fileName1, filetype = QFileDialog.getOpenFileName(self,
                                                              "选取文件",
                                                              "~/",
                                                              "All Files (*);;Text Files (*.txt)")  # 设置文件扩展名过滤,注意用双分号间隔

    def getDataFile(self):
        DataFileInput, filetype = QFileDialog.getOpenFileName(self,
                                                              "选取文件",
                                                              "~/",
                                                              "Excel Files (*.xlsx);;Excel 2003 Files (*.xls);;CSV Files (*.csv)")  # 设置文件扩展名过滤,注意用双分号间隔

        #print(DataFileInput,filetype)



        if ("csv" in DataFileInput):
            self.raw = pd.read_csv(DataFileInput)
        elif ("xls" in DataFileInput):
            self.raw = pd.read_excel(DataFileInput)
        #print(self.raw)

        self.model = PandasModel(self.raw)
        self.tableView.setModel(self.model)

    def saveDataFile(self):


        if self.model._changed == True:
            print("changed")
            print(self.model._df)



        DataFileOutput, ok2 = QFileDialog.getSaveFileName(self,
                                    "文件保存",
                                    "C:/",
                                    "Excel Files (*.xlsx);;CSV Files (*.csv)")  # 数据文件保存输出

        if(DataFileOutput !=''):

            if ("csv" in DataFileOutput):self.model._df.to_csv(DataFileOutput, sep=',', encoding='utf-8')

            elif ("xls" in DataFileOutput):self.model._df.to_excel(DataFileOutput, encoding='utf-8')

    def saveImgFile(self):
        ImgFileOutput, ok2 = QFileDialog.getSaveFileName(self,
                                    "文件保存",
                                    "C:/",
                                    "pdf Files (*.pdf);;SVG Files (*.svg);;PNG Files (*.png)")  # 设置文件扩展名过滤,注意用双分号间隔

        if (ImgFileOutput != ''):
            self.w.MyCanvas.print_figure(ImgFileOutput, dpi= 300 )
            #self.statusBar().showMessage('Saved to %s' % ImgFileOutput, 2000)

    def TAS(self):

        self.pop = TAS(df=self.model._df)
        self.pop.TAS()
        self.pop.show()

    def REE(self):
        self.reepop = REE(df=self.model._df)
        self.reepop.REE()
        self.reepop.show()

    def Trace(self):
        self.tracepop = Trace(df=self.model._df)
        self.tracepop.Trace()
        self.tracepop.show()

    def Trace2(self):
        self.trace2pop = Trace2(df=self.model._df)
        self.trace2pop.Trace2()
        self.trace2pop.show()

    def Zircon(self):
        print("Opening a new popup window...")
        #self.w = MyPopup(xlabel = r'$SiO_2 wt\%$', ylabel = r'$Na_2O + K_2O wt\%$', xlim = (30,90), ylim = (0, 20))
        #self.w.setGeometry(QtCore.QRect(100, 100, 532, 600))

        self.zirconpop = Zircon(df=self.model._df)
        self.zirconpop.MultiBallard()
        self.zirconpop.show()

    def Stereo(self):
        self.stereopop = Stereo(df=self.model._df)
        self.stereopop.Stereo()
        self.stereopop.show()

    def Rose(self):
        self.rosepop = Rose(df=self.model._df)
        self.rosepop.Rose()
        self.rosepop.show()

    def QFL(self):
        self.tripop = QFL(df=self.model._df)
        self.tripop.Tri()
        self.tripop.show()

    def QmFLt(self):
        self.tripop = QmFLt(df=self.model._df)
        self.tripop.Tri()
        self.tripop.show()

    def Mud(self):
        self.mudpop = MudStone(df=self.model._df)
        self.mudpop.Tri()
        self.mudpop.show()

    def CIPW(self):
        self.cipwpop = CIPW(df=self.model._df)
        self.cipwpop.CIPW()
        self.cipwpop.show()


    def QAPF(self):
        self.qapfpop = QAPF(df=self.model._df)
        self.qapfpop.QAPF()
        self.qapfpop.show()




    def Tri(self):
        pass


    def Auto(self):
        pass
Beispiel #5
0
 def QFL(self):
     self.tripop = QFL(df=self.model._df)
     self.tripop.Tri()
     self.tripop.show()