-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
95 lines (81 loc) · 3.74 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import json
import os
import locale
from UI.gui import App
from sticker.stickers import Stickers
from sticker.sticker_data import StickerDataNumber, StickerDataText, StickerDataDate, StickerDataList
from sticker.sticker_type import StickerType
def empty_tmp():
"""
Empty the tmp folder
:return: None
"""
for file in os.scandir(os.getcwd() + "\\tmp"):
os.remove(file.path)
def set_locale():
"""
Set the locale time to the system's locale time
:return: None
"""
locale.setlocale(locale.LC_TIME, '')
def get_stickers():
"""
Get the stickers from the data.json file and create the Stickers object
:return: The Stickers object
"""
data = json.load(open('model/data.json', encoding='utf-8-sig'))
stickers = Stickers()
for sticker in data:
datas = []
for data in sticker['data']:
if data['type'] == 'number':
datas.append(StickerDataNumber(data['name'],
inlineprefix=data['inline_prefix'],
inlinesuffix=data['inline_suffix'],
blockprefix=data['block_prefix'],
blocksuffix=data['block_suffix'],
font=data['font'],
prefixfont=data['prefix_font'],
suffixfont=data['suffix_font']))
elif data['type'] == 'text':
datas.append(StickerDataText(data['name'],
inlineprefix=data['inline_prefix'],
inlinesuffix=data['inline_suffix'],
blockprefix=data['block_prefix'],
blocksuffix=data['block_suffix'],
font=data['font'],
prefixfont=data['prefix_font'],
suffixfont=data['suffix_font']))
elif data['type'] == 'date':
datas.append(StickerDataDate(data['name'],
inlineprefix=data['inline_prefix'],
inlinesuffix=data['inline_suffix'],
blockprefix=data['block_prefix'],
blocksuffix=data['block_suffix'],
font=data['font'],
prefixfont=data['prefix_font'],
suffixfont=data['suffix_font']))
elif data['type'] == 'list':
datas.append(StickerDataList(data['name'],
data['values'],
inlineprefix=data['inline_prefix'],
inlinesuffix=data['inline_suffix'],
blockprefix=data['block_prefix'],
blocksuffix=data['block_suffix'],
font=data['font'],
prefixfont=data['prefix_font'],
suffixfont=data['suffix_font']))
stickers.add_sticker(StickerType(sticker['name'], datas, align=sticker['align']))
return stickers
def main():
"""
Main function
:return: None
"""
set_locale()
empty_tmp()
stickers = get_stickers()
app = App(stickers)
app.mainloop()
if __name__ == "__main__":
main()