A simple tabbed navigation with Nagare
Tabs are a widely used mean to navigate between categories or sections of a website. There are lots of howtos and tutorials to create clean tab based navigation with HTML and CSS.
Let's see how to handle such a navigation with Nagare. We are going to create a tabbed navigation between a TicTacToe and a Counter.
Requirements
We use TicTacToe and Counter examples from our Demonstration Portal. Hence nagare examples have to be installed with following command:
easy_install nagare.examples
To run our small example we use serve-module:
nagare-admin serve-module ./menu_example.py:TabNav menu_example
Some styling
Finally a bit of CSS can be added to get the tabbed rendering effect.
@presentation.render_for(TabNav)
def render(self, h, *args):
css = """
body {
font-family: verdana,'Bitstream Vera Sans',helvetica,arial,sans-serif;
}
ul.menu {
height: 2em;
list-style: none;
margin: 0;
padding: 0;
}
ul.menu li {
float: left;
margin: 0 1px 0 0;
padding-left: 10px;
border: 1px solid #555555;
border-bottom: none;
color: #555555;
}
ul.menu a {
color: #555555;
display: block;
float: left;
height: 2em;
line-height: 2em;
padding-right: 10px;
text-decoration: none;
}
ul.menu li.selected-entry {
background-color: #555555;
}
ul.menu li.selected-entry a {
color: #FFFFFF;
font-weight: bold;
}
div.content {
border: #555555 solid 2px;
clear: left;
padding: 1em;
}
"""
h << h.style(css, type="text/css")
h << self.menu
with h.div(class_='content'):
h << self.content
return h.root
This renders as following:
- Rq:
- As we use serve-module, CSS has to be embedded into HTML but it is usually put in the static folder of the application skeleton.
Attachments
-
tabbed_navigation.png
(10.1 KB) - added by crumble
2 months ago.
-
tabbed_navigation.2.png
(10.4 KB) - added by crumble
2 months ago.

rss
Comments
No comments.