Oct-21-2020, 12:37 PM
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()
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()