I have played with doing this several different ways, but to no avail.
Currently I have a function:
def qrret():
rows = db().select(db.geo_item.f_name,db.geo_item.f_qrcode, orderby=db.
geo_item.f_name)
rows2 = db().select(db.geo_collection.f_name, db.geo_collection.f_qrcode
, orderby=db.geo_collection.f_name)
items=[]
colls=[]
for row in rows:
items += [
OPTION(row.f_name, _value=row.f_qrcode)
]
for row in rows2:
colls += [
OPTION(row.f_name, _value=row.f_qrcode)
]
fields = [DIV(H4("Items"), SELECT(items, _name=items, _multiple=True,_size
=10), _class="span6"),
DIV(H4("Collections"), SELECT(colls, _name=colls, _multiple=True,_size
=10), _class="span6"), BR(),
DIV(INPUT(_type='submit'), _style="margin-top: 20px", _class=
"span12")]
form=FORM(fields, onvalidation=qrparse)
return dict(form=form)
This function returns the form as I need it in the view. The onvalidation
function 'qrparse' is:
def qrparse(form):
codes = form.vars.items
codes += form.vars.colls
images = qrmake(codes)
return images
Which in turn calls:
def qrmake(codes):
images = []
background = Image.new('RGBA', (1275,1650), (255, 255, 255, 255))
margin = 150
bg_w,bg_h=background.size
offset_left = margin
offset_down = margin
rowend = bg_w - margin
pageend = bg_h - margin
for i in xrange(len(codes)):
code = codes[i]
try:
img = Image.open(request.folder + 'uploads/' + code)
except:
continue
img.thumbnail((300, 300), Image.ANTIALIAS)
img_w,img_h=img.size
pasted = False
while pasted == False:
if offset_left + img_w > rowend:
offset_down += img_h
offset_left = margin
elif offset_down + img_h > pageend:
images += background
images += qrmake(codes[i:])
return images
else:
background.paste(img,(offset_left,offset_down))
pasted = True
images += background
return images
What I need to happen though is to display the images that I generated in
the validation. I have played with doing this several different ways, but
nothing has worked so far. Am I approaching this the wrong way or is there
something I am missing?
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.