Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Defining Convert and Outgoing:
- def BIcommand():
- outgoing()
- CONVERT()
- # Outgoing Data Function
- def outgoing():
- global out_buffer
- while 1:
- try:
- chatbox.insert(INSERT,"You: "+USER_ENTRY.get()+ "\n")
- user_input = USER_ENTRY.get()
- print(type(user_input))
- user_lower = user_input.lower()
- Mess_Trans = [] # Holds Translated message
- x = 0
- Count_Limit = len(user_lower)
- while x < Count_Limit:
- try:
- Mess_Trans = Mess_Trans + [T_Dictionary[user_lower[x]]]
- except ValueError:
- print("Internal Error Exception")
- tkinter.messagebox.showinfo("Internal Error","Dictionary Failed To Encrypt")
- x += 1
- # Serliazing List Before Exporting
- Mess_Seri = json.dumps(Mess_Trans)
- # Exporting Message
- if user_input:
- out_buffer += [Mess_Seri.encode()]
- # for i in wlist:
- s.send(out_buffer[0])
- out_buffer = []
- except IOError:
- print("\n\t\aIOError Exception")
- tkinter.messagebox.showinfo("Internal Error","Section 3: IOError on send attempt")
- input("\n\nPress Enter To Exit")
- # ----------------------------[ Section 3, GUI Chatbox ]
- # Setting Variables
- global textlimiter
- textlimiter = 0
- # Defining Functions
- # Chat Control and Command
- def CONVERT():
- if numlines > 15:
- chatbox.delete("1.0",END)
- chatbox.insert(INSERT,"Console: Limit Reached, Chat Wiped" + "\n")
- def chatexit():
- time.sleep(0.5)
- sys.exit()
- # Chatbox Window
- chat = Tk()
- chat.title("Net Send Client [0.5]")
- chat.geometry('550x500+200+200')
- #
- title = StringVar()
- title.set("Net Send Chat\n Type in box to send.")
- title_widget = Label(chat,textvariable = title, height = 4)
- title_widget.pack()
- #
- INPUT_BOX = StringVar()
- USER_ENTRY = Entry(chat,textvariable = INPUT_BOX)
- USER_ENTRY.pack(side=TOP, padx = 10, pady = 20)
- #
- send_button = Button(chat, text="Send",width = 20, command = outgoing)
- send_button.pack(padx = 10, pady = 10)
- #
- chatbox = Text(width = 60, height = 15, relief = SUNKEN)
- left = Frame(chatbox)
- right = Frame(chatbox)
- s_start = Scrollbar(right)
- s_start.pack(side=RIGHT)
- #
- exit_button = Button(chat, text="Close & Exit",width = 20, command = chatexit)
- exit_button.pack(side='bottom',padx = 15, pady = 14)
- #
- chatbox.grid(row = 0, column = 0, columnspan = 3)
- chatbox.pack()
- #
- chat.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment