how can I see what has been entered in the GUI1 and / or when I get back from the selected GUI2

Hello, I have the following problem: I created two GUI (GUI1 and GUI2). In the first (GUI1) I have two edit text in which I insert numerical values and two pop-up menus, and a callback function "forward" that brings me to the next GUI (GUI2) that contains two radio buttons, two list-box and two functions callback: a GUI allows you to go to the next (GUI3) the other to return to the previous GUI (GUI1). But when I select the pushbutton 'Back' to return to the gui1, the values in the edit text are not saved as well as the selections made in the pop-up menu. I wanted to know, kindly, how can I see what has been entered in the GUI1 and / or when I get back from the selected GUI2.
I saved the strings in the workspace. How do I set the value stored in the workspace in the function _OpeningFcn? I do not want that when the gui1 is started for the first time creates an error because it does not know the value saved in the workspace. If you start for the first time gui1 creates error?
Thank you for your cooperation.

回答(1 个)

Hi,
If I understand this correctly, in some callback in GUI1, you are calling GUI2 and closing GUI1? You want to pass on parameters from GUI1 to GUI2.
You can transfer the parameters when you call GUI2 (that is, GUI2(x,y,z) ) This will be picked up in the opening function of GUI2 and you can store the values there however you want, i usually put them in the handles structure. Set a debug point in the OpeningFcn of GUI2. To solve the problem when you go back, use nargin or something similar to check if you're going back or starting the first time.

9 个评论

I have created two GUI ( GUI1 and GUI2). In the first (GUI1) I have two edit text in which I insert numerical values ,two pop-up menu, and a callback function "forward" that brings me to the next GUI (GUI2) that contains two radio buttons, two list-box and two functions callback (a GUI allows you to go to the next (GUI3), the other to return to the previous GUI (GUI1)). But when I select the pushbutton 'back' in the second GUI (GUI2) (function_ pushbutton_ indietro_callback), to return to GUI1, the values contained in the edit text of the GUI1 not remain saved (empty cell,as if I had never entered the numeric value) as well as the selections made in the pop-up menu (always in gui1).However, the variables inserted and the initially selected strings are stored in the workspace. I wanted to know, kindly, as I see in the GUI1 the values entered in the edit text and the string selected in the pop-up menu when I get back from GUI2?
Thank you for your cooperation.
If you already have the values, set them in the OpeningFcn of GUI1. Use the set command to set a property.
Yes, but .... I do not have a default value in GUI1. When I run the GUI1 I who must enter a valore.Ad example: I have an edit text that contains the value 5. Then I run GUI2. But if I decide to go back (to GUI1) I want to see in my text edit the value 5. Then when I close the matlab software and reopen it later in the edit text in the GUI1 I can enter the value 3. GUI2 Then I run. But if I decide to go back (to GUI1) I want to see in my text edit the value 3. What should I write in the function of OpeningFcn of GUI1?
Then you should send the value 5 from GUI1 to GUI2 and store it there. When you go back to GUI1, send it when you call GUI1 from GUI2 and set the property in the opening function of GUI1.
The problem is I do not know set (do not know how to write) in the OpeningFcn "as property." If "A = 5" in the GUI1. Then I run GUI2. But if I decide to go back (to GUI1) I want to see in my edit text "A = 5". So that, seeing the value of "A = 5", I can change from "A = 5" to "A = 3".
I'm not sure I understand what the issue is. Can't you do something like this in the OpeningFcn?
function GUI1_OpeningFcn(hObject, eventdata, handles, varargin)
if exist('X')
set(handles.edit1,'String',num2str(X));
end
Hello, I put in the function OpeningFcn of GUI1:
if exist ('T') == 1
where T is my numeric variable. This is the part of code that I wrote in the function of Opening:
if exist ('T') == 1           Temperature = num2str (T);      set (handles.edit1_inseriretemperatura, 'String', C);      set (handles.text5, 'String', C);      end
When I go to GUI2 and go back to GUI1, the variable T is saved in the variable T workspace.Tuttavia does not appear in either 'edit1_inseriretemperatura nor in static text text5, that is edit1_inseriretemperatura and text5 fields are blank as if i ran the GUI1 for the first time. The code does not create any error but leave the text boxes where I insert the blank values. How can I do?
But the variables I have not saved and retrieved with setappdata or getappdata passing from GUI1 to GUI2 but through the commands save info_GUI1 T (in GUI1) and load info_GUI1 (in GUI2).
Although when I run exist ('T') in the command line, when I'm going back from GUI2 to GUI1: ans = 1 which means that the numerical variable T exists in the workspace.

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Entering Commands 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by