Skip to content

Commit

Permalink
qrcode's size default 400*400
Browse files Browse the repository at this point in the history
  • Loading branch information
imwr committed Sep 6, 2016
1 parent ea4bb48 commit b1a3658
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ A qrcode generator plugin for [wox][1]

## Features
* Support preview and save qrcode image
* Generater custom size/path/filename qrcode
* Generate custom size/path/filename qrcode

## Usage
* Install [wox][1] on windows, and launch it(press `Alt+Space`):
* Input command `wpm install qrcode` to install this plugin
* Input `qr` key to active it

## Syntax
`qr content [-s size] [-p path] [-f filename] <size [path] [filename]>`
`qr content [-s size] [-p path] [-f filename] [size [path] [[filename]]]`

**【size】** qrcode'size, default 100px. Plugin will change size automatically to fit content'length.
**【size】** qrcode'size, default 400 * 400 px. Plugin will change size automatically to fit content'length.
**【path】** qrcode'path, default Users Desktop. If path is not absolute, qrcode will also be saved in Users Desktop.
**【filename】** qrcode'filename, default `qrcode.png`

Expand All @@ -22,8 +22,9 @@ A qrcode generator plugin for [wox][1]
- `qr test 100 C:\Users filename`
- `qr test -s 100 -p C:\Users -f filename.png`

If a parameter contains any spaces, you should use quote, like this:
`qr "this is my content" -p "D:\Program Files\qrcode" ...`
If a parameter contains any spaces, you should use quote, like this:

- `qr "this is my content" -p "D:\Program Files\qrcode" ...`

## Screenshot
![image](Images/screenshot.png)
Expand Down
26 changes: 17 additions & 9 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def query(self, query):
if not query:
result.append({
"Title": "Enter qrcode content",
"SubTitle": "content [-s size] [-p path] [-f filename] size [path] [filename]",
"SubTitle": "content [-s size] [-p path] [-f filename] [size [path] [[filename]]]",
"IcoPath": "Images/icon.png",
})
return result
Expand All @@ -19,8 +19,8 @@ def query(self, query):

if len(paramters) == 1: # only content
result.append({
"Title": "Generate content: " + paramters[0],
"SubTitle": "Press key 'Enter' to preview qrcode",
"Title": "Content: " + paramters[0],
"SubTitle": "Press 'Enter' to preview qrcode",
"IcoPath": "Images/icon.png",
"JsonRPCAction": {
"method": "generte_qrcode",
Expand All @@ -37,7 +37,7 @@ def query(self, query):
size = int(v)
except ValueError:
result.append({
"Title": "Generate content: " + paramters[0],
"Title": "Content: " + paramters[0],
"SubTitle": "Size error",
"IcoPath": "Images/icon.png"
})
Expand All @@ -54,11 +54,19 @@ def query(self, query):
size = int(paramters[1])
except ValueError:
result.append({
"Title": "Generate content: " + paramters[0],
"SubTitle": "Size error",
"Title": "Content: " + paramters[0],
"SubTitle": "Size invalid",
"IcoPath": "Images/icon.png"
})
return result
else:
if size < 20 or size > 1000:
result.append({
"Title": "Content: " + paramters[0],
"SubTitle": "Size too small or big",
"IcoPath": "Images/icon.png"
})
return result
if len(paramters) > 2:
filepath = paramters[2]
if len(paramters) > 3:
Expand All @@ -67,8 +75,8 @@ def query(self, query):
filepath = self.get_path(filepath)
filename = self.get_file(filename)
result.append({
"Title": "Generate content: " + paramters[0],
"SubTitle": "Press key 'Enter' to save image*{} in {}".format(size, filepath + filename),
"Title": "Content: " + paramters[0],
"SubTitle": "Press 'Enter' to save {}*image in {}".format(size, filepath + filename),
"IcoPath": "Images/icon.png",
"JsonRPCAction": {
"method": "generte_qrcode",
Expand Down Expand Up @@ -100,7 +108,7 @@ def generte_qrcode(self, *arg):
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=((arg[1] / 20 - arg[1] / 100) if len(arg) > 1 else 8),
box_size=((arg[1] / 20 - arg[1] / 100) if len(arg) > 1 else 16),
border=2,
)
qr.add_data(arg[0])
Expand Down
4 changes: 2 additions & 2 deletions plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"ID":"c662afd496e248e1aba2d22ff5cbc71a",
"ActionKeyword":"qr",
"Name":"Qrcode",
"Description":"a qrcode generator",
"Description":"a qrcode generator 二维码生成器",
"Author":"imwr",
"Version":"1.0.0",
"Version":"1.0.2",
"Language":"python",
"Website":"http://github.com/imwr/Wox.Plugin.Qrcode",
"ExecuteFileName":"main.py",
Expand Down

0 comments on commit b1a3658

Please sign in to comment.