Haha, was actually working on this, have so far only created a listView containing labels for all Bodies in all open files, got stuck in a movie halfway through..
Code: Select all
from PySide import QtGui, QtCore
# Our main window will be a QListView
list = QtGui.QListView()
list.setWindowTitle('Import Link')
list.setMinimumSize(200, 400)
# Create an empty model for the list's data
model = QtGui.QStandardItemModel(list)
textInput = QtGui.QLineEdit(list)
# Find all PartDesign::Body inside all open documents
for documents in App.listDocuments().values():
for body in documents.findObjects("PartDesign::Body"):
print body.Label
item = QtGui.QStandardItem(body.Label)
# Add a checkbox to it
item.setCheckable(False)
# Add the item to the model
model.appendRow(item)
def on_item_changed(item):
# If the changed item is not checked, don't bother checking others
if not item.checkState():
return
# Loop through the items until you get None, which
# means you've passed the end of the list
i = 0
while model.item(i):
if not model.item(i).checkState():
return
i += 1
app.quit()
def on_text_changed(text):
#todo filter on text
print text
model.itemChanged.connect(on_item_changed)
textInput.textChanged.connect(on_text_changed)
# Apply the model to the list view
list.setModel(model)
# Show the window and run the app
list.show()