parent
b55277b638
commit
b0d7c22c9e
4
core.py
4
core.py
|
@ -1,6 +1,6 @@
|
||||||
import sys, io, os
|
import sys, io, os
|
||||||
from PyQt4 import QtCore, QtGui, uic
|
from PySide2 import QtCore, QtGui
|
||||||
from PyQt4.QtGui import QPainter, QColor
|
from PySide2.QtGui import QPainter, QColor
|
||||||
from os.path import expanduser
|
from os.path import expanduser
|
||||||
import subprocess as sp
|
import subprocess as sp
|
||||||
import numpy
|
import numpy
|
||||||
|
|
34
main.py
34
main.py
|
@ -1,6 +1,7 @@
|
||||||
import sys, io, os
|
import sys, io, os
|
||||||
from PyQt4 import QtCore, QtGui, uic
|
from PySide2 import QtCore, QtGui, QtWidgets
|
||||||
from PyQt4.QtGui import QPainter, QColor, QFont
|
from PySide2.QtGui import QPainter, QColor, QFont
|
||||||
|
from PySide2.QtUiTools import QUiLoader
|
||||||
from os.path import expanduser
|
from os.path import expanduser
|
||||||
import subprocess as sp
|
import subprocess as sp
|
||||||
import numpy
|
import numpy
|
||||||
|
@ -8,14 +9,14 @@ from PIL import Image, ImageDraw, ImageFont
|
||||||
from PIL.ImageQt import ImageQt
|
from PIL.ImageQt import ImageQt
|
||||||
import atexit
|
import atexit
|
||||||
from queue import Queue
|
from queue import Queue
|
||||||
from PyQt4.QtCore import QSettings
|
from PySide2.QtCore import QSettings, QFile
|
||||||
import signal
|
import signal
|
||||||
|
|
||||||
import preview_thread, core, video_thread
|
import preview_thread, core, video_thread
|
||||||
|
|
||||||
class Command(QtCore.QObject):
|
class Command(QtCore.QObject):
|
||||||
|
|
||||||
videoTask = QtCore.pyqtSignal(str, str, QFont, int, int, int, int, tuple, tuple, str, str)
|
videoTask = QtCore.Signal(str, str, QFont, int, int, int, int, tuple, tuple, str, str)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
QtCore.QObject.__init__(self)
|
QtCore.QObject.__init__(self)
|
||||||
|
@ -108,9 +109,9 @@ class Command(QtCore.QObject):
|
||||||
|
|
||||||
class Main(QtCore.QObject):
|
class Main(QtCore.QObject):
|
||||||
|
|
||||||
newTask = QtCore.pyqtSignal(str, str, QFont, int, int, int, int, tuple, tuple)
|
newTask = QtCore.Signal(str, str, QFont, int, int, int, int, tuple, tuple)
|
||||||
processTask = QtCore.pyqtSignal()
|
processTask = QtCore.Signal()
|
||||||
videoTask = QtCore.pyqtSignal(str, str, QFont, int, int, int, int, tuple, tuple, str, str)
|
videoTask = QtCore.Signal(str, str, QFont, int, int, int, int, tuple, tuple, str, str)
|
||||||
|
|
||||||
def __init__(self, window):
|
def __init__(self, window):
|
||||||
QtCore.QObject.__init__(self)
|
QtCore.QObject.__init__(self)
|
||||||
|
@ -221,7 +222,7 @@ class Main(QtCore.QObject):
|
||||||
def openInputFileDialog(self):
|
def openInputFileDialog(self):
|
||||||
inputDir = self.settings.value("inputDir", expanduser("~"))
|
inputDir = self.settings.value("inputDir", expanduser("~"))
|
||||||
|
|
||||||
fileName = QtGui.QFileDialog.getOpenFileName(self.window,
|
fileName, _ = QtWidgets.QFileDialog.getOpenFileName(self.window,
|
||||||
"Open Music File", inputDir, "Music Files (*.mp3 *.wav *.ogg *.flac)");
|
"Open Music File", inputDir, "Music Files (*.mp3 *.wav *.ogg *.flac)");
|
||||||
|
|
||||||
if not fileName == "":
|
if not fileName == "":
|
||||||
|
@ -231,7 +232,7 @@ class Main(QtCore.QObject):
|
||||||
def openOutputFileDialog(self):
|
def openOutputFileDialog(self):
|
||||||
outputDir = self.settings.value("outputDir", expanduser("~"))
|
outputDir = self.settings.value("outputDir", expanduser("~"))
|
||||||
|
|
||||||
fileName = QtGui.QFileDialog.getSaveFileName(self.window,
|
fileName, _ = QtWidgets.QFileDialog.getSaveFileName(self.window,
|
||||||
"Set Output Video File", outputDir, "Video Files (*.mkv)");
|
"Set Output Video File", outputDir, "Video Files (*.mkv)");
|
||||||
|
|
||||||
if not fileName == "":
|
if not fileName == "":
|
||||||
|
@ -241,7 +242,7 @@ class Main(QtCore.QObject):
|
||||||
def openBackgroundFileDialog(self):
|
def openBackgroundFileDialog(self):
|
||||||
backgroundDir = self.settings.value("backgroundDir", expanduser("~"))
|
backgroundDir = self.settings.value("backgroundDir", expanduser("~"))
|
||||||
|
|
||||||
fileName = QtGui.QFileDialog.getOpenFileName(self.window,
|
fileName, _ = QtWidgets.QFileDialog.getOpenFileName(self.window,
|
||||||
"Open Background Image", backgroundDir, "Image Files (*.jpg *.png);; Video Files (*.mp4)");
|
"Open Background Image", backgroundDir, "Image Files (*.jpg *.png);; Video Files (*.mp4)");
|
||||||
|
|
||||||
if not fileName == "":
|
if not fileName == "":
|
||||||
|
@ -303,7 +304,7 @@ class Main(QtCore.QObject):
|
||||||
self.window.label_preview.setPixmap(self._previewPixmap)
|
self.window.label_preview.setPixmap(self._previewPixmap)
|
||||||
|
|
||||||
def pickColor(self, colorTarget):
|
def pickColor(self, colorTarget):
|
||||||
color = QtGui.QColorDialog.getColor()
|
color = QtWidgets.QColorDialog.getColor()
|
||||||
if color.isValid():
|
if color.isValid():
|
||||||
RGBstring = '%s,%s,%s' % (str(color.red()), str(color.green()), str(color.blue()))
|
RGBstring = '%s,%s,%s' % (str(color.red()), str(color.green()), str(color.blue()))
|
||||||
btnStyle = "QPushButton { background-color : %s; outline: none; }" % color.name()
|
btnStyle = "QPushButton { background-color : %s; outline: none; }" % color.name()
|
||||||
|
@ -316,17 +317,20 @@ class Main(QtCore.QObject):
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
# command line mode
|
# command line mode
|
||||||
app = QtGui.QApplication(sys.argv, False)
|
app = QtWidgets.QApplication(sys.argv, False)
|
||||||
command = Command()
|
command = Command()
|
||||||
signal.signal(signal.SIGINT, command.cleanUp)
|
signal.signal(signal.SIGINT, command.cleanUp)
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
||||||
else:
|
else:
|
||||||
# gui mode
|
# gui mode
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app = QtGui.QApplication(sys.argv)
|
app = QtWidgets.QApplication(sys.argv)
|
||||||
window = uic.loadUi("main.ui")
|
file = QFile("main.ui")
|
||||||
|
file.open(QFile.ReadOnly)
|
||||||
|
loader = QUiLoader()
|
||||||
|
window = loader.load(file)
|
||||||
# window.adjustSize()
|
# window.adjustSize()
|
||||||
desc = QtGui.QDesktopWidget()
|
desc = QtWidgets.QDesktopWidget()
|
||||||
dpi = desc.physicalDpiX()
|
dpi = desc.physicalDpiX()
|
||||||
topMargin = 0 if (dpi == 96) else int(10 * (dpi / 96))
|
topMargin = 0 if (dpi == 96) else int(10 * (dpi / 96))
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from PyQt4 import QtCore, QtGui, uic
|
from PySide2 import QtCore, QtGui
|
||||||
from PyQt4.QtCore import pyqtSignal, pyqtSlot
|
from PySide2.QtCore import Signal, Slot
|
||||||
from PIL import Image, ImageDraw, ImageFont
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
from PIL.ImageQt import ImageQt
|
from PIL.ImageQt import ImageQt
|
||||||
import core
|
import core
|
||||||
|
@ -9,7 +9,7 @@ import numpy
|
||||||
|
|
||||||
class Worker(QtCore.QObject):
|
class Worker(QtCore.QObject):
|
||||||
|
|
||||||
imageCreated = pyqtSignal(['QImage'])
|
imageCreated = Signal(['QImage'])
|
||||||
|
|
||||||
def __init__(self, parent=None, queue=None):
|
def __init__(self, parent=None, queue=None):
|
||||||
QtCore.QObject.__init__(self)
|
QtCore.QObject.__init__(self)
|
||||||
|
@ -19,7 +19,7 @@ class Worker(QtCore.QObject):
|
||||||
self.queue = queue
|
self.queue = queue
|
||||||
|
|
||||||
|
|
||||||
@pyqtSlot(str, str, QtGui.QFont, int, int, int, int, tuple, tuple)
|
@Slot(str, str, QtGui.QFont, int, int, int, int, tuple, tuple)
|
||||||
def createPreviewImage(self, backgroundImage, titleText, titleFont, fontSize,\
|
def createPreviewImage(self, backgroundImage, titleText, titleFont, fontSize,\
|
||||||
alignment, xOffset, yOffset, textColor, visColor):
|
alignment, xOffset, yOffset, textColor, visColor):
|
||||||
# print('worker thread id: {}'.format(QtCore.QThread.currentThreadId()))
|
# print('worker thread id: {}'.format(QtCore.QThread.currentThreadId()))
|
||||||
|
@ -36,7 +36,7 @@ class Worker(QtCore.QObject):
|
||||||
}
|
}
|
||||||
self.queue.put(dic)
|
self.queue.put(dic)
|
||||||
|
|
||||||
@pyqtSlot()
|
@Slot()
|
||||||
def process(self):
|
def process(self):
|
||||||
try:
|
try:
|
||||||
nextPreviewInformation = self.queue.get(block=False)
|
nextPreviewInformation = self.queue.get(block=False)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from PyQt4 import QtCore, QtGui, uic
|
from PySide2 import QtCore, QtGui
|
||||||
from PyQt4.QtCore import pyqtSignal, pyqtSlot
|
from PySide2.QtCore import Signal, Slot
|
||||||
from PIL import Image, ImageDraw, ImageFont
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
from PIL.ImageQt import ImageQt
|
from PIL.ImageQt import ImageQt
|
||||||
import core
|
import core
|
||||||
|
@ -9,9 +9,9 @@ import sys
|
||||||
|
|
||||||
class Worker(QtCore.QObject):
|
class Worker(QtCore.QObject):
|
||||||
|
|
||||||
videoCreated = pyqtSignal()
|
videoCreated = Signal()
|
||||||
progressBarUpdate = pyqtSignal(int)
|
progressBarUpdate = Signal(int)
|
||||||
progressBarSetText = pyqtSignal(str)
|
progressBarSetText = Signal(str)
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
QtCore.QObject.__init__(self)
|
QtCore.QObject.__init__(self)
|
||||||
|
@ -19,7 +19,7 @@ class Worker(QtCore.QObject):
|
||||||
self.core = core.Core()
|
self.core = core.Core()
|
||||||
|
|
||||||
|
|
||||||
@pyqtSlot(str, str, QtGui.QFont, int, int, int, int, tuple, tuple, str, str)
|
@Slot(str, str, QtGui.QFont, int, int, int, int, tuple, tuple, str, str)
|
||||||
def createVideo(self, backgroundImage, titleText, titleFont, fontSize, alignment,\
|
def createVideo(self, backgroundImage, titleText, titleFont, fontSize, alignment,\
|
||||||
xOffset, yOffset, textColor, visColor, inputFile, outputFile):
|
xOffset, yOffset, textColor, visColor, inputFile, outputFile):
|
||||||
# print('worker thread id: {}'.format(QtCore.QThread.currentThreadId()))
|
# print('worker thread id: {}'.format(QtCore.QThread.currentThreadId()))
|
||||||
|
|
Reference in New Issue