e.g.
class FileFieldDesc(CoreWD):
^^^^^^^^^
name = "File Field"
for_widget = FileField("your_filefield", attrs=dict(size="30"))
as used in all the Source Code examples in the Toolbox. There's no
mention of this in any of the tutorials or group posts.
A simple example implementing the above would be fab.
Thanks
.M.
How does CoreWD relate to the example shown in the documentation?
WidgetDescription is a class designed to show your widget in Toolbox
Widget Browser.
So, if you are creating a widget called "IncredibleCode", you'll
probably want to show it creating a :
class IncredibleCodeDesc(WidgetDescription):
name = "My Incredible Code widget"
for_widget = IncredibleCode(.... you data here...)
Why should you use WidgetDescription when in TG's source code there
are lot os CoreWD ? - you may ask
The reason is that Widget Browser always show the widget class name.
Now suppose CheckBoxDesc was a direct subclass of WidgetDescription:
how would be shown CheckBox's class name ? It would show it as
turbogears.widgets.forms.Checkbox .
But we don't want this "forms" submodule to appear. All "core" widgets
can be used by your project simply doing a "from turbogears.widgets
import *"
That is the reason we have CoreWD... it overrides the
_get_full_class_name() method and ensures all classes are shown as
"turbogears.widgets.WIDGET_BEEN_DEMOSTRADED" ...
So, unless you are coding a core widget, to be included in Turbogears
main code, forget using CoreWD... You should you WidgetDescription
directly.
Now, understand that you don't need to write a WidgetDescription
unless you want your widget to appear in WidgetBrowser... but usually
it is cool to see you own widget in the browser... :)
I hope I could help you...
Cheers,
Roger
On 7/25/06, .M. <mic...@thequality.com> wrote:
>
Too bad it has a lot of words misspelling.. I was in a hurry yesterday
and forgot to use Google's Check spelling... :(
Cheers,
Roger