hey!
I’m new to GUI programming and I’m using PySide (as 3ds Max and Maya use it). I’m having a little difficulty trying to get my head around connecting slots and signals. I can connect up single signals no problem but with more complicated signals, I start to struggle a little bit and the documentation (Signals and Slots in PySide) is a little confusing.
I have separated the GUI from the core code and I’m trying to keep it that way.
Here is the GUI code in question (I have made it as simple as possible):
import sys
from PySide import QtGui
import otherlocalModule
class GUIWindow(QtGui.QWidget):
def __init__(self):
super(GUIWindow, self).__init__()
self.setWindowTitle("Example Window")
self.setGeometry(300, 250, 270, 200)
self.example_button = QtGui.QPushButton("Export Selection")
self.freeze_checkbox = QtGui.QCheckBox("Freeze Transform")
self.del_history_checkbox = QtGui.QCheckBox("Delete History")
self.example_button.clicked.connect(self.export_selection)
self.freeze_checkbox.isChecked.connect(self.export_selection)
self.del_history_checkbox.isChecked.connect(self.export_selection)
layout = QtGui.QVBoxLayout()
layout.addWidget(self.example_button)
layout.addWidget(self.freeze_checkbox)
layout.addWidget(self.del_history_checkbox)
self.setLayout(layout)
self.show()
def export_selection(self):
otherlocalModule.export_selection(self.freeze_checkbox.isChecked(), self.del_history_checkbox.isChecked())
if __name__ == '__main__':
try:
app = QtGui.QApplication(sys.argv)
app_window = GUIWindow()
app.exec_()
sys.exit(0)
except SystemExit:
pass
# otherLocalModule
# half-pseudo code
def export_selection(freeze_transform, delete_history):
for mesh in get_current_selection():
if freeze_transform:
FreezeTransforms(mesh)
if delete_history:
DeleteHistory(mesh)
exportSelection(mesh)
I’m trying to allow the user to customise their export process like Freezing Transforms or Deleting Histories and this connecting of signals/slots is currently what has stumped me so far.
Thanks!
Andrew