What problem i want show ip address local system in root
from tkinter import *
import socket
root = Tk()
root.geometry("640x480")
root.title("IT")
def ipadds():
hostname = socket.gethostname()
local_ip = socket.gethostbyname(hostname)
L1 = Label(root,text="Your IP is :", font=('Arial',10)).place(x=30,y=50)
E1 = Entry(root,width = 20,command=ipadds).place(x=95,y=50)
root.mainloop()
Is correct use command in Entry?
CodePudding user response:
There is no command
option in Entry
. Also need to adjust root.geometry
. Your Entry
code returns None
so need to pack
before place
. To get an entry showing need to use insert
.
from tkinter import *
import socket
root = Tk()
root.geometry("640x480 80 80")
root.title("IT")
def ipadds():
hostname = socket.gethostname()
local_ip = socket.gethostbyname(hostname)
return local_ip
L1 = Label(root,text="Your IP is :", font=('Arial',10)).place(x=30,y=50)
E1 = Entry(root,width = 20)
E1.pack()
E1.place(x=95,y=50)
ip = ipadds()
E1.insert('0',ip)
root.mainloop()