The Perl/Tk IPADM Client, ipadm
The client’s primary duties are to build the human interface and establish a communications link to the server, ipadmd. In order to talk to the server, ipadm starts the helper, ipadmh, as a separate process. Then ipadm sends a message to the daemon requesting a list of subnet descriptions, which it uses to construct the hypertext interface shown in Figure 19-2. Each subnet description has tags and bindings that react to mouseclicks and subsequently display the subnet’s nodes, as shown in Figure 19-3.
The following sections explain all this in detail.
Creating the Hypertext User Interface
As Figure 19-2 shows, ipadm’s MainWindow is essentially a single, scrolled ROText widget listing all of ACME Rocket Supply’s subnets.
my $t = $MW->Scrolled('ROText', qw/-width 80 -height 10 -relief ridge -scrollbars w/);
As the cursor passes over a subnet line, it becomes “hot,” is highlighted in green, and is able to respond to a button click. Clicking on a hot item opens a Toplevel “subnet editing” window, which we’ll see shortly. All these actions are controlled by text tags and bindings. First, we create and configure several tags:
$t->tagConfigure(qw/title -font/ => 'Helvetica 18 bold'); $t->tagConfigure(qw/subnet -lmargin1 .5c -lmargin2 1c -foreground blue/); $t->tagConfigure(qw/hot -relief raised -borderwidth 1 -background green/);
The title
tag is applied to the title line, giving
it a nice, large font. The subnet
tag is applied to each subnet line, and the ...
Get Mastering Perl/Tk now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.