我是QT的新手,我很难使用返回视频路径字符串的函数。此功能由Qt设计器生成的GUI按钮连接。当我尝试时,变量显示
<PyQt5.QtCore.QMetaObject.Connection object at 0x00000190D9F017B8>
这是我的代码。
import definition as df
from PyQt5 import uic, QtCore, QtGui, QtWidgets
import tkinter as tk
from tkinter import filedialog
import resources
root = tk.Tk()
root.withdraw()
def add_video():
source_video = filedialog.askopenfilename(title="Select file",
filetypes=(("MP4 File",
"*.mp4"), ("All Files", "*.*")))
dlg.txt_inputPath.setText(source_video)
dlg.txt_outputPath.setText(source_video[:-3]+"avi")
return source_video
def output():
outfile = filedialog.asksaveasfilename(title="file Name",
filetypes=("AVI File", "*.avi"))
dlg.txt_outputPath.setText(outfile)
def save_next():
print("here")
dlg.stackedWidget.setCurrentIndex(1)
extracted_audio = df.extract_audio(video)
text = df.audio_to_text(extracted_audio)
word_token = df.tokenize(text)
df.merge_video(video, word_token)
app = QtWidgets.QApplication([])
dlg = uic.loadUi("UI/mainwindow.ui")
video = dlg.btn_addvideo.clicked.connect(add_video)
dlg.btn_output.clicked.connect(output)
print(video)
dlg.btn_next.clicked.connect(save_next)
dlg.show()
app.exec()