combined toolkit.py & frame.py into toolkit package
This commit is contained in:
parent
aa464632c6
commit
b1713d38fa
|
@ -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
|
||||
------------
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# Allows for launching with python3 -m avpython
|
||||
|
||||
from avpython.main import main
|
||||
|
||||
main()
|
||||
main()
|
||||
|
|
|
@ -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))
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
from toolkit.common import *
|
|
@ -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
|
|
@ -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):
|
||||
|
|
Reference in New Issue