[Zope3-Users] Custom Image Widget
Adam Summers
adam at 4js.com.au
Mon Dec 11 12:15:54 EST 2006
Hi,
I have the following widgets.
class MyImageDisplayWidget(DisplayWidget):
class_ = Image
def __call__(self):
mycontent = u"oops! no img"
if self._renderedValueSet():
mycontent = "<img src=\"data:image/gif;base64, " +
b64encode(self._data.data) + " \" />"
return mycontent
MyImageListDisplayWidget = CustomWidgetFactory(SequenceDisplayWidget,
subwidget = MyImageDisplayWidget)
class MyImageWidget(FileWidget):
class_ = Image
def _toFieldValue(self, input):
value = super(MyImageWidget, self)._toFieldValue(input)
return self.class_(value)
MyImageListWidget = CustomWidgetFactory(ListSequenceWidget, subwidget =
MyImageWidget)
I want to build a better input widget (MyImageWidget), so that we can do
the following:
* If the field has no data, display a file input.
* If the field has data, display the image.
I know that there are design shortcomings in this, but I need a simple
example (and I only use the files in lists anyway, so I can delete images).
Any pointers on how to go about this would be much appreciated; as always
Thanks and Regards,
Adam
More information about the Zope3-users
mailing list