@@ -477,6 +477,16 @@ def set_origin_window(cls, window: ObjectEditWindow):
477477
478478 @classmethod
479479 def convert_types (cls , types_in ):
480+ def remove_wrapped (types : list ):
481+ r = types .copy ()
482+ for type_ in types :
483+ # It's a wrapper of some class -> remove the wrapped class
484+ if hasattr (type_ , "__wrapped__" ):
485+ if type_ .__wrapped__ in r :
486+ r .remove (type_ .__wrapped__ )
487+
488+ return r
489+
480490 while get_origin (types_in ) is Union :
481491 types_in = get_args (types_in )
482492
@@ -486,7 +496,15 @@ def convert_types(cls, types_in):
486496 else :
487497 types_in = [types_in , ]
488498
489- return types_in
499+ # Also include inherited objects
500+ subtypes = []
501+ for t in types_in :
502+ if hasattr (t , "__subclasses__" ) and t .__module__ .split ('.' , 1 )[0 ] in {"_discord" , "daf" }:
503+ for st in t .__subclasses__ ():
504+ subtypes .extend (cls .convert_types (st ))
505+
506+ # Remove wrapped classes (eg. wrapped by decorator)
507+ return remove_wrapped (types_in + subtypes )
490508
491509 def update_window_title (self ):
492510 self .origin_window .title (f"{ 'New' if self .old_object_info is None else 'Edit' } { self .get_cls_name (self .class_ )} object" )
@@ -623,12 +641,16 @@ def _gui_to_object(self):
623641 def _update_old_object (self , new : Union [ObjectInfo , Any ]):
624642 if self .old_object_info is not None :
625643 ret_widget = self .return_widget
626- if isinstance (ret_widget , ListBoxScrolled ):
627- ind = ret_widget .get ().index (self .old_object_info )
628- else :
629- ind = ret_widget ["values" ].index (self .old_object_info )
644+ # Ignore if not in list (Combobox allows to type values directly in instead of inserting them)
645+ # thus when edit is clicked, the old information is loaded into the object edit info, howver the actual
646+ # value while it was writen inside the combobox is not actually present in the list of it's values
647+ with suppress (ValueError ):
648+ if isinstance (ret_widget , ListBoxScrolled ):
649+ ind = ret_widget .get ().index (self .old_object_info )
650+ else :
651+ ind = ret_widget ["values" ].index (self .old_object_info )
630652
631- ret_widget .delete (ind )
653+ ret_widget .delete (ind )
632654
633655 self .return_widget .insert (tk .END , new )
634656 if isinstance (self .return_widget , ComboBoxObjects ):
0 commit comments