dlal66 has asked for the wisdom of the Perl Monks concerning the following question:
All is well except that what I'd like is that when a user resizes the window, the graph displayed should be "layedout" again so that it adjusts to the size of the window. I first tried to bind the '<Configure>' event to the canvas this way:my $gv = $root->Scrolled('GraphViz', -background => '#B0C0FF', -scrollbars=>'se', ) ->pack (-side=>'top',-expand =>1, -fill=>'both');
But nothing happens! I the binding is not used and the Subwidget returns an undefined "$canvas". So I modified the above code to bind the root window with Configure as in:my $canvas = $gv->Subwidget("canvas'); $canvas->bind('<Configure>', sub { my $w = shift; print $w->Width . " and " . $w->Heig +ht . "\n"; &redo_layout(); };
This works! But the behavior is not great. The graph layout does adjust but is a very "flickery" way. And strangely, window resize prints a lot of values for width and height when the bound subroutine is called. What can I do to make this a nice user experience? Why can't I bind '<Configure>' to the subwidget "canvas'? Thank you in advance.$root->bind('<Configure>', sub { my $w = shift; print $w->Width . " and " . $w->Heig +ht . "\n"; &redo_layout(); };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl tk graphviz
by zentara (Cardinal) on Feb 23, 2012 at 15:58 UTC | |
by dlal66 (Acolyte) on Feb 23, 2012 at 20:28 UTC |