deployed app exit when GUI appeared

2 ビュー (過去 30 日間)
raym
raym 2020 年 12 月 27 日
編集済み: raym 2020 年 12 月 27 日
Hi,
I have a function that shows a GUI with buttons and callbacks.
When running in matlab, it create the gui figure and release the command window, but callback still works when I click on GUI.
However, when I compiled it into exe, the GUI appears and immediately go sway and program exited.
Is there a way to hold the gui?
Thanks.

採用された回答

Walter Roberson
Walter Roberson 2020 年 12 月 27 日
Your flow of control does not waitfor() or uiwait() after creating the graphics, so you get to the bottom of the initialization loop and exit the program.
When you do not compile, then the graphics objects all keep existing because you have the keyboard to go back to for more interaction.
If you are using GUIDE, then look in the code generated for the GUI OpenFcn callback, and you will see a commented-out call to wait for the graphics window to close. Remove the comment marker so that wait becomes active.
  1 件のコメント
raym
raym 2020 年 12 月 27 日
編集済み: raym 2020 年 12 月 27 日
Dear Roberson,
I did not used the GUIDE, but only a f = figure(...).
I add a bottom line
uiwait(f)
and found that the GUI is now stablized.
But when I test a simple function with only one line:
function test
f = figure;
end
I found that there is no problem with this function. The figure is stable, so the uiwait is not necessary from this point.
What could be the discrepancy between such similar scenarios?
Thanks.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by