I'm trying to figure out what I'm doing wrong, I keep getting the error message
The string supplied did not seem to be a phone number
I'm trying to make a little app that does a lot of things with phone numbers like give the location and stuff like that.
Here's the code:
import tkinter as tk
from tkinter import *
import phonenumbers
from phonenumbers import geocoder
from PIL import Image, ImageTk
from tkinter.font import Font
root = tk.Tk()
canvas =tk.Canvas(root, width=600, height=300, bg="#000000")
canvas.grid(columnspan=4, rowspan=4)
root.title("phOsint")
textbox = Entry(root, width=40,)
textbox.grid(column=1, row=2)
myFont = Font(
family="Magneto",
size=12,
slant="roman")
logo = Image.open("anonlogorm.png",).convert("RGB")
logo = ImageTk.PhotoImage(logo)
logo_label = tk.Label(image=logo, borderwidth=0)
logo_label.image = logo
logo_label.grid(column=1, row=0)
instructions = tk.Label(root, text="Enter in a phone number, let's see where it's located ;)", fg="light green", bg="black", font=myFont)
instructions.grid(columnspan=3, column=0, row=1)
def button_command():
phoneNumber = phonenumbers.parse(str(textbox))
phoneNumber.strip()
print(geocoder.description_for_number(phoneNumber, "en"))
browse_text = tk.StringVar()
browse_btn = tk.Button(root, textvariable=browse_text, command=button_command, bg="purple", fg="white", height=2, width=10, font=myFont)
browse_text.set("Show Me")
browse_btn.grid(column=1, row=3)
canvas =tk.Canvas(root, width=600, height=250, bg="#000000")
canvas.grid(columnspan=3,)
root.mainloop()
You have passed the name of textbox
to phonenumbers.parse()
inside button_command()
, use textbox.get()
instead.
Also the result of phonenumbers.parse()
is not a string, you cannot call strip()
on it:
def button_command():
phoneNumber = phonenumbers.parse(textbox.get().strip())
print(geocoder.description_for_number(phoneNumber, "en"))