-
Notifications
You must be signed in to change notification settings - Fork 0
/
GUI.py
146 lines (108 loc) · 3.61 KB
/
GUI.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import sys
import threading
from tkinter import *
from valueToTerminal import *
keepGoing = False
def main_func():
# Execute Tkinter
root.mainloop()
def run_thread():
global keepGoing
keepGoing = True
print('starting thread')
threading.Thread(target=run, args=(email_var.get(), status)).start()
def stop_thread():
print('stopping thread')
global keepGoing
keepGoing = False
# create root window
root = Tk()
# root window title and dimension
root.title("Online Barcode Scanner")
root.geometry("500x200")
image = PhotoImage(file=r"efl3pl.png")
image = image.subsample(3, 3)
Label(root, image=image).grid(row=0, column=0,
columnspan=1, rowspan=1, padx=5, pady=5)
# status label settings
status = Label(root, text="Waiting for Gate Pass....")
status.config(font=("Arial", 15))
status.grid(row=1, column=1, sticky=W, pady=5)
# Credits settings
creator = Label(root, text="Developed by Zain Zameer")
creator.config(font=("Courier", 6))
creator.grid(row=7, column=0, sticky=W, pady=5)
# all widgets will be here
email_to = Label(root, text="GATE PASS ID")
# entry widgets
email_to.grid(row=2, column=0, sticky=W, pady=5)
# declaring string variable
# for storing name and password
email_var = StringVar(root, value="")
# entry widgets, used to take entry from user
e1 = Entry(root, textvariable=email_var)
# this will arrange entry widgets
e1.grid(row=2, column=1, pady=2)
btn_run = Button(root, text="Run",
command=run_thread)
btn_stop = Button(root, text="Stop",
command=stop_thread)
btn_run.grid(row=3, column=0, pady=2)
btn_stop.grid(row=3, column=1, pady=2)
########################################################################################################################
#
# MAIN RUNNING CODE
#
########################################################################################################################
def is_stop_pressed(browser, status):
global keepGoing
status.configure(text="Stopping...")
if not keepGoing:
goHome(browser)
logout(browser)
status.configure(text="Stopped!")
sys.exit()
def run(gate_pass, status):
try:
print('thread started')
url = ""
excel_file_loc = r''
#
# Get the open macro file instance
#
wb = xw.Book(excel_file_loc)
getExcelValue(wb)
# Delete session file
#
# os.remove('selenium_session')
# start the browser with terminal URL
browser = build_driver()
browser.get(url)
# Log in to the Virtual Terminal
status.configure(text="Logging In..")
logon(browser)
time.sleep(1)
is_stop_pressed(browser, status)
# Dock in
status.configure(text="Docking In..")
dockIN(browser, gate_pass, status, wb)
status.configure(text="Dock In Complete!.")
goHome(browser)
is_stop_pressed(browser, status)
# Go to ASN receipt
status.configure(text="Receiving in Progress!")
ASNReceipt(browser, wb, gate_pass, status)
status.configure(text="Receiving Complete!")
goHome(browser)
is_stop_pressed(browser, status)
# Go to Dock Out
status.configure(text="Docking Out..")
# dockOut(browser, gate_pass, status)
status.configure(text="Dock out Complete!")
# Logout of Virtual Terminal
status.configure(text="Logged Out")
logout(browser)
except Exception as e:
status.configure(text=e)
if __name__ == '__main__':
main_func()