I am trying to call a GUI f开发者_C百科rom a function, select an item from a pop-up menu in the GUI, and pass a variable associated with the pop-up selection back to the function. The only tutorials I find on GUIs have to do with just changing things within the GUI, but not sending anything out back to a main function.
So say I have 3 options in the pop-up: Image 1, Image 2, Image 3. When for instance Image 2 is selected and the OK button is pressed, I'd like the string 'Image 2' be passed back to the main function that called the GUI.
Thanks for the help!
You can try something like: [selection, ok] = listdlg('PromptString','Select a value:', 'SelectionMode','single', 'ListString',['Value 1';'Value 2';'Value 3'])
. The variable selection
will give you the index of the selected value.
精彩评论