Home > Articles > Open Source > Python

  • Print
  • + Share This
This chapter is from the book

19.5 Widget Browser

The Widget Browser is one of the most useful tools in the TurboGears Toolbox. We mentioned it in Chapter 16, "TurboGears Widgets: Bringing CSS, XHTML, and JavaScript Together in Reusable Components;" let's take a little bit more time to look at it in depth here. The Widget Browser makes use of a special feature of setuptools, which allows eggs to define an entry-point. Every widget package in the Cog Bin (www.turbogears.org/cogbin) has a specially-defined entry point. This allows the Widget Browser to dynamically grab information for every widget you have installed. The information is always up-to-date, and everything works.

There is one exception to this rule. Some third-party widgets do not define a widget description class and will not show up in the Widget Browser. If you're wondering what a widget description does, it isn't at all complicated. It defines a default instantiation of the widget, which is used to display the widget in the Toolbox.

As you can see in Figure 19.9, each widget is displayed with five tabs:

  • A sample of what the widget looks like in use
  • A description of the Widget (taken from the widget's docstring)
  • A listing of the widget's source code, which is invaluable when you want to know exactly how something is done
  • A listing of each of the widget's parameters and a brief description of what that parameter is for, which is taken from a params_doc dictionary in the widget itself so the description will always be up-to-date
  • A listing of that particular widget's template code that can be cut and pasted by using the "view plain" link, allowing you to customize the way the widget is displayed
Figure 19.9

Figure 19.9 Widget Browser

  • + Share This
  • 🔖 Save To Your Account