OperatorPage.showif()#

OperatorPage.showif() bool[source]#

Hook for controlling whether a page or section should be shown.

The showif hook is used by overloading. Inside the hook, you have access to the current experiment session via self.exp.

Examples

In this examples, the second page is shown only if “yes” was entered on the first page:

import alfred3 as al
exp = al.Experiment()


@exp.member
class Hello(al.Page):
    def on_exp_access(self):
        self += al.TextEntry(leftlab="Show second page?", name="el1")


@exp.member
class ShowPage(al.Page):
    title = "Showif Page"

    def showif(self):
        return self.exp.values.get("el1") == "yes"

In this example, the “Main” section is shown only if “yes” was entered on the first page:

import alfred3 as al
exp = al.Experiment()


@exp.member
class Hello(al.Page):
    def on_exp_access(self):
        self += al.TextEntry(leftlab="Show second page?", name="el1")


@exp.member
class Main(al.Section):

    def showif(self):
        return self.exp.values.get("el1") == "yes"

    def on_exp_access(self):
        self += al.Page(title="Showif Section Page 1", name="showif_page1")
        self += al.Page(title="Showif Section Page 2", name="showif_page2")