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

Last Next