Beispiel #1
0
 def new_form(self):
     form = Form(self.web_fixture.view, 'some_form')
     event = Event(label='click me', action=Action(self.action))
     event.bind('an_event', None)
     form.define_event_handler(event, target=self.target)
     form.add_child(ButtonInput(form, event))
     return form
Beispiel #2
0
def test_button_layouts(web_fixture):
    """A ButtonLayout can be be used on a Button to customise various visual effects."""

    event = Event(label='click me')
    event.bind('event', web_fixture)
    form = Form(web_fixture.view, 'test')
    form.define_event_handler(event)

    # Case: the defaults
    button = Button(form, event).use_layout(ButtonLayout())

    tester = WidgetTester(button)
    [button] = tester.xpath(XPath.button_labelled('click me'))
    assert button.attrib['class'] == 'btn reahl-primitiveinput'

    # Case: possible effects
    form = Form(web_fixture.view, 'test')
    form.define_event_handler(event)
    button = Button(form, event).use_layout(
        ButtonLayout(style='secondary', size='sm', active=True, wide=True))

    tester = WidgetTester(button)
    [button] = tester.xpath(XPath.button_labelled('click me'))
    assert button.attrib[
        'class'] == 'active btn btn-block btn-secondary btn-sm reahl-primitiveinput'
Beispiel #3
0
 def assemble(self):
     event = Event(label='Click me', action=Action(do_something))
     event.bind('anevent', None)
     viewa = self.define_view('/viewa', title='View a')
     viewa.set_slot('main', FormWithButton.factory(event))
     viewb = self.define_view('/viewb', title='View b')
     viewb.set_slot('main', FormWithButton.factory(event))
     self.define_transition(event, viewa, viewb)
Beispiel #4
0
 def assemble(self):
     event = Event(label='Click me', action=Action(do_something))
     event.bind('anevent', None)
     slot_definitions = {'main': FormWithButton.factory(event)}
     viewa = self.define_view('/viewa',
                              title='View a',
                              slot_definitions=slot_definitions)
     self.define_local_transition(event, viewa, guard=guard)
Beispiel #5
0
 def assemble(self):
     event = Event(label='Click me')
     event.bind('anevent', None)
     viewa = self.define_view('/viewa', title='View a')
     viewa.set_slot('main', FormWithButton.factory(event))
     viewb = self.define_view('/viewb', title='View b')
     viewc = self.define_view('/viewc', title='View c')
     self.define_transition(event, viewa, viewb, guard=false_guard)
     self.define_transition(event, viewa, viewc, guard=adjustable_guard)
Beispiel #6
0
        def assemble(self):
            event = Event(label='Click me')
            event.bind('anevent', None)

            step1 = self.define_view('/firstStepOfDetour', title='Step 1', detour=True)
            step1.set_slot('main', FormWithButton.factory(event))
            step2 = self.define_view('/lastStepOfDetour', title='Step 2')
            step2.set_slot('main', FormWithButton.factory(event))

            self.define_transition(event, step1, step2)
            self.define_return_transition(event, step2)
Beispiel #7
0
        def assemble(self):
            event = Event(label='Click me')
            event.bind('anevent', None)
            viewa = self.define_view('/viewa', title='View a')
            explicit_return_view = self.define_view('/explicitReturnView', title='Explicit Return View')

            detour = self.define_view('/detour', title='Detour')
            detour.set_slot('main', FormWithButton.factory(event))

            viewa.add_precondition(ViewPreCondition(lambda: False, exception=Detour(detour.as_bookmark(self), return_to=explicit_return_view.as_bookmark(self))))
            self.define_return_transition(event, detour)
Beispiel #8
0
        def assemble(self):
            event = Event(label='Click me')
            event.bind('anevent', None)
            viewa = self.define_view('/viewa', title='View a')

            step1 = self.define_view('/firstStepOfDetour', title='Step 1')
            step1.set_slot('main', FormWithButton.factory(event))
            step2 = self.define_view('/lastStepOfDetour', title='Step 2')
            step2.set_slot('main', FormWithButton.factory(event))

            viewa.add_precondition(ViewPreCondition(lambda: fixture.make_precondition_pass, exception=Detour(step1.as_bookmark(self))))
            self.define_transition(event, step1, step2)
            self.define_return_transition(event, step2)
Beispiel #9
0
            def assemble(self):
                event = Event(label='Click me')
                event.bind('anevent', None)
                slot_with_button = {'main': FormWithButton.factory(event)}

                step1 = self.define_view('/firstStepOfDetour',
                                         title='Step 1',
                                         slot_definitions=slot_with_button,
                                         detour=True)
                step2 = self.define_view('/lastStepOfDetour',
                                         title='Step 2',
                                         slot_definitions=slot_with_button)

                self.define_transition(event, step1, step2)
                self.define_return_transition(event, step2)
Beispiel #10
0
 def new_event(self):
     event = Event(readable=self.readable, writable=self.writable)
     event.bind('event_name', EmptyStub())
     self.form.define_event_handler(event)
     return event
Beispiel #11
0
 def new_event(self, label='click me'):
     event = Event(label=label)
     event.bind('aname', None)
     self.form.define_event_handler(event)
     return event