How to create reset button GUI

2 次查看(过去 30 天)
I need a create reset button in gui . if click reset button will clear all value in program but I don't know function reset
Help me Please .

采纳的回答

Walter Roberson
Walter Roberson 2012-5-23
set( findall(0, '-property', 'String'), 'String', {''});
arrayfun(@(H) set(H, 'Value', get(H, 'Min')), findall(0, '-property', 'Value', '-and', '-property', 'Min'));
You might perhaps be surprised at the effect that this has on uicontrol objects: for example, the content of all pop-up menus will disappear. As far as MATLAB is concerned, pop-up menus and listbox contents and pushbutton labels are "values", so they would be affected when you "clear all value in program". You could be more selective in what is cleared, but then it would not be all values.
  2 个评论
Mahdi Ghourchian
Mahdi Ghourchian 2019-8-21
编辑:Mahdi Ghourchian 2019-8-21
@Walter Roberson i have defined 12 push buttons which are movable.
I mean as soon as the operator run the matlab gui there are 12 push buttons which the operator can move .I used your code and it just clear the values the buttons as u mentioned.
But i want to define a button to clear the functionality of the other push buttons and not just the value.
I want to define a push button to reset my movable push buttons from movable into unmovable and a normal push button.
Do u have any idea?
Thnak u in advance
Walter Roberson
Walter Roberson 2019-8-26
You can use code to change the Callback property of a pushbutton to alter the behavior of the button.
You can use code to alter the 'enable' property of a pushbutton so that it can no longer be clicked.
You can use code to alter the 'visible' property of a pushbutton so that it shows up or not.
You can use code to make one pushbutton invisible and a different pushbutton visible in much the same position.

请先登录,再进行评论。

更多回答(1 个)

Taewa kaewplang
Taewa kaewplang 2012-5-23
And , if click reset button back to start openingFcn ?
Thank you
  1 个评论
Walter Roberson
Walter Roberson 2012-5-23
openingFcn is something created by GUIDE, not part of MATLAB itself. I do not know what the effect of calling it in your program would be. You would probably have to start with something like
delete(findall(0))

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Entering Commands 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by