@@ -122,6 +122,7 @@ def __init__(
122122 raise ValueError (f"Invalid theme color: { theme_color } . Use 'light' or 'dark'." )
123123
124124 self .root = self .__init_root (title , withdraw )
125+ self .root .protocol ("WM_DELETE_WINDOW" , self .__on_close )
125126 self .style : ttk .Style = ttk .Style ()
126127 self .theme : ExtensionTheme = ExtensionTheme ()
127128 self ._widgets = {}
@@ -135,7 +136,7 @@ def __init__(
135136 if add_custom_content :
136137 self .add_extension_content ()
137138
138- self .root . protocol ( "WM_DELETE_WINDOW" , self . __on_close )
139+ self .check_design_type ( )
139140
140141 def add_toggle_theme_button (self , parent , toggle_row , toggle_column ):
141142 """Create a button to toggle between light and dark themes."""
@@ -334,6 +335,70 @@ def add_extension_content(self):
334335 """
335336 raise NotImplementedError ("Subclasses must implement this method." )
336337
338+ @abstractmethod
339+ def check_design_type (self ):
340+ """Check the design type.
341+
342+ This method should be implemented by subclasses to add specific content
343+ to the extension UI.
344+ """
345+ raise NotImplementedError ("Subclasses must implement this method." )
346+
347+
348+ class ExtensionIcepakCommon (ExtensionCommon ):
349+ """Common methods for Icepak extensions."""
350+
351+ def check_design_type (self ):
352+ """Check if the active design is an Icepak design."""
353+ if self .aedt_application .design_type != "Icepak" :
354+ raise AEDTRuntimeError ("This extension can only be used with Icepak designs." )
355+
356+
357+ class ExtensionHFSSCommon (ExtensionCommon ):
358+ """Common methods for HFSS extensions."""
359+
360+ def check_design_type (self ):
361+ """Check if the active design is an HFSS design."""
362+ if self .aedt_application .design_type != "HFSS" :
363+ raise AEDTRuntimeError ("This extension can only be used with HFSS designs." )
364+
365+
366+ class ExtensionHFSS3DLayoutCommon (ExtensionCommon ):
367+ """Common methods for HFSS 3D Layout extensions."""
368+
369+ def check_design_type (self ):
370+ """Check if the active design is an HFSS 3D Layout design."""
371+ if self .aedt_application .design_type != "HFSS 3D Layout Design" :
372+ raise AEDTRuntimeError ("This extension can only be used with HFSS 3D Layout designs." )
373+
374+
375+ class ExtensionMaxwell2DCommon (ExtensionCommon ):
376+ """Common methods for Maxwell 2D extensions."""
377+
378+ def check_design_type (self ):
379+ """Check if the active design is a Maxwell 2D design."""
380+ if self .aedt_application .design_type != "Maxwell 2D" :
381+ raise AEDTRuntimeError ("This extension can only be used with Maxwell 2D designs." )
382+
383+
384+ class ExtensionMaxwell3DCommon (ExtensionCommon ):
385+ """Common methods for Maxwell 3D extensions."""
386+
387+ def check_design_type (self ):
388+ """Check if the active design is a Maxwell 3D design."""
389+ if self .aedt_application .design_type != "Maxwell 3D" :
390+ raise AEDTRuntimeError ("This extension can only be used with Maxwell 3D designs." )
391+
392+
393+ class ExtensionProjectCommon (ExtensionCommon ):
394+ """Common methods for project-level extensions."""
395+
396+ def check_design_type (self ):
397+ """Check the active design type.
398+
399+ Not required for extension at project level."""
400+ pass
401+
337402
338403def create_default_ui (title , withdraw = False ):
339404 import tkinter
0 commit comments