Skip to content

Instantly share code, notes, and snippets.

@koutoftimer
Created February 16, 2019 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koutoftimer/6f7beeaed830e706d48e8e1e9a91a0d4 to your computer and use it in GitHub Desktop.
Save koutoftimer/6f7beeaed830e706d48e8e1e9a91a0d4 to your computer and use it in GitHub Desktop.
Clipboard to QR code

Generates QR code from clipboard as PNG image and displays in default viewer. Usefull if you want to open link on you smartphone.

Installation

  • First of all you need to install python.
  • Then install dependencies python -m pip install -r requirements.txt.
  • Make qr.py easy to reach.
import os
import clipboard
import qrcode
from PIL import Image
BASE = os.path.dirname(__file__)
QR_FILE = os.path.join(BASE, 'qr.png')
if __name__ == '__main__':
link = clipboard.paste()
qr = qrcode.make(link)
with open(QR_FILE, 'wb') as f:
qr.save(f)
Image.open(QR_FILE).show()
clipboard==0.0.4
Pillow==5.4.1
qrcode==6.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment