Q1: Is there a way to choose multiple addresses?
A1: You could add a second combo widget and set the names again:
from scripting import *
import org.eclipse.swt as swt
import org.eclipse.swt.widgets as widgets
import org.eclipse.swt.layout as layout
ce = CE()
if __name__ == '__main__':
result = None
display = widgets.Display()
shell = widgets.Shell(display)
shell.pack()
shell.open()
dialog = widgets.Shell(shell, swt.SWT.DIALOG_TRIM | swt.SWT.APPLICATION_MODAL)
dialog.setLayout(layout.RowLayout())
dialog.setText("Address Search")
names = []
OIDs = []
sceneShapes = ce.getObjectsFrom(ce.scene, ce.isShape)
for s in sceneShapes:
name = ce.getAttribute(s, 'name')
if not (name == None) | (name == ""):
names.append(name)
OIDs.append(ce.getOID(s))
searchName = widgets.Combo(dialog, swt.SWT.READ_ONLY)
searchName.setItems(names)
searchName2 = widgets.Combo(dialog, swt.SWT.READ_ONLY)
searchName2.setItems(names)
ok = widgets.Button(dialog, swt.SWT.PUSH)
ok.setText ("OK")
cancel = widgets.Button(dialog, swt.SWT.PUSH);
cancel.setText("Cancel");
class MyListener(widgets.Listener):
def handleEvent(self, event):
global result, result2
if event.widget == ok:
result = searchName.getSelectionIndex()
result2 = searchName2.getSelectionIndex()
else:
result = -1
dialog.close()
listener = MyListener()
ok.addListener(swt.SWT.Selection, listener)
cancel.addListener(swt.SWT.Selection, listener)
dialog.pack()
dialog.open()
while not dialog.isDisposed():
if not display.readAndDispatch():
display.sleep ()
display.dispose()
if result>-1:
print "Selection:", names[result], names[result2]
ce.setSelection(ce.findByOID(OIDs[result]))
if result2>-1:
ce.setSelection([ce.findByOID(OIDs[result]), ce.findByOID(OIDs[result2])])
views = ce.getObjectsFrom(ce.get3DViews())
views[0].frame(ce.selection())
for more help on SWT widgets please visit: SWT Widgets
Q2: Is there a way to display the addresses in numerical order?
A2: "names" is a list of of strings please refer Python data structure sort list alphabetically - Stack Overflow on how to sort such lists. You probably also want to cut away the street numbers prior to sorting: python - How to split a string into a list? - Stack Overflow