Help. I cant get this to work. when I press the send button it giv

here is the code:

from tkinter import *
from firebase import firebase
from simplecrypt import encrypt, decrypt

login_window = Tk()
login_window.geometry("400x400")
login_window.config(bg='#AB92BF')

firebase = firebase.FirebaseApplication("https://chattap-335d8-default-rtdb.firebaseio.com/", None)

login_window = Tk()
login_window.geometry("400x400")
login_window.config(bg='#AB92BF')

username = ''
your_code = ''
your_friends_code = ''
message_text = ''
message_entry = ''
last_value = ''

def getData():
    global message_text 
    global last_value
    global your_code
    global your_friends_code
    get_your_data = firebase.get('/', your_code)
    print(get_your_data)
    byte_str = bytes.fromhex(get_your_data)
    original = decrypt('AIM', byte_str)
    print(original)
    final_message = original.decode("utf-8")
    print(final_message)
    message_text.insert(END, final_message+"\n")
    
    get_friends_data = firebase.get('/', your_friends_code)
    if (get_friends_data() != None):
        print(get_friends_data)
        byte_str = bytes.fromhex(get_friends_data)
        original = decrypt('AIM', byte_str)
        print(original)
        final_message = original.decode("utf-8")
        if (final_message != NONE):
            print(final_message)
            message_text.insert(END, final_message+"\n")
            last_value = final_message
        
    
def sendData(): 
    global username
    global message_entry
    global your_code
    message = username+ " : " + message_entry.get()
    ciphercode = encrypt('AIM', message)
    hex_string = ciphercode.hex()
    put_date = firebase.put("/", your_code, hex_string)
    print(put_date)
    getData()

def enterRoom():
    message_window = Tk()
    message_window.config(bg='#AFC1D6')
    message_window.geometry("600x500")
    
    message_text = Text(message_window, height=20, width=72)
    message_text.place(relx=0.5,rely=0.35, anchor=CENTER)
    
    message_label = Label(message_window, text="Message " , font = 'arial 13', bg='#AFC1D6', fg="white")
    message_label.place(relx=0.3,rely=0.8, anchor=CENTER)
    
    message_entry = Entry(message_window, font = 'arial 15')
    message_entry.place(relx=0.6,rely=0.8, anchor=CENTER)
    
    btn_send = Button(message_window, text="Send", font = 'arial 13', bg="#D6CA98", fg="black", padx=10, relief=FLAT, command=sendData)
    btn_send.place(relx=0.5,rely=0.9, anchor=CENTER)
    
    message_window.mainloop()
    login_window.destroy()
    

username_label = Label(login_window, text="Username : " , font = 'arial 13', bg ='#AB92BF', fg="white")
username_label.place(relx=0.3,rely=0.3, anchor=CENTER)

username_entry = Entry(login_window)
username_entry.place(relx=0.6,rely=0.3, anchor=CENTER)

your_code_label = Label(login_window, text="Your code :  " , font = 'arial 13', bg ='#AB92BF', fg="white")
your_code_label.place(relx=0.3,rely=0.4, anchor=CENTER)

your_code_entry = Entry(login_window)
your_code_entry.place(relx=0.6,rely=0.4, anchor=CENTER)

friends_code_label = Label(login_window, text="Your Friends code :  " , font = 'arial 13', bg ='#AB92BF', fg="white")
friends_code_label.place(relx=0.22,rely=0.5, anchor=CENTER)

friends_code_entry = Entry(login_window)
friends_code_entry.place(relx=0.6,rely=0.5, anchor=CENTER)

btn_start = Button(login_window, text="Start" , font = 'arial 13' , bg="#CEF9F2", fg="black", command=enterRoom, relief=FLAT, padx=10)
btn_start.place(relx=0.5,rely=0.65, anchor=CENTER)

login_window.mainloop()

I cant get this to work. when I press the send button it gives the following error:

Exception in Tkinter callback
Traceback (most recent call last):
  File "*filepath*\PythonSoftwareFoundation.Python.3.9_3.9.2800.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py", line 1892, in __call__
    return self.func(*args)
  File "*filepath*", line 53, in sendData
    message = username+ " : " + message_entry.get()
AttributeError: 'str' object has no attribute 'get' 
pls help.

I copied the lines that matter from your program into the repl:

>>> message_entry = ''
>>> type(message_entry)
<class 'str'>
>>> dir(message_entry)
['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__form
at__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__
init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__',
'__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__seta
ttr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count
', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isa
lpha', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace'
, 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'replace'
, 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startsw
ith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
>>> message_entry.get()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute 'get'

I define message_entry. Check that its type is str. Does it have a method get? No, it is not in the list. So, of course when you evaluate message_entry.get(), it fails.

Note: You may think that the message_entry you define in enterRoom may be visible in sendData, but it isn’t. It is local to the function enterRoom. Besides, enterRoom is not called anywhere, so the assignment to message_entry there is never executed.

Thanks! I made the message_entry global in the enterRoom, and it worked. But, it gave me the following error (this was from the firebase.put() function, i think):

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2800.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py", line 1892, in __call__
    return self.func(*args)
  File "filepath", line 56, in sendData
    put_date = firebase.put("/", your_code, hex_string)
  File "AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\firebase\decorators.py", line 20, in wrapped
    return f(*args, **kwargs)
  File "AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\firebase\firebase.py", line 295, in put
    assert name, 'Snapshot name must be specified'
AssertionError: Snapshot name must be specified