Custom UI for Blender 2.8 Addons

blender2-80

(calembendell) #1

Hullo everyone,

The available widgets that can be used to develop addons is unfortunately a little limiting for complex addons.
Customisability is also understandably low to keep the Blender editor’s appearance consistent.

If we need a sort of widget that is not already available in Blender, what is our best course of action?

I could write the necessary UI code in C to implement the widget, which would be painful and means the addon would take extra steps to install.

I could also implement the addon as a separate program that sends commands to Blender through an addon listening at a socket.
This adds to the complexity of the development of the addon and means that multiple windows need to be open, which is a pain, but grants all the flexibility an individual could want for the addon.

Is there another way?

Thanks!


(Roy Nieterau) #2

Do you have a design example of what you are trying to achieve that you are not able to produce with Blender’s UI? Maybe that could help you get started if others could help propose design ideas that would be a good fit in Blender?

If there really is good reason to use another UI toolkit… Managing other UI toolkits within Blender should be doable - I have seen some code examples using PyQt although I haven’t been able to run that stable myself yet, but I might be investigating that more soon as I need to reproduce the same UI I am using in multiple host applications, Maya, Houdini, Blender, etc. Using the same UI in multiple applications could be one of the reasons for not choosing specifically for Blender UI. :slight_smile:


(Ben H) #3

The available widgets that can be used to develop addons is unfortunately a little limiting for complex addons.

Could you be more specific about what you are looking for? Perhaps you have overlooked some options.


(SynaGl0w) #4

The current layout engine is very limited, especially via the python API. Despite that, the API does have one very handy feature: the as_pointer() method. If you look at the corresponding source you can recreate the C structs via the ctypes module and access many members that the python API does not provide access to. It’s actually quite amazing how many things the python API leaves out.

I assume what you are after is a custom widget placed in a panel along with other controls such as buttons and text fields? Always wanted a multi-line text widget with optional scroll bar(s). A widget with custom drawing and custom event handling (something that is usually possible in other UI toolkits).

I see a lot of possibilities to abuse the hell out of the gizmo API. Have not actually touched it much yet so we’ll see.

Supposedly custom editors should be a thing but can’t figure that out yet:
https://wiki.blender.org/wiki/Reference/Release_Notes/2.80/Python_API/UI_DESIGN

Some addons (asset managers, game engines etc) make sense to integrate as an entirely separate Editor. In 2.8 it is now possible for addons.


(calembendell) #5

Hey @BigRoy and @brhumphe,

I can definitely provide more context.
Many things are surprisingly difficult to do with Blender’s UI.
In my case, I wanted a big icon with a slider next to it or below it.
We tried to make Blender’s UI submit to that simple request for a bit before giving up since it isn’t really possible to set the size of an image.
Fortunately, the preview layout presents images as large enough to be legible if you’re presenting a complex image, so we settled for using 10 preview images rather than having a slider.

Now I would like to do things like allow an individual to select a point on a 2D grid to select X and Y values for complex morph targets, allowing procedural mesh editing to be controlled by selecting points on a grid.
Another thing I can’t figure out is how to let someone specify float curves in the editor for procedural generation or really to express any sort of complex data structure outside of having a very large dialogue box with single floats able to be specified.
I can’t really work around these requirements outside of creating an impossibly complex UI.

Thanks for the pointer to as_pointer @SynaGl0w, I’ll be giving it a look soon!
Having to boot up another UI would be a rubbish solution since it introduces a lot of unfortunate window management.
Maybe there’s a way to abuse the gizmo to deal with that indeed! :smiley:


(SynaGl0w) #6

That subject could supply an entire book of rants and rage.

The main reason I recommend looking into them is it appears they can be continuously active if desired (such as the ones in the 3D view), and handle drawing and input/events:
https://docs.blender.org/api/blender2.8/bpy.types.Gizmo.html
https://docs.blender.org/api/blender2.8/bpy.types.GizmoGroup.html

Still the annoying problem is being able to integrate any kind of custom control into Blenders UI system, layouts, panels, etc. The easy solution is to ignore the UI and just do custom drawing over the top of it, while consuming events that are relevant. If gizmos can work the way I assume, I might try to redo this little experiment: https://www.youtube.com/watch?v=3ZjZ1bx2hag It might be much easier now with gizmos.

Just curious, do you have a mockup image of the kind of interface you are trying to create?