<div dir="ltr">Hello Сергей, thank you very much for your advice. <div><br></div><div>I just replaced the first element of the tuple by my unique ID and it works like a charm. With this approach I can also remove all the "set" callback stuff altogether, which makes a much better code and the GUI responds as expected. The only minor annoyance is that I have to provide a string and not my own data to the tuple, otherwise Blender complains, well I just convert my ID to string and the job is done.</div><div><br></div><div>But regarding the GUI not updating stuff when we have a set callback, does anybody think this might be a bug?</div><div><br></div><div>Henrique Jung</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 9 April 2016 at 20:04, Сергей <span dir="ltr"><<a href="mailto:igelbox@gmail.com" target="_blank">igelbox@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello.<br><br>From blender api documentation (<a href="https://www.blender.org/api/blender_python_api_2_77_release/bpy.props.html" target="_blank">https://www.blender.org/api/blender_python_api_2_77_release/bpy.props.html</a>):<div>"items (sequence of string tuples or a function) – sequence of enum items formatted: [(identifier, name, description, "<div><br></div><div>Try to pass your unique identifiers as first tuple element, e.g.:<br><div>    devices = [("unique-device-id-1", "User-friendly device name",""),</div><div>               ("unique-device-id-2", "User-friendly device name","duplicated name"),</div><div>    ]</div><div>then 'my_settings.device' returns your 'unique-device-id-1' or 'unique-device-id-2' identifiers (not non-unique 'User-friendly device name')</div><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">2016-04-08 6:34 GMT+03:00 Henrique Nunes Jung <span dir="ltr"><<a href="mailto:henriquenj@gmail.com" target="_blank">henriquenj@gmail.com</a>></span>:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">Hello bf-python! This is my first time posting on this list.<div><br></div><div>I working on a plugin for Blender for some time now and I'm having some issues when using the EnumProperty object. My objective is to provide a drop-down menu for the user where he/she can select a given device from a list. I then want to retrieve the currently selected device and perform some initialization.</div><div><br></div><div>Well I managed to create the menu and populated it with my device list - which are strings, basically. But when the user select the device he wants, I can only access the string that is currently selected, and not the unique identifier of the string (such as an index). This can cause bugs on my plugin since I can have two devices with the same name. </div><div><br></div><div>One of my attempted solutions is using the "set" callback from the EnumProperties, that I can capture the "value" argument and use as an index. But there's one problem, as soon as I set a "set" callback function, the menu itself stop updating with the selected device, even though I receive the right value on my callback.</div><div><br></div><div>Here's a sample</div><div><br></div><div><div>        cls.device = EnumProperty(</div><div>                name="Device",</div><div>                description="Device to use for rendering",</div><div>                items=my_devices,</div><div>                set=set_my_device,</div><div>                )</div></div><div><br></div><div><div>def set_my_device(self, value):</div><div>    print("Device index is {0}".format(value))</div><div>    return None</div></div><div><br></div><div><br></div><div><br></div><div>I do receive the "Device index is X" with the right index, but the user interface does not change. I'm following the tutorial available on Property documentation [1], my guess is that I'm suppose to do something within the callback to get the right option to appear selected on Blender, but I don't know what it is.</div><div><br></div><div>Attached there's a minimal sample that you can copy and paste into blender to reproduce the problem. Button appears on the Render panel, below the  render button. I'm testing in 2.76b.</div><div><br></div><div>I stuck into this problem for some time and would really appreciate any help, or maybe some other solution to get the index from EnumProperty.</div><div><br></div><div>Henrique Jung</div><div><br></div><div>[1] <a href="https://www.blender.org/api/blender_python_api_current/bpy.props.html#get-set-example" target="_blank">https://www.blender.org/api/blender_python_api_current/bpy.props.html#get-set-example</a></div></div>
<br></div></div>_______________________________________________<br>
Bf-python mailing list<br>
<a href="mailto:Bf-python@blender.org" target="_blank">Bf-python@blender.org</a><br>
<a href="https://lists.blender.org/mailman/listinfo/bf-python" rel="noreferrer" target="_blank">https://lists.blender.org/mailman/listinfo/bf-python</a><br>
<br></blockquote></div><br></div></div></div></div>
<br>_______________________________________________<br>
Bf-python mailing list<br>
<a href="mailto:Bf-python@blender.org">Bf-python@blender.org</a><br>
<a href="https://lists.blender.org/mailman/listinfo/bf-python" rel="noreferrer" target="_blank">https://lists.blender.org/mailman/listinfo/bf-python</a><br>
<br></blockquote></div><br></div>