How to use uiwait in GUI

11 Ansichten (letzte 30 Tage)
Myrthe B.
Myrthe B. am 5 Feb. 2019
Beantwortet: Luna am 5 Feb. 2019
I want to use uiwait in my gui to prevent the rest of my script from advancing until the button 'end' is used. However, when I put uiwait in the opening function, it advances anyways. However, it only advances after using two buttons (initializing imfreehand) twice. If I put one more uiwait, the same happens after three times. Two other buttons don't have this effect on advancing the script. Therefore, it seem that these two buttons somehow delete the figure so uiwait advances. However, I can't figure out where, how and why.
Where should I put uiwait to have the desired effect (advancing only after the button 'end' is used)?
  2 Kommentare
Gani
Gani am 5 Feb. 2019
You can disable the 'end' button till your script completes using callback.
Myrthe B.
Myrthe B. am 5 Feb. 2019
Yes, I'm aware of that. Maybe it was not entirely clear. I have a base script where this GUI is a part of. I only want to advance with the rest of the script until the user is ready with manual adjusting and pushes 'end'. At the moment, the rest of my script advances before this manual adjusting is complete.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Luna
Luna am 5 Feb. 2019
Use waitfor instead. Waitfor pauses calculation until the object destroyed or deleted.
figHandle = uifigure(..) % or you can create another object, etc.
waitfor(figHandle); % when end button pressed, put delete to this button's callback and delete figHandle (or close figure inside this callback), so your code will continue after deletion.
% you can apply it any other objects not only figures

Weitere Antworten (0)

Kategorien

Mehr zu Maintain or Transition figure-Based Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by