@@ -985,43 +985,173 @@ def __init__(self, parent, title):
985985 def InitUI (self ):
986986 """ Init the UI.
987987 """
988- _icon = wx .Icon ()
989- _icon .CopyFromBitmap (load_and_resize_image ("preferences.png" ))
990- self .SetIcon (_icon )
991-
988+ icon = wx .Icon ()
989+ icon .CopyFromBitmap (load_and_resize_image ("preferences.png" ))
990+ self .SetIcon (icon )
991+
992992 self .SetMinSize ((400 ,500 ))
993-
994- ### Panel
993+
995994 panel = wx .Panel (self , wx .NewIdRef ())
996995 self .pref = Preferences (panel )
997-
998- ### Buttons
996+
997+ # Boutons Apply et Cancel
999998 self .cancel = wx .Button (panel , wx .ID_CANCEL )
1000999 self .apply = wx .Button (panel , wx .ID_OK )
1001-
1000+
1001+ # Bouton d'aide générale (NOUVEAU)
1002+ self .help_btn = wx .Button (panel , wx .ID_HELP , "?" )
1003+ self .help_btn .SetToolTip (_ ("Show help about preferences" ))
1004+
10021005 self .apply .SetToolTipString = self .apply .SetToolTip
10031006 self .cancel .SetToolTipString = self .cancel .SetToolTip
1004-
1007+
10051008 self .apply .SetToolTipString (_ ("Apply all changing" ))
10061009 self .cancel .SetToolTipString (_ ("Cancel without changing" ))
1010+
10071011 self .apply .SetDefault ()
1008-
1009- ### Sizers
1010- vsizer = wx .BoxSizer (wx .VERTICAL )
1011- hsizer = wx .BoxSizer (wx .HORIZONTAL )
1012-
1013- hsizer .Add (self .cancel , 0 )
1014- hsizer .Add (self .apply , 0 , wx .EXPAND | wx .LEFT , 5 )
1015- vsizer .Add (self .pref , 1 , wx .ALL | wx .EXPAND , 5 )
1016- vsizer .Add (hsizer , 0 , wx .ALL | wx .ALIGN_RIGHT , 5 )
1017-
1018- panel .SetSizer (vsizer )
1019- vsizer .Fit (panel )
1020-
1021- ### Binding
1012+
1013+ # Layout
1014+ vbox = wx .BoxSizer (wx .VERTICAL )
1015+ hbox_buttons = wx .BoxSizer (wx .HORIZONTAL )
1016+
1017+ hbox_buttons .Add (self .help_btn , 0 , wx .ALL , 5 )
1018+ hbox_buttons .AddStretchSpacer ()
1019+ hbox_buttons .Add (self .cancel , 0 , wx .ALL , 5 )
1020+ hbox_buttons .Add (self .apply , 0 , wx .ALL , 5 )
1021+
1022+ vbox .Add (self .pref , 1 , wx .EXPAND | wx .ALL , 10 )
1023+ vbox .Add (hbox_buttons , 0 , wx .EXPAND | wx .ALL , 5 )
1024+
1025+ panel .SetSizer (vbox )
1026+
1027+ # Binding
1028+ self .Bind (wx .EVT_BUTTON , self .OnShowPreferencesHelp , id = wx .ID_HELP )
10221029 self .Bind (wx .EVT_BUTTON , self .OnApply , id = wx .ID_OK )
10231030 self .Bind (wx .EVT_BUTTON , self .OnCancel , id = wx .ID_CANCEL )
1024- self .Bind (wx .EVT_BUTTON , self .OnClose , id = wx .ID_CLOSE )
1031+
1032+
1033+ def OnShowPreferencesHelp (self , event ):
1034+ """Show help about preferences dialog"""
1035+
1036+ help_msg = _ (
1037+ "DEVSimPy PREFERENCES\n \n "
1038+ "═══════════════════════════════════════\n \n "
1039+ "This dialog allows you to configure DEVSimPy settings.\n "
1040+ "Navigate through tabs to access different preference categories.\n \n "
1041+ "═══════════════════════════════════════\n \n "
1042+ "GENERAL TAB:\n \n "
1043+ "• Plug-ins Directory: Location of DEVSimPy plugins\n "
1044+ " Change to use custom plugin collections\n \n "
1045+ "• Library Directory: Location of DEVS model libraries\n "
1046+ " Main directory containing all model libraries\n \n "
1047+ "• Output Directory: Where simulation outputs are saved\n "
1048+ " Results, logs, and generated files location\n \n "
1049+ "• Number of Recent Files: Length of recent files list\n "
1050+ " Range: 2-20 files\n \n "
1051+ "• Font Size: Size of text in block diagrams\n "
1052+ " Range: 2-20 points\n \n "
1053+ "• Deep of History: Number of undo/redo levels\n "
1054+ " Range: 2-100 operations\n \n "
1055+ "• wxPython Version: Select wxPython version to use\n "
1056+ " Requires restart to take effect\n \n "
1057+ "• Transparency: Enable transparency for detached frames\n "
1058+ " Makes windows semi-transparent when moving\n \n "
1059+ "• Notifications: Enable notification messages\n "
1060+ " Show pop-up notifications for events\n \n "
1061+ "═══════════════════════════════════════\n \n "
1062+ "SIMULATION TAB:\n \n "
1063+ "• DEVS Kernel: Choose between PyDEVS and PyPDEVS\n "
1064+ " PyDEVS: Classic DEVS simulator\n "
1065+ " PyPDEVS: Parallel DEVS simulator (recommended)\n \n "
1066+ "• Default Strategy: Simulation algorithm to use\n "
1067+ " - original: Standard DEVS algorithm\n "
1068+ " - bag: Optimized message handling\n "
1069+ " - direct: Direct coupling (fastest)\n \n "
1070+ "• Sound on Success: Play sound when simulation completes\n "
1071+ " Select custom MP3/WAV file\n \n "
1072+ "• Sound on Error: Play sound when simulation fails\n "
1073+ " Helps detect problems quickly\n \n "
1074+ "• No Time Limit: Default state for NTL checkbox\n "
1075+ " Run simulations until all models inactive\n \n "
1076+ "• Plot Dynamic Frequency: How often to update plots\n "
1077+ " Higher = more frequent updates (slower)\n "
1078+ " Lower = less frequent updates (faster)\n \n "
1079+ "═══════════════════════════════════════\n \n "
1080+ "EDITOR TAB:\n \n "
1081+ "• Use DEVSimPy Local Editor: Use built-in code editor\n "
1082+ " When checked: Use internal editor\n "
1083+ " When unchecked: Use external editor\n \n "
1084+ "• Select External Editor: Choose external code editor\n "
1085+ " Available: Spyder, Pyzo, or others\n "
1086+ " Click Refresh to detect newly installed editors\n \n "
1087+ "Note: External editor must be installed separately\n "
1088+ "Use 'Update' button to install missing editors\n \n "
1089+ "═══════════════════════════════════════\n \n "
1090+ "AI TAB:\n \n "
1091+ "• Select an AI: Choose AI code generation service\n "
1092+ " - ChatGPT: OpenAI's language model\n "
1093+ " - Ollama: Local AI models\n \n "
1094+ "• API Key (ChatGPT): Your OpenAI API key\n "
1095+ " Get from: https://platform.openai.com/api-keys\n "
1096+ " Stored securely, never shared\n \n "
1097+ "• Port (Ollama): Local Ollama server port\n "
1098+ " Default: 11434\n "
1099+ " Ollama must be running locally\n \n "
1100+ "• Check Button: Verify AI configuration\n "
1101+ " Tests connection and validates settings\n \n "
1102+ "• Info Button: Open AI documentation\n "
1103+ " Learn more about selected AI service\n \n "
1104+ "═══════════════════════════════════════\n \n "
1105+ "PLUGINS TAB:\n \n "
1106+ "• Plugin List: All available DEVSimPy plugins\n "
1107+ " Checkbox = enabled/disabled state\n \n "
1108+ "• Add (+): Install new plugins\n "
1109+ " Browse for plugin files to add\n \n "
1110+ "• Delete (-): Remove all plugins\n "
1111+ " Warning: Deletes all plugin files!\n \n "
1112+ "• Refresh (⟳): Update plugin list\n "
1113+ " Detects newly added plugins\n \n "
1114+ "Double-click plugin name to enable/disable\n "
1115+ "Changes take effect after restart\n \n "
1116+ "═══════════════════════════════════════\n \n "
1117+ "APPLYING CHANGES:\n \n "
1118+ "• Apply: Save all changes and close dialog\n "
1119+ " Settings are written to .devsimpy config file\n \n "
1120+ "• Cancel: Discard changes and close\n "
1121+ " All modifications are lost\n \n "
1122+ "Some changes require DEVSimPy restart:\n "
1123+ "- wxPython version change\n "
1124+ "- DEVS kernel change (PyDEVS ↔ PyPDEVS)\n "
1125+ "- Plugin enable/disable\n "
1126+ "- Library directory change\n \n "
1127+ "═══════════════════════════════════════\n \n "
1128+ "TIPS:\n \n "
1129+ "- Save preferences before closing DEVSimPy\n "
1130+ "- Test AI configuration before using code generation\n "
1131+ "- Increase undo history for complex modeling\n "
1132+ "- Use PyPDEVS for better performance\n "
1133+ "- External editors provide better code assistance\n "
1134+ "- Plugins extend DEVSimPy functionality\n "
1135+ "- Check 'Output Directory' has write permissions"
1136+ )
1137+
1138+ try :
1139+ import wx .lib .dialogs
1140+ dlg = wx .lib .dialogs .ScrolledMessageDialog (
1141+ self ,
1142+ help_msg ,
1143+ _ ("Preferences Help" ),
1144+ size = (700 , 650 )
1145+ )
1146+ dlg .ShowModal ()
1147+ dlg .Destroy ()
1148+ except Exception as e :
1149+ # Fallback
1150+ wx .MessageBox (
1151+ help_msg ,
1152+ _ ("Preferences Help" ),
1153+ wx .OK | wx .ICON_INFORMATION
1154+ )
10251155
10261156 def OnApply (self , evt ):
10271157 """ Apply button has been clicked.
0 commit comments