def makeContents(cls, backButton: Button = None) -> Column:

        nameLabel: Label = Label("Name: ")
        raceLabel: Label = Label("Race: ")

        cls.nameField: TextField = TextField(width=150)
        cls.raceField: TextField = TextField(width=150)

        rows = [[nameLabel, cls.nameField], [raceLabel, cls.raceField]]
        fieldGrid: Grid = Grid(rows)

        cls.resultLabel = Label("")
        cls.resultLabel.width = 400

        minMaxAttrs = {'min': 50, 'max': 240}
        minMaxField: TextField = TextField(**minMaxAttrs)
        minMaxField.type = int
        minMaxField.set_text("222")

        okBtn = Button("OK", action=cls.ok)

        tbTestContainer = cls.makeTextBoxTesterContainer()
        contentAttrs = {"align": "c"}

        if backButton is None:
            contents: Column = Column([
                fieldGrid, cls.resultLabel, okBtn, minMaxField, tbTestContainer
            ], **contentAttrs)
        else:
            contents: Column = Column([
                fieldGrid, cls.resultLabel, okBtn, minMaxField,
                tbTestContainer, backButton
            ], **contentAttrs)

        return contents
示例#2
0
    def makeRegisterDisplay(self) -> Row:

        leftList: List[Widget] = []
        rightList: List[Widget] = []
        for regName in Chip8RegisterName:
            itemRef: ItemRef = ItemRef(base=self.chip8.registers,
                                       index=regName)
            regLabel: Label = Label(regName.name + ':', **self.labelAttrs)
            regValue: ValueDisplay = ValueDisplay(ref=itemRef,
                                                  width=42,
                                                  **self.labelAttrs)
            regValue.format = '0x%04X'

            pairRow: Row = Row([regLabel, regValue], **self.rowColumnAttrs)
            if regName.value % 2:
                rightList.append(pairRow)
            else:
                leftList.append(pairRow)

        leftColumn: Column = Column(leftList, **self.rowColumnAttrs)
        rightColumn: Column = Column(rightList, **self.rowColumnAttrs)
        gridAttrs = {
            'bg_color': Theme.LAMAS_MEDIUM_BLUE,
            'margin': 2,
            'border_width': 1
        }
        retGrid: Row = Row([leftColumn, rightColumn], **gridAttrs)
        return retGrid
示例#3
0
    def makeContents(cls, backButton: Button = None) -> Column:

        menu = Column([
            Button(text="Ask a Question", action=cls.test_ask),
            Button(text="Ask Old Filename", action=cls.test_old),
            Button(text="Ask New Filename", action=cls.test_new),
            Button(text="Look File/Directory", action=cls.test_lookfor),
            Button(text="Titled Dialog", action=cls.testTitledDialog),
        ],
                      align='l',
                      expand=3,
                      equalize='w')

        if backButton is None:
            contents = Column([
                menu,
            ], align='c', spacing=30)
        else:
            contents = Column([
                Label("File Dialogs",
                      font=ResourceUtility.get_font(18, "VeraBd.ttf")),
                menu,
                backButton,
            ],
                              align='c',
                              spacing=30)

        return contents
示例#4
0
    def makeContents(cls, client: Widget, backButton: Button = None) -> Column:

        labelFont = ResourceUtility.get_font(
            DemoListBoxScreen.DEMO_LABEL_TEXT_SIZE, Theme.BUILT_IN_FONT)

        demoListBoxLabel: Label = Label(text="Pick a good guy", font=labelFont)

        demoListBox: ListBox = ListBox(
            nrows=3,
            theClient=client,
            theItems=DemoListBoxScreen.DEMO_LIST_DATA,
            selectAction=cls.selectAction)

        cls.selectedLabel: Label = Label(text="No selection")
        lbColumnAttrs = {"align": "c", 'expand': 0}
        listBoxColumn = Column([demoListBoxLabel, demoListBox],
                               **lbColumnAttrs)

        columnAttrs = {"align": "l", 'expand': 0}
        if backButton is None:
            contents = Column([listBoxColumn, cls.selectedLabel],
                              **columnAttrs)
        else:
            contents = Column([listBoxColumn, cls.selectedLabel, backButton],
                              **columnAttrs)
        return contents
    def makeContents(cls, backButton: Button = None) -> Column:

        textLabel = Label("Make a choice: ")
        textMultiChoice = cls.makeTextMultiChoice()

        imageLabel = Label("Pick your ship: ")
        imageMultiChoice = cls.makeImageMultiChoice()

        rowAttrs = {'spacing': 2}
        textRow = Row([textLabel, textMultiChoice], **rowAttrs)
        imageRow = Row([imageLabel, imageMultiChoice], **rowAttrs)

        innerColumnAttrs = {"align": "l"}
        innerColumn: Column = Column([textRow, imageRow],
                                     spacing=10,
                                     **innerColumnAttrs)

        columnAttrs = {"align": "c", "margin": 5, 'border_width': 1}
        if backButton is None:
            # contents = Column([innerColumn, self.backButton], spacing=10, **columnAttrs)
            contents = innerColumn
        else:
            contents = Column([innerColumn, backButton],
                              spacing=10,
                              **columnAttrs)

        return contents
示例#6
0
    def __init__(self,
                 client=None,
                 responses=None,
                 default=0,
                 cancel=-1,
                 **kwds):
        """

        Args:
            client:    The widget the dialog is on top of

            responses: A list of responses

            default:   The index to the default response; Default is the first

            cancel:    The index to the cancel response; Default is None

            **kwds:
        """

        Widget.__init__(self, **kwds)
        if client or responses:
            rows = []
            w1 = 0
            w2 = 0
            if client:
                rows.append(client)
                w1 = client.width
            if responses:
                buttons = Row([
                    Button(text, action=lambda t=text: self.dismiss(t))
                    for text in responses
                ],
                              equalize='w')
                rows.append(buttons)
                w2 = buttons.width
            if w1 < w2:
                a = 'l'
            else:
                a = 'r'
            contents = Column(rows, align=a)
            m = self.margin
            contents.topleft = (m, m)
            self.add(contents)
            self.shrink_wrap()

        if responses and default is not None:
            self.enter_response = responses[default]
        if responses and cancel is not None:
            self.cancel_response = responses[cancel]
示例#7
0
    def __init__(self, prompt=None, suffixes=None, **kwds):

        super().__init__(**kwds)

        label = None
        d = self.margin
        self.suffixes = suffixes or ()
        if self.up_button_text is None:
            self.up_button_text = ''

        up_button = Button(self.up_button_text, action=self.go_up)
        dir_box = DirectoryPathView(self.box_width - up_button.width - 10,
                                    self)
        self.dir_box = dir_box
        top_row = Row([dir_box, up_button])
        list_box = FileListView(self.box_width - 16, self)
        self.list_box = list_box
        ctrls = [top_row, list_box]
        prompt = prompt or self.default_prompt

        if prompt:
            label = Label(prompt)
        if self.saving:
            filename_box = TextField(self.box_width)
            filename_box.change_action = self.update
            self.filename_box = filename_box
            ctrls.append(Column([label, filename_box], align='l', spacing=0))
        else:
            if label:
                ctrls.insert(0, label)

        ok_button = Button(self.ok_label,
                           action=self.ok,
                           enable=self.ok_enable)
        self.ok_button = ok_button
        cancel_button = Button("Cancel", action=self.cancel)
        vbox = Column(ctrls, align='l', spacing=d)
        vbox.topleft = (d, d)
        y = vbox.bottom + d
        ok_button.topleft = (vbox.left, y)
        cancel_button.topright = (vbox.right, y)
        self.add(vbox)
        self.add(ok_button)
        self.add(cancel_button)
        self.shrink_wrap()
        self._directory = None
        self.directory = os.getcwd()
        # print "FileDialog: cwd =", repr(self.directory) ###
        if self.saving:
            filename_box.focus()
    def makeContents(cls, backButton: Button = None) -> Column:

        model = DemoControlsModel()

        width_field = FloatField(ref=AttrRef(base=model, name='width'))
        height_field = FloatField(ref=AttrRef(base=model, name='height'))
        area_display = ValueDisplay(ref=AttrRef(base=model, name='area'),
                                    format="%.2f")
        shape = AttrRef(model, 'shape')
        shape_choices = Row([
            RadioButton(setting='rectangle', ref=shape),
            Label("Rectangle"),
            RadioButton(setting='triangle', ref=shape),
            Label("Triangle"),
            RadioButton(setting='ellipse', ref=shape),
            Label("Ellipse"),
        ])
        grid = Grid([
            [Label("Width"), width_field],
            [Label("Height"), height_field],
            [Label("Shape"), shape_choices],
            [Label("Value Area"), area_display],
        ])

        imgBtnBall: ImageButton = ImageButton(theImage="ball.gif")
        imgBtnHighlightedBall: ImageButton = ImageButton(
            theImage="ball.gif", highlightedBgImage="ball_highlighted.png")
        imgBtnDisabledBall: ImageButton = ImageButton(
            theImage="ball.gif",
            disabledBgImage="ball_disabled.png",
            enabled=False)
        imgBtnEnabledBall: ImageButton = ImageButton(
            theImage="ball.gif",
            enabledBgImage="ball_enabled.png",
            enabled=True)

        imgBtnTitle: Label = Label("Image Buttons")
        imgBtnGrid: Grid = Grid([[Label("Regular"), imgBtnBall],
                                 [Label("Highlighted"), imgBtnHighlightedBall],
                                 [Label("Disabled"), imgBtnDisabledBall],
                                 [Label("Enabled"), imgBtnEnabledBall]])

        width_field.focus()

        if backButton is None:
            contents = Column([grid, imgBtnTitle, imgBtnGrid])
        else:
            contents = Column([grid, imgBtnTitle, imgBtnGrid, backButton])
        return contents
示例#9
0
    def __init__(self, shell: Shell):

        self.logger = logging.getLogger(__name__)

        super().__init__(shell=shell)

        columnAttrs = {"align": "c", 'expand': 0}
        attrs = {'font': self.smallButtonFont}
        launchMusicDialogButt: Button = Button(
            text="Options Dialog",
            action=DemoMusicScreen.testOptionsDialog,
            **attrs)
        loadDemoMusicButt: Button = Button(
            text="Load Music", action=DemoMusicScreen.testLoadMusic, **attrs)
        playMusicButt: Button = Button(text="Play Music",
                                       action=DemoMusicScreen.playMusic,
                                       **attrs)
        stopMusicButt: Button = Button(text="Stop Music",
                                       action=DemoMusicScreen.stopMusic,
                                       **attrs)

        contents = Column([
            launchMusicDialogButt, loadDemoMusicButt, playMusicButt,
            stopMusicButt, self.backButton
        ], **columnAttrs)
        self.add_centered(contents)
        self.backButton.focus()
    def __init__(self, shell: Shell):

        self.logger = logging.getLogger(__name__)

        super().__init__(shell=shell)

        items = [
            MenuItem(text="Item 1", command="menuItem1"),
            MenuItem(text="Item 2", command="menuItem2"),
            MenuItem(text="Item 3", command="menuItem3"),
            MenuItem(text="Item 4", command="menuItem4")
        ]
        fileMenu = Menu(title="File", items=items)
        editMenu = Menu(title="Edit", items=items)
        viewMenu = Menu(title="View", items=items)
        helpMenu = Menu(title="Help", items=items)
        menus = [fileMenu, editMenu, viewMenu, helpMenu]

        menuBar = MenuBar(menus=menus, width=self.width / 2)

        framedMenuBar = Frame(client=menuBar)
        columnAttrs = {"align": "l", 'expand': 0}
        contents = Column([framedMenuBar, self.backButton], **columnAttrs)

        self.add_centered(contents)
        self.backButton.focus()
示例#11
0
    def makeContents(cls, backButton: Button = None) -> Column:

        DemoUserEventsScreen.classTextBox = TextBox()

        f1: Font = ResourceUtility.get_font(16, Theme.BUILT_IN_BOLD_FONT)
        textBoxTitle: Label = Label(text="User Events", font=f1)

        contentAttrs = {
            "align": "c"
        }
        if backButton is None:
            contents: Column = Column([textBoxTitle, DemoUserEventsScreen.classTextBox], **contentAttrs)
        else:
            contents: Column = Column([textBoxTitle, DemoUserEventsScreen.classTextBox, backButton], **contentAttrs)

        return contents
示例#12
0
    def makeStackDisplay(self) -> Column:

        stackLabel: Label = Label("Stack", **self.labelAttrs)
        stackBox: Chip8UIStack = Chip8UIStack(theChipStack=self.chip8.stack)

        stackContainer: Column = Column([stackLabel, stackBox],
                                        **self.rowColumnAttrs)
        return stackContainer
    def __init__(self):

        #
        # Python 3 update
        #
        super().__init__()
        emc = EnableMusicControl()
        mvc = MusicVolumeControl()
        controls = Grid([
            [Label("Enable Music"), emc],
            [Label("Music Volume"), mvc],
        ])
        buttons = Button("OK", self.ok)
        contents = Column([controls, buttons], align='r', spacing=20)
        contents.topleft = (20, 20)
        self.add(contents)
        self.shrink_wrap()
    def __init__(self, shell: Shell):

        super().__init__(shell)

        animationWidget: DemoAnimationWidget = DemoAnimationWidget(shell)

        content: Column = Column([animationWidget, self.backButton])
        self.add(content)
示例#15
0
    def __init__(self, shell: Shell):
        """

        :param shell:
        """
        self.logger = logging.getLogger(__name__)
        #
        # Python 3 update
        #
        # Screen.__init__(self, shell)
        super().__init__(shell)

        from albow.demo.DemoShell import DemoShell
        self.shell = cast(DemoShell, shell)
        f1 = ResourceUtility.get_font(DEMO_TITLE_TEXT_SIZE, Theme.BUILT_IN_FONT)

        title = Label("Albow Demonstration", font=f1)
        #  emptyButton = Button("Empty", enabled=False)

        menuArray = [
            [
                self.screen_button("R0C0"),
                self.screen_button("R0C1"),
                self.screen_button("R0C2"),
            ],
            # [
            #     self.screen_button("R1C0"),
            #     self.screen_button("R1Column1"),
            #     self.screen_button("R1C2"),
            # ],
            # [
            #     self.screen_button("R2C0"),
            #     self.screen_button("R2Column1"),
            #     self.screen_button("R2C2"),
            # ],
            # [
            #     self.screen_button("R3C0"),
            #     self.screen_button("R3Column1"),
            #     self.screen_button("R3C2")
            # ],
            # [
            #     self.screen_button("R4C0"),
            #     self.screen_button("R4Column1"),
            #     self.screen_button("R4C2")
            # ]
        ]

        menuGrid = Grid(rows=menuArray, column_spacing=10, row_spacing=2, margin=5)
        quitButton = Button("Quit", shell.quit)

        self.equallySizeButtons(menuArray)

        contents = Column([
            title,
            menuGrid,
            quitButton
        ], align='c', spacing=10, border_width=1, border_color=Theme.BLUE, margin=10)
        self.add_centered(contents)
    def __init__(self, shell: Shell):

        super().__init__(shell)

        grid        = DemoGridView()
        lbl         = Label("Cl1ck a Squ4r3")
        grid.output = lbl
        contents    = Column([grid, lbl, self.backButton], align='c', spacing=30)
        self.add_centered(contents)
示例#17
0
    def makeInstructionListDisplay(self) -> Column:

        instrLabel: Label = Label("Instructions", **self.labelAttrs)
        instrBox: Chip8UIInstructionList = Chip8UIInstructionList(
            instructionList=self.chip8.instructionList)

        instrContainer: Column = Column([instrLabel, instrBox],
                                        **self.rowColumnAttrs)
        return instrContainer
示例#18
0
    def _makeMainPartOfDialog(self, dlgTitleBar, message):

        lblMsg: Label = wrapped_label(message, self.wrap_width, margin=3)

        mainColAttrs: AttrDict = {
            'spacing': self.margin,
            'margin': 4,
            'align': 'l',
            'equalize': 'w',
        }
        mainColumn: Column = Column([dlgTitleBar, lblMsg], **mainColAttrs)
        return mainColumn
示例#19
0
    def __init__(self, theShell: Shell, theSurface: Surface):
        """

        Args:
            self:

            theShell:  The shell that wraps this screen

            theSurface: The pygame surface to use to drawn on

        Returns:  An instance of itself

        """
        self.surface: Surface = theSurface
        super().__init__(theShell)

        self.logger: Logger = getLogger(__name__)
        self.chip8: Chip8 = Chip8()
        self.selectedSprite: Chip8SpriteType = cast(Chip8SpriteType, None)
        self.vXvalue: int = 0
        self.vYvalue: int = 0
        vxAttrRef: AttrRef = AttrRef(base=self, name="vXvalue")
        vyAttrRef: AttrRef = AttrRef(base=self, name="vYvalue")

        vXLabel: Label = Label("Vx:")
        vYLabel: Label = Label("Vy:")

        vXField: IntField = IntField(width=100, ref=vxAttrRef)
        vYField: IntField = IntField(width=100, ref=vyAttrRef)

        spriteSelector: ListBox = ListBox(nrows=2,
                                          theClient=self,
                                          theItems=Chip8SpriteType.toStrList(),
                                          selectAction=self.selectAction)
        self.logger.info(f"list box width: {spriteSelector.width}")
        drawButton: Button = Button("Draw", action=self.drawAction)
        widgetList: List[Widget] = [
            drawButton, vXLabel, vXField, vYLabel, vYField, spriteSelector
        ]

        rowAttrs = {'margin': 3}
        inputRow: Row = Row(items=widgetList, **rowAttrs)
        framedInputRow: Frame = Frame(client=inputRow)

        chip8Screen: Chip8Screen = Chip8Screen(Chip8.virtualScreen)

        columnAttrs = {"align": "l", 'expand': 0, 'margin': 3}
        contents = Column([framedInputRow, chip8Screen], **columnAttrs)

        self.logger.info(
            f"framedInputRow size: {framedInputRow.size}, shell width: {self.shell.width} shell.height: {self.shell.height}"
        )
        self.add(contents)
    def makeTextBoxTesterContainer(cls) -> Row:

        cls.textBox = TextBox(theNumberOfColumns=20, theNumberOfRows=10)

        checkBoxRow: Row = Row([CheckBox(), Label('Last Line Visible')])

        appendTextButton: Button = Button('Append', action=cls.appendText)
        insertTextButton: Button = Button('Insert', action=cls.insertText)
        deleteTextButton: Button = Button('Delete', action=cls.deleteText)
        clearTextButton: Button = Button('Clear ', action=cls.clearText)

        contentAttrs = {"align": "l"}
        buttHolder: Column = Column([
            appendTextButton, insertTextButton, deleteTextButton,
            clearTextButton
        ], **contentAttrs)
        textBoxControlHolder: Column = Column([checkBoxRow, buttHolder],
                                              **contentAttrs)

        container: Row = Row([cls.textBox, textBoxControlHolder])

        return container
示例#21
0
    def __init__(self,
                 title: str = 'Default Title',
                 message: str = '',
                 okTxt: str = 'Ok',
                 cancelTxt: str = 'Cancel',
                 thirdButtTxt: str = None,
                 client=None,
                 wrapWidth: int = 100,
                 **kwds):
        """
        The dialog reports which button was pressed with the text of the button.
        TODO:  This constructor has way too many parameters;  Dude, simplify the parameter list;  Perhaps,
        use the kwds dictionary

        Args:
            title:          The title of the titled dialog
            message:        The message to display
            okTxt:          The text to display in the first button, The default is 'Ok'
            cancelTxt:      The text to display in the second button, The default is 'Cancel
            thirdButtTxt:   The text to display in the third button, The default is None which means the button will NOT be displayed
            client:         Where to center the window.  The default is the entire window
            wrapWidth:      When to start wrapping the message text
            **kwds:         Additional attributes to pass to the basic dialog
        """
        super().__init__(client=client, width=TitledDialog.TD_SIZE, **kwds)

        self.logger: Logger = getLogger(__name__)
        self.title: str = title
        self.wrap_width = wrapWidth
        self.logger.info(f'margin: {self.margin}')

        dlgTitleBar: DialogTitleBar = DialogTitleBar(
            theTitle=title, width=TitledDialog.TD_SIZE)
        mainContainer: Column = self._makeMainPartOfDialog(
            dlgTitleBar, message)

        buttRow = self._makeButtons(cancelTxt, okTxt, thirdButtTxt)

        dlgColAttrs: AttrDict = {
            'expand': 1,
            'margin': 8,
            'border_width': 2,
            'border_color': Theme.CITY_LIGHTS,
            'align': 'r',
        }
        dlgColumn: Column = Column([mainContainer, buttRow], **dlgColAttrs)
        dlgColumn.topleft = (self.margin, self.margin)

        self.add(dlgColumn)
        self.shrink_wrap()
    def makeEventsTab(cls) -> Column:

        userEvents: Column = DemoUserEventsScreen.makeContents()
        scheduledEventsTabPage: ScheduledEventTabPage = ScheduledEventTabPage(height=userEvents.height, width=userEvents.width)
        contentAttrs = {
            'align': "c",
            'margin': 10
        }
        eventTab: Column = Column([userEvents, scheduledEventsTabPage], **contentAttrs)

        from albow.demo.AlbowDemoScreen import AlbowDemoScreen

        AlbowDemoScreen.classScheduledEventsTabPage = scheduledEventsTabPage
        return eventTab
示例#23
0
    def __init__(self, shell):
        """

        :param shell:
        """
        super().__init__(shell)

        title = Label("Norwegian Butter Exports", font=self.labelFont)
        table: DemoTableView = DemoTableView()

        contents = Column([title, table, self.backButton],
                          spacing=BaseDemoScreen.DEFAULT_CONTENT_SPACING)

        self.add_centered(contents)
示例#24
0
    def makeContents(cls, backButton: Button = None) -> Column:

        cls.images = ImageArray.get_image_array("fruit.png", shape=3, border=2)
        cls.image = Image(cls.images[0])
        cls.index = 0

        if backButton is None:
            contents: Column = Column(
                [cls.image,
                 Button("Next Fruit", action=cls.next_image)],
                spacing=10)
        else:
            contentAttrs = {"align": "c", "margin": 10, 'border_width': 1}

            contents: Column = Column([
                Label("Image Array"),
                cls.image,
                Button("Next Fruit", action=cls.next_image),
                backButton,
            ],
                                      spacing=10,
                                      **contentAttrs)

        return contents
    def __init__(self, **kwds):

        super().__init__(**kwds)

        self.logger = logging.getLogger(__name__)
        self.textBox = TextBox()

        f1: Font = ResourceUtility.get_font(16, Theme.BUILT_IN_BOLD_FONT)
        textBoxTitle: Label = Label(text="Scheduled Events", font=f1)

        contentAttrs = {
            'align': 'c'
        }

        contents: Column = Column([textBoxTitle, self.textBox], **contentAttrs)
        self.token3 = None
        self.token6 = None
        self.add_centered(contents)
示例#26
0
    def __init__(self, shell: Shell):
        """

        :param shell:
        """
        super().__init__(shell)
        tabPanel = TabPanel(enterTabAction=self.enterTabAction,
                            exitTabAction=self.exitTabAction)
        tabPanel.size = 400, 200
        self.pages = tabPanel

        for i in range(1, 4):
            page = self.make_test_page(i)
            tabPanel.add_page("Page %s" % i, page)

        contents = Column([tabPanel, self.backButton],
                          spacing=BaseDemoScreen.DEFAULT_CONTENT_SPACING)
        self.add_centered(contents)
    def makeGridLikeTab(cls):

        gridTabAttrs = {
            'align': "c",
            'margin': 20
        }

        grid: DemoGridView = DemoGridView()
        lbl = Label("Cl1ck a Squ4r3")
        grid.output = lbl

        gridColumn: Column = Column([grid, lbl])

        table: DemoTableView = DemoTableView()
        palette: DemoPaletteView = DemoPaletteView()

        gridTab: Row = Row([table, palette, gridColumn], **gridTabAttrs)

        return gridTab
示例#28
0
    def __init__(self, shell: Shell):

        #
        # Python 3 update
        #
        super().__init__(shell)

        w, h = self.size        # Extract from tuple

        grid = DemoPaletteView()
        lbl  = Label("Cl1ck a Squ4r3")

        grid.border_width = 1
        grid.center = (w/2, h/2)
        grid.output = lbl
        columnAttrs = {
            "align": "c",
            'expand': 0
        }

        contents = Column([grid, lbl, self.backButton], **columnAttrs)
        self.add_centered(contents)
示例#29
0
    def __init__(self, shell: Shell):
        """

        :param shell:
        """
        self.logger = logging.getLogger(__name__)
        #
        # Python 3 update
        #
        # Screen.__init__(self, shell)
        super().__init__(shell)

        from albow.demo.DemoShell import DemoShell
        self.shell = cast(DemoShell, shell)
        f1 = ResourceUtility.get_font(DEMO_TITLE_TEXT_SIZE,
                                      Theme.BUILT_IN_FONT)

        title = Label("Albow Demonstration", font=f1)
        #  emptyButton = Button("Empty", enabled=False)

        menuArray = [[
            self.screen_button("Text Screen", self.shell.text_screen),
            self.screen_button("Text Fields", self.shell.fields_screen),
            self.screen_button("Controls", self.shell.controls_screen),
        ],
                     [
                         self.screen_button("Animation",
                                            self.shell.anim_screen),
                         self.screen_button("Grid View",
                                            self.shell.grid_screen),
                         self.screen_button("Palette View",
                                            self.shell.palette_screen),
                     ],
                     [
                         self.screen_button("Image Array",
                                            self.shell.image_array_screen),
                         self.screen_button("Modal Dialogs",
                                            self.shell.dialog_screen),
                         self.screen_button("Tab Panel",
                                            self.shell.tab_panel_screen),
                     ],
                     [
                         self.screen_button("Table View",
                                            self.shell.table_screen),
                         self.screen_button("MultiChoice",
                                            self.shell.multiChoiceScreen),
                         self.screen_button("MenuBar",
                                            self.shell.menuBarScreen)
                     ],
                     [
                         self.screen_button("Music", self.shell.musicScreen),
                         self.screen_button("ListBox",
                                            self.shell.listBoxScreen),
                         self.screen_button("User Events",
                                            self.shell.userEventsScreen)
                     ]]

        menuGrid = Grid(rows=menuArray,
                        column_spacing=5,
                        row_spacing=2,
                        margin=5)
        quitButton = Button("Quit", shell.quit)

        self.equallySizeButtons(menuArray)

        contents = Column([title, menuGrid, quitButton], align='c', spacing=10)
        self.add_centered(contents)
示例#30
0
def ask(theMessage: str,
        theResponses=None,
        default=0,
        cancel=-1,
        wrap_width=60,
        **kwds):
    """
    Displays a message in a modal dialog with a set of buttons labelled with the specified responses. Clicking a
    button causes the ask function to return the corresponding response string as its value. The default and
    cancel parameters are indexes into the response list specifying the values to be returned by Return/Enter
    and Escape, respectively.

    Args:
        theMessage: The message to display

        theResponses:  Possible responses

        default:  The index to the default message

        cancel: The index to the cancel message

        wrap_width:  The wrap width in characters

        **kwds: Additional keyword parameters passed to the Dialog constructor.

    Returns:    The dialog modal result

    """

    #
    # Fix 'Mutable default arguments'
    #
    if theResponses is None:
        theResponses = DEFAULT_ASK_RESPONSES

    box = Dialog(**kwds)
    d = box.margin
    lb = wrapped_label(theMessage, wrap_width)

    lb.topleft = (d, d)
    buts = []
    for caption in theResponses:
        but = Button(caption, action=lambda x=caption: box.dismiss(x))
        buts.append(but)

    brow = Row(buts, spacing=d, equalize='w')
    lb.width = max(lb.width, brow.width)
    col = Column([lb, brow], spacing=d, align='r')
    col.topleft = (d, d)

    if default is not None:
        box.enter_response = theResponses[default]
    else:
        box.enter_response = None
    if cancel is not None:
        box.cancel_response = theResponses[cancel]
    else:
        box.cancel_response = None

    box.add(col)
    box.shrink_wrap()

    return box.present()