From: Chris Sorrento on 19 Jul 2010 10:19 I have designed a GUI with multiple textboxes where I collect user input values (numerical values) and pass them to a function file for evaluation. But there are too many textboxes. To make the GUI more user friendly, I put default/suggested values in the "String" property of PropertyInspector. But Matlab reads that as []. So, I have to put my curser in each box and then either hit enter or tab to next textbox. This defeats the purpose of putting in default values. Any suggestions as to how I can get around this? I guess same question applies to other components in GUI - list, slider, radio buttons. Thank you in advance for taking time to read this.
From: Sean on 19 Jul 2010 11:35 "Chris Sorrento" <remove.this.string.agairan(a)hotmail.com> wrote in message <i21msp$db5$1(a)fred.mathworks.com>... > I have designed a GUI with multiple textboxes where I collect user input values (numerical values) and pass them to a function file for evaluation. But there are too many textboxes. To make the GUI more user friendly, I put default/suggested values in the "String" property of PropertyInspector. But Matlab reads that as []. So, I have to put my curser in each box and then either hit enter or tab to next textbox. This defeats the purpose of putting in default values. Any suggestions as to how I can get around this? I guess same question applies to other components in GUI - list, slider, radio buttons. Thank you in advance for taking time to read this. %Did you create your GUI with GUIDE? % %In your code opening function: set(handles.your_textbox,'String','Default Value'); % %To retrieve the values for your functions numeric_value = str2num(get(handles.your_textbox,'String')); You can use setappdata/getappdata with your handles to make the value retrievable from functions that will always need them too. %E.g. in your opening function: setappdata(0,'Hyour_textbox',handles.your_textbox); %in function fun(in) function out = fun(x) H = getappdata(0,'Hyour_textbox'); Val = str2num(get(H,'String')); out = Val^2*pi/in;
From: Chris Sorrento on 19 Jul 2010 12:07 Thank you Sean. I did create the GUI using GUIDE and I was simply changing the "String" value from within PropertyInspector. But as you have suggested, I might need to add this code that you suggested into the GUI .m file. That is exactly the guidence I was looking for. Thanks for your help. "Sean " <sean.dewolski(a)nospamplease.umit.maine.edu> wrote in message <i21rb8$2iu$1(a)fred.mathworks.com>... > > I have designed a GUI with multiple textboxes where I collect user input values (numerical values) and pass them to a function file for evaluation. But there are too many textboxes. To make the GUI more user friendly, I put default/suggested values in the "String" property of PropertyInspector. But Matlab reads that as []. So, I have to put my curser in each box and then either hit enter or tab to next textbox. This defeats the purpose of putting in default values. Any suggestions as to how I can get around this? I guess same question applies to other components in GUI - list, slider, radio buttons. Thank you in advance for taking time to read this. > > > %Did you create your GUI with GUIDE? > % > %In your code opening function: > set(handles.your_textbox,'String','Default Value'); > % > %To retrieve the values for your functions > numeric_value = str2num(get(handles.your_textbox,'String')); > > > You can use setappdata/getappdata with your handles to make the value retrievable from functions that will always need them too. > %E.g. in your opening function: > setappdata(0,'Hyour_textbox',handles.your_textbox); > > %in function fun(in) > function out = fun(x) > H = getappdata(0,'Hyour_textbox'); > Val = str2num(get(H,'String')); > out = Val^2*pi/in;
From: Andy on 19 Jul 2010 12:53 "Chris Sorrento" <remove.this.string.agairan(a)hotmail.com> wrote in message <i21msp$db5$1(a)fred.mathworks.com>... > I have designed a GUI with multiple textboxes where I collect user input values (numerical values) and pass them to a function file for evaluation. But there are too many textboxes. To make the GUI more user friendly, I put default/suggested values in the "String" property of PropertyInspector. But Matlab reads that as []. So, I have to put my curser in each box and then either hit enter or tab to next textbox. This defeats the purpose of putting in default values. Any suggestions as to how I can get around this? I guess same question applies to other components in GUI - list, slider, radio buttons. Thank you in advance for taking time to read this. Can you describe your problem in more detail? What do you mean by "too many textboxes"? Are your textboxes what GUIDE calls Edit Text boxes? What are some of your values which are not being correctly read? And what do you mean by "MATLAB reads that as []"? Are you saving your .fig file before re-running your GUI? When I create a new file in GUIDE, add an Edit Box, change the String field, save, and then run the GUI, I see a GUI with an editable text box that, by default, contains whatever I entered as the String. I cannot reproduce the error you've described.
|
Pages: 1 Prev: CRC check, Modbus for xPC Target Next: Problem xUnit static methods |