Example #1
0
def chooseElement(fam):
    elems = ap.getElements(fam)
    allelems  = [(e.name, Qt.Checked) if e.isEnabled()
                 else (e.name, Qt.Unchecked) for e in elems]
    enabled_0 = [i for i,e in enumerate(elems) if e.isEnabled()]
    extra_cols = [('s [m]', [e.sb for e in elems])]
    form = ElementPickDlg(allelems, title="Choose {0}".format(fam),
                          extra_cols = extra_cols)

    if form.exec_(): 
        enabled = form.checkedIndices()
        el0, el1 = [], []
        for i,e in enumerate(elems):
            if i in enabled_0 and i not in enabled:
                el0.append(i)
            elif i not in enabled_0 and i in enabled:
                el1.append(i)
            if i in enabled: e.setEnabled(True)
            else: e.setEnabled(False)

        if el0:
            _logger.info("{0} {1} '{2}' are disabled".format(
                len(el0), fam, [elems[i].name for i in el0]))
        if el1:
            _logger.info("{0} {1} '{2}' are enabled".format(
                len(el1), fam, [elems[i].name for i in el1]))
Example #2
0
def chooseElement(fam):
    elems = ap.getElements(fam)
    allelems = [(e.name, Qt.Checked) if e.isEnabled() else
                (e.name, Qt.Unchecked) for e in elems]
    enabled_0 = [i for i, e in enumerate(elems) if e.isEnabled()]
    extra_cols = [('s [m]', [e.sb for e in elems])]
    form = ElementPickDlg(allelems,
                          title="Choose {0}".format(fam),
                          extra_cols=extra_cols)

    if form.exec_():
        enabled = form.checkedIndices()
        el0, el1 = [], []
        for i, e in enumerate(elems):
            if i in enabled_0 and i not in enabled:
                el0.append(i)
            elif i not in enabled_0 and i in enabled:
                el1.append(i)
            if i in enabled: e.setEnabled(True)
            else: e.setEnabled(False)

        if el0:
            _logger.info("{0} {1} '{2}' are disabled".format(
                len(el0), fam, [elems[i].name for i in el0]))
        if el1:
            _logger.info("{0} {1} '{2}' are enabled".format(
                len(el1), fam, [elems[i].name for i in el1]))