I want to replace new data to my text file with variables. However my old variables gets replaced instead of the new ones. When printing the variable inside the updateConfig() function it prints out the old variable instead of the new one which means the new variables did not overwrite the old variable in the code. I was hoping someone could help me with a solution
DefaultTheme = Data1["Theme"]
OpacityValue = int(Data1["Opacity"])
def updateConfig():
Data1.update(Theme = DefaultTheme,Opacity = OpacityValue) #suppose to use new values but it uses #the old value
print(Data1)
f = open("Config","w")
f.write(str(Data1).replace("'",'"'))
f.close()
def OpacityChanger(Value,Text,Root):
Text.configure(text=f"Opacity: {round(Value)}%")
root.attributes("-alpha",(Value/100))
OpacityValue = Value #Supposed to overwrite old value
updateConfig()
def ThemeChanger(Theme):
root._set_appearance_mode(Theme)
DefaultTheme = Theme #Supposed to overwrite old value
updateConfig()
New contributor
DanCantFind is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.