magicgui icon indicating copy to clipboard operation
magicgui copied to clipboard

Clearer mapping between the widget types and Python's types?

Open HagaiHargil opened this issue 4 years ago • 1 comments

❓ Questions and Help

[ x ] I have searched the documentation

I needed a slice widget for today's fancy new GUI and quickly stumbled upon the widget list in the docs. I'm not sure why, but for the life of me I couldn't understand how to get a SliceEdit widget into my app. It took me too long to realize that I can simply annotate my parameter as a slice. I think it could be helpful if for each widget type the docs would point directly to the corresponding Python object. I believe there was an opposite Python -> widget table somewhere, but I can't find it now.

HagaiHargil avatar Feb 28 '21 17:02 HagaiHargil

yeah, I totally agree. will work on it. I think the "reverse" table (if you can even call it that) might be this.

I'll include this in whatever docs I write up, but generally speaking magicgui picks a widget like this:

  1. a type is determined using the type annotation if provided, then falling back to the type of the default value, then falling back to str
  2. type is converted to widget (this is the part that really needs clarification) using as-of-yet poorly documented logic in magicgui.type_map

however... one "trick" worth mentioning is that if you see a widget in magicgui.widgets, you should be able to use it with the widget_type argument to magicgui

thanks for flagging this. will try to write something up soon.

tlambert03 avatar Feb 28 '21 17:02 tlambert03