Skip to content

Commit 209a4b9

Browse files
committed
Blender: Clean up imports, fix class init
- BlenderListView was a QListView that was calling QTreeView.__init__() (Which is why we should really get in the habit of using super().)
1 parent 977a4df commit 209a4b9

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

src/windows/views/blender_listview.py

+25-13
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,14 @@
3333
import xml.dom.minidom as xml
3434
import functools
3535

36-
from PyQt5.QtCore import QSize, Qt, QEvent, QObject, QThread, pyqtSlot, pyqtSignal, QMetaObject, Q_ARG, QTimer
37-
from PyQt5.QtGui import *
38-
from PyQt5.QtWidgets import *
36+
from PyQt5.QtCore import (
37+
Qt, QObject, pyqtSlot, pyqtSignal, QMetaObject, Q_ARG, QThread, QTimer, QSize,
38+
)
39+
from PyQt5.QtWidgets import (
40+
QApplication, QListView, QMessageBox, QColorDialog,
41+
QComboBox, QDoubleSpinBox, QLabel, QPushButton, QLineEdit, QPlainTextEdit,
42+
)
43+
from PyQt5.QtGui import QColor, QImage, QPixmap
3944

4045
from classes import info
4146
from classes.logger import log
@@ -44,11 +49,9 @@
4449
from classes.app import get_app
4550
from windows.models.blender_model import BlenderModel
4651

47-
import json
48-
4952

5053
class BlenderListView(QListView):
51-
""" A TreeView QWidget used on the animated title window """
54+
""" A ListView QWidget used on the animated title window """
5255

5356
def currentChanged(self, selected, deselected):
5457
# Get selected item
@@ -74,7 +77,7 @@ def currentChanged(self, selected, deselected):
7477
self.generateUniqueFolder()
7578

7679
# Loop through params
77-
for param in animation.get("params",[]):
80+
for param in animation.get("params", []):
7881
log.info('Using parameter %s: %s' % (param["name"], param["title"]))
7982

8083
# Is Hidden Param?
@@ -588,7 +591,7 @@ def Render(self, frame=None):
588591

589592
def __init__(self, *args):
590593
# Invoke parent init
591-
QTreeView.__init__(self, *args)
594+
super().__init__(*args)
592595

593596
# Get a reference to the window object
594597
self.app = get_app()
@@ -633,7 +636,6 @@ def __init__(self, *args):
633636
# Refresh view
634637
self.refresh_view()
635638

636-
637639
# Background Worker Thread (for Blender process)
638640
self.background = QThread(self)
639641
self.worker = Worker() # no parent!
@@ -722,9 +724,14 @@ def Render(self, blend_file_path, target_script, preview_mode=False):
722724

723725
# Check the version of Blender
724726
import shlex
725-
log.info("Checking Blender version, command: {}".format(" ".join([shlex.quote(x) for x in command_get_version])))
727+
log.info("Checking Blender version, command: {}".format(
728+
" ".join([shlex.quote(x) for x in command_get_version])))
726729

727-
self.process = subprocess.Popen(command_get_version, stdout=subprocess.PIPE, stderr=subprocess.PIPE, startupinfo=startupinfo, universal_newlines=True)
730+
self.process = subprocess.Popen(
731+
command_get_version,
732+
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
733+
startupinfo=startupinfo, universal_newlines=True,
734+
)
728735

729736
# Check the version of Blender
730737
self.version = self.blender_version.findall(self.process.stdout.readline())
@@ -739,11 +746,16 @@ def Render(self, blend_file_path, target_script, preview_mode=False):
739746
return
740747

741748
# debug info
742-
log.info("Running Blender, command: {}".format(" ".join([shlex.quote(x) for x in command_render])))
749+
log.info("Running Blender, command: {}".format(
750+
" ".join([shlex.quote(x) for x in command_render])))
743751
log.info("Blender output:")
744752

745753
# Run real command to render Blender project
746-
self.process = subprocess.Popen(command_render, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, startupinfo=startupinfo, universal_newlines=True)
754+
self.process = subprocess.Popen(
755+
command_render,
756+
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
757+
startupinfo=startupinfo, universal_newlines=True,
758+
)
747759

748760
except Exception as ex:
749761
# Error running command. Most likely the blender executable path in

0 commit comments

Comments
 (0)