Reputation: 1
I want to show "Converting..." but it is not shown.
However, "Converted" is shown.
I tried to change the location of the "Converting..." and so on but it is not working..
I can't find the reference to fix this problem. TT
My code is as below.
Thank you!
Hi! I want to show "Converting..." but it is not shown.
However, "Converted" is shown.
I tried to change the location of the "Converting..." and so on but it is not working..
I can't find the reference to fix this problem. TT
My code is as below.
Thank you!
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import QIcon
from moviepy.editor import *
import argparse
class MyApp(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.setWindowTitle('Video2GIF')
# self.setWindowIcon(QIcon('./assets/logo.png'))
self.setGeometry(300, 300, 300, 200)
self.pushButton = QPushButton('Open File')
self.pushButton.clicked.connect(self.pushButtonClicked)
self.label = QLabel()
layout = QVBoxLayout()
layout.addWidget(self.pushButton)
layout.addWidget(self.label)
self.setLayout(layout)
def pushButtonClicked(self):
self.fileName = QFileDialog.getOpenFileName(
self, "open file", "./", "mp4 file(*.mp4) ;; avi file(*.avi)")
if self.fileName[0]:
self.label.setText("Converting...")
inputName = self.fileName[0]
outputName = inputName[:-4] + '.gif'
print(inputName)
print(outputName)
videoClip = VideoFileClip(inputName)
videoClip.write_gif(outputName)
# self.label.setText(" ")
self.label.setText("Converted!")
else:
self.label.setText("No file selected")
# def convert(self):
# inputName = self.fileName[0]
# outputName = inputName[:-4] + '.gif'
# print(inputName)
# print(outputName)
# videoClip = VideoFileClip(inputName)
# videoClip.write_gif(outputName)
# self.label.setText(" ")
# self.convertedLabel.setText("Converted!")
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = MyApp()
# print(str(ex.label.isVisible()))
ex.show()
sys.exit(app.exec_())
Upvotes: 0
Views: 38
Reputation: 61
import this widget
from PyQt5.QtWidgets import QApplication
then modify your function like this:
def pushButtonClicked(self):
self.fileName = QFileDialog.getOpenFileName(
self, "open file", "./", "mp4 file(*.mp4) ;; avi file(*.avi)")
if self.fileName[0]:
self.label.setText("Converting...")
QApplication.processEvents()
QApplication.processEvents()
inputName = self.fileName[0]
outputName = inputName[:-4] + '.gif'
print(inputName)
print(outputName)
videoClip = VideoFileClip(inputName)
videoClip.write_gif(outputName)
# self.label.setText(" ")
self.label.setText("Converted!")
else:
self.label.setText("No file selected")
Upvotes: 2