-
Notifications
You must be signed in to change notification settings - Fork 9
/
pytouch3.py
61 lines (47 loc) · 1.91 KB
/
pytouch3.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
import asyncio
import logging
import sys
import os.path as path
from PyQt6.QtWidgets import QApplication
from qasync import QEventLoop
from gui import EditorWindow
from margins import Margins
from printables.barcode import BarcodeData, Barcode
from printables.spacing import Spacing, SpacingData
from printables.text import TextData, Text as TextItem
from printables.image import ImageData, Image as ImageItem
from cli import get_parser, CliPrint
testdata = path.join(path.dirname(__file__) + '/testdata/')
if not sys.gettrace() is None:
logging.basicConfig(level=logging.DEBUG)
def run(seed=False):
app = QApplication(sys.argv)
editor = EditorWindow(app)
editor.show()
if seed:
editor.sources.add_item(TextItem(TextData('foo')))
editor.sources.add_item(TextItem(TextData('Bar1')))
# editor.sources.add_item(TextItem(TextData('Bar2')))
# editor.sources.add_item(Spacing(SpacingData(10)))
# editor.sources.add_item(TextItem(TextData('baz')))
# editor.sources.add_item(Barcode(BarcodeData(text='123456789012')))
# editor.sources.add_item(Barcode(BarcodeData(text='ACE222', code_type='code128')))
editor.sources.add_item(ImageItem(ImageData(image_source=path.join(testdata, 'whodat3.png'),
margins=Margins(vert=0,
left=15,
right=15,
scale=1))))
loop = QEventLoop(app)
asyncio.set_event_loop(loop)
asyncio.create_task(editor.init_async())
with loop:
loop.run_forever()
def main():
parser = get_parser()
args = parser.parse_args()
if args.runtime == "gui":
run("seed" in args and args.seed)
else:
CliPrint.run(args)
if __name__ == '__main__':
main()