Есть программа, которая по нажатию на кнопку создаёт .GIF
из .jpeg
изображений в заданную директорию.
Во время выполнения функции make_gif()
программа завивает до момента, пока не отработает функция.
Как убрать это зависание?
class Ui_Program(object):
def setupUi(self, Program):
Program.setObjectName("Program")
Program.resize(298, 99)
self.centralwidget = QtWidgets.QWidget(Program)
self.centralwidget.setObjectName("centralwidget")
self.filePath = QtWidgets.QLineEdit(self.centralwidget)
self.filePath.setGeometry(QtCore.QRect(10, 10, 281, 31))
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.filePath.setFont(font)
self.filePath.setStyleSheet("")
self.filePath.setText("")
self.filePath.setObjectName("filePath")
self.convert = QtWidgets.QPushButton(self.centralwidget)
self.convert.setGeometry(QtCore.QRect(30, 50, 241, 31))
font = QtGui.QFont()
font.setPointSize(14)
self.convert.setFont(font)
self.convert.setStyleSheet("QPushButton {\n"
" border-style: outset;\n"
" border: 1px solid gray;\n"
" border-width: 1px;\n"
" border-radius: 10px;\n"
" background-color: rgb(227, 227, 227);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color: rgb(203, 203, 203);\n"
"}\n"
"")
self.convert.setObjectName("btn")
self.statusLabel = QtWidgets.QLabel(self.centralwidget)
self.statusLabel.setGeometry(QtCore.QRect(10, 130, 241, 31))
font = QtGui.QFont()
font.setPointSize(14)
self.statusLabel.setFont(font)
self.statusLabel.setText("")
self.statusLabel.setObjectName("statusLabel")
Program.setCentralWidget(self.centralwidget)
self.retranslateUi(Program)
QtCore.QMetaObject.connectSlotsByName(Program)
def retranslateUi(self, Program):
_translate = QtCore.QCoreApplication.translate
Program.setWindowTitle(_translate("Program", "MainWindow"))
self.convert.setText(_translate("Program", "CONVERT"))
class MainWindow(QMainWindow, Ui_Program):
def __init__(self):
super(MainWindow, self).__init__()
self.ui = Ui_Program()
self.ui.setupUi(self)
self.ui.convert.clicked.connect(lambda: self.make_gif(self.filePath.text()))
def make_gif(self, file_path):
images = glob.glob(f"frames/*.jpg")
images.sort()
frames = [Image.open(image) for image in images]
frame_one = frames[0]
frame_one.save(f"{file_path}/example.gif", format="GIF", append_images=frames, save_all=True, duration=40, loop=0)
if __name__ == '__main__':
app = QApplication([])
window = MainWindow()
window.show()
app.exec_()