Created
January 26, 2017 10:03
-
-
Save DhavalThkkar/8faf4839399c781fcc4c3f8feb5ed112 to your computer and use it in GitHub Desktop.
new file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tkinter import * | |
import tkinter | |
from tkinter import ttk | |
import socket | |
def calculate(*args): | |
try: | |
str = (domain_name.get()) | |
ip_add = socket.gethostbyname(str) | |
ip_addr.set(ip_add) | |
ttk.Button(mainframe, text="process", command=calculate).grid(column=3, row=4, sticky=W) | |
except socket.gaierror: | |
ip_addr.set("Invalid Web address. Please Enter again!") | |
ttk.Button(mainframe, text="retry", command=calculate).grid(column=3, row=4, sticky=W) | |
root = Tk() | |
root.title("smtp_telnet") | |
C = tkinter.Canvas(root, bg="blue", height=250, width=300) | |
mainframe = ttk.Frame(root, padding="3 3 12 12") | |
mainframe.grid(column=0, row=0, sticky=(N, W, E, S)) | |
mainframe.columnconfigure(0, weight=1) | |
mainframe.rowconfigure(0, weight=1) | |
domain_name = StringVar() | |
ip_addr = StringVar() | |
domain_name_entry = ttk.Entry(mainframe, width=20, textvariable=domain_name) | |
domain_name_entry.grid(column=2, row=1, sticky=(W, E)) | |
ttk.Label(mainframe, textvariable=ip_addr).grid(column=2, row=2, sticky=(W, E)) | |
ttk.Button(mainframe, text="IP", command=calculate).grid(column=3, row=3, sticky=W) | |
ttk.Label(mainframe, text="Enter Domain name").grid(column=1, row=1, sticky=W) | |
ttk.Label(mainframe, text="IP address").grid(column=1, row=2, sticky=E) | |
ttk.Label(mainframe, text="").grid(column=3, row=2, sticky=W) | |
for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=5) | |
domain_name_entry.focus() | |
root.bind('<Return>', calculate) | |
root.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment