-
Notifications
You must be signed in to change notification settings - Fork 0
/
tracer.py
48 lines (39 loc) · 1.8 KB
/
tracer.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
# This is a code in which we impliment the code to track the country of mobile Number.
import json
import pycountry
from tkinter import Tk, Label, Button, Entry
from phone_iso3166.country import phone_country
class Location_Tracker:
def __init__(self, App):
self.window = App
self.window.title("Phone number Tracker")
self.window.geometry("500x400")
self.window.configure(bg="#000000")
self.window.resizable(False, False)
#___________Application menu_____________
Label(App, text="Enter a phone number",fg="White", font=("Times", 20), bg="#000000").place(x=150,y= 30)
self.phone_number = Entry(App, width=16, font=("Arial", 15), relief="flat")
self.track_button = Button(App, text="Track Country", bg="#1874CD", relief="sunken")
self.country_label = Label(App,fg="white", font=("Times", 20), bg="#000000")
#___________Place widgets on the window______
self.phone_number.place(x=170, y=120)
self.track_button.place(x=200, y=200)
self.country_label.place(x=100, y=280)
#__________Linking button with countries ________
self.track_button.bind("<Button-1>", self.Track_location)
#255757294146
def Track_location(self,event):
phone_number = self.phone_number.get()
country = "Country is Unknown"
if phone_number:
tracked = pycountry.countries.get(alpha_2=phone_country(phone_number))
print(tracked)
if tracked:
if hasattr(tracked, "official_name"):
country = tracked.official_name
else:
country = tracked.name
self.country_label.configure(text=country)
PhoneTracker = Tk()
MyApp = Location_Tracker(PhoneTracker)
PhoneTracker.mainloop()