Skip to content

Commit f4c29c7

Browse files
authored
Merge pull request #385 from capocchi/version-5.1
add info diag
2 parents 4612065 + 148d25f commit f4c29c7

File tree

3 files changed

+227
-8
lines changed

3 files changed

+227
-8
lines changed

devsimpy/DetachedFrame.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ def __init__(self, parent=None, ID=wx.NewIdRef(), title="", diagram=None, name="
152152
toolbar.EnableTool(ID_UPWARD, level != 0)
153153
#=======================================================================
154154

155+
# Bouton d'information (NOUVEAU)
156+
ID_DETACHED_INFO = self.toggle_list[6]
157+
self.tools.append(toolbar.AddTool(ID_DETACHED_INFO, "", load_and_resize_image('info.png'), shortHelp=_('Help')))
158+
155159
toolbar.Realize()
156160
self.SetToolBar(toolbar)
157161

devsimpy/LibPanel.py

Lines changed: 96 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def __init__(self, parent, name):
105105
self.__set_tips()
106106

107107
def BuildToolbar(self):
108-
""" creates one of the tool-bars
108+
""" creates one of the tool-bars
109109
The buttons act like radio buttons, setting a mode for the Panel
110110
Only one of them is pressed at a time. The SetMode() method handles this
111111
"""
@@ -128,13 +128,107 @@ def BuildToolbar(self):
128128
self.Bind(wx.EVT_TOOL, self.tree.OnDelete, id=Menu.ID_DELETE_LIB)
129129
#wx.EVT_TOOL(self, Menu.ID_IMPORT_LIB, mainW.OnImport)
130130
self.Bind(wx.EVT_TOOL, self.tree.OnUpdateAll, id=Menu.ID_REFRESH_LIB)
131-
self.Bind(wx.EVT_TOOL, self.tree.OnInfo, id=Menu.ID_HELP_LIB)
131+
self.Bind(wx.EVT_TOOL, self.OnShowLibraryHelp, id=Menu.ID_HELP_LIB) # Modifié ici
132132
self.Bind(wx.EVT_TOOL, self.tree.OnMCCClick, id=Menu.ID_MCC_LIB)
133133

134134
tb.Realize()
135135

136136
return tb
137137

138+
def OnShowLibraryHelp(self, event):
139+
"""Show help dialog about library management"""
140+
141+
help_msg = _(
142+
"LIBRARY MANAGEMENT PANEL\n\n"
143+
"═══════════════════════════════════════\n\n"
144+
"OVERVIEW:\n\n"
145+
"The library panel allows you to manage DEVS model libraries.\n"
146+
"Libraries are collections of reusable DEVS components that can be\n"
147+
"instantiated in your diagrams using drag-and-drop.\n\n"
148+
"═══════════════════════════════════════\n\n"
149+
"TOOLBAR BUTTONS:\n\n"
150+
"• Import (+): Add a new library to DEVSimPy.\n"
151+
" You can import:\n"
152+
" - Local directories containing Python DEVS models\n"
153+
" - ZIP archives (.zip) with model collections\n"
154+
" - Remote libraries from URLs\n\n"
155+
"• Delete (-): Remove selected library from the tree.\n"
156+
" Warning: This only removes from DEVSimPy, not from disk.\n\n"
157+
"• Reload (⟳): Refresh all libraries to detect new models.\n"
158+
" Use this after modifying model files externally.\n\n"
159+
"• Help (i): Show this help message.\n\n"
160+
"• A-Z: Toggle alphabetical sorting of models in libraries.\n"
161+
" When enabled, models are sorted by name.\n"
162+
" When disabled, models appear in directory order.\n\n"
163+
"═══════════════════════════════════════\n\n"
164+
"LIBRARY TREE:\n\n"
165+
"• Folders: Represent library directories\n"
166+
"• Green blocks: Atomic DEVS models (CodeBlock)\n"
167+
"• Yellow blocks: Coupled DEVS models (ContainerBlock)\n"
168+
"• Gray items: Invalid or incompatible models\n\n"
169+
"Right-click on items for context menu options:\n"
170+
"- Edit: Open model Python file in editor\n"
171+
"- Documentation: View model documentation\n"
172+
"- Properties: Inspect model metadata\n"
173+
"- Rename: Change model label\n"
174+
"- Export: Save model to file\n\n"
175+
"═══════════════════════════════════════\n\n"
176+
"SEARCH FIELD:\n\n"
177+
"Type to search for models by name across all libraries.\n"
178+
"Results appear in a temporary search tree.\n"
179+
"Click the X button to clear search and return to main tree.\n\n"
180+
"═══════════════════════════════════════\n\n"
181+
"HOW TO USE MODELS:\n\n"
182+
"1. Expand library folders to see available models\n"
183+
"2. Drag a model from the library tree\n"
184+
"3. Drop it onto the diagram canvas (right panel)\n"
185+
"4. The model is instantiated and ready to use\n"
186+
"5. Connect models by dragging from output to input ports\n\n"
187+
"═══════════════════════════════════════\n\n"
188+
"LIBRARY TYPES:\n\n"
189+
"• Domain Libraries: Official DEVSimPy model collections\n"
190+
" (Physics, Networks, Control, etc.)\n\n"
191+
"• User Libraries: Your custom model collections\n"
192+
" Add them via Import button\n\n"
193+
"• Remote Libraries: Libraries loaded from URLs\n"
194+
" Automatically updated when available\n\n"
195+
"═══════════════════════════════════════\n\n"
196+
"TIPS:\n\n"
197+
"- Use search to quickly find models in large libraries\n"
198+
"- Keep libraries organized in thematic folders\n"
199+
"- Reload after editing model Python files\n"
200+
"- Right-click models to view documentation\n"
201+
"- Use alphabetical sorting for easier navigation\n"
202+
"- Import ZIP archives to share library collections\n\n"
203+
"═══════════════════════════════════════\n\n"
204+
"CREATING YOUR OWN LIBRARIES:\n\n"
205+
"1. Create a folder with your Python DEVS models\n"
206+
"2. Each model should inherit from DomainBehavior/DomainStructure\n"
207+
"3. Use Import button to add your folder to DEVSimPy\n"
208+
"4. Your models appear in the library tree\n"
209+
"5. Optionally, create a ZIP archive for distribution\n\n"
210+
"For more information, consult the DEVSimPy documentation."
211+
)
212+
213+
try:
214+
import wx.lib.dialogs
215+
dlg = wx.lib.dialogs.ScrolledMessageDialog(
216+
self,
217+
help_msg,
218+
_("Library Management Help"),
219+
size=(650, 600)
220+
)
221+
dlg.ShowModal()
222+
dlg.Destroy()
223+
except Exception as e:
224+
# Fallback si wx.lib.dialogs n'est pas disponible
225+
wx.MessageBox(
226+
help_msg,
227+
_("Library Management Help"),
228+
wx.OK | wx.ICON_INFORMATION
229+
)
230+
231+
138232
def __set_tips(self):
139233
"""
140234
"""

devsimpy/devsimpy.py

Lines changed: 127 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ def MakeToolBar(self):
614614
tb.AddControl(level_label)
615615
tb.AddControl(self.spin)
616616

617+
617618
### add button to define downward and upward rules
618619
ID_UPWARD = self.toggle_list[4]
619620
ID_DOWNWARD = self.toggle_list[5]
@@ -626,7 +627,11 @@ def MakeToolBar(self):
626627

627628
##############################################################################################
628629

629-
for i in (3,8,12,17,21):
630+
# Bouton d'information de la toolbar (NOUVEAU)
631+
ID_TOOLBAR_INFO = self.toggle_list[6]
632+
self.tools.append(tb.AddTool(ID_TOOLBAR_INFO, "", load_and_resize_image("info.png"), shortHelp="Toolbar Help"))
633+
634+
for i in (3,8,12,17,21,23):
630635
tb.InsertSeparator(i)
631636

632637
### undo and redo button desabled
@@ -638,12 +643,30 @@ def MakeToolBar(self):
638643
### default direct connector toogled
639644
tb.ToggleTool(self.toggle_list[0], 1)
640645

641-
### Binding
646+
# Bindings
642647
tool_bindings = [
643-
self.OnNew, self.OnOpenFile, self.OnPrintPreview, self.OnSaveFile, self.OnSaveAsFile,
644-
self.OnUndo, self.OnRedo, self.OnZoom, self.OnUnZoom, self.AnnuleZoom,
645-
self.OnPriorityGUI, self.OnCheck, self.OnPlugins, self.OnSimulation,
646-
self.OnDirectConnector, self.OnSquareConnector, self.OnLinearConnector, self.OnCurveConnector
648+
self.OnNew,
649+
self.OnOpenFile,
650+
self.OnPrintPreview,
651+
self.OnSaveFile,
652+
self.OnSaveAsFile,
653+
self.OnUndo,
654+
self.OnRedo,
655+
self.OnZoom,
656+
self.OnUnZoom,
657+
self.AnnuleZoom,
658+
self.OnPriorityGUI,
659+
self.OnCheck,
660+
self.OnPlugins,
661+
self.OnSimulation,
662+
self.OnDirectConnector,
663+
self.OnSquareConnector,
664+
self.OnLinearConnector,
665+
self.OnCurveConnector,
666+
None, # Placeholder for level_label (no binding)
667+
None, # Placeholder for spin (has its own binding)
668+
self.OnDownWard,
669+
self.OnUpWard
647670
]
648671

649672
for tool, handler in zip(self.tools, tool_bindings):
@@ -657,10 +680,108 @@ def MakeToolBar(self):
657680
self.Bind(wx.EVT_TOOL, self.OnUpWard, id=ID_UPWARD)
658681
self.Bind(wx.EVT_TOOL, self.OnDownWard, id=ID_DOWNWARD)
659682

683+
self.Bind(wx.EVT_TOOL, self.OnShowToolbarHelp, id=ID_TOOLBAR_INFO)
660684
tb.Realize()
661685

662686
# self.SetToolBar(tb)
663687

688+
def OnShowToolbarHelp(self, event):
689+
"""Show help dialog about toolbar buttons"""
690+
691+
help_msg = _(
692+
"DEVSimPy TOOLBAR GUIDE\n\n"
693+
"═══════════════════════════════════════\n\n"
694+
"FILE OPERATIONS:\n\n"
695+
"• New (📄): Create a new empty DEVS diagram\n"
696+
" Shortcut: Ctrl+N\n\n"
697+
"• Open (📂): Load an existing .dsp or .yaml diagram file\n"
698+
" Shortcut: Ctrl+O\n\n"
699+
"• Print Preview (🖨️): Preview diagram before printing\n"
700+
" Shortcut: Ctrl+P\n\n"
701+
"• Save (💾): Save current diagram to file\n"
702+
" Shortcut: Ctrl+S\n"
703+
" If file is new, will prompt for filename\n\n"
704+
"• Save As (💾+): Save diagram with a new name\n"
705+
" Creates a copy with different filename\n\n"
706+
"═══════════════════════════════════════\n\n"
707+
"EDITING OPERATIONS:\n\n"
708+
"• Undo (↶): Undo last action\n"
709+
" Click to undo once\n"
710+
" Hold to see full history\n\n"
711+
"• Redo (↷): Redo previously undone action\n"
712+
" Click to redo once\n"
713+
" Hold to see forward history\n\n"
714+
"═══════════════════════════════════════\n\n"
715+
"VIEW OPERATIONS:\n\n"
716+
"• Zoom In (🔍+): Enlarge diagram view\n"
717+
" Makes models appear bigger\n\n"
718+
"• Zoom Out (🔍-): Reduce diagram view\n"
719+
" Makes models appear smaller\n\n"
720+
"• Reset Zoom (🔍): Return to 100% normal size\n"
721+
" Cancels all zoom operations\n\n"
722+
"═══════════════════════════════════════\n\n"
723+
"DEVS TOOLS:\n\n"
724+
"• Priority (F3): Define execution order for coupled models\n"
725+
" (PyDEVS only - not available in PyPDEVS)\n\n"
726+
"• Debugger (F4): Check diagram for errors\n"
727+
" Validates model connections and structure\n"
728+
" Must run before simulation\n\n"
729+
"• Plugins: Manage DEVSimPy plugins\n"
730+
" Enable/disable extensions\n"
731+
" Configure plugin settings\n\n"
732+
"• Simulation (F5): Launch simulation dialog\n"
733+
" Start DEVS simulation process\n"
734+
" Configure simulation parameters\n\n"
735+
"═══════════════════════════════════════\n\n"
736+
"CONNECTION TYPES:\n\n"
737+
"Choose how connections between models are drawn:\n\n"
738+
"• Direct (—): Straight line connections\n"
739+
" Shortest path between ports\n\n"
740+
"• Square (⌐⌙): Right-angle connections\n"
741+
" Horizontal then vertical routing\n\n"
742+
"• Linear (╱): Diagonal straight lines\n"
743+
" Direct but with angle constraints\n\n"
744+
"• Curve (∿): Curved/bezier connections\n"
745+
" Smooth rounded paths\n\n"
746+
"═══════════════════════════════════════\n\n"
747+
"ABSTRACTION HIERARCHY:\n\n"
748+
"• Level: Select abstraction level (0-20)\n"
749+
" Level 0: Base diagram\n"
750+
" Level 1+: Abstract views with DAM/UAM\n\n"
751+
"• Downward (⬇): Configure downward abstraction rules\n"
752+
" Define how to aggregate lower levels\n\n"
753+
"• Upward (⬆): Configure upward abstraction rules\n"
754+
" Define how to detail higher levels\n\n"
755+
"Note: DAM (Downward Abstraction Manager) and UAM (Upward\n"
756+
"Abstraction Manager) are only available at level > 0\n\n"
757+
"═══════════════════════════════════════\n\n"
758+
"TIPS:\n\n"
759+
"- Always save before simulation\n"
760+
"- Run Debugger (F4) before Simulation (F5)\n"
761+
"- Use connection types for cleaner diagrams\n"
762+
"- Undo/Redo support most editing operations\n"
763+
"- Zoom controls help with large diagrams\n"
764+
"- Abstraction levels enable hierarchical modeling"
765+
)
766+
767+
try:
768+
import wx.lib.dialogs
769+
dlg = wx.lib.dialogs.ScrolledMessageDialog(
770+
self,
771+
help_msg,
772+
_("Toolbar Help"),
773+
size=(650, 600)
774+
)
775+
dlg.ShowModal()
776+
dlg.Destroy()
777+
except Exception as e:
778+
# Fallback
779+
wx.MessageBox(
780+
help_msg,
781+
_("Toolbar Help"),
782+
wx.OK | wx.ICON_INFORMATION
783+
)
784+
664785
def GetExportPathsList(self):
665786
""" Return the list of exported path.
666787
"""

0 commit comments

Comments
 (0)