dpatel has asked for the wisdom of the Perl Monks concerning the following question:

hello, I need to create a GUI for test suite. I have no idea what it should contain and how it should look. So i want to ask first of all, what should I prefer to build GUI? or will Perl-tk be good enough? I need to run tests on linux machine. and it will be a client-server model in which client GUI will accept input for the actions to be performed and Server will perform the actions. (action may be starting test and logging output,etc). So can anyone suggest ideas how it should be?

Replies are listed 'Best First'.
Re: GUI for Test suite
by gemoroy (Beadle) on Apr 19, 2010 at 06:42 UTC
    So..Based on your description I do not see anything that could not be done at Tk(Perhaps your description is incomplete)
    It may look like:
    #!/usr/bin/perl -w use Tk; use Tk::DialogBox; use strict; my($main,$Edit); $main=MainWindow->new(-title => 'MyTestProg'); #Creating window with t +itle $main->Label(-text => 'Enter your action')->pack; $Edit=$main->Entry(-width => 20)->pack;#input field $main->Button(-text => 'Test', -command => \&process)->pack(-side => 'left'); #Button Calle +d 'Test' which calls the subroutine $main->Button(-text => 'Exit', -command => [$main => 'destroy'] #button for closing windwo )->pack; MainLoop;
    Subroutine process can be just a regular sub.
    The only difference is you must call smth like $request=$Edit->get to get data from input field
    And if you want to print smth to user you can create another window and use smth like
    ... $InfoWindow->add("Label", -text => "Output: $output")->pack; ... $InfoWindow->Show(); $InfoWindow->destroy;
    Here you can find everything you need about Tk http://www.ida.liu.se/~tompe/perltk/index.html
      Ok. I got it. But can you tell me how I can generate multiple windows one by one according to user's choice? I tried looking at tutorial for Toplevel widget but I am still not sure how to use it. do you have any better sollution?

        Maybe you are missing some basic info about GUI programming:

        GUIs like Tk are working with "callbacks". That is, if the user clicks on some button (or menu item or...), a subroutine is called that you provided when you created the button. So when you program a GUI you have to think backwards. Not you as script writer control the sequence of events, it is the user.

        If you want user-generated windows, you have to create (for example) a button before you call MainLoop. And provide a callback subroutine with the code to create a new window. This subroutine is not called by your code, it is called by Tks MainLoop.

        I'm not sure what you mean, but...for example you've created main window as in my prev post, with 2 buttons instead of input field (to make it simpler to explain)
        ... $main->Button(-text => 'Test', -command => \&Test)->pack(-side => 'left'); $main->Button(-text => 'Logging', -command => \&LogOutput)->pack(-side => 'left'); ... MainLoop; #Here Main window ends #And we declare our subs with own window for each sub test{ my $TestWindow; $TestWindow=$main->DialogBox(-title => 'Test sub window', -buttons => ["OK"]); #We've created dialog box for test sub output #Then folowing you testing code ... Testing code =) ... if($success){ $TestWindow->add("Label", -text => "Test passed!")->pack; } else { $TestWindow->add("Label", -text => "Test Failed!")->pack; } #Putting conditional output on our window $TestWindow->Show(); # Poping it in front main window #It is not separate window object, but dialog box produced #by main o +bject $InfoWindow->destroy; #Destroying it when OK pressed, and back to main + window }
        Same with logging sub..
Re: GUI for Test suite
by cdarke (Prior) on Apr 19, 2010 at 07:55 UTC
    The answer to "I have no idea what it should contain and how it should look" is simple: just read the program specification. Wot? Not got one? Then maybe you should sit down with your users/sponsors and write one first. Methinks someone decided on the solution before understanding the problem.

    If you have never written a GUI then you might consider a web-based approach instead - in other words let the browser be your GUI and use HTML. Since you are running on Linux then you probably already have all the components, like Apache, installed. This also has the advantange of allowing the users to access the interface remotely.

      oh... your idea seems to be promising in case of server client model. so in case if i use html, I will also have to use CGI, don't I? and Yes I have program specification. I need to give users 2-3 options, and he will choose and accordingly my program will choose the scripts to run. I have created a demo using perl-tk and in which i have used button . user will press the button and program will run specific perl scripts. i have used perl-tk in it. So can you elaborate how HTML could be more useful or better?