Building tools is always fun because of how much over-lap of tools are needed to support the main tool. I figured that it’s time to redesign my current builder with a new one hence this project is born.
When I design a complex window, I find that it’s always a good practice to break up the widgets into separate functions. In this case, my window only contains two widgets, ModuleForm and InformationForm, and PySide makes things easier in combining modules:
class MainWindow(QtWidgets.QMainWindow):
HEIGHT = 400
WIDTH = 400
INFORMATION = {}
module_form = None
information_form = None
# the main build blue-print to construct
# every time a module is added to module form, this updates the blueprint dictionary
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
# add the widgets to the layouts.
self.main_widget = QtWidgets.QWidget(self)
self.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
self.main_layout = QtWidgets.QHBoxLayout(self)
# add the two widgets to the main layout
horizontal_split = QtWidgets.QSplitter(QtCore.Qt.Horizontal)
self.main_layout.addWidget(horizontal_split)
self.module_form = ModuleForm(parent=self)
self.information_form = InformationForm(parent=self)
horizontal_split.addWidget(self.module_form)
horizontal_split.addWidget(self.information_form)
As you can guess the ModuleForm are where each rig module class is stored; and when that is selected, it triggers an InformationForm refresh, showing the necessary information for that module, and it works like so:
This project is still in its infancy, I still need to add a blueprint file feature that saves and loads the module configuration as per rig specifications. My main purpose of this project is so that I can build creature rigs cleanly — including creature face work, I find that upkeep for creating faces is high, so having a modular based builder keeps file scenes nice and tidy.
I am not worried about the aesthetics of the tool for now, just its modular utility:
As I can see, PySide offers much flexibility with UI tool design, for example, I found out that you can add separate widgets to a QListWidgetItem like so:
@add_module_decorator
def add_module(self, *args):
"""
adds the module
:param args:
:return:
"""
module_name = args[0]
item = QtWidgets.QListWidgetItem()
widget = ModuleWidget(module_name=module_name, list_widget=self.module_form.list, item=item, parent=self)
item.setSizeHint(widget.sizeHint())
# add a widget to the list
self.module_form.list.addItem(item)
self.module_form.list.setItemWidget(item, widget)
return widget
And that QListWidgetItem contains a Widget with QLabel attached with a colored QtGui.QPixmap which can be changed just by re-assigning a different QtGui.QPixmap by using these two lines of code:
def change_status(self, color="green"):
"""
Change the status of the widget to "built"
"""
self.q_pix = QtGui.QPixmap(buttons[color])
self.icon.setPixmap(self.q_pix)