How to put pictures in a GUI that opens from the main GUI!

2 visualizzazioni (ultimi 30 giorni)
Hello! I created a GUI with buttons that call other side GUI, each with different information. But I still fail to put images in these windows, and need multiple images to better explain the content.
Please help me!
  2 Commenti
Geoff Hayes
Geoff Hayes il 14 Feb 2016
Valaire - you need to provide more information. Where are you trying to "put" these images? Have you defined axes objects within your GUI (or GUIs)?
Valarie
Valarie il 15 Feb 2016
Modificato: Geoff Hayes il 15 Feb 2016
Hello Geoff! On my main GUI there is a pushbutton (16) with the following code:
-----------------------------------------------
% --- Executes on button press in pushbutton16.
function pushbutton16_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton16 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
open('help01.fig');
-----------------------------------------------
On my help01 GUI I want to put a picture and a text box in order to better explain the content. There is a button and an axis with the following code:
-----------------------------------------------
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes1)
imshow('2p1.png')
-----------------------------------------------
So the problem is, when I call the pushbutton16 in the main GUI, image 2p1.png not appear.

Accedi per commentare.

Risposta accettata

Geoff Hayes
Geoff Hayes il 15 Feb 2016
Valarie - your line of code
open('help01.fig');
just opens or displays the figure corresponding to the GUI but does not perform any of the initializations that would occur when launching the GUI correctly. Replace this callback with just
function pushbutton16_Callback(hObject, eventdata, handles)
help01;
to launch the GUI when pressing this pushbutton 16. Note also, that if you want to show the image when the help GUI launches, you must put that command in the OpeningFcn of your GUI (not the pushbutton 5 unless you intend the image to load when the user presses this button).
  1 Commento
Valarie
Valarie il 15 Feb 2016
Thank you Geoff, it works! And now the picture appears when the window is launched.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by