forked from yasirSub/AndroidStudioV1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig_manager.py
More file actions
30 lines (26 loc) · 998 Bytes
/
config_manager.py
File metadata and controls
30 lines (26 loc) · 998 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import json
import os
from tkinter import messagebox
class ConfigManager:
def __init__(self, config_file="config/anoid.json"):
self.config_file = config_file
self.config = self.load_config()
def load_config(self):
try:
with open(self.config_file, 'r') as file:
return json.load(file)
except Exception as e:
messagebox.showerror("Error", f"Failed to load configuration: {e}")
return {}
def save_config(self, config=None):
try:
if config is None:
config = self.config
with open(self.config_file, 'w') as file:
json.dump(config, file, indent=2)
messagebox.showinfo("Success", "Configuration saved successfully.")
except Exception as e:
messagebox.showerror("Error", f"Failed to save configuration: {e}")
def update_config(self, new_config):
self.config = new_config
self.save_config()