In the main file below I have created class objects (f1,f2) and a function (set_values) to access and modify class objects. And the above function is called in another file. But I am getting an error
'NameError: name 'f2' is not defined'. Any ideas...?
from threading import Thread
import tkinter as tk
import temp_gui
import temp_friday_ai
if __name__ == '__main__':
a = temp_friday_ai.welcome()
temp_friday_ai.Speak_text_a(a)
root = tk.Tk()
root.geometry('350x550')
root.title('FRIDAY')
root.rowconfigure(0 , weight = 8)
root.rowconfigure(1 , weight = 1)
root.columnconfigure(0 , weight = 1)
root.columnconfigure(1 , weight = 1)
color1 = '#0e1221'
color2 = '#423F3E'
f1 = temp_gui.rootdUpper(root , color1)
f2 = temp_gui.Chat(root ,color2)
f2.create_widgets(f2.l)
Thread(target= temp_friday_ai.friday_main, args= (root, f1, f2, )).start()
root.mainloop()
def set_values(d):
global f1
global f2
for x in d.keys():
if x =='theme':
if d[x] == 'Dark': color1 ,color2 , mode = '#0e1221' ,'#423F3E' ,'dark'
else : color1 ,color2 , mode = '#b3c6c7' ,'#203030' ,'light'
f2.theme_mode(color1,color2,mode)#calling class method
f1.theme_mode(color1,color2,mode)
elif x == 'gender':
if d[x] =='Male': temp_friday_ai.engine.setProperty('voice', temp_friday_ai.voices[1].id)
else: temp_friday_ai.engine.setProperty('voice', temp_friday_ai.voices[0].id)
elif x == 'voice':
if d[x] == 'Slow': r = 100
elif d[x] == 'Normal': r = 150
else: r = 200
temp_friday_ai.engine.setProperty('rate' , r)