webgme icon indicating copy to clipboard operation
webgme copied to clipboard

Api for changing the preferences of an object ?

Open magyariE opened this issue 5 years ago • 4 comments

Hello,

I have read the python bindings (Core, Utils), but could not find a way to set up the color or other properties of an object on the UI. Is that possible?

Thanks Endre

magyariE avatar Jul 13 '20 14:07 magyariE

Yes, indeed! When it comes to preferences, that usually suggests that it is a 'registry' rather than an 'attribute'. The main advantage of this separation is that you keep all purely visual features in one place, while the ones that actually gives to the semantics of the model among the attributes. Another hint is the actual name of the feature shown in the property editor. For example, color of the node should be simply 'color' but you can also change the 'textColor' and the 'borderColor' if you would like (to set, use the 'set_registry' function). I do not know from the top of my head what is the usual format we use for these color, but you can set it on the UI and just print it from your plugin (Probably hex values representing RGB).

Hope this helps, Let me know if you have further questions!

kecso avatar Jul 13 '20 16:07 kecso

Hello,

core.set_registry(TestItem, 'color', 0xFF0000)

this did not work. Any idea? Thanks Endre

On 13 Jul 2020, at 18:14, Tamas Kecskes [email protected] wrote:

Yes, indeed! When it comes to preferences, that usually suggests that it is a 'registry' rather than an 'attribute'. The main advantage of this separation is that you keep all purely visual features in one place, while the ones that actually gives to the semantics of the model among the attributes. Another hint is the actual name of the feature shown in the property editor. For example, color of the node should be simply 'color' but you can also change the 'textColor' and the 'borderColor' if you would like (to set, use the 'set_registry' function). I do not know from the top of my head what is the usual format we use for these color, but you can set it on the UI and just print it from your plugin (Probably hex values representing RGB).

Hope this helps, Let me know if you have further questions!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/webgme/webgme/issues/1705#issuecomment-657653161, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQAXYJK6J6K4VZBZ6ZQGLULR3MXHFANCNFSM4OYQRTOA.

magyariE avatar Jul 17 '20 12:07 magyariE

Hey, sorry for the late response. So apparently, we store the color values as string (that way you not only able to set values like #FF0000, but things like 'red'). Other than that, just make sure to call the save function so that your changes are stored.

hope this helps! br, Tamas

kecso avatar Jul 19 '20 14:07 kecso

setPreferences (color, “#FF0000”) worked Thanks, Endre

On 19 Jul 2020, at 16:30, Tamas Kecskes [email protected] wrote:

Hey, sorry for the late response. So apparently, we store the color values as string (that way you not only able to set values like #FF0000, but things like 'red'). Other than that, just make sure to call the save function so that your changes are stored.

hope this helps! br, Tamas

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/webgme/webgme/issues/1705#issuecomment-660653126, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQAXYJPFRYV2LW3J767OSYDR4L7QPANCNFSM4OYQRTOA.

magyariE avatar Jul 23 '20 11:07 magyariE