fork download
  1. from tkinter import *
  2. import socket
  3.  
  4. def runningServ(event):
  5.  
  6. winConnect.insert(1.0,"running\n")
  7.  
  8. hostStr=host.get()
  9. portInt=port.get()
  10.  
  11. mainSocket.bind((hostStr, portInt))
  12. mainSocket.listen(4)
  13.  
  14. while True:
  15. conn, addr = mainSocket.accept()
  16. data = conn.recv(1024)
  17. winConnect.insert('connect: '+str(addr))
  18.  
  19. mainSocket=socket.socket()
  20. root=Tk()
  21. root.title("server setting")
  22.  
  23. lab0=Label(root, text='Host: ')
  24. host=StringVar()
  25. host.set('')
  26. fieldHost=Entry(root, width=20, textvariable=host)
  27. lab0.grid(row=2,column=2)
  28. fieldHost.grid(row=2,column=3)
  29.  
  30. lab1=Label(root, text='Port: ')
  31. port=IntVar()
  32. port.set(9090)
  33. fieldPort=Entry(root, width=20, textvariable=port)
  34. lab1.grid(row=4,column=2)
  35. fieldPort.grid(row=4,column=3)
  36.  
  37. winConnect=Text(root,width=20, height=5)
  38. winConnect.grid(row=6,column=3)
  39. scr = Scrollbar(root,command=winConnect.yview)
  40. winConnect.configure(yscrollcommand=scr.set)
  41. #winConnect.insert(1.0,"running\n")
  42. scr.grid(row=6,column=4)
  43.  
  44. butt=Button(root,text='Running')
  45. butt.grid(row=7,column=2)
  46. butt.bind("<Button-1>",runningServ)
  47.  
  48. root.mainloop()
Runtime error #stdin #stdout #stderr 0.05s 26344KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 20, in <module>
  File "/usr/lib/python3.4/tkinter/__init__.py", line 1854, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable