fixing bugs
This commit is contained in:
parent
4d955c5a06
commit
e32ba958cb
|
@ -1,4 +1,4 @@
|
|||
from PyQt5 import QtGui, QtCore, QtWidgets
|
||||
from PyQt5 import uic, QtGui, QtCore, QtWidgets
|
||||
from PIL import Image
|
||||
import os
|
||||
|
||||
|
@ -114,6 +114,9 @@ class Component(QtCore.QObject):
|
|||
except:
|
||||
return (255, 255, 255)
|
||||
|
||||
def loadUi(self, filename):
|
||||
return uic.loadUi(os.path.join(self.core.componentsPath, filename))
|
||||
|
||||
'''
|
||||
### Reference methods for creating a new component
|
||||
### (Inherit from this class and define these)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from PIL import Image, ImageDraw
|
||||
from PyQt5 import uic, QtGui, QtCore, QtWidgets
|
||||
from PyQt5 import QtGui, QtCore, QtWidgets
|
||||
from PyQt5.QtGui import QColor
|
||||
from PIL.ImageQt import ImageQt
|
||||
import os
|
||||
|
@ -13,8 +13,7 @@ class Component(__base__.Component):
|
|||
|
||||
def widget(self, parent):
|
||||
self.parent = parent
|
||||
page = uic.loadUi(os.path.join(
|
||||
os.path.dirname(os.path.realpath(__file__)), 'color.ui'))
|
||||
page = self.loadUi('color.ui')
|
||||
|
||||
self.color1 = (0, 0, 0)
|
||||
self.color2 = (133, 133, 133)
|
||||
|
@ -177,7 +176,7 @@ class Component(__base__.Component):
|
|||
self.sizeWidth, self.sizeHeight
|
||||
)
|
||||
painter.end()
|
||||
imBytes = image.bits().asstring(image.numBytes())
|
||||
imBytes = image.bits().asstring(image.byteCount())
|
||||
return Image.frombytes('RGBA', (width, height), imBytes)
|
||||
|
||||
def loadPreset(self, pr, presetName=None):
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from PIL import Image, ImageDraw
|
||||
from PyQt5 import uic, QtGui, QtCore, QtWidgets
|
||||
from PyQt5 import QtGui, QtCore, QtWidgets
|
||||
import os
|
||||
from . import __base__
|
||||
|
||||
|
@ -12,8 +12,7 @@ class Component(__base__.Component):
|
|||
def widget(self, parent):
|
||||
self.parent = parent
|
||||
self.settings = parent.settings
|
||||
page = uic.loadUi(os.path.join(
|
||||
os.path.dirname(os.path.realpath(__file__)), 'image.ui'))
|
||||
page = self.loadUi('image.ui')
|
||||
self.imagePath = ''
|
||||
self.x = 0
|
||||
self.y = 0
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import numpy
|
||||
from PIL import Image, ImageDraw
|
||||
from PyQt5 import uic, QtGui, QtCore, QtWidgets
|
||||
from PyQt5 import QtGui, QtCore, QtWidgets
|
||||
from PyQt5.QtGui import QColor
|
||||
import os
|
||||
from . import __base__
|
||||
|
@ -17,8 +17,7 @@ class Component(__base__.Component):
|
|||
self.parent = parent
|
||||
self.visColor = (255, 255, 255)
|
||||
|
||||
page = uic.loadUi(os.path.join(
|
||||
os.path.dirname(os.path.realpath(__file__)), 'original.ui'))
|
||||
page = self.loadUi('original.ui')
|
||||
page.comboBox_visLayout.addItem("Classic")
|
||||
page.comboBox_visLayout.addItem("Split")
|
||||
page.comboBox_visLayout.addItem("Bottom")
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from PIL import Image, ImageDraw
|
||||
from PyQt5.QtGui import QPainter, QColor, QFont
|
||||
from PyQt5 import uic, QtGui, QtCore, QtWidgets
|
||||
from PyQt5 import QtGui, QtCore, QtWidgets
|
||||
from PIL.ImageQt import ImageQt
|
||||
import os
|
||||
import io
|
||||
|
@ -29,8 +29,7 @@ class Component(__base__.Component):
|
|||
self.xPosition = width / 2 - fm.width(self.title)/2
|
||||
self.yPosition = height / 2 * 1.036
|
||||
|
||||
page = uic.loadUi(os.path.join(
|
||||
os.path.dirname(os.path.realpath(__file__)), 'text.ui'))
|
||||
page = self.loadUi('text.ui')
|
||||
page.comboBox_textAlign.addItem("Left")
|
||||
page.comboBox_textAlign.addItem("Middle")
|
||||
page.comboBox_textAlign.addItem("Right")
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from PIL import Image, ImageDraw
|
||||
from PyQt5 import uic, QtGui, QtCore, QtWidgets
|
||||
from PyQt5 import QtGui, QtCore, QtWidgets
|
||||
import os
|
||||
import math
|
||||
import subprocess
|
||||
import threading
|
||||
from queue import PriorityQueue
|
||||
|
@ -79,9 +80,18 @@ class Video:
|
|||
self.frameNo += 1
|
||||
|
||||
# If we run out of frames, use the last good frame and loop.
|
||||
if len(self.currentFrame) == 0:
|
||||
self.frameBuffer.put((self.frameNo-1, self.lastFrame))
|
||||
continue
|
||||
try:
|
||||
if len(self.currentFrame) == 0:
|
||||
self.frameBuffer.put((self.frameNo-1, self.lastFrame))
|
||||
continue
|
||||
except AttributeError as e:
|
||||
self.parent.showMessage(
|
||||
msg='%s couldn\'t be loaded.' % os.path.basename(
|
||||
self.videoPath
|
||||
),
|
||||
detail=str(e)
|
||||
)
|
||||
self.parent.stopVideo()
|
||||
|
||||
self.currentFrame = pipe.stdout.read(self.chunkSize)
|
||||
if len(self.currentFrame) != 0:
|
||||
|
@ -97,10 +107,7 @@ class Component(__base__.Component):
|
|||
def widget(self, parent):
|
||||
self.parent = parent
|
||||
self.settings = parent.settings
|
||||
page = uic.loadUi(os.path.join(
|
||||
os.path.dirname(os.path.realpath(__file__)),
|
||||
'video.ui'
|
||||
))
|
||||
page = self.loadUi('video.ui')
|
||||
self.videoPath = ''
|
||||
self.x = 0
|
||||
self.y = 0
|
||||
|
@ -243,9 +250,9 @@ def scale(scale, width, height, returntype=None):
|
|||
width = (float(width) / 100.0) * float(scale)
|
||||
height = (float(height) / 100.0) * float(scale)
|
||||
if returntype == str:
|
||||
return (str(int(width)), str(int(height)))
|
||||
return (str(math.ceil(width)), str(math.ceil(height)))
|
||||
elif returntype == int:
|
||||
return (int(width), int(height))
|
||||
return (math.ceil(width), math.ceil(height))
|
||||
else:
|
||||
return (width, height)
|
||||
|
||||
|
|
21
src/core.py
21
src/core.py
|
@ -29,6 +29,7 @@ class Core():
|
|||
else:
|
||||
# unfrozen
|
||||
self.wd = os.path.dirname(os.path.realpath(__file__))
|
||||
self.componentsPath = os.path.join(self.wd, 'components')
|
||||
|
||||
self.loadEncoderOptions()
|
||||
self.videoFormats = Core.appendUppercase([
|
||||
|
@ -66,14 +67,12 @@ class Core():
|
|||
|
||||
def findComponents(self):
|
||||
def findComponents():
|
||||
srcPath = os.path.join(self.wd, 'components')
|
||||
if os.path.exists(srcPath):
|
||||
for f in sorted(os.listdir(srcPath)):
|
||||
name, ext = os.path.splitext(f)
|
||||
if name.startswith("__"):
|
||||
continue
|
||||
elif ext == '.py':
|
||||
yield name
|
||||
for f in sorted(os.listdir(self.componentsPath)):
|
||||
name, ext = os.path.splitext(f)
|
||||
if name.startswith("__"):
|
||||
continue
|
||||
elif ext == '.py':
|
||||
yield name
|
||||
self.modules = [
|
||||
import_module('components.%s' % name)
|
||||
for name in findComponents()
|
||||
|
@ -93,10 +92,12 @@ class Core():
|
|||
return None
|
||||
|
||||
component = self.modules[moduleIndex].Component(
|
||||
moduleIndex, compPos, self)
|
||||
moduleIndex, compPos, self
|
||||
)
|
||||
self.selectedComponents.insert(
|
||||
compPos,
|
||||
component)
|
||||
component
|
||||
)
|
||||
self.componentListChanged()
|
||||
|
||||
# init component's widget for loading/saving presets
|
||||
|
|
|
@ -123,7 +123,8 @@ class PresetManager(QtWidgets.QDialog):
|
|||
def clearPreset(self, compI=None):
|
||||
'''Functions on mainwindow level from the context menu'''
|
||||
compI = self.parent.window.listWidget_componentList.currentRow()
|
||||
self.core.clearPreset(compI, self.parent)
|
||||
self.core.clearPreset(compI)
|
||||
self.parent.updateComponentTitle(compI, False)
|
||||
|
||||
def openSavePresetDialog(self):
|
||||
'''Functions on mainwindow level from the context menu'''
|
||||
|
|
|
@ -49,8 +49,19 @@ class Worker(QtCore.QObject):
|
|||
|
||||
components = nextPreviewInformation["components"]
|
||||
for component in reversed(components):
|
||||
frame = Image.alpha_composite(
|
||||
frame, component.previewRender(self))
|
||||
try:
|
||||
newFrame = component.previewRender(self)
|
||||
frame = Image.alpha_composite(
|
||||
frame, newFrame)
|
||||
except ValueError:
|
||||
self.parent.showMessage(
|
||||
msg="Bad frame returned by %s's previewRender method. "
|
||||
"This is a fatal error." %
|
||||
str(component),
|
||||
detail="bad frame: w%s, h%s" % (
|
||||
newFrame.width, newFrame.height)
|
||||
)
|
||||
quit(1)
|
||||
|
||||
self._image = ImageQt(frame)
|
||||
self.imageCreated.emit(QtGui.QImage(self._image))
|
||||
|
|
Reference in New Issue