Skip to content

Instantly share code, notes, and snippets.

@cstrap
Created February 10, 2011 17:02
Show Gist options
  • Save cstrap/820889 to your computer and use it in GitHub Desktop.
Save cstrap/820889 to your computer and use it in GitHub Desktop.
Command line QrCode creation
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
from pygooglechart import QRChart
class QrCodeCreator(object):
def __init__(self):
self.parser = argparse.ArgumentParser(description='QrCode Creation')
self.parser.add_argument('-t', '--text', type=str,
help='Text for QrCode')
self.parser.add_argument('-f', '--filename', type=str,
help='Set the filename [optional]', default="qrcode")
def _create_qrcode(self):
qr = QRChart(250, 250)
qr.add_data(self.args.text)
qr.set_ec("H",0)
qr.download("%s.png" % self.args.filename)
def parse_args(self):
self.args = self.parser.parse_args()
self._create_qrcode()
if __name__ == '__main__' :
qr = QrCodeCreator()
qr.parse_args()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment