Python Forum
[Tkinter] Display IP address in listbox
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Display IP address in listbox
#1
Hi,

I'm trying to display various Windows settings in a simple Python GUI, starting with the current IP
(The next step would be to add a new button to change the IP etc...)

The IP currently gets displayed in the terminal window rather than in the listbox as desired, just not sure
how to resolve this? Full code is below, any help on this will be hugely appreciated.

from tkinter import *
import socket

def displayIP():
list1.delete(0,END)
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8",80))
ADDR = (print(s.getsockname()[0]))
list1.insert(END,ADDR)

window=Tk()

window.wm_title("Quick Configurator")

list1=Listbox(window, height=6,width=35)
list1.grid(row=2,column=0,rowspan=6,columnspan=2)

sb1=Scrollbar(window)
sb1.grid(row=14,column=2,rowspan=10)

list1.configure(yscrollcommand=sb1.set)
sb1.configure(command=list1.yview)

b1=Button(window,text="Current IP", width=16,command=displayIP)
b1.grid(row=2,column=3)

window.mainloop()
Reply


Messages In This Thread
Display IP address in listbox - by dominicrsa - Oct-21-2020, 12:37 PM
RE: Display IP address in listbox - by deanhystad - Oct-21-2020, 12:43 PM
RE: Display IP address in listbox - by dominicrsa - Oct-21-2020, 01:00 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Display and update the label text which display the serial value jenkins43 5 8,990 Feb-04-2019, 04:36 AM
Last Post: Larz60+
  Display more than one button in GUI to display MPU6000 Sensor readings barry76 4 3,834 Jan-05-2019, 01:48 PM
Last Post: wuf
  [Tkinter] THow to search a string in a file and display it in listbox by Tkinter mosavit 2 5,605 Jun-21-2017, 08:02 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020