Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install zw.widget

How to install zw.widget

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install zw.widget
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.1.6.2 Failed View build log
Windows (64-bit)
0.1.6.2 Failed View build log
Mac OS X (10.5+)
0.1.6.2 Available View build log
Linux (32-bit)
0.1.6.2 Available View build log
Linux (64-bit)
0.1.6.2 Available View build log
 
Author
License
GPLv3
Lastest release
version 0.1.6.2 on Jan 5th, 2011

Zaehlwerk Widgets

Some widgets for the z3c.form framework.

  • Color widget
  • Email widget
  • Lines widget
  • TinyMCE widget

ColorWidget

The widget can render an input field with color preview:

>>> from zope.interface.verify import verifyClass
>>> from z3c.form.interfaces import IWidget
>>> from zw.widget.color.widget import ColorWidget

The ColorWidget is a widget:

>>> verifyClass(IWidget, ColorWidget)

System Message: ERROR/3 (<string>, line 26)

Inconsistent literal block quoting.

True

The widget can render a input field only by adapting a request:

>>> from z3c.form.testing import TestRequest
>>> request = TestRequest()
>>> widget = ColorWidget(request)

Such a field provides IWidget:

>>> IWidget.providedBy(widget)

System Message: ERROR/3 (<string>, line 37)

Inconsistent literal block quoting.

True

We also need to register the template for at least the widget and request:

>>> import os.path
>>> import zope.interface
>>> from zope.publisher.interfaces.browser import IDefaultBrowserLayer
>>> from zope.pagetemplate.interfaces import IPageTemplate
>>> import zw.widget.color
>>> import z3c.form.widget
>>> template = os.path.join(os.path.dirname(zw.widget.color.__file__),

System Message: ERROR/3 (<string>, line 49)

Inconsistent literal block quoting.

... 'color_input.pt') >>> factory = z3c.form.widget.WidgetTemplateFactory(template) >>> zope.component.provideAdapter(factory, ... (zope.interface.Interface, IDefaultBrowserLayer, None, None, None), ... IPageTemplate, name='input')

If we render the widget we get the HTML:

>>> print widget.render()

System Message: ERROR/3 (<string>, line 58)

Inconsistent literal block quoting.

<input type="text" class="color-widget" value="" />

Adding some more attributes to the widget will make it display more:

>>> widget.id = 'id'
>>> widget.name = 'name'
>>> widget.value = u'value'
>>> print widget.render()
<span id="" class="color-widget color-sample"
style="background-color: #value;">
</span>
<input type="text" id="id" name="name" class="color-widget"
value="value" />

EmailWidget

The widget can render an ordinary input field:

>>> from zope.interface.verify import verifyClass
>>> from z3c.form.interfaces import IWidget, INPUT_MODE, DISPLAY_MODE
>>> from zw.widget.email.widget import EmailWidget

The EmailWidget is a widget:

>>> verifyClass(IWidget, EmailWidget)

System Message: ERROR/3 (<string>, line 88)

Inconsistent literal block quoting.

True

The widget can render a input field only by adapting a request:

>>> from z3c.form.testing import TestRequest
>>> request = TestRequest()
>>> widget = EmailWidget(request)

Such a field provides IWidget:

>>> IWidget.providedBy(widget)

System Message: ERROR/3 (<string>, line 99)

Inconsistent literal block quoting.

True

We also need to register the template for at least the widget and request:

>>> import os.path
>>> import zope.interface
>>> from zope.publisher.interfaces.browser import IDefaultBrowserLayer
>>> from zope.pagetemplate.interfaces import IPageTemplate
>>> import zw.widget.email
>>> import z3c.form.widget
>>> template = os.path.join(os.path.dirname(zw.widget.email.__file__),

System Message: ERROR/3 (<string>, line 111)

Inconsistent literal block quoting.

... 'email_input.pt') >>> factory = z3c.form.widget.WidgetTemplateFactory(template) >>> zope.component.provideAdapter(factory, ... (zope.interface.Interface, IDefaultBrowserLayer, None, None, None), ... IPageTemplate, name='input')

If we render the widget we get the HTML:

>>> print widget.render()

System Message: ERROR/3 (<string>, line 120)

Inconsistent literal block quoting.

<input type="text" class="email-widget" value="" />

Adding some more attributes to the widget will make it display more:

>>> widget.id = 'id'
>>> widget.name = 'name'
>>> widget.value = u'name@domain.tld'
>>> print widget.render()
<input type="text" id="id" name="name" class="email-widget"
value="name@domain.tld" />

More interesting is to the display view:

>>> widget.mode = DISPLAY_MODE
>>> template = os.path.join(os.path.dirname(zw.widget.email.__file__),

System Message: ERROR/3 (<string>, line 136)

Inconsistent literal block quoting.

... 'email_display.pt') >>> factory = z3c.form.widget.WidgetTemplateFactory(template) >>> zope.component.provideAdapter(factory, ... (zope.interface.Interface, IDefaultBrowserLayer, None, None, None), ... IPageTemplate, name='display') >>> print widget.render() <span id="id" class="email-widget"> <a href="mailto:name@domain.tld"> name@domain.tld </a> </span>

But if we are not authenticated it should be obscured:

>>> widget.obscured = True
>>> print widget.render()
<span id="id" class="email-widget">
name@domain.tld
</span>

LinesWidget

The widget can render a HTML text input field, which collects list items by line.

>>> from zope.interface.verify import verifyClass
>>> from z3c.form.interfaces import IWidget
>>> from zw.widget.lines.widget import LinesWidget

The LinesWidget is a widget:

>>> verifyClass(IWidget, LinesWidget)
True

The widget can render a textarea field only by adapteing a request:

>>> from z3c.form.testing import TestRequest
>>> request = TestRequest()
>>> widget = LinesWidget(request)

Such a field provides IWidget:

>>> IWidget.providedBy(widget)
True

We also need to register the template for at least the widget and request:

>>> import os.path
>>> import zope.interface
>>> from zope.publisher.interfaces.browser import IDefaultBrowserLayer
>>> from zope.pagetemplate.interfaces import IPageTemplate
>>> import zw.widget.lines
>>> import z3c.form.widget
>>> template = os.path.join(os.path.dirname(zw.widget.lines.__file__),
...   'lines_input.pt')
>>> factory = z3c.form.widget.WidgetTemplateFactory(template)
>>> zope.component.provideAdapter(factory,
...     (zope.interface.Interface, IDefaultBrowserLayer, None, None, None),
...       IPageTemplate, name='input')

If we render the widget we get the HTML:

>>> print widget.render()
<textarea class="lines-widget"></textarea>

Adding some more attributes to the widget will make it display more:

>>> widget.id = 'id'
>>> widget.name = 'name'
>>> widget.value = u'value'
>>> print widget.render()
<textarea id="id" name="name" class="lines-widget">value</textarea>

TinyWidget

The widget can render a HTML text input field based on the TinyMCE JavaScript Content Editor from Moxicode Systems

..http://tinymce.moxiecode.com

>>> from zope.interface.verify import verifyClass
>>> from zope.app.form.interfaces import IInputWidget
>>> from z3c.form.interfaces import IWidget
>>> from zw.widget.tiny.widget import TinyWidget

The TinyWidget is a widget:

>>> verifyClass(IWidget, TinyWidget)
True

The widget can render a textarea field only by adapteing a request:

>>> from z3c.form.testing import TestRequest
>>> request = TestRequest()
>>> widget = TinyWidget(request)

Such a field provides IWidget:

>>> IWidget.providedBy(widget)
True

We also need to register the template for at least the widget and request:

>>> import os.path
>>> import zope.interface
>>> from zope.publisher.interfaces.browser import IDefaultBrowserLayer
>>> from zope.pagetemplate.interfaces import IPageTemplate
>>> import zw.widget.tiny
>>> import z3c.form.widget
>>> template = os.path.join(os.path.dirname(zw.widget.tiny.__file__),
...   'tiny_input.pt')
>>> factory = z3c.form.widget.WidgetTemplateFactory(template)
>>> zope.component.provideAdapter(factory,
...     (zope.interface.Interface, IDefaultBrowserLayer, None, None, None),
...       IPageTemplate, name='input')

If we render the widget we get the HTML:

>>> print widget.render()
<textarea class="tiny-widget" cols="60" rows="10"></textarea>

Adding some more attributes to the widget will make it display more:

>>> widget.id = 'id'
>>> widget.name = 'name'
>>> widget.value = u'value'
>>> print widget.render()
<textarea id="id" name="name" class="tiny-widget" cols="60"
rows="10">value</textarea>

TODO: Testing for ECMAScript code...

CHANGES

Version 0.1.6.2 (2009-01-09)
  • Lines: converter should work only on LinesWidget
Version 0.1.6.1 (2008-12-28)
  • packaging problem in setup.py
Version 0.1.6 (2008-12-28)
  • tinyMCE update (3.2.1.1)
  • tinyMCE is not included in the sources but downloaded.
  • z3c.autoinclude dependency removed
Version 0.1.5 (2008-11-18)
  • tinyMCE update (3.2.1)
Version 0.1.4 (2008-06-08)
  • tinyMCE update (3.0.9)
Version 0.1.3 (2008-06-08)
  • tinyMCE bug fix for gecko based browsers
Version 0.1.2 (2008-04-13)
  • email widget for z3c.schema.email added.
Version 0.1 (2008-02-17)
  • Initial release

Subscribe to package updates

Last updated Jan 5th, 2011

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.