Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Tk - is MainWindow robust?

by matt.tovey (Beadle)
on Dec 01, 2005 at 10:59 UTC ( [id://513234]=perlquestion: print w/replies, xml ) Need Help??

matt.tovey has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I have a Tk application that, apart from it's own window, needs to open a MainWindow on a large number of other displays (today: 20+, tomorrow: ??). This is going to be somewhat error-prone, and the application should be able to continue to run on whichever nodes do manage to start up successfully, so I need the opening of the MainWindow's to not cause too many problems in the event that a node is down, a display does not allow connections, etc. This is what I'm thinking so far:
use strict; use Tk; my @Displays = qw"node1:0 node2:0"; my $top = MainWindow->new(); my %top; my $orig_display = $ENV{'DISPLAY'}; foreach (@Displays) { $ENV{'DISPLAY'} = $_; if (eval {$top{$_} = MainWindow->new()}) { print "MainWindow opened on $_\n"; } else { print "MainWindow failed to open on $_\n"; $top{$_} = 0; } } $ENV{'DISPLAY'} = $orig_display; MainLoop;
Can anybody see any problems with this? Or perhaps have any ideas, how this could be done better? I couldn't find any documentation for MainWindow... Cheers, Matt

Replies are listed 'Best First'.
Re: Tk - is MainWindow robust?
by rinceWind (Monsignor) on Dec 01, 2005 at 11:17 UTC

    I would use local for tweaking the environment variable:

    use strict; use Tk; my @Displays = qw"node1:0 node2:0"; my $top = MainWindow->new(); my %top; foreach (@Displays) { local $ENV{'DISPLAY'} = $_; if (eval {$top{$_} = MainWindow->new()}) { print "MainWindow opened on $_\n"; } else { print "MainWindow failed to open on $_\n"; $top{$_} = 0; } } MainLoop;

    --

    Oh Lord, won’t you burn me a Knoppix CD ?
    My friends all rate Windows, I must disagree.
    Your powers of persuasion will set them all free,
    So oh Lord, won’t you burn me a Knoppix CD ?
    (Missquoting Janis Joplin)

      Good tip - thanks.
Re: Tk - is MainWindow robust?
by samizdat (Vicar) on Dec 01, 2005 at 15:24 UTC
    Matt, while I'm amazed at how far you're getting and I don't know what the application you're trying to deploy is, I'd humbly suggest that you think seriously about building a web front end for your application rather than trying to build and maintain a mixed-world (UNIX+WinXP+Exceed+???) application. Apache is designed to be scalable and failure-tolerant, and the web interface is/can be relatively portable. Your talent and time are better spent solving many problems for your org rather than getting caught up in one.

    Don Wilde
    "There's more than one level to any answer."
Re: Tk - is MainWindow robust?
by zentara (Archbishop) on Dec 01, 2005 at 13:04 UTC
    I don't really understand what you are trying to do? It would seem that if you want to open linked displays on different machines, you would get more reliable results using sockets to communicate, rather than relying on the MainWindow's event loop.

    I'm not really a human, but I play one on earth. flash japh
      My current version does indeed use sockets. Problems with it are:
      - All nodes need to have the relevant modules and libs available (I'm using Imager). Node architectures are also not homogeneous.
      - The nodes' displays need to be started from the master. I'm currently doing this with rexec and it's not as neat as I would like.
      - The new version needs to support WindowsXP, which has Exceed running (X-Server), but no rexecd.

      Hence my thought to just open MainWindows direct from the master.

        how about still use sockets (or pipes), but instead of establishing a communication between different programs on different boxes uning local displays, communicate between different programs on a single local box using remote displays? I mean, if your current version is somewhat like
        box1:select(@handles_from_boxes) and do_logic()
        box2:tk-interface.pl: connect to box1, create windows and buttons,
        
        then I propose to do this instead:
        box1: for ( @boxes) {
             $ENV{DISPLAY} = $_;
             system "tk-interface.pl";
        }
        select(@handles_from_boxes) and do_logic()
        

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://513234]
Approved by tbone1
Front-paged by Courage
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-23 06:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found