As said in the title, I am having some problems with firebase’s firebase.put()
function.
here’s 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')
fbase = firebase.FirebaseApplication("https://chattap-335d8-default-rtdb.firebaseio.com/", None)
print("firebase done")
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():
global message_entry
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()
and here’s the error i get on cliking the “send” button"
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 58, in sendData
put_date = firebase.put("/", your_code, hex_string)
AttributeError: module 'firebase.firebase' has no attribute 'put'
also getting the same error on clicking the “sign up” button in the following code:
import hashlib as h
from tkinter import *
from firebase import firebase
registration_window = Tk()
registration_window.geometry("400x400")
firebase.FirebaseApplication("https://project-mk1-default-rtdb.firebaseio.com/", None)
login_username_entry = ""
login_password_entry = ""
def login():
print("login function")
def register():
username = username_entry.get()
password = password_entry.get()
encpswrd = h.md5(password.encode())
hex_string = encpswrd.hexdigest()
print(username)
print(password)
print(encpswrd)
print(hex_string)
put_date = firebase.put("/", username, hex_string)
def login_window():
global login_username_entry
global login_password_entry
registration_window.destroy()
login_window = Tk()
login_window.geometry("400x400")
log_heading_label = Label(login_window, text="Log In" , font = 'arial 18 bold')
log_heading_label.place(relx=0.5,rely=0.2, anchor=CENTER)
login_username_label = Label(login_window, text="Username : " , font = 'arial 13')
login_username_label.place(relx=0.3,rely=0.4, anchor=CENTER)
login_username_entry = Entry(login_window)
login_username_entry.place(relx=0.6,rely=0.4, anchor=CENTER)
login_password_label = Label(login_window, text="Password : " , font = 'arial 13')
login_password_label.place(relx=0.3,rely=0.5, anchor=CENTER)
login_password_entry = Entry(login_window)
login_password_entry.place(relx=0.6,rely=0.5, anchor=CENTER)
btn_login = Button(login_window, text="Log In" , font = 'arial 13 bold' , command=login, relief=FLAT)
btn_login.place(relx=0.5,rely=0.65, anchor=CENTER)
login_window.mainloop()
heading_label = Label(registration_window, text="Register" , font = 'arial 18 bold')
heading_label.place(relx=0.5,rely=0.2, anchor=CENTER)
username_label = Label(registration_window, text="Username : " , font = 'arial 13')
username_label.place(relx=0.3,rely=0.4, anchor=CENTER)
username_entry = Entry(registration_window)
username_entry.place(relx=0.6,rely=0.4, anchor=CENTER)
password_label = Label(registration_window, text="Password : " , font = 'arial 13')
password_label.place(relx=0.3,rely=0.5, anchor=CENTER)
password_entry = Entry(registration_window)
password_entry.place(relx=0.6,rely=0.5, anchor=CENTER)
btn_reg = Button(registration_window, text="Sign Up" , font = 'arial 13 bold' ,command=register, relief=FLAT, padx=10)
btn_reg.place(relx=0.5,rely=0.75, anchor=CENTER)
btn_login_window = Button(registration_window, text="Log In" , font = 'arial 10 bold' , command=login_window, relief=FLAT)
btn_login_window.place(relx=0.9,rely=0.06, anchor=CENTER)
registration_window.mainloop()
all help’s appreciated :D. Thanks!