如何保存更改

时间:2018-12-23 19:31:03

标签: python-3.x pyqt5

我要保存在.txt或csv中选择的路径...我该怎么做...?

我在Windows 10上使用PyQt5和python 3。 预先感谢您的提示或建议。 这是一段代码:

import sys
from PyQt5 import QtCore, QtGui, QtWidgets
from interfazPrueba import *

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
          MainWindow.setObjectName("MainWindow")
          MainWindow.resize(430, 317)
          self.btnVideo = QtWidgets.QPushButton(self.centralwidget)
          self.btnVideo.setObjectName("btnVideo")
          self.verticalLayout.addWidget(self.btnVideo)
          self.btnCargar = QtWidgets.QPushButton(self.centralwidget)
          self.btnCargar.setObjectName("btnCargar")
          self.verticalLayout.addWidget(self.btnCargar)

          self.btnVideo.clicked.connect(self.findVideo)

          self.btnCargar.clicked.connect(self.save_text)  
          self.retranslateUi(MainWindow)
          QtCore.QMetaObject.connectSlotsByName(MainWindow)


    def findVideo (self):
        fileName, _ = QtWidgets.QFileDialog.getOpenFileName(None, "Selecciona un video...", "","Archivo permitido(*.avi, *.mp4)" )
        self.lineEdit.setText(fileName)


    def save_text(self):
        with open('../TFG-Vehicles/NuevaForma/video/videosLargos/texto.txt', 'w') as f:
        my_text = self.text.toPlainText()
        f.write(my_text)

0 个答案:

没有答案