Created
February 10, 2011 17:02
-
-
Save cstrap/820889 to your computer and use it in GitHub Desktop.
Command line QrCode creation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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