Guest User

Final Section

a guest
Mar 19th, 2013
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. # Defining Convert and Outgoing:
  2. def BIcommand():
  3. outgoing()
  4. CONVERT()
  5.  
  6. # Outgoing Data Function
  7. def outgoing():
  8. global out_buffer
  9. while 1:
  10. try:
  11. chatbox.insert(INSERT,"You: "+USER_ENTRY.get()+ "\n")
  12. user_input = USER_ENTRY.get()
  13. print(type(user_input))
  14.  
  15. user_lower = user_input.lower()
  16. Mess_Trans = [] # Holds Translated message
  17. x = 0
  18. Count_Limit = len(user_lower)
  19. while x < Count_Limit:
  20. try:
  21. Mess_Trans = Mess_Trans + [T_Dictionary[user_lower[x]]]
  22. except ValueError:
  23. print("Internal Error Exception")
  24. tkinter.messagebox.showinfo("Internal Error","Dictionary Failed To Encrypt")
  25. x += 1
  26. # Serliazing List Before Exporting
  27. Mess_Seri = json.dumps(Mess_Trans)
  28.  
  29. # Exporting Message
  30.  
  31. if user_input:
  32. out_buffer += [Mess_Seri.encode()]
  33. # for i in wlist:
  34. s.send(out_buffer[0])
  35. out_buffer = []
  36.  
  37.  
  38. except IOError:
  39. print("\n\t\aIOError Exception")
  40. tkinter.messagebox.showinfo("Internal Error","Section 3: IOError on send attempt")
  41. input("\n\nPress Enter To Exit")
  42.  
  43. # ----------------------------[ Section 3, GUI Chatbox ]
  44.  
  45. # Setting Variables
  46. global textlimiter
  47. textlimiter = 0
  48. # Defining Functions
  49. # Chat Control and Command
  50. def CONVERT():
  51. if numlines > 15:
  52. chatbox.delete("1.0",END)
  53. chatbox.insert(INSERT,"Console: Limit Reached, Chat Wiped" + "\n")
  54.  
  55. def chatexit():
  56. time.sleep(0.5)
  57. sys.exit()
  58. # Chatbox Window
  59. chat = Tk()
  60. chat.title("Net Send Client [0.5]")
  61. chat.geometry('550x500+200+200')
  62. #
  63. title = StringVar()
  64. title.set("Net Send Chat\n Type in box to send.")
  65. title_widget = Label(chat,textvariable = title, height = 4)
  66. title_widget.pack()
  67. #
  68. INPUT_BOX = StringVar()
  69. USER_ENTRY = Entry(chat,textvariable = INPUT_BOX)
  70. USER_ENTRY.pack(side=TOP, padx = 10, pady = 20)
  71. #
  72. send_button = Button(chat, text="Send",width = 20, command = outgoing)
  73. send_button.pack(padx = 10, pady = 10)
  74. #
  75. chatbox = Text(width = 60, height = 15, relief = SUNKEN)
  76. left = Frame(chatbox)
  77. right = Frame(chatbox)
  78. s_start = Scrollbar(right)
  79. s_start.pack(side=RIGHT)
  80. #
  81. exit_button = Button(chat, text="Close & Exit",width = 20, command = chatexit)
  82. exit_button.pack(side='bottom',padx = 15, pady = 14)
  83. #
  84. chatbox.grid(row = 0, column = 0, columnspan = 3)
  85. chatbox.pack()
  86. #
  87. chat.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment