Ejemplo n.º 1
0
def test_beadtoolbar(bokehaction):
    "test the toolbar"
    server = bokehaction.start('taskview.toolbar.BeadToolbar', 'taskapp.default')
    beads  = DataSelectionBeadController(server.ctrl)

    server.load('big_legacy', rendered = "toolbardialog")
    assert frozenset(beads.availablebeads) == frozenset(range(39))

    server.change('Main:toolbar', 'discarded', '0,1,3')
    assert frozenset(beads.availablebeads) == (frozenset(range(39))-{0,1,3})

    server.change('Main:toolbar', 'discarded', '')
    assert frozenset(beads.availablebeads) == frozenset(range(39))

    bead1 = server.widget['Main:toolbar'].bead
    server.press('Shift-Delete')
    assert frozenset(beads.availablebeads) == frozenset(range(39))-{bead1}

    bead2 = server.widget['Main:toolbar'].bead
    server.press('Shift-Delete')
    assert frozenset(beads.availablebeads) == frozenset(range(39))-{bead1, bead2}

    server.load('CTGT_selection/Z(t)bd1track10.gr', rendered = "toolbardialog")
    assert frozenset(beads.availablebeads) == frozenset((1,))

    server.load('CTGT_selection/Z(t)bd0track10.gr', rendered = "toolbardialog")
    assert frozenset(beads.availablebeads) == frozenset((0, 1))

    server.change('Main:toolbar', 'discarded', '0')
    assert frozenset(beads.availablebeads) == frozenset((1,))
Ejemplo n.º 2
0
    def setup(ctrl, tbar: DpxToolbar, _):
        "sets-up the gui"
        bdctrl = DataSelectionBeadController(ctrl)

        def _ondiscard_currentbead(*_):
            bead = bdctrl.bead
            if bead is None:
                return
            with ctrl.action:
                bdctrl.setdiscarded(ctrl, set(bdctrl.discarded) | {bead})

        def _ondiscard_currentbead_cb(attr, old, value):
            _ondiscard_currentbead()

        def _onaccepted_cb(attr, old, new):
            beads = parseints(new)
            ctrl.display.handle('selectingbeads',
                                args={
                                    "text": new,
                                    "accept": True,
                                    "beads": beads
                                })
            if not (None in beads or (len(new) and len(beads) == 0)):
                beads = set(bdctrl.allbeads) - beads
                if (not tbar.seltype) and beads != set(bdctrl.discarded):
                    with ctrl.action:
                        bdctrl.setdiscarded(ctrl, beads)
                    return
            _ontasks()

        def _ondiscarded_cb(attr, old, new):
            beads = parseints(new)
            ctrl.display.handle('selectingbeads',
                                args={
                                    "text": new,
                                    "accept": False,
                                    "beads": beads
                                })
            if not (None in beads or (len(new) and len(beads) == 0)):
                if tbar.seltype and beads != set(bdctrl.discarded):
                    with ctrl.action:
                        bdctrl.setdiscarded(ctrl, beads)
                    return
            _ontasks()

        tbar.on_change('currentbead', _ondiscard_currentbead_cb)
        tbar.on_change('discarded', _ondiscarded_cb)
        tbar.on_change('accepted', _onaccepted_cb)

        def _ontasks(**_):
            disc = set(bdctrl.discarded)
            acc = set(bdctrl.allbeads) - disc
            tbar.update(accepted=', '.join(str(i) for i in sorted(acc)),
                        discarded=', '.join(str(i) for i in sorted(disc)))

        ctrl.tasks.observe("updatetask", "addtask", "removetask", _ontasks)
        ctrl.display.observe("tasks", _ontasks)

        ctrl.display.updatedefaults('keystroke',
                                    delbead=_ondiscard_currentbead)
Ejemplo n.º 3
0
    def _oktooltips(self, ttips):
        row = self._theme.tooltipok
        trk = self._model.track
        for bead in DataSelectionBeadController(self._ctrl).allbeads:
            if bead not in ttips:
                ttips[bead] = [
                    row.format(trk.rawprecision(bead), trk.beadextension(bead))
                ]

        return {i: ''.join(j) for i, j in ttips.items()}
Ejemplo n.º 4
0
    def setup(ctrl, tbar: DpxToolbar, _):
        "adds items to doc"
        bdctrl = DataSelectionBeadController(ctrl)

        def _chg_cb(attr, old, new):
            with ctrl.action:
                bdctrl.setbead(ctrl, new)
            tbar.bead = bdctrl.bead

        def _chg_cb2(step):
            if bdctrl.bead is not None:
                _chg_cb(None, None, bdctrl.bead + step)

        tbar.on_change('bead', _chg_cb)

        ctrl.display.updatedefaults('keystroke',
                                    beadup=lambda: _chg_cb2(1),
                                    beaddown=lambda: _chg_cb2(-1))
Ejemplo n.º 5
0
    def status(self, root, disc) -> Dict[str, Set[int]]:
        "return the beads per status"
        data = self.dataframe.get(root, None)
        if data is None:
            return {}

        out = {
            i: set(j)
            for i, j in data.groupby("status").bead.unique().items()
        }
        if isinstance(disc, (set, list)):
            disc = set(disc)
        else:
            disc = set(DataSelectionBeadController(disc).discarded)

        for i in out.values():
            i.difference_update(disc)
        out["discarded"] = disc
        return out
Ejemplo n.º 6
0
 def _cmd2():
     bdctrl = DataSelectionBeadController(server.ctrl)
     avail = list(bdctrl.availablebeads)
     with server.ctrl.action:
         bdctrl.setdiscarded(server.ctrl, set(avail[:5] + avail[10:]))