-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple urlChecker.py
49 lines (35 loc) · 1.14 KB
/
simple urlChecker.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
# pip install validators
# pip install tkinter
# import the neccessary packages
import tkinter as tk
import validators
from tkinter import messagebox
# create a GUI window
root = tk.Tk()
# setting the title for the window
root.title("URL Validator")
# setting the size of the window to display
root.geometry("250x100")
def checkUrl():
# to get the entered data in the Entry field
urlEntry = f'{baseString.get()}'
# print(url)
if len(urlEntry) == 0:
messagebox.showerror("Error!", "Enter a valid string")
elif validators.url(urlEntry):
messagebox.showinfo("Success", "URL you entered is Valid")
else:
messagebox.showwarning("Invalid", "URL is not Valid")
# displaying text in the window
label = tk.Label(root, text = "Enter URL to check (with http or https)")
label.pack()
# to hold a string value
baseString = tk.StringVar()
# getting input from the user using Entry
entry = tk.Entry(root, textvariable=baseString)
entry.pack()
# checking the entered string is valid url or not
validateButton = tk.Button(text="Check", command = checkUrl)
validateButton.pack()
# start the GUI Window
root.mainloop()