From 680214f5180a12f2250d8e266df9375ce99b9f80 Mon Sep 17 00:00:00 2001 From: tassaron Date: Fri, 23 Jun 2017 23:00:24 -0400 Subject: qt5 fixes also pep8 compliance --- src/components/__base__.py | 14 +++++++------- src/components/color.py | 15 +++++++++------ src/components/image.py | 2 +- src/components/video.py | 14 ++++++++------ 4 files changed, 25 insertions(+), 20 deletions(-) (limited to 'src/components') diff --git a/src/components/__base__.py b/src/components/__base__.py index a4677b1..a24af40 100644 --- a/src/components/__base__.py +++ b/src/components/__base__.py @@ -39,7 +39,7 @@ class Component(QtCore.QObject): then update self.page widgets using the preset dict. ''' self.currentPreset = presetName \ - if presetName != None else presetDict['preset'] + if presetName is not None else presetDict['preset'] def preFrameRender(self, **kwargs): '''Triggered only before a video is exported (video_thread.py) @@ -66,8 +66,8 @@ class Component(QtCore.QObject): print('Couldn\'t locate preset "%s"' % preset) quit(1) else: - print('Opening "%s" preset on layer %s' % \ - (preset, self.compPos)) + print('Opening "%s" preset on layer %s' % ( + preset, self.compPos)) self.core.openPreset(path, self.compPos, preset) else: print( @@ -88,8 +88,8 @@ class Component(QtCore.QObject): and return this as an RGB string and QPushButton stylesheet. In a subclass apply stylesheet to any color selection widgets ''' - dialog = QtGui.QColorDialog() - dialog.setOption(QtGui.QColorDialog.ShowAlphaChannel, True) + dialog = QtWidgets.QColorDialog() + dialog.setOption(QtWidgets.QColorDialog.ShowAlphaChannel, True) color = dialog.getColor() if color.isValid(): RGBstring = '%s,%s,%s' % ( @@ -142,10 +142,10 @@ class Component(QtCore.QObject): return image ''' + class BadComponentInit(Exception): def __init__(self, arg, name): - string = \ -'''################################ + string = '''################################ Mandatory argument "%s" not specified in %s instance initialization ###################################''' diff --git a/src/components/color.py b/src/components/color.py index 8f9a1d1..2e3902a 100644 --- a/src/components/color.py +++ b/src/components/color.py @@ -53,7 +53,7 @@ class Component(__base__.Component): page.spinBox_height.valueChanged.connect(self.update) page.checkBox_trans.stateChanged.connect(self.update) - self.fillLabels = [ \ + self.fillLabels = [ 'Solid', 'Linear Gradient', 'Radial Gradient', @@ -126,8 +126,8 @@ class Component(__base__.Component): r, g, b = self.color1 shapeSize = (self.sizeWidth, self.sizeHeight) # in default state, skip all this logic and return a plain fill - if self.fillType==0 and shapeSize == (width, height) \ - and self.x == 0 and self.y == 0: + if self.fillType == 0 and shapeSize == (width, height) \ + and self.x == 0 and self.y == 0: return Image.new("RGBA", (width, height), (r, g, b, 255)) frame = self.blankFrame(width, height) @@ -143,9 +143,11 @@ class Component(__base__.Component): image = ImageQt(frame) painter = QtGui.QPainter(image) if self.stretch: - w = width; h = height + w = width + h = height else: - w = self.sizeWidth; h = self.sizeWidth + w = self.sizeWidth + h = self.sizeWidth if self.fillType == 1: # Linear Gradient brush = QtGui.QLinearGradient( @@ -170,7 +172,8 @@ class Component(__base__.Component): else: brush.setColorAt(1.0, QColor(*self.color2)) painter.setBrush(brush) - painter.drawRect(self.x, self.y, + painter.drawRect( + self.x, self.y, self.sizeWidth, self.sizeHeight) painter.end() imBytes = image.bits().asstring(image.numBytes()) diff --git a/src/components/image.py b/src/components/image.py index 8ca88d3..3517af6 100644 --- a/src/components/image.py +++ b/src/components/image.py @@ -85,7 +85,7 @@ class Component(__base__.Component): def pickImage(self): imgDir = self.settings.value("backgroundDir", os.path.expanduser("~")) - filename = QtGui.QFileDialog.getOpenFileName( + filename, _ = QtWidgets.QFileDialog.getOpenFileName( self.page, "Choose Image", imgDir, "Image Files (%s)" % " ".join(self.imageFormats)) if filename: diff --git a/src/components/video.py b/src/components/video.py index 58ce7a3..0090426 100644 --- a/src/components/video.py +++ b/src/components/video.py @@ -41,8 +41,8 @@ class Video: '-i', self.videoPath, '-f', 'image2pipe', '-pix_fmt', 'rgba', - '-filter:v', 'scale=%s:%s' % - scale(self.scale, self.width, self.height, str), + '-filter:v', 'scale=%s:%s' % scale( + self.scale, self.width, self.height, str), '-vcodec', 'rawvideo', '-', ] @@ -180,7 +180,7 @@ class Component(__base__.Component): def pickVideo(self): imgDir = self.settings.value("backgroundDir", os.path.expanduser("~")) - filename = QtGui.QFileDialog.getOpenFileName( + filename, _ = QtWidgets.QFileDialog.getOpenFileName( self.page, "Choose Video", imgDir, "Video Files (%s)" % " ".join(self.videoFormats) ) @@ -199,8 +199,8 @@ class Component(__base__.Component): '-i', self.videoPath, '-f', 'image2pipe', '-pix_fmt', 'rgba', - '-filter:v', 'scale=%s:%s' % - scale(self.scale, width, height, str), + '-filter:v', 'scale=%s:%s' % scale( + self.scale, width, height, str), '-vcodec', 'rawvideo', '-', '-ss', '90', '-vframes', '1', @@ -238,6 +238,7 @@ class Component(__base__.Component): def commandHelp(self): print('Load a video:\n path=/filepath/to/video.mp4') + def scale(scale, width, height, returntype=None): width = (float(width) / 100.0) * float(scale) height = (float(height) / 100.0) * float(scale) @@ -248,6 +249,7 @@ def scale(scale, width, height, returntype=None): else: return (width, height) + def finalizeFrame(self, imageData, width, height): if self.distort: try: @@ -265,7 +267,7 @@ def finalizeFrame(self, imageData, width, height): imageData) if self.scale != 100 \ - or self.xPosition != 0 or self.yPosition != 0: + or self.xPosition != 0 or self.yPosition != 0: frame = self.blankFrame(width, height) frame.paste(image, box=(self.xPosition, self.yPosition)) else: -- cgit v1.2.3