I am having issues with defining the width and height of the frame widget "$mini" in the following code. It is an embedded frame that is created to display an image when the grab() function is called. The frame is placed in a scrolling frame named "$frame2_1". When the frame is created it appears in the center of $frame2_1 with an inch padding(?) on both sides?

I would like to align the widget to the left side of the frame and resize to something else. However, configure(-width ##) does not work? I can move the widgets inside around using place() but nothing I do will increase/change the size of the frame $mini?

Please forgive me dumping the entire code here (~120 lines). It would be nice if I could display a picture of what the gui is doing.

#!/usr/bin/perl -w use strict; use Tk; use Tk::WinPhoto; use Tk::JPEG; #Global variables my $img_count = 0; #number of images displayed my @mini; #array of frames created when image is grabbed #Main window parameters my $mw = MainWindow->new(); $mw->minsize(qw(670 510)); $mw->configure(-background=>'gray'); $mw->title("Screen Capture GUI"); my $but_capture = $mw->Button( -text => "Capture Screen", -command => +sub { \&Grab() } ); $but_capture -> place(-x=>10,-y=>5, -width=>650); my $exit = $mw->Button( -text => "Exit", -command => sub { exit } ); $exit -> place(-x=>560,-y=>460, -width=>100); my $frame2_1 = $mw->Scrolled('Frame',-scrollbars=> "e"); $frame2_1 -> place(-x=>10,-y=>50, -width=>650, -height=>400 ); MainLoop(); ###################################################################### +#### ###################################################################### +#### sub Grab(){ #Takes picture and makes thumbnail to display in mini frame ###################################################################### +#### #Creating file handle and taking picture my $tim = time(); my $fname = "/tmp/".$tim.".jpg"; #print "$fname\n"; system("import -frame $fname"); #resize to display in window my $fname2=$fname."sm.jpg"; system("convert -size 230X230 $fname -resize 230x230 $fname2"); ###################################################################### +#### $img_count++; #Frame packed in scrolling Frame $mini[$img_count] = $frame2_1->Frame(-background=>'#3300ff'); $mini[$img_count] -> configure(-relief => 'groove', -borderwidth => 2) +; $mini[$img_count] ->pack(); #need to create new frame to hold contents #stupid pack needs to create area to display things, this works but no +t quite right? my $dummy = $mini[$img_count]->Canvas(); $dummy -> create('rectangle', 0,0,500,300, -fill=>"black"); $dummy -> pack(); #items for mini frame my $img_label = $mini[$img_count]->Label(-text=>"Image $img_count"); $img_label -> place(-x=>5,-y=>5); my $pic_location = $mini[$img_count]->Label(-text=>"Pathname:"); $pic_location -> place(-x=>5,-y=>25 ); my $pic_fname = $mini[$img_count]->Entry(-width=>50,-textvariable=>"$f +name"); $pic_fname -> place(-x=>70,-y=>25 ); my $pic = $mini[$img_count]->Photo( -file =>"$fname2"); my $f =$mini[$img_count]->Label(-image => $pic); $f -> place(-x=>5,-y=>50 ); my $i = $img_count; my $but_delete = $mini[$img_count] ->Button( -text => "Delete Image", +-command => sub { \&Delete($mini[$i], $i) } ); $but_delete -> place(-x=>5,-y=>240 ); my $blank1 = $frame2_1->Label(-text=>""); $blank1 ->pack(); #Removes items from scrolling frame and replaces them with most recent + frame created at top ################################################ my $k = $img_count-1; if($img_count>=2){ while($k!=0){ $mini[$k]->packForget; $k--; } $k=$img_count; while($k!=0){ $mini[$k]->pack(); $k--; } } ################################################ #print "i =$img_count :: mini is $mini[$img_count]\n"; } #close Grab() ###################################################################### +#### ###################################################################### +#### sub Delete(){ my ($fn, $i) =@_; #if only one image displayed if ($img_count == 1){$fn ->destroy; $img_count--; return;} #print "Image $i deleted is $fn\n"; $fn ->destroy; #Deleted image now need to reorder array @mini[] splice(@mini,$i,1); $img_count--; }

In reply to Unable to resize embedded frame in perl/Tk by nikwasi

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.