Install Toscawidgets for Pylons

Well I'll have to go through my notes. The middleware setup is the tricky part but only needs to be done once per app. There are two setups:

  1. A Getting Started version
  2. And An Alternative 'Mako' Setup version

Currently I'm using the latter which is probably dumb since I don't use any Mako at all. Not sure about the usage of global variable like c so I'll leave this for later testing.

TinyMCE

Install it

easy_install twTinyMCE

Use it

In your controller code:

from toscawidgets.widgets.tinymce import TinyMCE

## ....

c.w=WidgetBunch()
c.w.tmce=TinyMCE(id='tmcew',
            label = _('Long Description'),
            name = 'richer_text')

In your Template:

${c.w.tmce.display(c.Description)}

Tabber

There are two ways to use the tabber widget.

Use Without Installing

Tabber comes originally from http://www.barelyfitz.com/projects/tabber/. It consists basically of two files, one is a css file with all of the style stuff (you should edit to color coordiante with your site) and the other is a javascript file that handles the tabbing stuff.

This is a simple widget and if you follow the creators page you can use it without having a widget. The creation of the widget ensures that the .js and .css files are added to the rendered html.

Using the twTabber widget (see below) only ensures that these two files are added to the header. Since the template you are writing had to include the class=tabber attributes, you can easily add the include files to the header yourself. It may even make more sense to require the code change to the template rather than to the controller (MVC and all of that). Otherwise you may be including a WidgetBunch? (c.w) when it is not otherwise required.

Install and use

Install it

Does not (as of this writing) appear to be available in the Cheeseshop but is available from the Turbogears Trac site. See:

http://trac.turbogears.org/browser/projects/twTabber/trunk

You can install it from the svn source:

svn co http://svn.turbogears.org/projects/twTabber/trunk  twTabber
cd twTabber
python setup.py install

In your controller code:

from toscawidgets.widgets.tabber import Tabber 

## ....

c.w=WidgetBunch()
c.w.tabber = Tabber()

In your Template

Whether you have chosen to install twTabber or [Use Without Installing] your basic template usage looks the same:

<div class="tabber">                                                                                   
<div class="tabbertab">                                                                                
<h2>Income Statement</h2>                                                                              
this is Income                                                                                         
</div>                                                                                                 
<div class="tabbertab">                                                                                
<h2>Balance Sheet</h2>                                                                                 
this is in balance                                                                                     
</div>                                                                                                 
<div class="tabbertab">                                                                                
<h2>Statement of Cash Flows</h2>                                                                       
this is Cash Flow stuff                                                                                
</div>                                                                                                 
</div>