-
Notifications
You must be signed in to change notification settings - Fork 1
/
multi_form.py
64 lines (53 loc) · 1.89 KB
/
multi_form.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
from ox_script import *
import datetime
import os
form_list = []
selected_form = ""
def find_forms():
global selected_form
global form_list
form_list = [file for file in os.listdir() if file.endswith(".txt")]
if(len(form_list) != 0):
selected_form = form_list[0]
def update_selected_form(value):
global form_list
global selected_form
selected_form = form_list[int(value)]
def start_printing():
global selected_form
global today_date
serial_num = int(serial_num_controller.value)
for i in range(0, int(print_num_controller.value)):
cmd = PTK_UpdateAllFormVariables(
selected_form,
Input1=today_date,
Input2="{:03d}".format(serial_num + i),
)
PTK_SendCmdToPrinter(cmd)
def empty(value):
pass
if __name__ == "__main__":
find_forms()
controller = PTK_UIInit(
PTK_UIPage(
form_list_controller := PTK_UIList(
title="Form Name",
items=form_list,
valueType="int",
value=0,
Onpressed=update_selected_form,
),
date_controller := PTK_UITextBox(title="Today's Date", value="--"),
serial_num_controller := PTK_UIInput(
title="Starting Serial", value="001", Onsubmit=empty
),
print_num_controller := PTK_UIInput(
title="Print Quantity", value="001", Onsubmit=empty
),
PTK_UIButton(title="Print", Onpressed=start_printing),
),
# Setting require_execute_confirmation to False will allow the script to run without the need to press the execute button on the printer
require_execute_confirmation=False,
)
today_date = datetime.datetime.now().strftime("%Y-%m-%d")
date_controller.update(today_date)