From: Andrew Kingston <andrew@peerless.co.uk>
Subject: fancy submit gui's
   Date: Wed, 25 Apr 2007 09:23:55 -0400
Msg# 1531
View Complete Thread (6 articles) | All Threads
Last Next
Hi

I'm not sure if there's is any way to do this, but what I want to do is when I make a choice in one field of a submit gui it greys out (or at least clears) another input field. Anybody have any ideas?

Cheers
Andrew

   From: Greg Ercolano <erco@(email surpressed)>
Subject: Re: fancy submit gui's
   Date: Wed, 25 Apr 2007 14:05:57 -0400
Msg# 1532
View Complete Thread (6 articles) | All Threads
Last Next
Andrew Kingston wrote:
I'm not sure if there's is any way to do this, but what I want to do is when I make a choice in one field of a submit gui it greys out (or at least clears) another input field. Anybody have any ideas?

	The 'input' program would have to be improved to support this.
	It could be done, the 'choice' widgets just don't have 'updatecommands'
	implemented at this time. ('buttons' do, though)

	An example of buttons doing this is the "Update" button in the submit-shake
	script; push it, and it parses the frame range from the shk file, and then
	updates that info into the 'Frames:' field.

	A simple example of how this works is:

---- snip
#!/usr/bin/perl
require "ctime.pl";

#
# Simple demo of 'updatecommand'
#

# INPUT PROGRAM
my $input = "/usr/local/rush/examples/bin/input";
if ( ! -f $input ) { $input = "c:/rush/examples/bin/input"; }

# TMP DIR
$tmp = "/var/tmp";                              # modern unix
if ( ! -d $tmp ) { $tmp = "/usr/tmp"; } # old unix
if ( ! -d $tmp ) { $tmp = "c:/temp"; }          # windows

# MAIN
{
    # 'UPDATE TIME' BUTTON WAS PUSHED?
    if ( $ARGV[0] eq "-update" )
    {
        # LOAD KEY/VALUE FILE
        open(IN, "<$ENV{INPUT_DBASE}");
        my $infile = <IN>;
        close(IN);

        # GET CURRENT TIME
        my $current_time = "The current time is " . ctime(time());

        # UPDATE TIME VALUE
        #    This is where you can make any changes to the user's
        #    input form that you want.
        #
        $infile =~ s/Time:.*\n/Time: $current_time/;

        # WRITE OUT MODIFIED FILE
        open(OUT, ">$ENV{INPUT_DBASE}");
        print OUT $infile;
        close(OUT);

        # DONE -- "input" program will now load our changes.
        exit(0);
    }

    # CREATE INPUT DEFINITION FILE
    $inputfile = "$tmp/input-example.in";
    unless ( open(FD, ">$inputfile") )
        { print STDERR "ERROR: $inputfile: $!\n"; exit(1); }

    print FD <<"EOF";

        # CREATE A WINDOW
        window
        {
            name          "Update Test"
            xysize        400 200
        }
        xy 100 50
        input
        {
            name          "The Time Is:"
            dbname        "Time"
            default       "-"
            xysize        280 25
        }
        xyinc 0 10
        button
        {
            name          "Update Time"
            xysize        140 25
            updatecommand "perl $0 -update"             # invokes self when button pushed
        }
EOF
    close(FD);

    # CREATE HISTORY FILE IF IT DOESN'T EXIST
    $histfile = "$tmp/input-example.hist";
    open(FD, ">>$histfile"); close(FD);

    # RUN INPUT PROGRAM
    #    Parses files we created and runs input
    #
    exec("$input -P -d $inputfile -H $histfile");
    print STDERR "ERROR: Could not execute 'input': $!\n";
}
---- snip

	Meanwhile, I'll see if I can include a version of the "input" program
	that allows the 'choice' widget to run an 'updatecommand', similar to
	how buttons do currently. This would get you what you want, and probably
	wouldn't be hard to add to the 'input' program.

PS. What most people do to get fancy guis is to re-implement the render script
    using perltk. (ie. you don't have to use the 'input' program that
    comes with rush to do the GUI; it's just that perltk wasn't stable on all
    platforms at the time rush was released back in 2000)

    Either that, or you can re-implement the script in another language that
    you're more comfortable with; some folks prefer python or ruby, which is fine too.
    (There are some example .py and .rb scripts in the rush/examples dir)

   From: Andrew Kingston <andrew@peerless.co.uk>
Subject: Re: fancy submit gui's
   Date: Tue, 08 May 2007 08:41:48 -0700
Msg# 1539
View Complete Thread (6 articles) | All Threads
Last Next
Greg Ercolano wrote:
Andrew Kingston wrote:
I'm not sure if there's is any way to do this, but what I want to do is when I make a choice in one field of a submit gui it greys out (or at least clears) another input field. Anybody have any ideas?

    The 'input' program would have to be improved to support this.
    It could be done, the 'choice' widgets just don't have 'updatecommands'
    implemented at this time. ('buttons' do, though)

An example of buttons doing this is the "Update" button in the submit-shake script; push it, and it parses the frame range from the shk file, and then
    updates that info into the 'Frames:' field.

    A simple example of how this works is:

---- snip
#!/usr/bin/perl
require "ctime.pl";

#
# Simple demo of 'updatecommand'
#

# INPUT PROGRAM
my $input = "/usr/local/rush/examples/bin/input";
if ( ! -f $input ) { $input = "c:/rush/examples/bin/input"; }

# TMP DIR
$tmp = "/var/tmp";                              # modern unix
if ( ! -d $tmp ) { $tmp = "/usr/tmp"; } # old unix
if ( ! -d $tmp ) { $tmp = "c:/temp"; }          # windows

# MAIN
{
    # 'UPDATE TIME' BUTTON WAS PUSHED?
    if ( $ARGV[0] eq "-update" )
    {
        # LOAD KEY/VALUE FILE
        open(IN, "<$ENV{INPUT_DBASE}");
        my $infile = <IN>;
        close(IN);

        # GET CURRENT TIME
        my $current_time = "The current time is " . ctime(time());

        # UPDATE TIME VALUE
        #    This is where you can make any changes to the user's
        #    input form that you want.
        #
        $infile =~ s/Time:.*\n/Time: $current_time/;

        # WRITE OUT MODIFIED FILE
        open(OUT, ">$ENV{INPUT_DBASE}");
        print OUT $infile;
        close(OUT);

        # DONE -- "input" program will now load our changes.
        exit(0);
    }

    # CREATE INPUT DEFINITION FILE
    $inputfile = "$tmp/input-example.in";
    unless ( open(FD, ">$inputfile") )
        { print STDERR "ERROR: $inputfile: $!\n"; exit(1); }

    print FD <<"EOF";

        # CREATE A WINDOW
        window
        {
            name          "Update Test"
            xysize        400 200
        }
        xy 100 50
        input
        {
            name          "The Time Is:"
            dbname        "Time"
            default       "-"
            xysize        280 25
        }
        xyinc 0 10
        button
        {
            name          "Update Time"
            xysize        140 25
updatecommand "perl $0 -update" # invokes self when button pushed
        }
EOF
    close(FD);

    # CREATE HISTORY FILE IF IT DOESN'T EXIST
    $histfile = "$tmp/input-example.hist";
    open(FD, ">>$histfile"); close(FD);

    # RUN INPUT PROGRAM
    #    Parses files we created and runs input
    #
    exec("$input -P -d $inputfile -H $histfile");
    print STDERR "ERROR: Could not execute 'input': $!\n";
}
---- snip

    Meanwhile, I'll see if I can include a version of the "input" program
    that allows the 'choice' widget to run an 'updatecommand', similar to
how buttons do currently. This would get you what you want, and probably
    wouldn't be hard to add to the 'input' program.

That would be great. I could set up a button to do it, but I don't really want to rely on users having to press it to get the right options. The input program is nice and easy to use as well - which I like & you get a consistent look & feel using it


PS. What most people do to get fancy guis is to re-implement the render script
    using perltk. (ie. you don't have to use the 'input' program that
comes with rush to do the GUI; it's just that perltk wasn't stable on all
    platforms at the time rush was released back in 2000)

Either that, or you can re-implement the script in another language that you're more comfortable with; some folks prefer python or ruby, which is fine too.
    (There are some example .py and .rb scripts in the rush/examples dir)


Definitely most comfortable with Perl. Not used Perltk yet - I may have to look in to that.

Cheers
Andrew

   From: Greg Ercolano <erco@(email surpressed)>
Subject: Re: fancy submit gui's
   Date: Tue, 08 May 2007 11:33:58 -0700
Msg# 1540
View Complete Thread (6 articles) | All Threads
Last Next
Andrew Kingston wrote:
> That would be great.  I could set up a button to do it, but I don't 
> really want to rely on users having to press it to get the right 
> options.

	Yep. I recently added a similar 'updatecommand' feature
	to the browse menu, so that when a new file was 'browsed',
	the update command would automatically be executed.

	Doing this for the pulldown menus would be similar.. I'll try
	to attack it today, if possible.

> The input program is nice and easy to use as well - which I 
> like & you get a consistent look & feel using it

	Cool.. thanks.
	Nice thing about it is you can use it to make GUIs even in csh/bash! ;)

> Definitely most comfortable with Perl.  Not used Perltk yet - I may have 
> to look in to that.

	Yes, I think perltk comes with activestate perl, so if you're all
	windows, you probably already have it.

	perltk probably is NOT already on your osx/linux machines though,
	so you'd have to install it if using those platforms, which is kinda
	a hassle probably. (One of the many reasons I wrote 'input', to prevent
	users having to install the TK stuff globally)

	I'll follow up here when I have a modified version of 'input'
	that supports 'updatecommand' for the chooser.

   From: Greg Ercolano <erco@(email surpressed)>
Subject: Re: fancy submit gui's
   Date: Wed, 09 May 2007 02:54:46 -0700
Msg# 1541
View Complete Thread (6 articles) | All Threads
Last Next
Greg Ercolano wrote:
> 	Yep. I recently added a similar 'updatecommand' feature
> 	to the browse menu, so that when a new file was 'browsed',
> 	the update command would automatically be executed.
> 
> 	Doing this for the pulldown menus would be similar.. I'll try
> 	to attack it today, if possible.

   Done.

   Andrew, please try:
   http://www.seriss.com/rush/releases/patches-for-102.42a8/input-with-choice-updatecommand.tar.gz

   Contents:

-rwxr-xr-x root/root      2644 2007-05-08 18:47:17 test-choice-updatecommand.pl
-rwxr--r-- root/root   1175552 2007-05-08 18:47:27 input.exe
-rwxr-xr-x root/root   1169516 2007-05-08 18:07:38 input-mac
-rwxr-xr-x root/root   1307324 2007-05-08 17:10:51 input.fedora3

   There's one 'input' executable for each platform; just rename out
   your old input program, and install the new with a matching filename
   to try it out.

   The perl script is one that I used to test the feature; feel free
   to try it. (Be sure to invoke it with an absolute path, for the same
   reason the rush scripts need to be) Note that you can simply add
   an 'updatecommand' into the 'choice' section. Whenever the choice
   is changed by the user, the updatecommand is executed. Script shows
   how this works.

   To rename out the old, and install the new:

WINDOWS
    move c:\rush\examples\bin\input.exe c:\rush\examples\bin\input-orig.exe
    copy input.exe c:\rush\examples\bin\input.exe

LINUX
    mv /usr/local/rush/examples/bin/input /usr/local/rush/examples/bin/input-orig
    cp input.fedora3 /usr/local/rush/examples/bin/input

MAC
    ( cd /usr/local/rush/examples/bin/; mv input input-orig )
    ( cd /usr/local/rush/examples/bin/input.app/Contents/MacOS/; mv input input-orig )
    cp input-mac /usr/local/rush/examples/bin/input
    cp input-mac /usr/local/rush/examples/bin/input.app/Contents/MacOS/input

    Let me know if you have any questions.
    Note the special four-step commands are needed for the MAC.

   From: Andrew Kingston <andrew@peerless.co.uk>
Subject: Re: fancy submit gui's
   Date: Wed, 09 May 2007 06:37:21 -0700
Msg# 1542
View Complete Thread (6 articles) | All Threads
Last Next
Greg Ercolano wrote:
Greg Ercolano wrote:
	Yep. I recently added a similar 'updatecommand' feature
	to the browse menu, so that when a new file was 'browsed',
	the update command would automatically be executed.

	Doing this for the pulldown menus would be similar.. I'll try
	to attack it today, if possible.

   Done.

   Andrew, please try:
   http://www.seriss.com/rush/releases/patches-for-102.42a8/input-with-choice-updatecommand.tar.gz

   Contents:

-rwxr-xr-x root/root      2644 2007-05-08 18:47:17 test-choice-updatecommand.pl
-rwxr--r-- root/root   1175552 2007-05-08 18:47:27 input.exe
-rwxr-xr-x root/root   1169516 2007-05-08 18:07:38 input-mac
-rwxr-xr-x root/root   1307324 2007-05-08 17:10:51 input.fedora3

   There's one 'input' executable for each platform; just rename out
   your old input program, and install the new with a matching filename
   to try it out.

   The perl script is one that I used to test the feature; feel free
   to try it. (Be sure to invoke it with an absolute path, for the same
   reason the rush scripts need to be) Note that you can simply add
   an 'updatecommand' into the 'choice' section. Whenever the choice
   is changed by the user, the updatecommand is executed. Script shows
   how this works.

   To rename out the old, and install the new:

WINDOWS
    move c:\rush\examples\bin\input.exe c:\rush\examples\bin\input-orig.exe
    copy input.exe c:\rush\examples\bin\input.exe

LINUX
    mv /usr/local/rush/examples/bin/input /usr/local/rush/examples/bin/input-orig
    cp input.fedora3 /usr/local/rush/examples/bin/input

MAC
    ( cd /usr/local/rush/examples/bin/; mv input input-orig )
    ( cd /usr/local/rush/examples/bin/input.app/Contents/MacOS/; mv input input-orig )
    cp input-mac /usr/local/rush/examples/bin/input
    cp input-mac /usr/local/rush/examples/bin/input.app/Contents/MacOS/input

    Let me know if you have any questions.
    Note the special four-step commands are needed for the MAC.
Wow - so quick.  I've downloaded it - I'll let you know how I get on.

Cheers
Andrew