# How added new page in notebook?

**URL:** <https://www.ruby-forum.com/t/how-added-new-page-in-notebook/115159>\
**Category:** Ruby-Gnome 2\
**Created:** [September 21, 2007, 7:10am UTC](https://www.ruby-forum.com/t/how-added-new-page-in-notebook/115159 "2007-09-21T07:10:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fjimmy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/7bcc69/32.png) [@fjimmy](https://www.ruby-forum.com/u/fjimmy)\
**Post date:** [September 21, 2007, 7:10am UTC](https://www.ruby-forum.com/t/how-added-new-page-in-notebook/115159/1 "2007-09-21T07:10:56Z")

</div>

Hi All,

Hi All,

I’m a newbie at ruby GUI. I learning how to append a page in the  
notebook on the fly by attaching a function to a button. The idea is to  
add/delete a page everytime I press the button. By using this way, I  
could delete a page in the notebook on the fly but I couldn’t add a page  
in the notebook on the fly. Anybody know how to add the page in the  
notebook on the fly? I didn’t receive any error message but I didn’t see  
any new page added to the notebook.

Below are the methods that I used to remove/add page to the notebook:

def remove\_book( button, notebook )  
page = notebook.page  
notebook.remove\_page( page )  
end

def add\_book( button, notebook)  
checkbutton = Gtk::Button.new( “Check me please!” )  
label = Gtk::Label.new( “Add Page” )  
notebook.insert\_page( 2, checkbutton, label)  
end

Thanks for your input.

fjimmy

---

<div class="post-metadata">

**Author:** ![fjimmy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/7bcc69/32.png) [@fjimmy](https://www.ruby-forum.com/u/fjimmy)\
**Post date:** [September 21, 2007, 8:53am UTC](https://www.ruby-forum.com/t/how-added-new-page-in-notebook/115159/2 "2007-09-21T08:53:50Z")

</div>

Jimmy Fnu wrote:

> def add\_book( button, notebook)  
> checkbutton = Gtk::Button.new( “Check me please!” )  
> label = Gtk::Label.new( “Add Page” )  
> notebook.insert\_page( 2, checkbutton, label)  
> end

Try:

def add\_book( button, notebook)  
checkbutton = Gtk::Button.new( “Check me please!” )  
label = Gtk::Label.new( “Add Page” )  
notebook.insert\_page( 2, checkbutton, label)

checkbutton.show  
label.show  
end

best,  
Dan

* * *

This [SF.net](http://SF.net) email is sponsored by: Microsoft  
Defy all challenges. Microsoft(R) Visual Studio 2005.  
[http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/](http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/)

---

<div class="post-metadata">

**Author:** ![fjimmy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/7bcc69/32.png) [@fjimmy](https://www.ruby-forum.com/u/fjimmy)\
**Post date:** [September 22, 2007, 2:17am UTC](https://www.ruby-forum.com/t/how-added-new-page-in-notebook/115159/3 "2007-09-22T02:17:01Z")

</div>

Hi Dan,

It’s working.  
Thanks:)

fjimmy

Daniel L. wrote:

> def add\_book( button, notebook)  
> checkbutton = Gtk::Button.new( “Check me please!” )  
> label = Gtk::Label.new( “Add Page” )  
> notebook.insert\_page( 2, checkbutton, label)
> 
> checkbutton.show  
> label.show  
> end
> 
> best,  
> Dan
> 
> * * *
> 
> This [SF.net](http://SF.net) email is sponsored by: Microsoft  
> Defy all challenges. Microsoft(R) Visual Studio 2005.  
> [http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/](http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/)
