Skip to content
This repository has been archived by the owner on Dec 17, 2020. It is now read-only.

Commit

Permalink
- Feature: Added an image button to the widgets demo.
Browse files Browse the repository at this point in the history
  • Loading branch information
strichter committed Oct 3, 2007
1 parent 60258d8 commit 37a7f96
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Expand Up @@ -5,6 +5,8 @@ CHANGES
Version 1.5.0 (9/??/2007)
-------------------------

- Feature: Added an image button to the widgets demo.

- Feature: Added a single checkbox widget for a boolean to the "all widgets"
demo.

Expand Down
9 changes: 7 additions & 2 deletions buildout.cfg
@@ -1,6 +1,6 @@
[buildout]
develop = .
parts = demo test coverage
develop = . ../z3c.form ../z3c.formui
parts = demo test coverage eggdeps

[test]
recipe = zc.recipe.testrunner
Expand All @@ -10,6 +10,11 @@ eggs = z3c.formdemo [app, test]
recipe = zc.recipe.egg
eggs = z3c.coverage

[eggdeps]
recipe = zc.recipe.egg
eggs = gtkeggdeps
z3c.formdemo [app, test]

[zope3]
location = .

Expand Down
22 changes: 22 additions & 0 deletions src/z3c/formdemo/i18n.py
@@ -0,0 +1,22 @@
##############################################################################
#
# Copyright (c) 2007 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""I18n message factory z3c.formdemo
$Id$
"""
__docformat__ = "reStructuredText"

import zope.i18nmessageid

MessageFactory = zope.i18nmessageid.MessageFactory('z3c.formdemo')
14 changes: 10 additions & 4 deletions src/z3c/formdemo/widgets/README.txt
Expand Up @@ -47,7 +47,7 @@ form:
>>> user.getControl('Date/Time').value = u'7/1/07 12:15 AM'
>>> user.getControl('Decimal').value = u'12439.986'
>>> user.getControl('Dotted Name').value += u'demo'
>>> user.getControl('Float').value += u'12439.986'
>>> user.getControl('Float').value = u'12439.986'
>>> user.getControl('Frozen Set').getControl('One').click()
>>> user.getControl('Id').value += u'demo'
>>> user.getControl('Integer').value = u'12439'
Expand Down Expand Up @@ -77,7 +77,7 @@ Let's now ensure that the data has been truly uploaded:
>>> fields = interfaces.IAllFields(getRootFolder())

>>> fields.asciiField
'This is\n ASCII. Add on.'
'This is\r\n ASCII. Add on.'
>>> fields.asciiLineField
'An ASCII line. Add on.'
>>> fields.boolField
Expand All @@ -101,7 +101,7 @@ Let's now ensure that the data has been truly uploaded:
>>> fields.dottedNameField
'z3c.formdemo'
>>> fields.floatField
12.811999999999999
12439.986000000001
>>> fields.frozenSetField
frozenset([3])
>>> fields.idField
Expand All @@ -117,7 +117,7 @@ Let's now ensure that the data has been truly uploaded:
>>> fields.sourceTextField
u'<source /> Add on.'
>>> fields.textField
u'Some\n Text. Add on.'
u'Some\r\n Text. Add on.'
>>> fields.textLineField
u'Some Text line. Add on.'
>>> fields.timeField
Expand All @@ -130,3 +130,9 @@ Let's now ensure that the data has been truly uploaded:
'http://zope.org/Documentation'
>>> fields.hiddenField
u'Some Hidden Text. Add on.'

We also have an image button, that can be clicked:

>>> user.getControl(name='form.buttons.pressme').click()
>>> testing.printElement(user, "//div[@class='summary']")
<div class="summary">Press me was clicked!</div>
15 changes: 13 additions & 2 deletions src/z3c/formdemo/widgets/browser.py
Expand Up @@ -28,7 +28,7 @@
from zope.app.session.interfaces import ISession

from z3c.form.interfaces import IWidgets
from z3c.form import form, field
from z3c.form import button, form, field
from z3c.form.browser import checkbox
from z3c.form.interfaces import HIDDEN_MODE
from z3c.formdemo.widgets import interfaces
Expand Down Expand Up @@ -79,12 +79,23 @@ class AllFields(persistent.Persistent):

class AllFieldsForm(form.EditForm):
"""A form showing all fields."""
form.extends(form.EditForm)
fields = field.Fields(interfaces.IAllFields).omit(
'dictField', 'objectField')
fields['checkboxBoolField'].widgetFactory = \
checkbox.SingleCheckBoxFieldWidget
checkbox.SingleCheckBoxFieldWidget

buttons = form.EditForm.buttons + \
button.Buttons(
button.ImageButton(name='pressme', image=u'pressme.png')
)

label = 'Widgets Demo'

@button.handler(buttons['pressme'])
def handlePressMe(self, action):
self.status = u'Press me was clicked!'

def getContent(self):
return interfaces.IAllFields(self.context)

Expand Down
7 changes: 7 additions & 0 deletions src/z3c/formdemo/widgets/configure.zcml
@@ -1,8 +1,15 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:z3c="http://namespaces.zope.org/z3c"
i18n_domain="z3c.formdemo">

<browser:resource
name="pressme.png"
file="pressme.png"
layer="z3c.formdemo.layer.IDemoBrowserLayer"
/>

<z3c:pagelet
name="widgets.html"
for="*"
Expand Down
Binary file added src/z3c/formdemo/widgets/pressme.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 37a7f96

Please sign in to comment.