'Dynamic' plugs and expressions/connections

22 views
Skip to first unread message

Carlo Giesa

unread,
Sep 19, 2025, 6:47:00 AM (10 days ago) Sep 19
to gaffer-dev
Hi there!

I just would like to share a common situation that we encounter in Gaffer and would like to check with you what would be the easiest and best approach to handle this.

On pipeline nodes, we have 'dynamic' information that involves a setup of plugs. Those setups can change, depending on a situation. As a concrete example, in our publishes, we have a 'context' information (not to be mixed up with a Gaffer.Context) that defines basically 'where' the publish takes place. Our 'contexts' can be of different types and each type has a collection of context levels. Another example is published files. One single publish can contain one or more files or file streams, e.g. different aovs for a single render. Each file or file stream has its basename and path.

To manage this information on reader and publisher nodes, we have pipeline tools that create/delete plugs depending on the publish.

Now, we have situations where we would like to drive things based on this 'dynamic' information by using direct links or expressions. The problem is, since the information is 'dynamic' a plug might appear or disappear which will break direct connections or expression setups.

I'm trying to figure out what we are doing wrong here and wondered if for such situations, we should better use custom plugs or encode dynamic information in json strings that can be put on a single string plug. I guess that former is the more elegant solution, but I'm not sure how much work this implies and if this needs to be done in C++ or if Python is enough. I'm also wondering if for the latter solution, we could still have a way to show the custom string plug in a more fancy way in the GUI, to be more readable for users.

We don't have this issue in Nuke or Houdini where we actually can check for a knob or parm existence inside expressions and deal with it.

Any input would be more than welcome!

Thanks,
Carlo

Carlo Giesa

unread,
Sep 19, 2025, 10:47:06 AM (10 days ago) Sep 19
to gaffe...@googlegroups.com
So, I could move forward on this one. By applying a custom PlugValueWidget to a string plug, I can handle the completely custom display for a simple string plug, that is pretty neat and doesn't need a lot of dev. The user sees a combination of different widgets that he/she can interact with and behind the curtain, we just store everything in a string plug as a json string.

The only thing that I'm missing for now is the correct right-click menu (for now, I get a popup menu that is proper to the widgets that I build) that includes items like "Create Python Expression", "Copy Value"..... and I can't do any drag and drop. Still investigating.

Greets,
Carlo

--
You received this message because you are subscribed to the Google Groups "gaffer-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gaffer-dev+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/gaffer-dev/e0a2ca4b-f512-4971-a9ef-fdec6667ad61n%40googlegroups.com.

John Haddon

unread,
Sep 22, 2025, 5:47:31 AM (7 days ago) Sep 22
to gaffe...@googlegroups.com
Hi Carlo,

Sorry, I should have replied earlier - glad you've found the custom PlugValueWidget stuff though - that does sound like a good solution for your use case.

The usual popup menu is something you add by calling `self._addPopupMenu( targetWidget )`. Behind the scenes it uses `buttonPressSignal()`, so one reason it might not work is if something else is intercepting that signal. If you get stuck, I'm happy to take a closer look if you can send a minimal cut-down example that shows the problem...

Cheers...
John


Carlo Giesa

unread,
Sep 22, 2025, 7:01:17 AM (7 days ago) Sep 22
to gaffe...@googlegroups.com
Hi John!

Thanks for your reply. No problem at all. I did indeed find the 'self._addPopupMenu' method and now everything is working as expected. Really neat.

Greets,
Carlo

Carlo Giesa

unread,
Sep 26, 2025, 3:47:40 AM (3 days ago) Sep 26
to gaffe...@googlegroups.com
I'm trying to figure out the last feature which would be the left- and middle-mouse button drag'n'drop behaviour that I don't manage to get work to connect a plug or to copy its value. I can't see anything specific in the internal PlugValueWidgets of Gaffer on that matter. Any hint?

John Haddon

unread,
Sep 26, 2025, 4:35:22 AM (3 days ago) Sep 26
to gaffe...@googlegroups.com
On Fri, Sep 26, 2025 at 8:47 AM 'Carlo Giesa' via gaffer-dev <gaffe...@googlegroups.com> wrote:
I'm trying to figure out the last feature which would be the left- and middle-mouse button drag'n'drop behaviour that I don't manage to get work to connect a plug or to copy its value. I can't see anything specific in the internal PlugValueWidgets of Gaffer on that matter. Any hint?

I think only the LabelPlugValueWidget supports the starting of a drag - that's done in `LabelPlugValueWidget.__dragBegin`.

But receiving a drag should be implemented for you by the PlugValueWidget base class already, in `PlugValueWidget.__dragEnter`. If uses `self._convertValue()` to coerce the received value to something suitable for that plug - you can override that in your subclass to provide specific conversions.

I suspect you've found those already though, so it might be a case of doing a bit of debugging to see why they're not working for your specific widget...

Cheers...
John

Carlo Giesa

unread,
Sep 26, 2025, 6:08:20 AM (3 days ago) Sep 26
to gaffe...@googlegroups.com
I think that I have a more or less working solution. I had to connect a slot that simply returns True to the buttonPressSignal of each of my widgets. This works great on TextWidgets, but makes problems on widgets like the BoolWidget and Button where I have to double click afterwards to make them work. I just decided to only apply this setup on all my TextWidgets which does already work pretty nicely.

If you have any hint how to make my drag'n'drop behaviour combinable with the standard click mechanism of BoolWidgets and Buttons, I'd be happy. But I'm already pretty satisfied with the current result. :)

Greets,
Carlo

--
You received this message because you are subscribed to the Google Groups "gaffer-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gaffer-dev+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages