0

I want to save the path that I choose in a .txt or csv... How Can I do it this...?

I am using PyQt5 and python 3 on windows 10. Thank you in advance for tips or advice. This is a piece of code:

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)
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Lewis
  • 466
  • 5
  • 16
  • 1
    1) change `self.lineEdit.setText(fileName)` to `self._filename = fileName` – eyllanesc Dec 23 '18 at 19:34
  • 1
    2) change `my_text = self.text.toPlainText()` to `my_text = self._filename` – eyllanesc Dec 23 '18 at 19:35
  • please use English because it is the language of the site. On the other hand I told you to remove it because I do not see where you have defined the lineEdit, I assume that you have only shown part of your code, so instead of using what I indicated in my first comments, it only changes: `my_text = self.lineEdit.text()` – eyllanesc Dec 23 '18 at 19:55
  • I cant speak... i dont have reputation? please write me to luis.salgado.lsm@gmail.com and I send you a few questions about PyQt5 that I cant solve... :( thank you dude... – Lewis Dec 23 '18 at 20:10
  • I only use the email for jobs, not for discussions for it, there is the chat room: https://chat.stackexchange.com/rooms/87435/pyqt – eyllanesc Dec 23 '18 at 20:12

0 Answers0