the block/blog

June 3, 2011

pyQT with Maya2011: adding a dynamic checkbox list

Filed under: Code, Maya, python, tool — katisss @ 6:41 am

I decided to give good old texture checker tool a new gui as maya 2011 stopped supporting some formating features it was using.
After building a .ui in QtDesigner i added code to update the dynamic checkbox list (a QListWidget) and connect the other widgets.

gui6.jpg

I didn't find accessing the dynamically created check boxes too straight forward, so here is a code snippet:

 
#get the list
listWidget=self.chLayout.itemAt(0).widget()
 
#add check boxes
item = QtGui.QListWidgetItem(listWidget)
ch = QtGui.QCheckBox()
listWidget.setItemWidget(item, ch)
 
#query check boxes status
for index in xrange(listWidget.count()):
    check_box = listWidget.itemWidget(listWidget.item(index))
    state = check_box.checkState()
 

Here is a useful example for using pyQt in maya with Threads in a way that doesn't block the gui.

And here is the code.

Powered by WordPress