11.19 Using PyQt5 Addons
11.19.1 Corvid PyQt5 Addon Instructions
Cubit ships with PyQt5 and it is available for use in Cubit automatically. To use a PyQt5 addon, you need to edit the Cubit.ini.
11.19.1.1 Linux or macOS Instructions
Note, the libglib2 library needs to be installed on linux systems for PyQt5 to work properly.
vi ~/.config/Coreform/Cubit.ini
plugin\addons=/home/USER/custom_corvid_component/custom_corvid_component.CorvidComponent
11.19.1.2 Windows Instructions
vim C:\Users\USER\AppData\Roaming\Coreform\Cubit.ini
plugin\addons=C:/Users/USER/custom_corvid_component/custom_corvid_component.CorvidComponent
/home/USER/custom_corvid_component/custom_corvid_component is the path to the custom_corvid_component.py module. USER is your username on your machine. .CorvidComponent is "dot" followed by the CorvidComponent class name.
start_up(self, with_gui: int) -> None clean_up(self) -> None interrupt_progress(self) -> None
11.19.2 Porting from PyQt4 to PyQt5
-import PyQt4.QtCore as qtcore -import PyQt4.QtGui as qtgui -from PyQt4 import uic +import PyQt5.QtCore as qtcore +import PyQt5.QtGui as qtgui +import PyQt5.QtWidgets as QtWidgets +from PyQt5 import uic
- qtgui.QAction.__init__(self, parent) + QtWidgets.QAction.__init__(self, parent) - qtgui.QToolButton.__init__(self, parent) + QtWidgets.QToolButton.__init__(self, parent) - spaceX = self.spacing() + wid.style().layoutSpacing(qtgui.QSizePolicy.PushButton, qtgui.QSizePolicy.PushButton, qtcore.Qt.Horizontal) - spaceY = self.spacing() + wid.style().layoutSpacing(qtgui.QSizePolicy.PushButton, qtgui.QSizePolicy.PushButton, qtcore.Qt.Vertical) + spaceX = self.spacing() + wid.style().layoutSpacing(QtWidgets.QSizePolicy.PushButton, QtWidgets.QSizePolicy.PushButton, qtcore.Qt.Horizontal) + spaceY = self.spacing() + wid.style().layoutSpacing(QtWidgets.QSizePolicy.PushButton, QtWidgets.QSizePolicy.PushButton, qtcore.Qt.Vertical)
# Set up connections - qtcore.QObject.connect(tbolt.gbox_advanced , qtcore.SIGNAL(’toggled(bool)’) , self.check_hex_round_advanced) - qtcore.QObject.connect(tbolt.radio_hex , qtcore.SIGNAL(’toggled(bool)’) , self.check_hex_round_advanced) - qtcore.QObject.connect(tbolt.but_boltgen , qtcore.SIGNAL(’clicked()’) , self.on_make_bolt ) + #qtcore.QObject.connect(tbolt.gbox_advanced , qtcore.SIGNAL(’toggled(bool)’) , self.check_hex_round_advanced) + tbolt.gbox_advanced.toggled.connect(self.check_hex_round_advanced) + #qtcore.QObject.connect(tbolt.radio_hex , qtcore.SIGNAL(’toggled(bool)’) , self.check_hex_round_advanced) + tbolt.radio_hex.toggled.connect(self.check_hex_round_advanced) + #qtcore.QObject.connect(tbolt.but_boltgen , qtcore.SIGNAL(’clicked()’) , self.on_make_bolt ) + tbolt.but_boltgen.clicked.connect(self.on_make_bolt)
11.19.3 Future: Pyside Addon Instructions
./pip3 install pside2