First, your pack problem. Generally the way you would organize the screen, is to nest frames inside one another, to whatever depth you need to achieve your desired effect. You must remember to set your packing options though, like expand, fill, and whatever. Generally the idea is to arrange it, so that as the GUI Mainwindow is resized, it all stays together in a nice way.

For your given code, you are not using a very good approach, but for the sake of teaching you, I will slightly modify it to show the principle.

#!/usr/bin/perl -w use strict; use Tk; use Tk::ProgressBar; # Main Window my $mw = new MainWindow; # take out your geometry line to see what is happening, # see how it resizes after removing the following line # $mw->geometry("1600x900"); #GUI Building Area #make the 2 header frames my $topframe = $mw->Frame()->pack(-expand=>0, -fill=>'x'); my $secframe = $mw->Frame()->pack(-expand=>0, -fill=>'x'); my $label = $topframe ->Label (-text => "first", -foreground => "blue" +, -font => "Arial 7") ->pack(-fill => 'x'); $label = $secframe ->Label (-text => "second", -foreground => "blue", -font => "Arial 12") ->pack(); # notice no fill +on this button my $mainframe = $mw->Frame->pack(-expand=>1, -fill=>'both'); # make subframes for the rest, so you can add buttons my %frames; foreach my $pos('third','forth','fifth','rest'){ $frames{$pos} = $mainframe->Frame(-bg=>'white')->pack(-side=>'left', -expand=>1, -fill=>'both'); my $label = $frames{$pos} ->Label (-text => $pos, -foreground => "bl +ue", -font=> "Arial 10") ->pack (-side => 'top', -anchor => 'nw', -ipa +dx => '50', -fill => 'x'); ############################################### # # Creating the button my $button = $frames{$pos}->Button( -text => 'Create car folders '. $pos, -bac => 'lightblue', -width => '17', -command => \&push_button)->pack(-side => 'top', -anchor=>'nw'); } MainLoop;
as to your IPC problem, you ususally need to use fileevent to read an external socket or process. See tk-ps or the following code:
#!/usr/bin/perl use warnings; use strict; use Tk; use IPC::Open3; $|=1; my $pid=open3(\*IN,\*OUT,0,'/bin/sh'); my $mw = new MainWindow(-title=>'Left Click->Update Right Click->Clo +se'); $mw->fontCreate('medium', -family=>'courier', -weight=>'bold', -size=>int(-14*14/10)); my $text = $mw->Scrolled('Text', -bg => 'black', -fg => 'lightsteelblue', -width => 130, -height => 30, -font => 'medium', )->pack; $mw->fileevent(\*OUT,'readable',\&get_from); $mw->bind('<ButtonPress-1>' => sub{ $text->delete('1.0','end'); $text->update; print IN "ps auxww\n"; }); $mw->bind('<ButtonPress-3>' => sub{ exit }); print IN "ps auxww\n"; MainLoop; sub get_from { my $pstext = (<OUT>); $text->insert('end',$pstext); $text->see('1.0'); } __END__

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

In reply to Re: Perl TK GUI! by zentara
in thread Perl TK GUI! by negativ_m

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.