Advertisement
webbersof

QR program

Feb 13th, 2022
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.02 KB | None | 0 0
  1. import pyqrcode
  2. import time
  3. from pyzbar.pyzbar import decode
  4. from PIL import Image
  5. if __name__ == '__main__':
  6.  
  7.     while 1:
  8.         print('What do you want to do:\n1 - Generate QR Code\n2 - Scan QR Code')
  9.         sa = int(input('Enter your choice: '))
  10.  
  11.         if sa == 1:
  12.             sen = input('Enter text or URL address: ')
  13.             qr = pyqrcode.create(sen)
  14.             file = input('Give a title to your QR code: ')
  15.             qr.png(f'{file}.png', scale=8)
  16.             time.sleep(2)
  17.             print('Successfully generated...')
  18.  
  19.         elif sa == 2:
  20.             say = input('Which file do you want to Scan: ')
  21.             a = decode(Image.open(f'{say}.png'))
  22.             print('Scanning...')
  23.             time.sleep(2)
  24.             print(f'\n Text Scanned: {a[0][0]}')
  25.  
  26.         else:
  27.             print('Warning! Wrong choice... Please try again!\n')
  28.  
  29.         command = input('Do you want to continue - [Y/N]: ').lower()
  30.         if command == 'y':
  31.             continue
  32.         else:
  33.             exit()
  34.  
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement