def displayForDisplay(display):
    allDisplays = cells.Sequence(list(display.displays))

    result = cells.Card(allDisplays,
                        header=display.title if display.title else None)

    return result
Ejemplo n.º 2
0
    def projectLine(project):
        def deleter():
            def reallyDelete():
                project.deleteSelf()
                setattr(cells.sessionState(), "modalOverlay", None)

            cells.sessionState().modalOverlay = cells.Modal(
                f"Really delete project '{project.name}'?",
                "Because you can't undo this yet.",
                Cancel=lambda: setattr(cells.sessionState(), "modalOverlay", None),
                OK=reallyDelete
                ).tagged("RFE_DeleteProjectModal")

        def renamer():
            cells.sessionState().modalOverlay = ModalEditBox(
                f"Rename project '{project.name}'",
                project.name,
                onOK=lambda newName: (
                    setattr(project, 'name', newName),
                    setattr(cells.sessionState(), "modalOverlay", None)
                    ),
                onCancel=lambda: setattr(cells.sessionState(), 'modalOverlay', None)
                ).tagged("RFE_RenameProjectModal")

        def isSelected():
            if cells.sessionState().selected_module is not None and cells.sessionState().selected_module.exists():
                return cells.sessionState().selected_module.project == project
            return False

        return cells.Sequence([
                cells.Octicon("file-directory").nowrap(),

                cells.Subscribed(
                    lambda: cells.Text(project.name).width(200).nowrap()
                        .background_color(None if not isSelected() else SELECTED_PROJECT_COLOR)
                    ).nowrap(),

                cells.Button(
                    cells.Octicon("pencil").color(BUTTON_COLOR),
                    renamer, small=True, style="light"
                    ).nowrap().tagged(f"RFE_RenameProjectButton_{project._identity}"),

                cells.Button(
                    cells.Octicon("trashcan").color(BUTTON_COLOR),
                    deleter, small=True, style="light"
                    ).nowrap().tagged(f"RFE_DeleteProjectButton_{project._identity}"),

                cells.Button(
                    cells.Octicon("plus").color(BUTTON_COLOR),
                    lambda: ResearchFrontend.createNewModule(project),
                    small=True, style="light"
                    ).nowrap().tagged(f"RFE_NewModuleButton_{project._identity}")
                ]
            ).nowrap()
    def cardContents():
        if showChart.get():
            xySlot = cells.Slot()

            return cells.Plot(downsamplePlotData, xySlot=xySlot).width("100%")
        else:
            seq = []
            for plottedSet in list(display.unnamed) + list(
                    display.named.values()):
                seq.append(
                    research_app.DisplayForDataset.displayForDataset(
                        DatasetDisplay.Dataset(dataset=plottedSet)))
            return cells.Sequence(seq)
Ejemplo n.º 4
0
    def moduleLine(module):
        def selectModule():
            cells.sessionState().selected_module = module

        def deleter():
            def reallyDelete():

                module.deleteSelf()
                setattr(cells.sessionState(), "modalOverlay", None)

            cells.sessionState().modalOverlay = cells.Modal(
                f"Really delete '{module.project.name}.{module.name}'?",
                "Because you can't undo this yet.",
                Cancel=lambda: setattr(cells.sessionState(), "modalOverlay", None),
                OK=reallyDelete
                ).tagged("RFE_DeleteModuleModal")

        def renamer():
            cells.sessionState().modalOverlay = ModalEditBox(
                f"Rename module '{module.project.name}.{module.name}'",
                module.name,
                onOK=lambda newName: (
                    setattr(module, 'name', newName),
                    setattr(cells.sessionState(), "modalOverlay", None)
                    ),
                onCancel=lambda: setattr(cells.sessionState(), 'modalOverlay', None)
                ).tagged("RFE_RenameModuleModal")

        def isSelected():
            if cells.sessionState().selected_module is not None and cells.sessionState().selected_module.exists():
                return cells.sessionState().selected_module == module
            return False

        return cells.Sequence([
                cells.Clickable(
                    cells.Octicon("file").nowrap() +
                    cells.Text(module.name).width(200).nowrap(),
                    selectModule
                    ).nowrap().background_color(None if not isSelected() else SELECTED_MODULE_COLOR),

                cells.Button(
                    cells.Octicon("pencil").color(BUTTON_COLOR),
                    renamer, small=True, style="light"
                    ).nowrap().tagged(f"RFE_RenameModuleButton_{module._identity}"),

                cells.Button(
                    cells.Octicon("trashcan").color(BUTTON_COLOR),
                    deleter, small=True, style="light"
                    ).nowrap().tagged(f"RFE_DeleteModuleButton_{module._identity}")
                ]
            ).nowrap()
Ejemplo n.º 5
0
 def displaysDisplay(evaluation):
     return cells.Sequence(
         [cells.Cell.makeCell(display) + cells.Padding() for display in evaluation.displays]
     )