Tutorial on how to build a GUI programmatically? (without using GUIDE)

10 views (last 30 days)
I am looking for a tutorial on how to build a GUI in Matlab without using GUIDE. Unfortunately most information online is about GUIDE and GUIDE's output.
For example, I don't understand why this works:
bgColor = get(source,'BackgroundColor');
if all(bgColor)
bgColor = [1 1 1];
disp white
end
but this doesn't work:
if bgColor = [1 1 1]
dips white
end
I have also difficulties understanding the concept of handles and callback function. Is a handle a predetermined value? I thought it was. But if I write
'callback',{@my_funct,h1}
am I assigning the handle h1?
These are the kind of questions I have, that's why I would like to read a good tutorial. I haven't found one yet.

Accepted Answer

Image Analyst
Image Analyst on 6 Dec 2015
This
if bgColor = [1 1 1]
dips white
end
doesn't work for two reasons. One is that first it does the assignment, NOT comparison, bgColor = [1 1 1], and this produces an error:
Error: File: test1.m Line: 9 Column: 12
The expression to the left of the equals sign is not a valid target for an assignment.
If you want to go the difficult and tedious route of setting up all the controls yourself, with all their properties, sizes, locations, callbacks, etc. instead of using GUIDE, then you can get hints from the examples here: http://www.mathworks.com/matlabcentral/fileexchange/24861-41-complete-gui-examples
The second problem is there is probably no function called "dips" - perhaps you misspelled disp???
There is a replacement for GUIDE out but it's not well publicized. I don't even remember how to get to it. It's been officially released and you're free to use it but I think it's not fully supported yet and is just kind of an early preview for people who want to try it, and it's still a work in progress. Sorry, I don't have the information on it, but someone will add that, I'm sure.
  3 Comments
Image Analyst
Image Analyst on 7 Dec 2015
You really should use all(bgcolor == [1,1,1]) if you want to check all of them.
Sorry, I use GUIDE so I can't give you any more advice on how to avoid it. I have no interest whatsoever in delving into the low level function calls necessary to build a user interface - it's a waste of my time. I can do it much, much faster with GUIDE so I don't bother torturing myself with such low level tedium. My time is better spent on the main algorithm, not trying to recreate what GUIDE can already do. Good luck though.
Image Analyst
Image Analyst on 8 Mar 2016
Here is the link to the appdesigner, the new user interface program that is a replacement for GUIDE:
It is only available starting with MATLAB R2016a, which just became available online within the last few days. I don’t have that version yet but I plan on getting it soon. And then I will start experimenting with AppDesigner. From what I can see so far, it seems nicer and more sophisticated than GUIDE.

Sign in to comment.

More 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!