in reply to Perl TK GUI!

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

Replies are listed 'Best First'.
Re^2: Perl TK GUI!
by negativ_m (Novice) on Feb 13, 2014 at 13:26 UTC

    I appreciate this very much.

    It really helps me.

    Thank you one more time. Have a great day