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

[no subject]



--- Cut Here ----
 sub start_app {
  my($org, $user, $pass, $server) = undef;

  my $login = MainWindow->new();
  $login->configure(-title => 'Login');
  $login->geometry("+100+300");
  my $frm1 = $login->Frame(
    -relief => "groove",
    -borderwidth => 3);
  $frm1->pack(-side => 'top', -fill => 'x');
  my $frm1_lbl1 = $frm1->Label (
    -text => 'Server Address:');
  $frm1_lbl1->pack( -side => 'left');
  $server = $frm1->Entry( -width => 32, -background => 'white');
  $server->pack( -side => 'right', -pady => 3);

  my $frm2 = $login->Frame(
    -relief => "groove",
    -borderwidth => 3);
  $frm2->pack(-side => 'top', -fill => 'x');
  my $frm2_lbl1 = $frm2->Label (
    -text => 'Organization:');
  $frm2_lbl1->pack( -side => 'left');
  $org = $frm2->Entry( -width => 32, -background => 'white');
  $org->pack( -side => 'right', -pady => 3);

  my $frm3 = $login->Frame(
    -relief => "groove",
    -borderwidth => 3);
  $frm3->pack(-side => 'top', -fill => 'x');
  my $frm3_lbl1 = $frm3->Label (
    -text => 'Username:');
  $frm3_lbl1->pack( -side => 'left');
  $user = $frm3->Entry( -width => 32, -background => 'white');
  $user->pack( -side => 'right', -pady => 3);

  my $frm4 = $login->Frame(
    -relief => "groove",
    -borderwidth => 3);
  $frm4->pack(-side => 'top', -fill => 'x');
  my $frm4_lbl1 = $frm4->Label (
    -text => 'Password:');
  $frm4_lbl1->pack( -side => 'left');
  $pass = $frm4->Entry( -width => 32, -background => 'white');
  $pass->pack( -side => 'right', -pady => 3);

  my $frm4 = $login->Frame(
    -relief => "groove",
    -borderwidth => 3);
  $frm4->pack(-side => 'top', -fill => 'x');
  my $submit = $frm4->Button( -text => 'Login', -command => sub
{ login_button;} );
  $submit->pack(-side => 'left');
  my $exit = $frm4->Button( -text => 'Cancel', -command => sub {exit
0;} );
  $exit->pack(-side => 'right');


  MainLoop();
}
------------------------
That code is simply to build a login window that when ran will prompt
the user to log into our application.  I've got all the login stuff
done.  It simply does a post on login.html with the org,user, and pass
values.

What I'm trying to do is center that window.

Before I get any further is Perl Tk really usable or clunky.  I like the
fact that I can use perl to scrap our pages and do all the other nice
things that perl can do.

On the perl side I'm using the following regex to grok the fields from
each <tr> that has data.
--- Cut Here ---
  foreach my $line (@lines) {
    next unless $line =~ m/alarm_detail\.html\?id=(\d+).+?[center;|
critical]">(.+?)<\/td>.+?center;">(.+?)<\/td>.+?center;">(.+?)<\/td>.+?
center;">(.+?)<\/td>.+?center;">(.+?)<\/td>.+?center;">(.+?)<\/td>.+?
center;">(.+?)<\/td>/;
    print INDEX "$line\n\n\n";
    $ALARMS{$1}{'alarm_id'}     = $1;
    $ALARMS{$1}{'level'}        = $2;
    $ALARMS{$1}{'raised'}       = $3;
    $ALARMS{$1}{'description'}  = $4;
    $ALARMS{$1}{'location'}     = $5;
    $ALARMS{$1}{'device'}       = $6;
    $ALARMS{$1}{'alarm_name'}   = $7;
  }
------------------------------------

Is there a way to simplify that regex?  And on the last '>(.+?)<\/td>'
It is possible that that could be '></td>' or '>User</td>'  If a user is
not assigned to that alarm then there is nothing there.  How can I fix
that piece to match on '></td>' or '>Bob</td>'.

Thanks,
Chris



</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00692.html">[ale] Bob Toxen's iptables rules help needed</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00694.html">[ale] Bob Toxen's iptables rules help needed</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00708.html">[ale] Bob Toxen's iptables rules help needed</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00695.html">[ale] Bootable iso images...</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00693"><strong>Date</strong></a></li>
<li><a href="threads.html#00693"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>