from Tkinter import *
import sys
import socket

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)


def label2():
    mylabel2 =Label(text='IP').place(x=20,y=40)
def button_action():

    text1= textinput.get()

    sock.sendall(text1)
    textlabel1 =Label(text=text1,width=43,height=10,bg="#fff",bd=2,relief=SUNKEN).place(x=25,y=120)
    entry1.delete(0,END)

def enter_action(self):
    button_action()

def button_port_action():
    #server_address = (, 80)
    ip = portinput.get()

    sock.connect((ip,80))



tk = Tk()
tk.geometry('400x400+500+200')
tk.title('Python Powered')
textinput=StringVar()
portinput =StringVar()
textlabel1 =Label(width=43,height=10,bg="#fff",bd=2,relief=SUNKEN).place(x=25,y=120)
label2()

#label1 =Label(text='Are you sure').place(x=30,y=50)
button1 = Button(tk,text='Send', command= button_action).place(x=325,y=67)
entry1= Entry(tk,textvariable=textinput,width=35)
entry1.bind("<Return>",enter_action)
entry1.place(x=20,y=70)

port_entry= Entry(tk,textvariable=portinput,width=20)
port_entry.place(x=50,y=40)
Button_port = Button(tk,text='Set', command= button_port_action).place(x=325,y=37)


#label2 =Label(text='Label 2').pack()



tk.mainloop()
