Borrar filtros
Borrar filtros

why doesn't uidropdown doesn't seem to work correctly (NOT in guide or app designer)?

25 visualizaciones (últimos 30 días)
I know you are supposed to look through documentation for basic questions like this, but everything I've found is extremely confusing and unhelpful. Most of the tutorials out there also assume that if you are wanting to create graphical user interface elements that you are working in app designer, which I am not, and to my understanding has a completely different syntax for working with these, so they aren't helpful either. All I want to do is simple, have a dropdown element and access whatever is currently selected or entered, but this seems to be impossible.
says to save and run this as a .m file, but the example doesn't seem to work the way other ui objects do. It DOES is produce a figure with a dropdown menu as you would expect, but if you select a different element it does not update, the selected item just reverts back to the default value when you let go of the menu.
function updateDropDown
fig = uifigure('Position',[500 500 300 200]);
dd = uidropdown(fig, ...
'Editable','on', ...
'Items',{'Red','Green','Blue'}, ...
'ValueChangedFcn',@addItems);
end
function addItems(src,event)
val = event.Value;
if event.Edited
src.Items{end+1} = val;
end
end
for any other uielement, I can simply access object.Value to access whatever that element has been set at, and if the selection changes that variable changes, but it seems to be impossible to change uidropdown's object.Value.
I gather the answer has to do with callbacks somehow, but I cannot find a good tutorial or explanation for these, they all seem to assume you are using app designer. for example:
why are some callbacks written as @(src, event) callback (src, event) whereas others are
@callback(src, event)
what is src and what is event? these are never previously defined variables, they seem to just be something you have to add in for syntax reasons, but what actually are they? The syntax for using callbacks also seem to be inconsistent. the uicontrol function seems to be very different from any of the others.
Is there a more detailed documentation for using callbacks on ui elements OUTSIDE of app editor for this other than the official one that someone could point me to? because that does not do a good job explaining anything. And why can't I make even a simple dropdown menu that actually lets me interact?
  5 comentarios
Rik
Rik el 5 de Ag. de 2023
I'm on mobile so searching the documentation is harder (as is testing it), but is there a reason you're using ValueChangedFcn instead of Callback? And have you tried setting breakpoints in your callback function to see what is happening with the variables?
Andrew Morris
Andrew Morris el 6 de Ag. de 2023
I've tried the simplest code possible:
fig = uifigure;
dd = uidropdown('Items',{'option1', 'option2', 'option3'});
it will still not let me click on anything other than the default option, even without any callback.
dd.Value is always "option1"
I think this is relevent. The following loads on the terminal when MATLAB is started:
MATLAB is selecting SOFTWARE OPENGL rendering.
MESA-LOADER: failed to open radeonsi: /usr/lib/dri/radeonsi_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
failed to load driver: radeonsi
MESA-LOADER: failed to open zink: /usr/lib/dri/zink_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
failed to load driver: zink
MESA-LOADER: failed to open kms_swrast: /usr/lib/dri/kms_swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
failed to load driver: kms_swrast
MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
failed to load swrast driver.
I will try this again on Windows and see if i can get it to work. This is not not the first time I've had a problem with OpenGL and MATLAB running on Linux.

Iniciar sesión para comentar.

Respuestas (1)

Suman Sahu
Suman Sahu el 22 de Ag. de 2023
Hi Andrew,
I have tried running your code on my machine(Windows) and there does not seem to be any issue with the code. I looked at your comments, you are working on a Linux machine and the issue is apparently with your graphics drivers. Here are some troubleshooting steps that you can follow to resolve your issue:
  1. Try re-installing or updating the appropriate graphics drivers.
  2. OpenGL configuration: Try to run MATLAB with hardware OpenGL rendering if software OpenGL is being used and try software OpenGL rendering if hardware OpenGL is being used.
You can check the current rendering implementation using the following function in MATLAB command window:
Info = rendererinfo(gca)
To start MATLAB session with hardware OpenGL use following command in your system’s command prompt or terminal:
matlab -nosoftwareopengl
To start MATLAB session with software OpenGL use:
matlab -softwareopengl

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by