Пример #1
0
def show(items, duration=0):
    # set the current parent
    parent = exp._current_parent

    # See if there is already a swap state
    add_swap_state = True
    if parent.timeline.events.has_key(parent.cur_event_time):
        # see if there is a swap state at that time
        states = parent.timeline.events[parent.cur_event_time]
        for s in states:
            if isinstance(s, SwapState):
                # no need to add a swap state
                add_swap_state = False

                # get the preproc state for that swap
                # it will have the same parent
                preproc = None
                for c in s.parent.children():
                    if isinstance(c, PreprocState):
                        preproc = c
                        break
                if preproc is None:
                    raise AssertionError("Proprocessing state was not found.")
                # no need to keep looking
                break

    if add_swap_state:
        # create the preproc and swap with the same serial parent
        with Serial():
            with PreprocState():
                # add the show to it with lag
                ShowState(items,
                          event_time=exp._current_parent.cur_event_time - LAG)
            # append swap state
            s = SwapState()
            exp._add_transition_if_needed(s)
    else:
        print "Appending to existing swap"
        # add the show to existing preproc (found above)
        ShowState(items,
                  parent=preproc,
                  event_time=preproc.cur_event_time - LAG)

        # add a new dummy state in the current flow
        s = DummyState()
        exp._add_transition_if_needed(s)

    # if we have a specified duration, wait and call hide
    if duration > 0:
        if exp._current_parent.childMode() == QState.ExclusiveStates:
            wait(duration)
            hide(items)
        else:
            with Serial():
                wait(duration)
                hide(items)
    return items
Пример #2
0
def show(items,duration=0):
    # set the current parent
    parent = exp._current_parent

    # See if there is already a swap state
    add_swap_state = True
    if parent.timeline.events.has_key(parent.cur_event_time):
        # see if there is a swap state at that time
        states = parent.timeline.events[parent.cur_event_time]
        for s in states:
            if isinstance(s,SwapState):
                # no need to add a swap state
                add_swap_state = False

                # get the preproc state for that swap
                # it will have the same parent
                preproc = None
                for c in s.parent.children():
                    if isinstance(c,PreprocState):
                        preproc = c
                        break
                if preproc is None:
                    raise AssertionError("Proprocessing state was not found.")
                # no need to keep looking
                break

    if add_swap_state:
        # create the preproc and swap with the same serial parent
        with Serial():
            with PreprocState():
                # add the show to it with lag
                ShowState(items, event_time=exp._current_parent.cur_event_time-LAG)
            # append swap state
            s = SwapState()
            exp._add_transition_if_needed(s)
    else:
        print "Appending to existing swap"
        # add the show to existing preproc (found above)
        ShowState(items, parent=preproc, 
                  event_time=preproc.cur_event_time-LAG)

        # add a new dummy state in the current flow
        s = DummyState()
        exp._add_transition_if_needed(s)

    # if we have a specified duration, wait and call hide
    if duration > 0:
        if exp._current_parent.childMode() == QState.ExclusiveStates:
            wait(duration)
            hide(items)
        else:
            with Serial():
                wait(duration)
                hide(items)
    return items
Пример #3
0
    """
    Class to create a simple text object.
    """
    def __init__(self,txt,font=def_font,loc=(0,0)):
        QGraphicsSimpleTextItem.__init__(self,txt)
        self.setPos(*loc)
        self.setFont(font)



if __name__ == "__main__":

    from experiment import run

    show(Text("+",loc=(400,300)),duration=1005)
    wait(1005)
    with Parallel():
        show(Text("Jubba",loc=(400,300)),duration=1005)
        show(Text("Jubba2",loc=(200,100)),duration=2010)
        with Serial():
            wait(1005)
            show(Text("Wubba",loc=(300,200)),duration=1005)
            show(Text("Wubba2",loc=(300,200)),duration=2010)
        with Serial():
            wait(2010)
            show(Text("Lubba",loc=(500,400)),duration=2010)

    # for i in range(10):
    #     show(Text(str(i),loc=(400,300)),duration=10)

    # run the experiment