Advertisement
orfwefwef

Untitled

Feb 18th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. from Tkinter import *
  2.  
  3. root=Tk()
  4.  
  5. def enter():
  6. PORT=int(entry1.get())
  7. entry1.delete(0,END)
  8. HOST = 'localhost'
  9. BUFSIZ = 1024
  10. ADDR = (HOST,PORT)
  11. tcpCliSock = socket(AF_INET, SOCK_STREAM)
  12. tcpCliSock.connect(ADDR)
  13. def connection():
  14.  
  15. txt.insert(END," \n > ")
  16. data = entry1.get()
  17. txt.insert(END,data)
  18. tcpCliSock.send(data)
  19. data = tcpCliSock.recv(1024)
  20. if not data:
  21. print"you are out, bye bye"
  22. txt.insert(END,"\n"+data)
  23.  
  24.  
  25.  
  26.  
  27.  
  28. root.geometry("600x700+40+40")
  29. root.title("the client")
  30. txt=Text(root,bg="cyan",bd=8,width=60)
  31. txt.pack()
  32. entry1=Entry(root, font='Ariel 18',fg="black")
  33. entry1.pack(fill=X)
  34. btn1=Button(root,text=" Enter ",command=enter)
  35. btn1.pack()
  36. btn2=Button(root,text="Send ",command=connection)
  37. btn2.pack()
  38. menubar = Menu(root)
  39. filemenu= Menu(menubar,tearoff=0)
  40. filemenu.add_command(label="New")
  41. root.title("the client")
  42. menubar.add_cascade(label="File",menu=filemenu)
  43. helpmenu=Menu(menubar,tearoff=0)
  44. helpmenu.add_command(label="Send")
  45. menubar.add_cascade(label="Help",menu=helpmenu)
  46. aboutmenu=Menu(menubar,tearoff=0)
  47. aboutmenu.add_command(label="About me")
  48. aboutmenu.add_command(label="Version")
  49. menubar.add_cascade(label="About",menu=aboutmenu)
  50. root.config(menu=menubar)
  51. txt.insert(END,"please enter the port")
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement