I test this one, looks it work but i don’t know where is the result and how to save it
import qrcode
import qrcode.image.svg
if method == 'basic':
# Simple factory, just a set of rects.
factory = qrcode.image.svg.SvgImage
elif method == 'fragment':
# Fragment factory (also just a set of rects)
factory = qrcode.image.svg.SvgFragmentImage
else:
# Combined path factory, fixes white space that may occur when zooming
factory = qrcode.image.svg.SvgPathImage
img = qrcode.make('Some data here', image_factory=factory)
Did you download the pymaging library to create the images? It says it is pure python and 2.7 compatible so it might work in GH.
import os
print os.getcwd()
should tell you where python is working - maybe it is there …?
Also it includes a template for making your own factory - it looks as though it would be quite easy to implement a Rhino template to draw squares in Rhino representing your QR code !
Hi @seghierkhaled .
I would like to use the qrcode module in GHPython and RhinoPython, but when I try to import qrcode, I get an import error. how can I use qrcode in GHpython?
Sorry, I had to read it properly again. However, I couldn’t figure out why the first line of the import shows invalid syntax.
Where is the qrcode module installed? I’m sorry that this is a fundamental question.
Thanks for your help!
You should put the qrcode module in your scripts folder. For Rhino 7 on Windows this should be %HOMEPATH%\AppData\Roaming\McNeel\Rhinoceros\7.0\scripts
You should have a folder called qrcode in there containing files like this:
and this file : rhino_image.py (1.5 KB) in the image directory
Did you download version 7 from Pypi ? It looks like they have gone Python 3 only - you may need to download and unpack the tar package from here qrcode · PyPI
If I remember correctly, Six should be a Python module that attempts to render scripts written in Python 2.7 and 3.x+ better compatible. The entire module should be contained within a single Python file. As long as you copy it to a directory that Rhino loads by default or even to your own project/module, you should be able to import from it. You can get it on GitHub.
I have incompatible libraries - I am stuck on 3.8 for the new day job, but at least I have f-strings and type annotations. Looking forward to structural pattern matching in 3.10 if I ever get there !!!