SPUG: Tk question.

rick.croote at philips.com rick.croote at philips.com
Wed Sep 20 14:36:51 CDT 2000


Ron,

I recommend taking out all the height and width options in the frames and letting them float to the size of their content.  At first it won't look like they are there, but once you start putting widgets in each, things will all fall into place.  The only 
reason I can think of to declare the frame sizes is that if the layout is as important as the content, and even if it is, you may be better off adding them after the fact rather than fighting to make everything fit up front.

Rick Croote
ATL Ultrasound





ronh at iainc.com@SMTP at pm.org on 09/20/2000 12:11:51 PM
Sent by:	owner-spug-list at pm.org
To:	spug-list at pm.org@SMTP
cc:	 
Subject:	SPUG: Tk question.
Classification:	

Hi,

The code below puts three Frames in a MainWindow.

I want one Frame to occupy the top half of the MainWindow and the other two
to split the bottom half. To get this when I put a Canvas in the top Frame,
I find I need to make the Canvas 8 pixels smaller than the Frame.

Why?

I looked in Tk docs, but couldn't find anything that explained this (to me,
anyway).

I'd like to know so that I don't paint myself into a corner.

Whatever the explanation, is hardcoding the 8 pixels a safe way to handle
the issue?

Any other comments on the code welcome.

Thanks.

Ron Hartikka
    Interautomation, Inc.
    email    => ronh at iainc.com
    Dearborn => 313-248-5401
    Mobile   => 734-216-2845

##################################################


use Tk;
use strict;

ui();

sub ui{
	my $scale = 1.5;
	my $scale_v = 2 * $scale;
	my $scale_h = 5 * $scale;
	my $graph_height = $scale_v * 100;
	my $graph_width = $scale_h * 100;
	my $policy_height = $graph_height;
	my $policy_width = $graph_width / 2;

	my $mw =MainWindow->new;

	my $fr_graph = $mw->Frame(-height => $graph_height,
								-width => $graph_width,
								-relief => 'raised',
								-borderwidth => 2)->pack();

	my $fr_policy = $mw->Frame(-height => $policy_height,
								-width => $policy_width,
								-relief => 'raised',
								-borderwidth => 2)->pack(-side => 'left');

	my $fr_shift = $mw->Frame(-height => $policy_height,
								-width => $policy_width,
								-relief => 'raised',
								-borderwidth => 2)->pack(-side => 'left');

	my $canvas = $fr_graph->Canvas(-height => $graph_height,
								-width => $graph_width-8)->pack();

	MainLoop();
}


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/





 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/





More information about the spug-list mailing list