You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
magicgui has a global map to determine which widget to use for each type. A problem I'm facing now is that if I updated the type map in my module, it will affect all other modules that depend on magicgui. More specifically, I want to use LineEdit for all the simple types including int and float for my purpose but I don't want to change the behaviors of others (for example, if Annotated[int, {"max": 10}] is used in another module, it stops working if I change the widget for int to LineEdit). I think this problem can be solved by using type_registered context manager, but here's much simpler solution and I'd like to discuss whether we should have this feature.
In the type_map submodule, we can define a WidgetStore class that holds a mapping from type to widget and has all the methods useful for the type mapping tasks:
magicgui
has a global map to determine which widget to use for each type. A problem I'm facing now is that if I updated the type map in my module, it will affect all other modules that depend onmagicgui
. More specifically, I want to useLineEdit
for all the simple types includingint
andfloat
for my purpose but I don't want to change the behaviors of others (for example, ifAnnotated[int, {"max": 10}]
is used in another module, it stops working if I change the widget forint
to LineEdit). I think this problem can be solved by usingtype_registered
context manager, but here's much simpler solution and I'd like to discuss whether we should have this feature.In the
type_map
submodule, we can define aWidgetStore
class that holds a mapping from type to widget and has all the methods useful for the type mapping tasks:This does not affect the current usages because we can just define a default global
WidgetStore
instance.If one wants to use their own rule, they can just create their own widget store.
If you think it's reasonable, I'm happy to send a PR.
The text was updated successfully, but these errors were encountered: