diff --git a/README.md b/README.md index 9149b4f..5f4e1e7 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Dependencies ------------ Python 3.4, FFmpeg 3.3, PyQt5, Pillow-SIMD, NumPy -**Note:** Pillow may be used as a drop-in replacement for Pillow-SIMD if problems are encountered installing. However this will result in much slower video export times. For help troubleshooting installation problems, the * For any problems with installing Pillow-SIMD, see the [Pillow installation guide](http://pillow.readthedocs.io/en/3.1.x/installation.html). +**Note:** Pillow may be used as a drop-in replacement for Pillow-SIMD if problems are encountered installing. However this will result in much slower video export times. For help installing Pillow-SIMD, see the [Pillow installation guide](http://pillow.readthedocs.io/en/3.1.x/installation.html). Installation ------------ diff --git a/src/__main__.py b/src/__main__.py index a68739e..3babeae 100644 --- a/src/__main__.py +++ b/src/__main__.py @@ -1,3 +1,5 @@ +# Allows for launching with python3 -m avpython + from avpython.main import main -main() \ No newline at end of file +main() diff --git a/src/component.py b/src/component.py index adb170e..7842bd6 100644 --- a/src/component.py +++ b/src/component.py @@ -112,37 +112,6 @@ class Component(QtCore.QObject): def commandHelp(self): '''Print help text for this Component's commandline arguments''' - def pickColor(self): - ''' - Use color picker to get color input from the user, - and return this as an RGB string and QPushButton stylesheet. - In a subclass apply stylesheet to any color selection widgets - ''' - dialog = QtWidgets.QColorDialog() - dialog.setOption(QtWidgets.QColorDialog.ShowAlphaChannel, True) - color = dialog.getColor() - if color.isValid(): - RGBstring = '%s,%s,%s' % ( - str(color.red()), str(color.green()), str(color.blue())) - btnStyle = "QPushButton{background-color: %s; outline: none;}" \ - % color.name() - return RGBstring, btnStyle - else: - return None, None - - def RGBFromString(self, string): - '''Turns an RGB string like "255, 255, 255" into a tuple''' - try: - tup = tuple([int(i) for i in string.split(',')]) - if len(tup) != 3: - raise ValueError - for i in tup: - if i > 255 or i < 0: - raise ValueError - return tup - except: - return (255, 255, 255) - def loadUi(self, filename): return uic.loadUi(os.path.join(self.core.componentsPath, filename)) diff --git a/src/components/color.py b/src/components/color.py index ef4dd95..8d2526d 100644 --- a/src/components/color.py +++ b/src/components/color.py @@ -5,7 +5,8 @@ from PIL.ImageQt import ImageQt import os from component import Component -from frame import BlankFrame, FloodFrame, FramePainter, PaintColor +from toolkit.frame import BlankFrame, FloodFrame, FramePainter, PaintColor +from toolkit import rgbFromString, pickColor class Component(Component): @@ -76,8 +77,8 @@ class Component(Component): return page def update(self): - self.color1 = self.RGBFromString(self.page.lineEdit_color1.text()) - self.color2 = self.RGBFromString(self.page.lineEdit_color2.text()) + self.color1 = rgbFromString(self.page.lineEdit_color1.text()) + self.color2 = rgbFromString(self.page.lineEdit_color2.text()) self.x = self.page.spinBox_x.value() self.y = self.page.spinBox_y.value() self.sizeWidth = self.page.spinBox_width.value() @@ -229,7 +230,7 @@ class Component(Component): } def pickColor(self, num): - RGBstring, btnStyle = super().pickColor() + RGBstring, btnStyle = pickColor() if not RGBstring: return if num == 1: diff --git a/src/components/image.py b/src/components/image.py index c0d1c0d..7f3f610 100644 --- a/src/components/image.py +++ b/src/components/image.py @@ -3,7 +3,7 @@ from PyQt5 import QtGui, QtCore, QtWidgets import os from component import Component -from frame import BlankFrame +from toolkit.frame import BlankFrame class Component(Component): diff --git a/src/components/original.py b/src/components/original.py index f5776a4..586204a 100644 --- a/src/components/original.py +++ b/src/components/original.py @@ -7,7 +7,8 @@ import time from copy import copy from component import Component -from frame import BlankFrame +from toolkit.frame import BlankFrame +from toolkit import rgbFromString, pickColor class Component(Component): @@ -48,7 +49,7 @@ class Component(Component): def update(self): self.layout = self.page.comboBox_visLayout.currentIndex() - self.visColor = self.RGBFromString(self.page.lineEdit_visColor.text()) + self.visColor = rgbFromString(self.page.lineEdit_visColor.text()) self.scale = self.page.spinBox_scale.value() self.y = self.page.spinBox_y.value() @@ -116,7 +117,7 @@ class Component(Component): self.visColor, self.layout) def pickColor(self): - RGBstring, btnStyle = super().pickColor() + RGBstring, btnStyle = pickColor() if not RGBstring: return self.page.lineEdit_visColor.setText(RGBstring) diff --git a/src/components/sound.py b/src/components/sound.py index bd7d002..5b06405 100644 --- a/src/components/sound.py +++ b/src/components/sound.py @@ -2,7 +2,7 @@ from PyQt5 import QtGui, QtCore, QtWidgets import os from component import Component -from frame import BlankFrame +from toolkit.frame import BlankFrame class Component(Component): diff --git a/src/components/text.py b/src/components/text.py index 19460e5..fc3ef5f 100644 --- a/src/components/text.py +++ b/src/components/text.py @@ -4,7 +4,8 @@ from PyQt5 import QtGui, QtCore, QtWidgets import os from component import Component -from frame import FramePainter +from toolkit.frame import FramePainter +from toolkit import rgbFromString, pickColor class Component(Component): @@ -64,7 +65,7 @@ class Component(Component): self.fontSize = self.page.spinBox_fontSize.value() self.xPosition = self.page.spinBox_xTextAlign.value() self.yPosition = self.page.spinBox_yTextAlign.value() - self.textColor = self.RGBFromString( + self.textColor = rgbFromString( self.page.lineEdit_textColor.text()) btnStyle = "QPushButton { background-color : %s; outline: none; }" \ % QColor(*self.textColor).name() @@ -146,7 +147,7 @@ class Component(Component): return image.finalize() def pickColor(self): - RGBstring, btnStyle = super().pickColor() + RGBstring, btnStyle = pickColor() if not RGBstring: return self.page.lineEdit_textColor.setText(RGBstring) diff --git a/src/components/video.py b/src/components/video.py index 9e3db30..a9f334e 100644 --- a/src/components/video.py +++ b/src/components/video.py @@ -7,7 +7,7 @@ import threading from queue import PriorityQueue from component import Component, BadComponentInit -from frame import BlankFrame +from toolkit.frame import BlankFrame from toolkit import openPipe, checkOutput diff --git a/src/core.py b/src/core.py index a0a028b..07c1f71 100644 --- a/src/core.py +++ b/src/core.py @@ -11,7 +11,7 @@ from importlib import import_module from PyQt5.QtCore import QStandardPaths import toolkit -from frame import Frame +from toolkit.frame import Frame import video_thread diff --git a/src/preview_thread.py b/src/preview_thread.py index 6c33aff..c28e048 100644 --- a/src/preview_thread.py +++ b/src/preview_thread.py @@ -9,7 +9,7 @@ from PIL.ImageQt import ImageQt from queue import Queue, Empty import os -from frame import Checkerboard +from toolkit.frame import Checkerboard class Worker(QtCore.QObject): diff --git a/src/toolkit/__init__.py b/src/toolkit/__init__.py new file mode 100644 index 0000000..3fca275 --- /dev/null +++ b/src/toolkit/__init__.py @@ -0,0 +1 @@ +from toolkit.common import * diff --git a/src/toolkit.py b/src/toolkit/common.py similarity index 71% rename from src/toolkit.py rename to src/toolkit/common.py index 5493f37..e3a1649 100644 --- a/src/toolkit.py +++ b/src/toolkit/common.py @@ -1,6 +1,7 @@ ''' Common functions ''' +from PyQt5 import QtWidgets import string import os import sys @@ -69,6 +70,39 @@ def disableWhenEncoding(func): return decorator +def pickColor(): + ''' + Use color picker to get color input from the user, + and return this as an RGB string and QPushButton stylesheet. + In a subclass apply stylesheet to any color selection widgets + ''' + dialog = QtWidgets.QColorDialog() + dialog.setOption(QtWidgets.QColorDialog.ShowAlphaChannel, True) + color = dialog.getColor() + if color.isValid(): + RGBstring = '%s,%s,%s' % ( + str(color.red()), str(color.green()), str(color.blue())) + btnStyle = "QPushButton{background-color: %s; outline: none;}" \ + % color.name() + return RGBstring, btnStyle + else: + return None, None + + +def rgbFromString(string): + '''Turns an RGB string like "255, 255, 255" into a tuple''' + try: + tup = tuple([int(i) for i in string.split(',')]) + if len(tup) != 3: + raise ValueError + for i in tup: + if i > 255 or i < 0: + raise ValueError + return tup + except: + return (255, 255, 255) + + def LoadDefaultSettings(self): ''' Runs once at each program start-up. Fills in default settings for any settings not found in settings.ini diff --git a/src/frame.py b/src/toolkit/frame.py similarity index 100% rename from src/frame.py rename to src/toolkit/frame.py diff --git a/src/video_thread.py b/src/video_thread.py index 60db99f..1f2eaf5 100644 --- a/src/video_thread.py +++ b/src/video_thread.py @@ -19,7 +19,7 @@ import time import signal from toolkit import openPipe -from frame import Checkerboard +from toolkit.frame import Checkerboard class Worker(QtCore.QObject):