[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] GUI Idea



    The following is a description of an idea I have thrown together for
the purpose of enabling one to create simple GUI's very quickly.  I have
decided to post it here because MacPerl (and Perl in general) would be
perfect for utilizing such a tool, and because MacPerl, in my opinion,
is the best thing out there (sans a simple GUI).  Also, forgive me if
someone has already come up with something that does something similar
to this.  If you have, I would love to get ahold of it.

   I came up with the idea by asking myself what I thought the simplest
way to describe the various elements in a GUI window would be.  I have
been calling it "Instant Interface," but that name may already be
taken.  I did a search for it and didn't find anything threatening.
Briefly, it uses a simple language (if you can call it that) that
describes a GUI layout (similar to HTML forms, but very simple).  An
example of it is:

  Enter your information and hit the OK button.

First Name[]     Last[]
Favorite sport
-Football     -Handball

   (Cancel)    (OK)

    This would be displayed to the user as a GUI window that would look
the same as the above, except that [] would be a text field, '-' would
be a checkbox, and (Cancel) and (OK) would be buttons.  After it was
shown to a user, whom clicked the OK button, it might look like this:

  Enter your information and hit the OK button

First Name[George]     Last[Michael]
Favorite sport
-Football     +Handball

   (Cancel)    (OK)

    As you can see, the entered text would be put between the brackets,
and the '-' would be changed to a '+' if the box was checked.  A simple
line of Perl code could easily extract the information.  In a similar
way, other elements could be represented:

Larger, multiline fields by {}
Radio buttons by * and @ (checked and unchecked)
Pictures by <image.gif>

    If you're wondering how, exactly, it would be presented to the user,
the actual software could take two forms.  The first, and simplest,
would be a stand-alone application (similar to a web browser) that would
display Instant Interface files.  The second way would be a Perl module
that would let one open a window directly through Perl.

STAND-ALONE VERSION:
I am currently, but very slowly, trying to implement this to use at
work.  It will serve as a means of making preference files for the Perl
scripts I make for others to use.  To do this, I would use the program
to save a text file as an Instant Inteface file (just as one saves a
text file as a MacPerl file).  When the user opened the file, it would
be displayed as a GUI window.  Into it, he could enter stuff and hit the
OK button, causing whatever he entered to be saved into the file as
described above.  When the perl script was run, it would open the
Instant Interface text file and extract the information it wanted.  I
plan eventually to implement buttons that launch MacPerl droplets (or
any other file).  Such a button might look like

(Launch Script)TheScript.pl)

    I have yet to figure out how parameter passing will be done.
Perhaps each element will have a default parameter type (if one
parameter was given to a button, we could assume it was a file to
execute and if one parameter was given to a text field, we could assume
it was the width).  Passing multiple parameters to an object could be
done as it is in HTML (with name=value pairs).

(Launch Script) launch=TheScript.pl color=black)


PERL MODULE:
A simple perl module could be implemented that used the stand-alone
version for dialog capabilites or a more complex module could
re-implement it.  A simple module may be able to display dialogs for
input and get back a hash as in:

%Answers = II::Dialog(<<END)

Enter your name[]
@Male   *Female

END

    Since no buttons were specified, default Cancel and OK buttons could
be displayed automatically. $Answers["name"] would contain whatever name
they entered, $Answers["Male"] would contain "true" if it was checked,
and so-on.  To avoid any naming conflicts that might arise, one could
specify a name for the field like this:

Enter your name[Namefield[]

    That would cause "Namefield" to be the index to the hash.
    A more complex version of the module might allow one to assign
javascript-like event-handling PERL functions to objects like this:

  (Enter Information) onclick="APerlFunction()")
or
  (Close Window) onclick="II::CloseWindow()")

    These functions would have access to a global hash that would
contain information about what was entered.

Other details:
-Lines that are beginning or ending with more than two spaces would be
centered
-A line that contains a single underscore would cause an HTML-like
horizontal rule
-Any reserved characters entered by a user would be stored as escape
sequences.  (\d for dash, \p for plus, \S and \s for squair brackets,
etc.)

    Well, there it is.  I will be slowly working on the standalone
version.  If you have any ideas, let me know.  If anyone has any use for
this and wants to try to do any work on it or any variation of it, feel
free.  If I get anywhere on it, it will probably be a while, but will
post it somewhere when I do.

--Craig Muth


- Craig Muth
- Online Designer
- The Cincinnati Enquirer/Post



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch