GUI checkbox display different from value

2 views (last 30 days)
Adam
Adam on 25 Nov 2014
Edited: Adam on 25 Nov 2014
Greetings,
I am seeing some odd behavior in a GUI I designed using GUIDE. I have a single checkbox in the GUI, and it works as a checkbox should, changing value in the callback appropriately.
However, an odd behavior that I have seen is this:
If the checkbox is "checked" (value = 1) and I run the code again without closing down the previous GUI window, the new checkbox is displayed as checked, but the handle value of the checkbox is verified as zero (the appropriate default value).
It seems as if the handles are behaving correctly, but the displayed check box is retaining the last visual state of the previous execution of the GUI. Closing the previous GUI window before running the code again solves the problem, but I would think that the checkbox should reflect the same appropriate initial state from the beginning, regardless of past execution.
Any advice? How do I fix this issue? Is it possible to set the default "display" value of the checkbox?
I have decent experience with MATLAB, but this is my first foray into GUIs, so I apologize if this is a silly question. I appreciate any and all help.
Thank you in advance.
  1 Comment
Adam
Adam on 25 Nov 2014
Edited: Adam on 25 Nov 2014
If you have a GUI defined as a singleton (which is the default setting) then running it again with one still open can be liable to have some side-effects from my experience.
If you really want to run it afresh you should close it first, if you want to return to the existing singleton instance I generally keep a handle to it when I create it and, when my code requests to open the GUI again I first check if the handle is still valid (i.e. the GUI is still open) and if it is I simply make that the current figure rather than re-initialising it.

Sign in to comment.

Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!