qrcode

563 views
Skip to first unread message

Fabiano Almeida

unread,
Oct 13, 2015, 5:05:23 PM10/13/15
to web...@googlegroups.com
Hi all!

How to dynamically generate qr code in web2py?

grateful,


Fabiano
.

Niphlod

unread,
Oct 13, 2015, 5:20:08 PM10/13/15
to web2py-users
with any qrcode library or qrcode ondemand service out there ? What did you try ?

黄祥

unread,
Oct 13, 2015, 5:28:17 PM10/13/15
to web2py-users
i think there is web2py appliances that create some thing like this before : semanticwebexample

best regards,
stifan

Richard Vézina

unread,
Oct 13, 2015, 8:07:39 PM10/13/15
to web2py-users
You can have a look on the side of elaphe : https://bitbucket.org/whosaysni/elaphe/

For most type of code it works... But there were issue with bouding box for some of them in the pass, hope it has been solve since then...

Richard

--
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 web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael M

unread,
Oct 14, 2015, 12:05:17 PM10/14/15
to web2py-users
def qrpage():
    #Install Python Modules: (Pillow,qrcode)
    
    ToQRData = auth.user.username + ' Likes MLP:FIM'
    import qrcode
    import StringIO
    qr = qrcode.QRCode(
        version=1,
        error_correction=qrcode.constants.ERROR_CORRECT_L,
        box_size=10,
        border=1,
    )
    qr.add_data(ToQRData)
    qr.make(fit=True)

    # use an in-memory object to save
    output = StringIO.StringIO()
    img = qr.make_image()
    img.save(output)

    # and the use getvalue() method to get the string
    img_tag = '<img src="data:image/png;base64,%s">' % output.getvalue().encode('base64').replace('\n', '')
    return locals()

Fabiano Almeida

unread,
Oct 14, 2015, 1:57:23 PM10/14/15
to web...@googlegroups.com
Hi Niphlod,

I trying to generate qr code with built-in feature, for local use, mobile for reading.

thx

--

Fabiano Almeida

unread,
Oct 14, 2015, 1:57:52 PM10/14/15
to web...@googlegroups.com
Hi Stifan

I installed the semanticwebexample and not found reference to qr code on it.

thx

--

Fabiano Almeida

unread,
Oct 14, 2015, 1:59:00 PM10/14/15
to web...@googlegroups.com
Hi Richard,

elaphe worked! thank you!

How to show a text message with qrcode on same page?

Thx

Fabiano Almeida

unread,
Oct 14, 2015, 1:59:25 PM10/14/15
to web...@googlegroups.com
Hi Michael,

With your example, return this:

Qrpage

StringIO:<module 'StringIO' from '/usr/lib/python2.7/StringIO.pyc'>
ToQRData:Fabiano Likes MLP:FIM
img:<qrcode.image.pil.PilImage object at 0x7f02d1c0a9d0>
img_tag:<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQ4AAAEOAQAAAABQysQIAAAB0klEQVR4nO2aQY7cIBBFXwVLs4Qb5Cj4BjnT3MwcZQ4wEl6OBPpZgJ3OIhopTnpsC1YNfouvUulTRbWJT1b99hkBA/nD0rL/ksq29WU79eVMcq+HeElSgRSAmPsXSZKW08m9GlLNLAAxO5G+lx7iZGZP13JfpIVzfZFew1druR8Ss9MvZ/haLfdAJsAJqJBmh+E/jJgrRD1Zy/2QCVbbNv7dlH6AUninn/pTyb0Y0kuDtjLtQns806jIjiDJzMxCNbPgRDOKdcLmdcLms8m9FIIWX9CCE/iCFi9p8RIxu5G7xxCk7NQ6tKjSTIG4G8Xo1Y4gPVmVnVrX1nIXAC+N6B5C+uuC1B8WNlMAKTffOJPciyHNcrvv4lqZ0NK2Vw8jun+P9FutPY/5PbBbOTac4V8gyV5EfDPrnfA6tXMpn1HulZDWCZvN+6tuCtX6CqeTeyHksS/r5cJePeA0brWDSNqyFFYzYq6mhWrgCzafTe7VkH02EduAwsnm5hbP13JDZJtNpADgP1oW29xS+XRyL4u4/rqwsJVqr+NWO4BMj5t1KobPWBQQ36bnarkf8jibwGeIS52UDMDruVruh/w2m6D2YMcc6B/GbOIAYuO/OP8R+Qk7Fi5D47GUFwAAAABJRU5ErkJggg==">
output:<StringIO.StringIO instance at 0x7f02d1be67e8>
qr:<qrcode.main.QRCode instance at 0x7f02d1bf40e0>
qrcode:<module 'qrcode' from '/usr/local/lib/python2.7/dist-packages/qrcode-5.1-py2.7.egg/qrcode/__init__.pyc'>

How to show de picture + text message?

thx

--

Carlos Costa

unread,
Oct 14, 2015, 2:03:01 PM10/14/15
to web...@googlegroups.com

--
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 web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--


Carlos J. Costa
Cientista da Computação  | BS Computer Science
Esp. Gestão em Telecom   |
PgC Telecom Mangement
<º))><

Michael M

unread,
Oct 14, 2015, 3:00:51 PM10/14/15
to web2py-users
create a default/qrpage.html

insert this   {{=XML(img_tag)}}

Fabiano Almeida

unread,
Oct 14, 2015, 3:11:25 PM10/14/15
to web...@googlegroups.com
Hi Michael,

2015-10-14 16:00 GMT-03:00 Michael M <prea...@gmail.com>:
{{=XML(img_tag)}}

It worked! Grateful for all!

Fabiano.

Michael M

unread,
Oct 14, 2015, 3:44:45 PM10/14/15
to web2py-users
Glad it worked for you!

I like the method that I found(just took three working pieces and pushed together) because no static files are generated using StringIO memory and encoding it with Base64.  (as far as I know)  ;)

isi_jca

unread,
Jul 23, 2016, 8:05:49 AM7/23/16
to web2py-users

Hi!!!.

When I try to print qrcode image to pdf using pyfpdf, I get the next error:

<type 'exceptions.RuntimeError'> FPDF error: Unsupported image type: pilimage object at 0x7f2e82f13a50>

Versión
web2py™ Version 2.14.5-stable+timestamp.2016.04.14.03.26.16
Python Python 2.7.6: /usr/bin/python (prefix: /usr)
 
Anyone have experience with this topic?

Regards.

Jorge Luis Hernández Dueñas

unread,
Oct 12, 2018, 3:27:29 AM10/12/18
to web2py-users
Hi, I have the same error, I try to save a qr image and I have tried it in many ways but it keeps giving me error. Please, if you solved it, it would be very helpful for me.

isi_jca

unread,
Oct 25, 2018, 5:07:00 PM10/25/18
to web2py-users
Reply all
Reply to author
Forward
0 new messages