-1

i want to make this as an executable file which can be used as ann app on any computer to reveal their ip and mac address and i want the printed result to appear on the GUI but i have no idea how to do that.Here's the code:

from tkinter import *

import socket

import re, uuid

root = Tk()
root.geometry("400x250")

frame = Frame(root)
frame.bind("<Button-1>")
frame.pack()

def printName(event):
    hostname = socket.gethostname()
    IPAddr = socket.gethostbyname(hostname)
    print("Your computer name is:" + hostname)
    print("Your Computer IP Address is:" + IPAddr)
    print ("The MAC address is formatted and expressed in a less complex way : ", end="")
    print (':'.join(re.findall('..', '%012x' % uuid.getnode())))

theLabel = Label(root, text="IP-Mac",)
theLabel.pack()

button_1 = Button(root, text="show")
button_1.bind("<Button-1>", printName)
button_1.pack()

root.mainloop()
jizhihaoSAMA
  • 12,336
  • 9
  • 27
  • 49

1 Answers1

0

Use extra labels with placeholders:

theLabel = Label(root, text="IP-Mac",)
theLabel.pack()

ipLabel = Label(root, text="Gonna be the IP",)
ipLabel.pack()
... 

In printName you can then set their text instead of printing:

ipLabel.config(text=IPAddr)
... 
Banana
  • 2,295
  • 1
  • 8
  • 25