Adding Pages and Menus

CollapsableMenu Single Line Menu
    WebMenu Documentation >>  Creating Menus in Python >>  Adding Pages and Menus
QuickNavigationMenu QuickParentNavigationMenu
<< >> << ^ >>
MultiLineMenu
Introduction | Creating Menus in Python | The WebPage Class | The HiddenPage Class | The WebMenu Class | Using XML to define a Web Menu object | Q&A | CSS Declarations
Setting the Defaults | Adding Pages and Menus

Once you set the default values to help WebMenu draw your menus, you need to describe your menu structure. There are two classes used by WebMenu: WebPage and WebMenu. Technically WebMenu is a subclass of WebPage, but you will be using the WebMenu class to create the menu object.

>>>import WebMenu
>>>myMenu = WebMenu.WebMenu("WebMenu Documentation","webmenu.html",'',"home")

A WebMenu object is created with four arguments:Title, file, full title, and a key. The fulltitle and key are optional paramaters. Titles can be long, but keys can be short and unique. Keys are never translated into HTML. If you want the menu to draw a short name, such as "Q&A", you can use set full title attribute to "Questions and Answers" and modern browsers will show "Questions and Answers" as a tooltip when the user mouses over the menu item. I've started the procedure for creating the menu for this minisite. The next page is the introduction page, so I use:

>>>myMenu.Add(WebMenu.WebPage("Introduction","intro.html","intro"))

This creates one page in the menu structure. A WebPage object is created using the same three arguments. Unfortunately the next page is actually a submenu with two pages under it (This page is one of them). To create a submenu you need to create another menu object, load up the pages, and then add that menu to the main menu:

>>>subMenu =WebMenu.WebMenu("Creating Menus in Python","python.html","python")
>>>subMenu.Add(WebMenu.WebPage("Setting the Defaults","default.html","default")
>>>subMenu.Add(WebMenu.WebPage("Adding Pages and Menus","adding.html","adding")
>>>myMenu.Add(subMenu)

Once a submenu is added to another menu, adding pages to the submenu won't be added to the main menu structure. Now all that's left is to create the four remaining pages:

>>>myMenu.Add(WebMenu.WebPage("The WebPage Class","webpageclass.html","webpage")
>>>myMenu.Add(WebMenu.WebPage("The WebMenu Class","webmenuclass.html","webmenu")
>>>myMenu.Add(WebMenu.WebPage("Using XML to define a Web Menu object","xml.html","xml")
>>>myMenu.Add(WebMenu.WebPage("Questions about WebMenu","questions.html","qna")

That's it for the menu to this site. I will use this menu as an example in the rest of this minisite.

Back to my code page Back to my home page ©2003 english@spiritone.com