Skip to content

Commit 2ca184e

Browse files
committed
added gui support for windows
multithreading now possible with gui (windows only)
1 parent 8d409cf commit 2ca184e

File tree

5 files changed

+81
-7
lines changed

5 files changed

+81
-7
lines changed

gui.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
from appJar import gui
2+
import subprocess
3+
import sys
4+
5+
def open_cmd(args):
6+
7+
if sys.platform == 'win32':
8+
command = 'start cmd /k'
9+
for arg in args:
10+
command += " " + arg
11+
subprocess.call(command, shell = True)
12+
13+
def parse_complete():
14+
15+
pass
16+
17+
def parse_checker():
18+
19+
args = ['python', '-u', 'web_diff.py']
20+
21+
link = app.getEntry('Website')
22+
if(link):
23+
args.append(link)
24+
if(app.getCheckBox('-r')):
25+
args.append('-r')
26+
if(app.getCheckBox('-o')):
27+
args.append('-o')
28+
if(app.getCheckBox('-t')):
29+
args.append('-t')
30+
time_nr = app.getEntry('Time')
31+
if(time_nr):
32+
args.append(time_nr)
33+
if(app.getCheckBox('-w')):
34+
args.append('-w')
35+
if(app.getCheckBox('-v')):
36+
args.append('-v')
37+
38+
open_cmd(args)
39+
40+
def parse_check(button):
41+
42+
app.threadCallback(parse_checker, parse_complete)
43+
44+
app = gui("web_diff gui", "500x500")
45+
app.setLocation("CENTER")
46+
app.setBg("SteelBlue")
47+
app.setFont(15)
48+
app.setResizable(False)
49+
50+
app.addLabelEntry("Website",0,0,4)
51+
app.addCheckBox("-r",1,0)
52+
app.addCheckBox("-o",1,1)
53+
app.addCheckBox("-t",1,2)
54+
app.addLabelEntry("Time",1,3)
55+
app.setEntryDefault("Time", 60)
56+
app.addCheckBox("-w",2,0)
57+
app.addCheckBox("-v",2,1)
58+
59+
app.addButton("Check", parse_check, 3,1)
60+
61+
app.setFocus("Website")
62+
63+
app.go()

guiStarter.bat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
python gui.py
3+
exit

optional-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
appjar

runWIN.vbs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Set oShell = CreateObject ("Wscript.Shell")
2+
Dim strArgs
3+
strArgs = "cmd /c guiStarter.bat"
4+
oShell.Run strArgs, 0, false

web_diff.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import requests
33
import subprocess
44
import sys
5+
import time
56
import warnings
67
import webbrowser
7-
from time import sleep, ctime
88

99
def open_link_in_broswer(url):
1010

@@ -49,7 +49,7 @@ def parse_args(args):
4949
v = True #bool if checking the ssl cert
5050
t_flag_found = False #bool if -t was found
5151
t_nr_found = False #bool if -t has a value
52-
52+
5353
while i < len(args):
5454
if not link_found:
5555
if is_url(args[i]):
@@ -69,16 +69,19 @@ def parse_args(args):
6969
elif args[i] == '-v':
7070
v = False
7171
i += 1
72+
7273
if not link_found:
7374
print("\nProvide a valid url")
7475
print("example: https://en.wikipedia.org/wiki/Static_web_page")
7576
print("")
7677
correct = False
78+
7779
if t_flag_found and not t_nr_found:
7880
print("\nProvide a number for the -t flag")
7981
print("example: -t 30")
8082
print("")
8183
correct = False
84+
8285
if correct:
8386
web_diff(link, r, o, t, w, v)
8487

@@ -101,12 +104,12 @@ def web_diff(link, r, o, t, w, v):
101104
while no_diff:
102105
print("\nchecking again in " + str(t) + " secs")
103106
print("-----")
104-
sleep(t)
107+
time.sleep(t)
105108
updated_res = get_website_data(link, v)
106109
print("\nsaved updated(?) site info for: " + link)
107-
print("diff checking @ " + str(ctime()))
110+
print("diff checking @ " + str(time.ctime()))
108111
print("-----")
109-
no_diff = not is_diff(initial_res,updated_res)
112+
no_diff = not is_diff(initial_res, updated_res)
110113
if not no_diff:
111114
print("\ndiff found!")
112115
print("-----")
@@ -117,6 +120,7 @@ def web_diff(link, r, o, t, w, v):
117120
if r:
118121
web_diff(link, r, o, t, w, v)
119122
else:
123+
no_diff = False
120124
break
121125
else:
122126
print("\nno diff found")
@@ -160,6 +164,5 @@ def main():
160164
else:
161165
parse_args(sys.argv)
162166

163-
164167
if __name__ == '__main__':
165-
main()
168+
main()

0 commit comments

Comments
 (0)