# Problem with Table in a ScrolledWindow in a Notebook

**URL:** <https://www.ruby-forum.com/t/problem-with-table-in-a-scrolledwindow-in-a-notebook/89453>\
**Category:** Ruby-Gnome 2\
**Created:** [March 20, 2007, 4:28pm UTC](https://www.ruby-forum.com/t/problem-with-table-in-a-scrolledwindow-in-a-notebook/89453 "2007-03-20T16:28:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dhstudio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b487fb/32.png) [@dhstudio](https://www.ruby-forum.com/u/dhstudio)\
**Post date:** [March 20, 2007, 4:28pm UTC](https://www.ruby-forum.com/t/problem-with-table-in-a-scrolledwindow-in-a-notebook/89453/1 "2007-03-20T16:28:50Z")

</div>

Hi,

In the following script when I select ‘page 2’ in the notebook,  
the hello button isn’t shown. If I switch tabs, then show ‘page 2’,  
for a second time, the button is shown.

Am I doing something wrong?

# Martin.

require ‘gtk2’

Gtk.init

win = Gtk::Window.new

notebook = Gtk::Notebook.new()

table = Gtk::Table.new(1,1)

scrolled\_win = Gtk::ScrolledWindow.new  
scrolled\_win.add\_with\_viewport( table )

notebook.append\_page( Gtk::Label.new(“empty”), Gtk::Label.new(“page 1”))  
notebook.append\_page( scrolled\_win, Gtk::Label.new(“page 2”))

win.add( notebook )

win.show\_all

notebook.signal\_connect(“switch-page”){|w,page,page\_num|  
if( page\_num==1)  
table.resize(1,1)  
button = Gtk::Button.new(“hello”)  
table.attach\_defaults( button, 0,1, 0,1 )  
button.show  
end  
}

Gtk.main

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys-and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![dhstudio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b487fb/32.png) [@dhstudio](https://www.ruby-forum.com/u/dhstudio)\
**Post date:** [March 20, 2007, 4:37pm UTC](https://www.ruby-forum.com/t/problem-with-table-in-a-scrolledwindow-in-a-notebook/89453/2 "2007-03-20T16:37:51Z")

</div>

On Tue, Mar 20, 2007 at 03:27:57PM +0000, Martin P. wrote:

> Hi,
> 
> In the following script when I select ‘page 2’ in the notebook,  
> the hello button isn’t shown. If I switch tabs, then show ‘page 2’,  
> for a second time, the button is shown.
> 
> Am I doing something wrong?

Switch to using signal\_connect\_after. Otherwise, you end up doing  
something before Gtk::Notebook does, which makes it all sorts of funky  
for some reason:

notebook.signal\_connect\_after(‘switch-page’) { |w,page,page\_num| blah }

-pete

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys-and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![dhstudio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b487fb/32.png) [@dhstudio](https://www.ruby-forum.com/u/dhstudio)\
**Post date:** [March 20, 2007, 5:01pm UTC](https://www.ruby-forum.com/t/problem-with-table-in-a-scrolledwindow-in-a-notebook/89453/3 "2007-03-20T17:01:53Z")

</div>

Peter J. wrote:

> Switch to using signal\_connect\_after. Otherwise, you end up doing  
> something before Gtk::Notebook does, which makes it all sorts of funky  
> for some reason:

That’s the one! Thanks very much.  
Martin.

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys-and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)
