@@ -26,6 +26,57 @@ def run(self) -> None:
2626 def display_current_status (self , text : str ):
2727 self .main_window .update_message (text )
2828
29+ class AdvancedSettingsWindow (tk .Toplevel ):
30+ """
31+ Self-contained settings sub-window for the UI
32+ """
33+
34+ def __init__ (self , parent ):
35+ super ().__init__ (parent )
36+ self .title ('Advanced Settings' )
37+ self .minsize (300 , 300 )
38+ self .create_widgets ()
39+ self .settings = Settings ()
40+
41+ # Populate UI
42+ settings_dict = self .settings .get_dict ()
43+
44+ if 'base_url' in settings_dict :
45+ self .base_url_entry .insert (0 , settings_dict ['base_url' ])
46+ if 'model' in settings_dict :
47+ self .model_entry .insert (0 , settings_dict ['model' ])
48+
49+ def create_widgets (self ) -> None :
50+ label_base_url = tk .Label (self , text = 'Custom OpenAI-Like API Model Base URL' )
51+ label_base_url .pack (pady = 10 )
52+
53+ # Entry for Base URL
54+ self .base_url_entry = ttk .Entry (self , width = 30 )
55+ self .base_url_entry .pack ()
56+
57+ # Model Label
58+ label_model = tk .Label (self , text = 'Custom Model Name:' )
59+ label_model .pack (pady = 10 )
60+
61+ # Entry for Model
62+ self .model_entry = ttk .Entry (self , width = 30 )
63+ self .model_entry .pack ()
64+
65+ # Save Button
66+ save_button = ttk .Button (self , text = 'Save Settings' , command = self .save_button )
67+ save_button .pack (pady = 20 )
68+
69+ def save_button (self ) -> None :
70+ base_url = self .base_url_entry .get ().strip ()
71+ model = self .model_entry .get ().strip ()
72+ settings_dict = {
73+ "base_url" : base_url ,
74+ "model" : model ,
75+ }
76+
77+ self .settings .save_settings_to_file (settings_dict )
78+ self .destroy ()
79+
2980 class SettingsWindow (tk .Toplevel ):
3081 """
3182 Self-contained settings sub-window for the UI
@@ -86,7 +137,11 @@ def create_widgets(self) -> None:
86137
87138 # Save Button
88139 save_button = ttk .Button (self , text = 'Save Settings' , command = self .save_button )
89- save_button .pack (pady = 20 )
140+ save_button .pack (pady = (10 , 0 ))
141+
142+ # Button to open Advanced Settings
143+ advanced_settings_button = ttk .Button (self , text = 'Advanced Settings' , command = self .open_advanced_settings )
144+ advanced_settings_button .pack (pady = (0 , 10 ))
90145
91146 # Hyperlink Label
92147 link_label = tk .Label (self , text = 'Instructions' , fg = '#499CE4' )
@@ -111,6 +166,10 @@ def save_button(self) -> None:
111166 self .settings .save_settings_to_file (settings_dict )
112167 self .destroy ()
113168
169+ def open_advanced_settings (self ):
170+ # Open the advanced settings window
171+ UI .AdvancedSettingsWindow (self )
172+
114173 class MainWindow (tk .Tk ):
115174 def __init__ (self ):
116175 super ().__init__ ()
0 commit comments