-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
57 lines (38 loc) · 1.4 KB
/
Copy pathmain.py
File metadata and controls
57 lines (38 loc) · 1.4 KB
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
import pyautogui as pa
import keyboard as k
import json as js
import gui as gui
import types
from types import BarcodeElement
BARCODES_PATH = "barcodes.json"
def SimulateBarcodeFromHotkey(barcodeToSimulate):
pa.write(barcodeToSimulate + "\n")
print("Simulato l'inserimento del barcode: ", barcodeToSimulate)
#region GESTIONE HOTKEY
def RefreshHotKeys():
k.clear_all_hotkeys
for element in barcodeList:
k.add_hotkey(element.hotkey, SimulateBarcodeFromHotkey, args=[element.barcode])
print("Aggiunta combinazione " + element.hotkey + " per richiamare " + element.barcode)
print("Hotkeys aggiunte: " + str(k._hotkeys))
#endregion
#region METODI GUI
def SimulateBarcode(e, v):
if (v['BARCODE_LIST'] == []):
return
barcodeToSimulateElement = v['BARCODE_LIST'][0]
barcodeToSimulate = barcodeToSimulateElement.barcode
pa.write(barcodeToSimulate + "\n")
print("Simulato l'inserimento del barcode: ", barcodeToSimulate)
def SaveBarcodes():
with open(BARCODES_PATH, "w") as barcodes_file:
js.dump(barcodeList, barcodes_file, indent=4, cls=BarcodeElementEncoder)
def LoadBarcodes():
with open(BARCODES_PATH, 'r') as barcodes_file:
barcodeList = js.load(barcodes_file)
print("Barcodes aggiunti: " + str(barcodeList))
RefreshWindow()
#endregion
LoadBarcodes()
print("LoadedBarcodes: " + str(barcodeList))
RefreshHotKeys()