MATLAB SIMULINK 7 - GRAPHICAL USER INTERFACE Manual de usuario Pagina 197

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 330
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 196
Examples: Programming GUI Components
8-25
is fixed, then you can use this approach. Else, you can use the index to retrieve
the actual string for the selected item.
function popupmenu1_Callback(hObject, eventdata, handles)
val = get(hObject,'Value');
switch val
case 1
% User selected the first item
case 2
% User selected the second item
% Proceed with callback...
Using the Index to Determine the Selected String
This example retrieves the actual string selected in the pop-up menu. It uses
the pop-up menu
Value property to index into the list of strings. This approach
may be useful if your program dynamically loads the contents of the pop-up
menu based on user action and you need to obtain the selected string. Note that
it is necessary to convert the value returned by the
String property from a cell
array to a string.
function popupmenu1_Callback(hObject, eventdata, handles)
val = get(hObject,'Value');
string_list = get(hObject,'String');
selected_string = string_list{val}; % Convert from cell array
% to string
% Proceed with callback...
Panel
Panels group GUI components and can make a GUI easier to understand by
visually grouping related controls. A panel can contain panels and button
groups as well as axes and user interface controls such as push buttons, sliders,
pop-up menus, etc. The position of each component within a panel is
interpreted relative to the lower left corner of the panel.
If the GUI is resized, the panel and its components are also resized, but you
may want to adjust the size and position of the panel’s components. You can do
this if you set the GUI
Resize behavior to Other (Use ResizeFcn) and provide
a
ResizeFcn callback for the panel.
Vista de pagina 196
1 2 ... 192 193 194 195 196 197 198 199 200 201 202 ... 329 330

Comentarios a estos manuales

Sin comentarios