Enaml 0.9.1
  • Site
      • Getting Started
      • Developer Guides
      • Architecture Reference
      • FAQs
      • Examples
      • API Reference
  • Page
      • Banner Example
  • Index
  • Getting Started
  • Developer Guides
  • Architecture Reference
  • FAQs
  • Examples
    • Tutorial Examples
    • Widgets Examples
    • Layout Examples
    • Stdlib Examples
    • Dynamic Examples
    • Aliases Examples
    • Styling Examples
      • Banner Example
      • Dock Item Alerts Example
      • Gradient Push Button Example
    • Templates Examples
    • Applib Examples
    • Workbench Examples
  • API Reference

Banner ExampleΒΆ

banner

An example of using style sheets to create a banner from a Label.
$ enaml-run banner
../_images/ex_banner.png
#------------------------------------------------------------------------------
#  Copyright (c) 2013, Nucleic Development Team
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#------------------------------------------------------------------------------
""" An example of using style sheets to create a banner from a Label.

<< autodoc-me >>
"""
from enaml.widgets.api import (
    Window, Container, Label, Form, Field, Html, MultilineField, CheckBox
)
from enaml.styling import StyleSheet, Style, Setter
from enaml.layout.api import vbox, hbox, align


enamldef BannerSheet(StyleSheet):
    Style:
        element = 'Label'
        style_class = 'banner'
        Setter:
            field = 'background'
            value = ('lineargradient(x1: 0, y1:0, x2:0, y2:1, '
                        'stop: 0 #222222, stop: 0.5 #1A1A1A, stop: 1 #111111)')
        Setter:
            field = 'color'
            value = '#FFFFEF'
        Setter:
            field = 'padding'
            value = '5px'
        Setter:
            field = 'font'
            value = '18pt Verdana'


enamldef Main(Window):
    title = 'Banner Example'
    BannerSheet:
        pass
    Container:
        constraints = [
            vbox(hbox(form, description), primary),
            banner.top == top,
            banner.left == left,
            banner.right == right,
            banner.bottom + 10 == form.top,
            align('top', form, description),
        ]
        Label: banner:
            text = 'Banner Text'
            style_class << 'banner' if cbox.checked else ''
        Form: form:
            padding = 0
            hug_width = 'strong'
            hug_height = 'required'
            Label:
                text = 'First'
            Field:
                placeholder = 'First Value'
            Label:
                text = 'Second'
            Field:
                placeholder = 'Second Value'
            Label:
                text = 'Third'
            Field:
                placeholder = 'Third Value'
            Label:
                text = 'Fourth'
            Field:
                placeholder = 'Fourth Value'
            CheckBox: cbox:
                text = 'Toggle Banner Style'
                checked = True
        MultilineField: description:
            text = 'description...'
            enabled = False
            constraints = [height == form.height]
        Html: primary:
            source = '<h1><center>Primary Content</center></h1>'

Back to top

© Copyright 2013, Nucleic Development Team.
Last updated on Feb 18, 2014.
Created using Sphinx 1.1.3.