Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Help with Scrolled Pane mouse wheel binds

by Phinix (Acolyte)
on Dec 10, 2012 at 22:40 UTC ( #1008176=perlquestion: print w/ replies, xml ) Need Help??
Phinix has asked for the wisdom of the Perl Monks concerning the following question:

Good day all,

I was looking for some help getting a scrolled Pane frame to move with mouse wheel binds. Basically I have a container frame, and inside that a scrolled Pane, and inside that an inner frame where I plan to put my stuff.

Here's a sample:

#!/usr/local/bin/perl -w use strict; use Tk; use Tk::Pane; my $mw = new MainWindow; my $containerframe = $mw-> Frame()-> form(-left => '%0', -right => '%1 +00', -top => '%0', -bottom => '%100'); my $scrollpane = $containerframe->Scrolled('Pane', -scrollbars => 'oe' +, -sticky => 'nsew')-> form(-left => '%0', -right => '%100', -top => +'%0', -bottom => '%100'); my $innerframe = $scrollpane->Frame()-> form(-left => '%0', -right => +'%100', -top => '%0', -bottom => '%100'); $innerframe-> Label(-text => "test\n")-> pack for 1 .. 112; MainLoop;

That is all well and good, only I've been having trouble with the syntax for adding a mouse wheel bind that will scroll the Pane and thus the inner content frame attached to it.

Comment on Help with Scrolled Pane mouse wheel binds
Download Code
Re: Help with Scrolled Pane mouse wheel binds
by zentara (Archbishop) on Dec 10, 2012 at 23:27 UTC
Re: Help with Scrolled Pane mouse wheel binds
by Phinix (Acolyte) on Dec 10, 2012 at 23:55 UTC

    Hey Zen. Well, I saw that one actually, and tried it on my example above, which worked. Here is the code I used to test it:

    #!/usr/local/bin/perl -w use strict; use Tk; require Tk::DynaMouseWheelBind; my $mw = new MainWindow; my @scrollables = ('Tk::Pane'); $mw->DynaMouseWheelBind(@scrollables); my $containerframe = $mw-> Frame()-> form(-left => '%0', -right => '%1 +00', -top => '%0', -bottom => '%100'); my $scrollpane = $containerframe->Scrolled('Pane', -scrollbars => 'oe' +, -sticky => 'nsew')-> form(-left => '%0', -right => '%100', -top => +'%0', -bottom => '%100'); $scrollpane = $scrollpane->Subwidget('scrolled'); my $innerframe = $scrollpane->Frame()-> form(-left => '%0', -right => +'%100', -top => '%0', -bottom => '%100'); $innerframe-> Label(-text => "test\n")-> pack for 1 .. 112; MainLoop;

    However, when I try to incorporate it the exact same way into my working project I get errors:

    error:window ".frame.notebook.page3.frame.frame.frame1.frame.pane" is +n't packed at C:/Perl/site/lib/Tk/Widget.pm line 1218, <PLUGINS> line 39. at C:/Perl/site/lib/Tk/After.pm line 90 Tk::Error: window ".frame.notebook.page3.frame.frame.frame1.frame.pane +" isn't pa cked at C:/Perl/site/lib/Tk/Widget.pm line 1218, <PLUGINS> l ine 39. at C:/Perl/site/lib/Tk/After.pm line 90 Tk callback for pack Tk::After::once at C:/Perl/site/lib/Tk/After.pm line 90 [once,[{},after#38,idle,once,[{},packscrollbars]]] ("after" script)

      Fixed it... Just wish I knew how. In my program I had to remove the line "$scrollpane = $scrollpane->Subwidget('scrolled');", after which it works as intended. If anyone can tell me why I would sure appreciate it!

      EDIT: Probably something to do with my scrolled frame being several levels embedded and also on a Notebook tab. Just a note, removing that line will prevent sub-windows within your main scrolled Pane scrolling on their own. There is probably a work-around to get both working but for now this does what I need.

      Thanks!
        You're talking to yourself there Phinix, seriously :)
      Just wish I knew how. In my program I had to remove the line "$scrollpane = $scrollpane->Subwidget('scrolled');",

      That error probably comes from the line

      $scrollpane = $scrollpane->Subwidget('scrolled');
      You can't have $scrollpane in both variable positions. You would use
      my $real_pane = $scrollpane->Subwidget('scrolled');
      but that didn't work for me either. I also suspect it has something to do with you using nested frames with the ScrolledPane. My first guess as to why, is possibly the expand and fill options of the frames. I'm not that familiar with the Form manager.

      I'm not really a human, but I play one on earth.
      Old Perl Programmer Haiku ................... flash japh

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1008176]
Approved by Tommy
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (13)
As of 2014-09-23 13:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (221 votes), past polls