Core WD in Widget Browser

0 views
Skip to first unread message

.M.

unread,
Jul 23, 2006, 9:16:35 AM7/23/06
to TurboGears
No doubt this will be incredibly obvious in hindsight but how do you
actually use the Widget Browser source code in your apps? It's not
clear how to define the CoreWD argument.

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.

.M.

unread,
Jul 25, 2006, 7:16:16 PM7/25/06
to TurboGears
Still can't work out Widgets and feeling very intelligent.

How does CoreWD relate to the example shown in the documentation?

http://trac.turbogears.org/turbogears/wiki/SimpleWidgetForm

Ian Wilson

unread,
Jul 25, 2006, 8:15:23 PM7/25/06
to turbo...@googlegroups.com
As far as I can tell that class exists just to allow Widget developers
a way of displaying code to declare their widget and the widget itself
on the Widget browser's page. You only use the line starting with
for_widget in your code. Its misleading.
-Ian

Roger Demetrescu

unread,
Jul 25, 2006, 8:16:20 PM7/25/06
to turbo...@googlegroups.com
Hi Michela,

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:
>

Jorge Vargas

unread,
Jul 26, 2006, 1:43:13 AM7/26/06
to turbo...@googlegroups.com
so far the best explanation I have seen :)

Roger Demetrescu

unread,
Jul 26, 2006, 8:37:43 AM7/26/06
to turbo...@googlegroups.com
Thanks Jorge... :)

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

Reply all
Reply to author
Forward
0 new messages