-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui.py
119 lines (97 loc) · 2.41 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
# This file was generated by the Tkinter Designer by Parth Jadhav
# https://github.com/ParthJadhav/Tkinter-Designer
from pathlib import Path
# from tkinter import *
# Explicit imports to satisfy Flake8
from tkinter import Label, Tk, Canvas, Entry, Text, Button, PhotoImage
from ip2geotools.databases.noncommercial import DbIpCity
OUTPUT_PATH = Path(__file__).parent
ASSETS_PATH = OUTPUT_PATH / Path("./assets")
def relative_to_assets(path: str) -> Path:
return ASSETS_PATH / Path(path)
window = Tk()
window.geometry("300x550")
window.configure(bg = "#5DC1C7")
window.title("IP2GEO")
canvas = Canvas(
window,
bg = "#5DC1C7",
height = 550,
width = 300,
bd = 0,
highlightthickness = 0,
relief = "ridge"
)
canvas.place(x = 0, y = 0)
canvas.create_text(
75.0,
26.0,
anchor="nw",
text="IP 2 GEO",
fill="#FFFFFF",
font=("Roboto", 36 * -1)
)
entry_image_1 = PhotoImage(
file=relative_to_assets("entry_1.png"))
entry_bg_1 = canvas.create_image(
150.5,
173.0,
image=entry_image_1
)
entry_1 = Entry(
bd=0,
bg="#E5E5E5",
highlightthickness=0,
fg="black"
)
entry_1.place(
x=52.0,
y=145.0,
width=197.0,
height=54.0
)
canvas.create_text(
36.0,
125.0,
anchor="nw",
text="ENTER IP ADDRESS",
fill="#FCFAFA",
font=("Roboto", 12 * -1)
)
def ip_check():
response = DbIpCity.get(entry_1.get(),api_key='free')
'''
print("IP country:",response.country)
print("IP city:",response.city)
print("IP latitude:",response.latitude)
print("IP longitude:",response.longitude)
'''
co = "IP country: "+response.country
ci = "IP city: " + response.city
li = "IP latitude: "+ str(response.latitude)
lo = "IP longitude: " + str(response.longitude)
country = Label(text=co,bg="#5DC1C7",fg="white")
country.place(x=30,y=350)
city = Label(text=ci,bg="#5DC1C7",fg="white")
city.place(x=30,y=400)
lit = Label(text=li,bg="#5DC1C7",fg="white")
lit.place(x=30,y=450)
lon = Label(text=lo,bg="#5DC1C7",fg="white")
lon.place(x=30,y=500)
button_image_1 = PhotoImage(
file=relative_to_assets("button_1.png"))
button_1 = Button(
image=button_image_1,
borderwidth=0,
highlightthickness=0,
command=lambda: ip_check(),
relief="flat",
)
button_1.place(
x=95.0,
y=250.0,
width=110.0,
height=45.0
)
window.resizable(False, False)
window.mainloop()