Example #1
0
    def addTab(self, id):
        """Add a new tab into the TabArea widget.  The tab is appended
        after previously added tabs.

        @param id Identifier for the tab.  The name and the icon of
        the tab will be determined using this identifier.

        @return The Area object for the contents of the tab.
        """
        book = self.getWxWidget()
        #tab = scrolled.ScrolledPanel(book, -1)
        #tab.SetupScrolling()
        tab = wx.Panel(book, -1, style=wx.CLIP_CHILDREN)

        if host.isWindows():
            tab.SetBackgroundStyle(wx.BG_STYLE_SYSTEM)

        # Put the new tab in the page map so that when an event
        # occurs, we will know the ID of the tab.
        self.panelMap.append((id, tab))

        # Insert the page into the book.
        book.AddPage(tab, language.translate(id))

        import sb.widget.area
        area = sb.widget.area.Area(id, tab, ui.ALIGN_VERTICAL)
        area.setExpanding(True)
        area.setWeight(1)

        # Store the Area object in a dictionary for quick access.
        self.tabAreas[id] = area

        self.updateIcons()

        return area
Example #2
0
    def addTab(self, id):
        """Add a new tab into the TabArea widget.  The tab is appended
        after previously added tabs.

        @param id Identifier for the tab.  The name and the icon of
        the tab will be determined using this identifier.

        @return The Area object for the contents of the tab.
        """
        book = self.getWxWidget()
        # tab = scrolled.ScrolledPanel(book, -1)
        # tab.SetupScrolling()
        tab = wx.Panel(book, -1, style=wx.CLIP_CHILDREN)

        if host.isWindows():
            tab.SetBackgroundStyle(wx.BG_STYLE_SYSTEM)

        # Put the new tab in the page map so that when an event
        # occurs, we will know the ID of the tab.
        self.panelMap.append((id, tab))

        # Insert the page into the book.
        book.AddPage(tab, language.translate(id))

        import sb.widget.area

        area = sb.widget.area.Area(id, tab, ui.ALIGN_VERTICAL)
        area.setExpanding(True)
        area.setWeight(1)

        # Store the Area object in a dictionary for quick access.
        self.tabAreas[id] = area

        self.updateIcons()

        return area
Example #3
0
def createButtonDialog(id, buttons, defaultButton=None, size=None,
                       resizable=True):
    """Returns the area where the caller may add the contents of the
    dialog.

    @param id Identifier of the dialog.
    @param buttons An array of button commands.
    @param defaultButton The identifier of the default button.

    @return Tuple (dialog, user-area)
    """
    dialog = createDialog(id, ui.ALIGN_HORIZONTAL, size, resizable)
    area = dialog.getArea()

    area.setMinSize(400, 20)

    # The Snowberry logo is on the left.
    #area.setWeight(0)
    #imageArea = area.createArea(alignment=ui.ALIGN_VERTICAL, border=0,
    #                            backgroundColor=wx.Colour(255, 255, 255))
    #imageArea.setWeight(1)
    #imageArea.setExpanding(True)
    #imageArea.addSpacer()
    #imageArea.setWeight(0)
    #imageArea.createImage('snowberry')

    area.setWeight(1)
    area.setBorderDirs(ui.BORDER_NOT_BOTTOM)
    contentArea = area.createArea(alignment=ui.ALIGN_VERTICAL, border=6)
    contentArea.setWeight(0)

    # Generous borders.
    contentArea.setBorder(16)

    contentArea.setWeight(1)
    userArea = contentArea.createArea(border=6)

    # Create the buttons.
    contentArea.setWeight(0)
    contentArea.setBorderDirs(ui.BORDER_NOT_TOP)
    buttonArea = contentArea.createArea(alignment=ui.ALIGN_HORIZONTAL,
                                        border=0)

    # If no explicit spacing is defined, use the default right
    # alignment.
    if '' not in buttons:
        # The implied spacer.
        buttonArea.addSpacer()

    buttonArea.setBorder(6, ui.BORDER_LEFT_RIGHT)
    buttonArea.setWeight(0)

    if not host.isMac():
        # Follow the general guidelines of the platform.
        if '' in buttons:
            # Only reverse the portion after the ''.
            index = buttons.index('') + 1
            sub = buttons[index:]
            sub.reverse()
            buttons = buttons[:index] + sub
        else:
            buttons.reverse()

    for button in buttons:
        # If an empty identifier is given, insert a space here.
        if button == '':
            buttonArea.setWeight(1)
            buttonArea.addSpacer()
            buttonArea.setWeight(0)
            continue

        if button == defaultButton:
            style = wb.Button.STYLE_DEFAULT
        else:
            style = wb.Button.STYLE_NORMAL

        widget = buttonArea.createButton(button, style=style)
        dialog.identifyWidget(button, widget)

    # By default, focus the default button.
    if defaultButton:
        dialog.focusWidget(defaultButton)

    return dialog, userArea
Example #4
0
def createButtonDialog(id,
                       buttons,
                       defaultButton=None,
                       size=None,
                       resizable=True):
    """Returns the area where the caller may add the contents of the
    dialog.

    @param id Identifier of the dialog.
    @param buttons An array of button commands.
    @param defaultButton The identifier of the default button.

    @return Tuple (dialog, user-area)
    """
    dialog = createDialog(id, ui.ALIGN_HORIZONTAL, size, resizable)
    area = dialog.getArea()

    area.setMinSize(400, 20)

    # The Snowberry logo is on the left.
    #area.setWeight(0)
    #imageArea = area.createArea(alignment=ui.ALIGN_VERTICAL, border=0,
    #                            backgroundColor=wx.Colour(255, 255, 255))
    #imageArea.setWeight(1)
    #imageArea.setExpanding(True)
    #imageArea.addSpacer()
    #imageArea.setWeight(0)
    #imageArea.createImage('snowberry')

    area.setWeight(1)
    area.setBorderDirs(ui.BORDER_NOT_BOTTOM)
    contentArea = area.createArea(alignment=ui.ALIGN_VERTICAL, border=6)
    contentArea.setWeight(0)

    # Generous borders.
    contentArea.setBorder(16)

    contentArea.setWeight(1)
    userArea = contentArea.createArea(border=6)

    # Create the buttons.
    contentArea.setWeight(0)
    contentArea.setBorderDirs(ui.BORDER_NOT_TOP)
    buttonArea = contentArea.createArea(alignment=ui.ALIGN_HORIZONTAL,
                                        border=0)

    # If no explicit spacing is defined, use the default right
    # alignment.
    if '' not in buttons:
        # The implied spacer.
        buttonArea.addSpacer()

    buttonArea.setBorder(6, ui.BORDER_LEFT_RIGHT)
    buttonArea.setWeight(0)

    if not host.isMac():
        # Follow the general guidelines of the platform.
        if '' in buttons:
            # Only reverse the portion after the ''.
            index = buttons.index('') + 1
            sub = buttons[index:]
            sub.reverse()
            buttons = buttons[:index] + sub
        else:
            buttons.reverse()

    for button in buttons:
        # If an empty identifier is given, insert a space here.
        if button == '':
            buttonArea.setWeight(1)
            buttonArea.addSpacer()
            buttonArea.setWeight(0)
            continue

        if button == defaultButton:
            style = wb.Button.STYLE_DEFAULT
        else:
            style = wb.Button.STYLE_NORMAL

        widget = buttonArea.createButton(button, style=style)
        dialog.identifyWidget(button, widget)

    # By default, focus the default button.
    if defaultButton:
        dialog.focusWidget(defaultButton)

    return dialog, userArea