Skip to content

Commit 7688826

Browse files
committed
提交代码
1 parent 3e2b36e commit 7688826

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

xianhuan/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Python技术 公众号文章代码库
1010

1111
## 实例代码
1212

13+
[丢弃Tkinter,这款GUI神器值得拥有!](https://github.com/JustDoPython/python-examples/tree/master/xianhuan/gooey):丢弃Tkinter,这款GUI神器值得拥有!
14+
1315
[知乎热门:如何提高爬虫速度?](https://github.com/JustDoPython/python-examples/tree/master/xianhuan/spiderspeed):知乎热门:如何提高爬虫速度?
1416

1517
[Python异常还能写得如此优雅!](https://github.com/JustDoPython/python-examples/tree/master/xianhuan/retry):Python异常还能写得如此优雅!

xianhuan/gooey/gooeydemo.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
"""
4+
@author: 闲欢
5+
"""
6+
from gooey import Gooey, GooeyParser
7+
8+
9+
@Gooey(
10+
richtext_controls=True, # 打开终端对颜色支持
11+
program_name="MQTT连接订阅小工具", # 程序名称
12+
encoding="utf-8", # 设置编码格式,打包的时候遇到问题
13+
progress_regex=r"^progress: (\d+)%$" # 正则,用于模式化运行时进度信息
14+
)
15+
def main():
16+
settings_msg = 'MQTT device activation information subscription'
17+
parser = GooeyParser(description=settings_msg)
18+
19+
subs = parser.add_subparsers(help='commands', dest='command')
20+
21+
my_parser = subs.add_parser('MQTT消息订阅')
22+
my_parser.add_argument("connect", metavar='运行环境',help="请选择开发环境",choices=['dev环境','staging环境'], default='dev环境')
23+
my_parser.add_argument("device_type",metavar='设备类型',help="请选择设备类型",choices=['H1','H3'],default='H1')
24+
my_parser.add_argument("serialNumber", metavar='设备SN号',default='LKVC19060047',help='多个请用逗号或空格隔开')
25+
26+
siege_parser = subs.add_parser('进度条控制')
27+
siege_parser.add_argument('num',help='请输入数字',default=100)
28+
29+
args = parser.parse_args()
30+
print(args, flush=True) # flush=True在打包的时候会用到
31+
32+
33+
if __name__ == '__main__':
34+
main()

0 commit comments

Comments
 (0)