Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: A 2D layout of graphs in Perl/Tk

by rcseege (Pilgrim)
on Oct 12, 2006 at 13:02 UTC ( [id://577822]=note: print w/replies, xml ) Need Help??


in reply to Re^2: A 2D layout of graphs in Perl/Tk
in thread A 2D layout of graphs in Perl/Tk

As for packing each Canvas inside a frame, I think I was off in my first comment. It wasn't as bad as I remembered it being. I must have been remembering how it used to be before a patch was put in Pane some time back. It doesn't make any difference if you put the Canvas in a frame or not.

The only reason I put each Cavas in a frame in the example was so that I could put controls along with the Canvas, and correctly manage resizing. In terms of the example, there's actually a benefit of not having each Canvas in a Frame (Aside from the Scrolled Frame). Typically, when you create something like this, you have to either store a variable pointing to each Canvas so that you can directly access it later. You can still do this, but if each Canvas has been gridded, then you can use grid methods to access a row, column, one cell, or all of the gridded widgets. The way I currently have it, this is inconvenient because the easy access is to the frame. It would simplify things a bit if you modified createTile to something like this:

sub createTile { my ($parent, $x, $y) = @_; my $sc = $parent->Scrolled('Canvas', -scrollbars => 'osoe', -scrollregion => [0, 0, 200, 200], -width => 125, -height => 125, -background => randColor() )->pack( -padx => 5, -pady => 5, -row => $x, -column => $y, -sticky => 'nsew' ); my $count = int(rand(6)) + 2; foreach my $i (1 .. $count) { my ($x, $y) = (randNumber(), randNumber()); my $size = randNumber(); $sc->createRectangle($x, $y, $x+$size, $y+$size, -fill => randColor(), -outline => 'black', -width => 2 ); } }

Now access to each Canvas is a bit easier using gridSlaves or gridLocation.

As an aside, the interface choice seems a little odd to me. The zooming part strikes me as a bit user unfriendly. It probably makes sense for your problem, but it seems frustrating to me that the views are separated into so many small boxes that I can only resize so far. Zooming only exasperates the problem - Now I have more information that I can potentially look at, but I have to scroll more to see it all.

Why not pack as much information as is useful within the size constraints for each Canvas in the grid. And then have a way of drilling down or at least temporarily hide the others using gridForget, and allow the user to focus on one Canvas with an expanded information set and zooming capabilities? Anyway... just a few random thoughts.

Rob

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://577822]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-24 04:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found