Exemple #1
0
    def on_save_pressed(self):
        options = QFileDialog.Options()
        filename, _ = QFileDialog.getSaveFileName(self,
                                                  "Save contour to DXF file",
                                                  "",
                                                  "DXF File (*.dxf)",
                                                  options=options)
        if filename:
            doc = ezdxf.new('R2000')
            msp = doc.modelspace()

            points = []
            contours = self.cnt.tolist()
            contours.append(contours[0])
            for p in contours:
                points.append((p[0][0] / self.scaling, p[0][1] / self.scaling))
            msp.add_lwpolyline(points)
            doc.saveas(filename)

            self.save_preferences()
Exemple #2
0
 def loadGeometry(self):
     options = QFileDialog.Options()
     options |= QFileDialog.DontUseNativeDialog
     qs, _ = QFileDialog.getOpenFileName(self,
                                         'Load geometry from pickle file',
                                         '',
                                         '*.pickle',
                                         options=options)
     if qs:
         filename = str(qs)
         print(filename)
         data = pickle.load(open(filename, 'rb'))
         if isinstance(data, dict):
             self.sim.loadGeometryFromPickle(data)
             self.frameNo = self.sim.stepNum
             if self.run:
                 self.frameNo += 1
             self.updateGL()
         else:
             print("Pickle is in an unsupported format, sorry")
Exemple #3
0
 def load_animation(self):
     options = QFileDialog.Options()
     # filter: "All Files (*)", "Python Files (*.py)", "PKL Files (*.pkl)"
     fileName, _ = QFileDialog.getOpenFileName(
         self,
         "QFileDialog.getOpenFileName()",
         "",
         "PKL Files (*.pkl)",
         options=options)
     if fileName:
         QMessageBox.information(
             self, "Message", "animation file is loaded \n %s" % fileName)
         with open(fileName,
                   'rb') as file:  # james.p 파일을 바이너리 읽기 모드(rb)로 열기
             ani_data = pickle.load(file)
         temp_ani = GraphicDisplay(ani_data['width'],
                                   ani_data['height'],
                                   unit_pixel=ani_data['unit'])
         temp_ani.data = ani_data['data']
         temp_ani.mainloop()
Exemple #4
0
 def out_all_variants_clicked_action(self):
     if not self.current_taskset_id:
         return
     options = QFileDialog.Options()
     file_name, _ = QFileDialog.getSaveFileName(self, "Сохранить варианты в Word", "",
                                                "Документы Word (*.docx);;All Files (*)", options=options)
     document = Document()
     if not self.variants_table:
         self.variants_table = Variants(self.cur)
     temp_list = self.variants_table.select_detail(self.current_taskset_id)
     for row in temp_list:
         condition = row[3]
         document.add_paragraph(condition)
         document.add_paragraph("\n")
     if self.ui.key_out_cb.isChecked():
         for row in temp_list:
             answer = row[4]
             document.add_paragraph(answer)
             document.add_paragraph("\n")
     document.save(file_name)
Exemple #5
0
 def action_save_data_frame(self):
     self.saveFlag = True
     options = QFileDialog.Options()
     options |= QFileDialog.DontUseNativeDialog
     file_name, _ = QFileDialog.getSaveFileName(
         self,
         "Save DataFrame",
         "",
         "CSV (*.csv);;TXT (*.txt);;Excel File (*.xlsx)",
         options=options)
     if file_name:
         if file_name.split(".")[-1] not in ["csv", "xlsx"]:
             file_name = file_name + "." + re.findall("\*\.(.*)\)", _)[0]
         if file_name.split(".")[-1] == "csv":
             sep, okPressed = QInputDialog.getText(self, "CSV Seperator",
                                                   "Seperator:",
                                                   QLineEdit.Normal, ",")
             self.saveSep = sep
         self.saveFileName = file_name
     self.load_data_frame()
Exemple #6
0
 def SaveAverage(self):
     suggested = self.lineEditFilename.text() + '_clus.xls'
     options = QFileDialog.Options()
     options |= QFileDialog.DontUseNativeDialog
     filesave, _ = QFileDialog.getSaveFileName(
         self,
         "QFileDialog.getSaveFileName()",
         suggested,
         "Excel Files(*.xls)",
         options=options)
     if filesave:
         __, ext = os.path.splitext(filesave)
         if ext == '.xls':
             filesave = filesave
         else:
             filesave = filesave + '.xls'
         df_save = pd.DataFrame({'Wavenumber': self.wavenumber})
         df_spec = pd.DataFrame(self.spmean.T, columns=[self.label])
         df_save = pd.concat([df_save, df_spec], axis=1, sort=False)
         df_save.to_excel(filesave, index=False)
Exemple #7
0
 def __init__(self):
     super().__init__()
     self.setWindowTitle('Cохранение')
     self.setGeometry(10, 10, 640, 480)
     options = QFileDialog.Options()
     options |= QFileDialog.DontUseNativeDialog
     fileName, _ = QFileDialog.getSaveFileName(self,
                                               "Cохранение",
                                               "",
                                               "Text Files (*.txt)",
                                               options=options)
     if fileName:
         print(fileName)
         if '.txt' in fileName:
             self.filename = fileName
         else:
             self.filename = fileName + '.txt'
     else:
         print(None)
         self.filename = None
Exemple #8
0
 def openFileNameDialog(self):
     options = QFileDialog.Options()
     options |= QFileDialog.DontUseNativeDialog
     #fileName, _ = QFileDialog.getOpenFileName(self, "QFileDialog.getOpenFileName()", "",".csv Files (*.csv)", options = options)
     #if fileName:
     #    print(fileName)
     fileURL, _ = QFileDialog.getOpenFileUrl(self,
                                             "QFileDialog.getOpenFileUrl()",
                                             "",
                                             ".csv Files (*.csv)",
                                             options=options)
     print(fileURL)
     if (fileURL.toString() != ''):
         self.dfExport = pd.read_csv(fileURL.toString(), index_col=False)
         self.ui.bgg_tabs.setTabEnabled(1, True)
         self.ui.bgg_tabs.setCurrentIndex(1)
         self.ui.dfPreview.setEnabled(True)
         self.updatePreview()
     else:
         print('nada')
Exemple #9
0
 def onSave(self):
     if self.ui.signatureTextEdt.document().isEmpty():
         mess = "Nothing to save. Sign message first."
         myPopUp_sb(self.main_wnd, QMessageBox.Warning, 'SPMT - no signature', mess)
         return
     options = QFileDialog.Options()
     options |= QFileDialog.DontUseNativeDialog
     fileName, _ = QFileDialog.getSaveFileName(self.main_wnd, "Save signature to file", "sig.txt",
                                               "All Files (*);; Text Files (*.txt)", options=options)
     try:
         if fileName:
             save_file = open(fileName, 'w', encoding="utf-8")
             save_file.write(self.ui.signatureTextEdt.toPlainText())
             save_file.close()
             myPopUp_sb(self.main_wnd, QMessageBox.Information, 'SPMT - saved', "Signature saved to file")
             return
     except Exception as e:
         err_msg = "error writing signature to file"
         printException(getCallerName(), getFunctionName(), err_msg, e.args)
     myPopUp_sb(self.main_wnd, QMessageBox.Warning, 'SPMT - NOT saved', "Signature NOT saved to file")
Exemple #10
0
    def save_scene_image(self):
        if self.file_names:
            print("aurea")
            options = QFileDialog.Options()
            options |= QFileDialog.DontUseNativeDialog
            file, _ = QFileDialog.getSaveFileName(self, "Save Image", "",
                                                  "Image (*.png)")
            if ".png" not in file:
                file = file + ".png"

            isize = self.graphicsScene.sceneRect().size().toSize()
            qimage = QtGui.QImage(isize, QtGui.QImage.Format_ARGB32)
            qimage.fill(QtCore.Qt.white)
            painter = QtGui.QPainter(qimage)
            self.graphicsScene.render(painter)
            painter.end()
            qimage.save(file)
        else:
            QMessageBox.information(self, "Message",
                                    "4D Seismic Matrices not selected.")
Exemple #11
0
    def openFileNameDialog(self):
        options = QFileDialog.Options()
        options |= QFileDialog.DontUseNativeDialog
        fileName, _ = QFileDialog.getOpenFileName(
            self,
            "QFileDialog.getOpenFileName()",
            "",
            "All Files (*);;Python Files (*.py)",
            options=options)
        if fileName:
            print(fileName)

            self.cur_file = fileName
            self.selected_file.setText("The selected file is: " +
                                       self.cur_file)
            self.selected_file.adjustSize()

            return fileName
        else:
            return "Error"
Exemple #12
0
 def open_file(self):
     options = QFileDialog.Options()
     options |= QFileDialog.DontUseNativeDialog
     fileName, _ = QFileDialog.getOpenFileName(
         self,
         "QFileDialog.getOpenFileName()",
         "",
         "Graphviz Files (*.dot);;All Files (*)",
         options=options,
     )
     if fileName:
         self._open_file_name = fileName
         self._open_file = QFile(self._open_file_name)
         if not self._open_file.exists():
             QMessageBox.critical(
                 self, "Open SVG File",
                 "Could not open file '%s'." % self._open_file)
         else:
             self._do_timer = True
             self.flush()
Exemple #13
0
 def loadDataBase(self):
     options = QFileDialog.Options()
     options |= QFileDialog.DontUseNativeDialog
     fileName, _ = QFileDialog.getOpenFileName(self.clearMask(), "QFileDialog.getOpenFileName()", "",
                                               "Python Files (*.csv)", options=options)
     if fileName:
         self.pt_dbpath.setPlainText(fileName)
         print(fileName)
         self.predictor.db_file_name = fileName
         self.pt_dbpath.setDisabled(True)
         fileSize = os.path.getsize(fileName)
         if fileSize < 10000:
             QtWidgets.QMessageBox.information(self.clearMask(), "Data Error",
                                               "The data base is too small or empty.\nTry another one.")
         else:
             self.newFileFlag = True
     else:
         QtWidgets.QMessageBox.information(self.clearMask(), "Data Error",
                                     "No file selected. Please select a Data Base")
         return
Exemple #14
0
	def guardar_imagen(self):
		try:
			options = QFileDialog.Options()
			options |= QFileDialog.DontUseNativeDialog
			file_name, _ = QFileDialog.getSaveFileName(self, "QFileDialog.getSaveFileName()","",'Solo en PNG (*.png)', options=options)
			if file_name:
				
				pixmap = self.pixmap_fil

				# Save QPixmap to QByteArray via QBuffer.
				byte_array = QByteArray()
				buffer = QBuffer(byte_array)
				buffer.open(QBuffer.ReadWrite)
				pixmap.save(buffer, Path(file_name).suffix[1:])

				with open(file_name, 'wb') as out_file:
					out_file.write(byte_array)

		except Exception:
			print("Error de lectura/escritura de archivo.")
Exemple #15
0
 def on_btn_save_csv_released(self):
     """
     Slot documentation goes here.
     """
     options = QFileDialog.Options()
     options |= QFileDialog.DontUseNativeDialog
     filename, selectedFilter = QFileDialog.getSaveFileName(
         self,
         self.tr("Guardar CSV..."),
         "",
         self.tr("*.csv"),
         self.tr("*.csv"),
         options=options)
     # añadimos extension si
     if len(filename) > 0:
         if not filename.endswith(".csv"):
             filename = filename + ".csv"
         with open(filename, "w") as f:
             for index in range(self.list_export.count()):
                 f.write(self.list_export.item(index).text() + "\n")
    def selecionarImagen(self):
        global imagencv2
        global imagen
        imagen, extension = QFileDialog.getOpenFileName(
            self,
            "Seleccionar imagen",
            getcwd(),
            "Archivos de imagen (*.png *.jpg)",
            options=QFileDialog.Options())
        print(imagen)

        if imagen:
            # Adaptar imagen
            pixmapImagen = QPixmap(imagen).scaled(400, 1250,
                                                  Qt.KeepAspectRatio,
                                                  Qt.SmoothTransformation)

            # Mostrar imagen
            self.label.setPixmap(pixmapImagen)
            imagencv2 = cv2.imread(imagen, 0)
Exemple #17
0
    def upload(self):

        options = QFileDialog.Options()
        #options |= QFileDialog.DontUseNativeDialog
        fileName, _ = QFileDialog.getOpenFileName(
            self,
            "Seleccione Planilla de Datos",
            "",
            "Hoja de Cálculo (*.xlsx)",
            options=options)
        if fileName:
            dbp.processing(fileName)
            deltaOptions = [
                i / self.cant_puntos for i in range(self.cant_puntos)
            ]
            DataFrame = mss.correr(deltaOptions)
            self.x = DataFrame[0]
            self.y = DataFrame[1]
            self.deltaOptions = DataFrame[2]
            self.graficar()
Exemple #18
0
    def __init__(self, parent=None, closeAction=None):
        super(LensSetter, self).__init__(parent)

        options = QFileDialog.Options()
        options |= QFileDialog.DontUseNativeDialog

        #    Use importlib resourses path to get path to lens directory
        with path("poptics", "lenses") as p:  # New code
            dir = p
        dir = str(dir)

        fileName, _ = QFileDialog.getOpenFileName(self,"Lens Files",dir,\
                            "Lens Files (*.lens)", options=options)
        if fileName:
            setCurrentLens(fileName)  # Set the current lens.

        if closeAction != None:  # Do any specified action
            closeAction()

        self.close()  # Clase the frame
Exemple #19
0
    def LoadSpec(self):
        options = QFileDialog.Options()
        options |= QFileDialog.DontUseNativeDialog
        self.fileName, __ = QFileDialog.getOpenFileName(
            self, "Open Matrix File", "",
            "Matrix File (*.mat)")  #, options=options)
        if self.fileName:
            self.foldername = dirname(self.fileName)
            self.lineEditFileNum.setText('1')
            self.lineEditTotal.setText('1')
            self.Onefile.emit(self.fileName)

        else:
            msg = QMessageBox()
            msg.setIcon(QMessageBox.Critical)
            msg.setText('No file is loaded')
            msg.setInformativeText("Please select a file")
            msg.setWindowTitle("Warning")
            msg.setStandardButtons(QMessageBox.Ok)
            msg.exec_()
Exemple #20
0
    def load_file_ctr_model(self):
        options = QFileDialog.Options()
        options |= QFileDialog.DontUseNativeDialog
        fileName, _ = QFileDialog.getOpenFileName(
            self,
            "QFileDialog.getOpenFileName()",
            "",
            "Data Files (*.xlsx);;All Files (*.csv)",
            options=options)
        if fileName:
            self.lineEdit_data_file.setText(fileName)
            self.data = pd.read_excel(fileName)
        col_labels = 'col_labels\n' + str(list(self.data.columns)) + '\n'
        self.potentials = sorted(list(set(list(self.data['potential']))))
        self.hk_list = list(
            set(list(zip(list(self.data['H']), list(self.data['K'])))))

        self.textEdit_summary_data.setText('\n'.join(
            [col_labels, str(self.hk_list),
             str(self.potentials)]))
Exemple #21
0
    def openImage(self):
        #https://gist.github.com/acbetter/32c575803ec361c3e82064e60db4e3e0
        options = QFileDialog.Options()

        filename, _ = QFileDialog.getOpenFileName(self, 'Bild laden', '', 'Bilder (*.png *.jpg *.gif)', options=options)

        if filename:
            image = QImage(filename)
            if image.isNull():
                QMessageBox.information(self, "Image Viewer", "Cannot load %s." % filename)
                return

            #self.ui.imageLabel.setPixmap(QPixmap.fromImage(image).scaled(self.ui.imageLabel.maximumHeight(),self.ui.imageLabel.maximumWidth(), Qt.KeepAspectRatio))
            self.ui.imageLabel.setPixmap(QPixmap.fromImage(image))
            self.scaleFactor = 1.0
            self.ui.imageLabel.setScaledContents(True)
            self.ui.imageLabel.adjustSize()
            self.filename = filename
            self.image = image
            self.imagedata = self.convertToBinaryData(filename)
Exemple #22
0
    def export_adi(self):
        print("export_adi")
        options = QFileDialog.Options()
        options |= QFileDialog.DontUseNativeDialog
        file_name, _ = QFileDialog.getSaveFileName(self,
                                                   "Export adi",
                                                   "",
                                                   "Adi (*.adi)",
                                                   options=options)
        if file_name:
            print(file_name)
            copy_file = shutil.copyfile('log.adi', file_name + '.adi')

            if copy_file != '':
                print("Export complete")
                std.std.message(self,
                                "Export to\n" + copy_file + "\n completed",
                                "Export complited")
            else:
                std.std.message(self, "Can't export to file", "Sorry")
Exemple #23
0
    def openFileNamesDialog(self):

        #Abrir archivo
        options = QFileDialog.Options()
        options |= QFileDialog.DontUseNativeDialog
        files, _ = QFileDialog.getOpenFileNames(
            self,
            "QFileDialog.getOpenFileNames()",
            "",
            "All Files (*);;Python Files (*.py)",
            options=options)
        if files:
            print(files)
        self.imagePath = files[0]
        print(self.imagePath)
        pixmap = QPixmap(self.imagePath)
        #Escalar archivo
        pixmap2 = pixmap.scaled(421, 241)
        #Imprimir imagen en pantalla
        self.show_image.setPixmap(pixmap2)
Exemple #24
0
    def selectFile(self):
        '''
        Show file dialog to select AIB transactions file
        '''
        options = QFileDialog.Options()
        options |= QFileDialog.DontUseNativeDialog

        self.filePath, _ = QFileDialog.getOpenFileName(self._view,
                                                       "Транзакции за месяц",
                                                       r"d:\\",
                                                       " Files (*.csv *out)",
                                                       options=options)

        if self.filePath:
            # show selected file name
            fileName = Path(self.filePath).name
            self._view.labelSelectedFile.setStyleSheet("color: rgb(0, 255, 0)")
            self._view.labelSelectedFile.setText(fileName)

            self._view.buttonConvert.setEnabled(True)
Exemple #25
0
    def pdf_export(self):

        if not self.document.isEmpty():
            file1, _ = QFileDialog.getSaveFileName(self, "Exportar a PDF", "file",
                                                           "Archivos PDF (*.pdf);;All Files (*)",
                                                           options=QFileDialog.Options())

            if file1:
                
                impres = QPrinter(QPrinter.HighResolution)
                impres.setOutputFormat(QPrinter.PdfFormat)
                impres.setOutputFileName(file1)
                
                self.document.print_(impres)

                QMessageBox.information(self, "Finalizado", "Se exportó correctamente el archivo",
                                        QMessageBox.Ok)
        else:
            QMessageBox.critical(self, "Atención", "No hay datos en la tabla",
                                 QMessageBox.Ok)
Exemple #26
0
 def openFileNameDialog(self):
     options = QFileDialog.Options()
     #options |= QFileDialog.DontUseNativeDialog
     fileName, _ = QFileDialog.getOpenFileName(
         self,
         "QFileDialog.getOpenFileName()",
         r'C:\Users\Jimmy\Desktop\3D Printing research\Silcers\Slic3r\STL SAMPLES',
         "SVG Files (*.svg);;All Files (*)",
         options=options)
     if fileName:
         self.ui.textBrowser.append(
             '<span style="color:darkolivegreen;font-weight:bold">File Found</span>'
         )
         print(fileName)
         #return fileName
         self.model_layers = []
         self.image_converter.openfile(fileName)
         self.model_layers = self.image_converter.get_model_layers()
         self.ui.verticalSlider.setRange(0, len(self.model_layers) - 1)
         self.disp_layers(0)
Exemple #27
0
    def openFileNamesDialog(self):
        """
        Nombre: openFileNamesDialog
        Parametros: No recibe parametros.
        Descripción: muestra un DialogFile para abrir una Archivo o varios archivos.
        Retorno: Retorna la dirección de todos los archivos.
        """
        options = QFileDialog.Options()
        options |= QFileDialog.DontUseNativeDialog
        files, _ = QFileDialog.getOpenFileNames(
            self,
            "Abrir Archivo",
            "",
            "All Files (*);;Python Files (*.py)",
            options=options)
        if files:

            return ",".join(files)
        else:
            return False
Exemple #28
0
    def _doBrowse(self):
        """Browse for a folder path.
        """
        logger.verbose("GuiProjectLoad browse button clicked")
        dlgOpt = QFileDialog.Options()
        dlgOpt |= QFileDialog.DontUseNativeDialog
        projFile, _ = QFileDialog.getOpenFileName(
            self,
            "Open novelWriter Project",
            "",
            "novelWriter Project File (%s);;All Files (*)" % nwFiles.PROJ_FILE,
            options=dlgOpt)
        if projFile:
            thePath = os.path.abspath(os.path.dirname(projFile))
            self.selPath.setText(thePath)
            self.openPath = thePath
            self.openState = self.OPEN_STATE
            self.accept()

        return
 def select_file_location(self):
     """
     녹화하기 버튼을 눌렀을 때 저장할 파일 위치 선택하도록 하는 메소드
     """
     options = QFileDialog.Options() | QFileDialog.DontUseNativeDialog
     self.file_name = QFileDialog.getSaveFileName(None,
                                                  "저장될 파일 위치",
                                                  "",
                                                  "avi Files (*.avi)",
                                                  "",
                                                  options=options)[0]
     if not self.file_name:
         return False
     else:
         self.output_file_name = self.file_name + ".avi"
         self.screen_recorder.file_name = self.file_name + \
             "temp.avi"  # 녹음 파일(임시 파일)명 설정
         self.audio_recorder.file_name = self.file_name + \
             "temp.wav"  # 녹화 파일(임시 파일)명 설정
         return True
Exemple #30
0
    def open_files_dialog(self):
        options = QFileDialog.Options()
        options |= QFileDialog.Directory
        options |= QFileDialog.ShowDirsOnly
        self.selected_dir = QFileDialog.getExistingDirectory(self,
                                                             options=options)

        files = os.listdir(self.selected_dir)
        self.image_list = []
        for x in files:
            if x.endswith('jpg') or x.endswith('png'):
                self.image_list.append(x)

        if len(self.image_list) > 0:
            self.current_image_name = os.path.join(self.selected_dir,
                                                   self.image_list[0])
            self.image_viewer.loadImageFromFile(self.current_image_name)
            self.load_labels(self.current_image_name)
            self.current_image_index = 0
            self.enable_buttons()