@@ -72,12 +72,13 @@ def __init__(
7272 check_parameters : bool = True ,
7373 allow_save = True ,
7474 additional_values : dict = {},
75+ _annotations_override : dict = None ,
7576 ):
7677 super ().__init__ (class_ , return_widget , parent , old_data , check_parameters ,allow_save )
7778 self ._map : Dict [str , Tuple [ComboBoxObjects , Iterable [type ]]] = {}
7879 dpi_5 = dpi_scaled (5 )
7980
80- if not (annotations := get_annotations (class_ )):
81+ if not (annotations := _annotations_override or get_annotations (class_ )):
8182 raise TypeError ("This object cannot be edited." )
8283
8384 # Template
@@ -297,15 +298,9 @@ class NewObjectFrameStructView(NewObjectFrameStruct):
297298 get mapped as annotations, which the :class:`NewObjectFrameStruct` knows how to handle.
298299 """
299300 def __init__ (self , class_ , * args , ** kwargs ):
300- class Viewer :
301- def __init__ (self ) -> None :
302- pass
303-
304- Viewer .__name__ = class_ .__name__
305-
306301 old_data : ObjectInfo = kwargs ["old_data" ]
307- Viewer . __init__ . __annotations__ = {k : v .class_ if isinstance (v , ObjectInfo ) else type (v ) for k , v in old_data .data .items ()}
308- super ().__init__ (Viewer , * args , ** kwargs )
302+ annotations = {k : v .class_ if isinstance (v , ObjectInfo ) else type (v ) for k , v in old_data .data .items ()}
303+ super ().__init__ (class_ , * args , ** kwargs , _annotations_override = annotations )
309304
310305 @gui_except ()
311306 def _edit_selected (self , key : str , combo : ComboBoxObjects ):
@@ -322,5 +317,3 @@ def _edit_selected(self, key: str, combo: ComboBoxObjects):
322317 return self .new_object_frame (selection .class_ , combo , old_data = selection )
323318 else :
324319 return self .new_object_frame (type (selection ), combo , old_data = selection )
325-
326-
0 commit comments