What are the pros and cons of creating GUIs (graphical user
interfaces) with GUIDE and programmatically (code only)?
For either method, what are the pros and cons of using the switchyard
approach to functions vs function handles? When I speak of
switchyard I mean calling one function with a switch and a number of
cases to execute the proper function.
A bit about me and why I asked these questions:
I've been programming GUIs for a year now and I see people mostly
discussing GUIDE methods. After using GUIDE for a bit I grew to hate
it. The GUI based programs in Matlab I've used (and reverse
engineered) and been able to find code for all seem to be done using
the programmatic method. This is why I would like to know why you
use the methods you use.
I don't like code generated by GUIDE. One of the reasons is the
following. It could use new possibilities of MATLAB 7+, for example,
nested function, but it dosn't.
Jeremy Smith wrote:
> What are the pros and cons of creating GUIs (graphical user
> interfaces) with GUIDE and programmatically (code only)?
>
> For either method, what are the pros and cons of using the switchyard
> approach to functions vs function handles? When I speak of
> switchyard I mean calling one function with a switch and a number of
> cases to execute the proper function.
>
> A bit about me and why I asked these questions:
> I've been programming GUIs for a year now and I see people mostly
> discussing GUIDE methods. After using GUIDE for a bit I grew to hate
> it. The GUI based programs in Matlab I've used (and reverse
> engineered) and been able to find code for all seem to be done using
> the programmatic method. This is why I would like to know why you
> use the methods you use.
>
> Thanks in advance for your replies.
Personally, I generally program them but use GUIDE to help me tweak the
layout. Here's an article I wrote on using nested functions, including
a discussion of some of the pros. It includes a link to code you can
download.
> What are the pros and cons of creating GUIs (graphical user
> interfaces) with GUIDE and programmatically (code only)?
>
> For either method, what are the pros and cons of using the
> switchyard
> approach to functions vs function handles? When I speak of
> switchyard I mean calling one function with a switch and a number
> of
> cases to execute the proper function.
I have always written my Matlab guis by hand. Since I've never
really used GUIDE, I can't give a good comparison between the two
methods, but from what I've seen, GUIDE code seems needlessly long
and messy. I also dislike that it monopolizes the UserData field,
which I often use for my own purposes. Designing a gui by hand can
be a little time-consuming, but I prefer that to having to keep track
of two files for every gui (.m and .fig). Plus, as the previous
poster mentioned, creating a gui from scratch allows you to make use
of nested functions, which can often simplify gui code.
I created my first GUI with the GUIDE (I think with Matlab 5.?). And
I immediately thought that the code was too hermetic. The second GUI
was coded by hand.
IMHO, there are two other good reasons (with the one that Loren
mentioned) for NEWBIES to start with the GUIDE:
1) The "Object Browser" and "Property Inspector" are nice tools
displaying all properties and object hierarchy in an elegant way
(better than the "Property Editor"). The way they open is easier
(double-click) than command line INSPECT(obj_handle).
2) I think GUIDE may be more efficient for simple GUIs with a some
objects and basic interactivities.
BUT... I see a major drawback: the backward compatibility of the code
generated by the GUIDE.
Ex: the famous "Undefined function or variable 'gui_mainfcn'." for
users that have Matlab version older than R13 (-> the only
solution: UPGRADE $$$).
Most of the recent submissions on FEX containing GUIs are not
available for these users !
My opinion:
a) start with GUIDE (see 1) above)
b) leave it or only use it for the layout (Loren's comment)
Kelly wrote:
> Jeremy Smith wrote:
>
> > What are the pros and cons of creating GUIs (graphical user
> > interfaces) with GUIDE and programmatically (code only)?
> >
> > For either method, what are the pros and cons of using the
> > switchyard
> > approach to functions vs function handles? When I speak of
> > switchyard I mean calling one function with a switch and a number
> > of
> > cases to execute the proper function.
>
> I have always written my Matlab guis by hand. Since I've never
> really used GUIDE, I can't give a good comparison between the two
> methods, but from what I've seen, GUIDE code seems needlessly long
> and messy. I also dislike that it monopolizes the UserData field,
> which I often use for my own purposes. Designing a gui by hand can
> be a little time-consuming, but I prefer that to having to keep track
> of two files for every gui (.m and .fig). Plus, as the previous
> poster mentioned, creating a gui from scratch allows you to make use
> of nested functions, which can often simplify gui code.
>
> -Kelly
What I've done with acceptable results, so far is to do most of the
development in guide and then have it export to a single m-file.
Granted the full file can be huge, but I don't have to worry about two
files or the like, and I can use guide for the graphical layout.
There are a number of reasons I have been coding by hand. They boil
down to two basic reasons.
1) Easy deployment: A year later I'm still working on the GUI I
began developing for my employer after first starting Matlab GUI
programming and I'm releasing new beta versions at a regular rate.
The fewer files someone has to update the better. Someone who worked
in our lab before my time created a GUI program in Matlab for the lab
and it was a mess of little functions. I used it infrequently enough
that I could never remember which function to run. There is no need
to worry about a fig file either.
2) GUIDE Generated Code: To me it has always looked like a mess. I
have never liked it.
When I create a new GUI I use GUIDE to lay it out but I never save or
generate any files. Each time I use GUIDE I write the parameters I
like directly into my GUI.
I prefer the function method over the switchyard method. It's easier
to navigate subfunctions using the dropdown menu in the editor. The
code is also easier to read, especially when there are a lot of loops
and other indenting functions.
It's good to hear my reasons aren't totally uncommon.
Jeremy Smith wrote:
>
>
> What are the pros and cons of creating GUIs (graphical user
> interfaces) with GUIDE and programmatically (code only)?
>
> For either method, what are the pros and cons of using the
> switchyard
> approach to functions vs function handles? When I speak of
> switchyard I mean calling one function with a switch and a number
> of
> cases to execute the proper function.
>
> A bit about me and why I asked these questions:
> I've been programming GUIs for a year now and I see people mostly
> discussing GUIDE methods. After using GUIDE for a bit I grew to
> hate
> it. The GUI based programs in Matlab I've used (and reverse
> engineered) and been able to find code for all seem to be done
> using
> the programmatic method. This is why I would like to know why you
> use the methods you use.
>
> Thanks in advance for your replies.
I made my first GUI in Matlab 10+ years ago. I played a little with
GUIDE when it appeared and have not tried it since.
GUI without GUIDE
Pros (without order)
Possibility to control the GUI layout programatically. (See Layout
Manager at xtargets.com for an advanced example.) That makes it
possible to adapt the GUI nicely to (take advantage of) various
screen sizes. Furthermore, it saves time to stick to scheme and resit
all tweaking.
Reuse of GUI-related code. I define groups of controls, which I
reuse. E.g. a listbox together with pushbuttons for search and sort
and a context menu for copy and copy options. I do not modify such
groups for various GUIs, which help both me and other user to
remember how they behave. Theese groups become kind of high level
controls.
Cons (without order)
There are little documentation and help. You have to invent the wheel
yourself.
Take more time to make a simple guis.
There is an upfront investment. Low productivity to start with.
And last, the combination of nested functions and function handles is
superior to the switch-yard pattern.
Jeremy Smith wrote:
>
>
> What are the pros and cons of creating GUIs (graphical user
> interfaces) with GUIDE and programmatically (code only)?
>
> For either method, what are the pros and cons of using the
> switchyard
> approach to functions vs function handles? When I speak of
> switchyard I mean calling one function with a switch and a number
> of
> cases to execute the proper function.
>
> A bit about me and why I asked these questions:
> I've been programming GUIs for a year now and I see people mostly
> discussing GUIDE methods. After using GUIDE for a bit I grew to
> hate
> it. The GUI based programs in Matlab I've used (and reverse
> engineered) and been able to find code for all seem to be done
> using
> the programmatic method. This is why I would like to know why you
> use the methods you use.
>
> Thanks in advance for your replies.
I made my first GUI in Matlab 10+ years ago. I played a little with
GUIDE when it appeared and have not tried it since.
GUI without GUIDE
Pros (without order)
Possibility to control the GUI layout programatically. (See Layout
Manager at xtargets.com for an advanced example.) That makes it
possible to adapt the GUI nicely to (take advantage of) various
screen sizes. Furthermore, it saves time to stick to scheme and resit
all tweaking.
Reuse of GUI-related code. I define groups of controls, which I
reuse. E.g. a listbox together with pushbuttons for search and sort
and a context menu for copy and copy options. I do not modify such
groups for various GUIs, which help both me and other user to
remember how they behave. Theese groups become kind of high level
controls.
Cons (without order)
There are little documentation and help. You have to invent the wheel
yourself.
Take more time to make a simple guis.
There is an upfront investment. Low productivity to start with.
And last, the combination of nested functions and function handles is
superior to the switch-yard pattern.
This utility takes a fig file and generates a cell array of valid
command strings that can be pasted in code or even sent to eval
(although i've never used it this way except for batch testing). You
can specify object properties to include or exclude, and/or extract
only non-default props. The generated code (still) often needs some
manual polish, but (IMHO) a very minor one, and to me - its
definitely a time saver.
Another reason for coding by hand is that you can use a source code
control system (e.g. CVS) and keep track of the changes you make to the
code - my experience was that it's not really practicable to compare
two versions of code generated by GUIDE because it often does massive
reordering after trivial changes.
Scott Seidman wrote:
> Loren Shure <loren@mathworks.com> wrote in news:ecn2v0$665$1
> @fred.mathworks.com:
>
>> Here's an article
>
> Link please, Loren?
>
"Neo Patrix" <neo.patrix@googlemail.com> wrote in message
news:ef3f3e7.13@webcrossing.raydaftYaTP...
> @Mathworks
>
> you bloody mother fuckers....do you mean to say that I have to copy
> every external header file & library to
> %MATLAB%\extern ?
>
> In that case what good is all that money paid up for license?
"Neo Patrix" <neo.patrix@googlemail.com> wrote in message
news:ef3f3e7.13@webcrossing.raydaftYaTP...
> @Mathworks
>
> you bloody mother fuckers....do you mean to say that I have to copy
> every external header file & library to
> %MATLAB%\extern ?
>
> In that case what good is all that money paid up for license?
Could you clarify what you're trying to do that is causing you to need to
copy every header file and library to the extern subdirectory? I admit I'm
not an expert on the deployment capabilities of MATLAB, but I don't believe
you need to do that as long as the header files and libraries are on the
system path and/or in the LD_LIBRARY_PATH when you compile. If you post
what you're doing here, or contact our technical support staff, people who
are more familiar with the deployment capabilites than I am can take a look.
--
Steve Lord
slord@mathworks.com
Tags for this Thread
Add a New Tag:
Separated by commas
Ex.: root locus, bode
What are tags?
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.