# Tabs

**URL:** <https://www.ruby-forum.com/t/tabs/163016>\
**Category:** wxRuby\
**Created:** [March 16, 2009, 6:08pm UTC](https://www.ruby-forum.com/t/tabs/163016 "2009-03-16T18:08:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tcsnide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@tcsnide](https://www.ruby-forum.com/u/tcsnide)\
**Post date:** [March 16, 2009, 6:08pm UTC](https://www.ruby-forum.com/t/tabs/163016/1 "2009-03-16T18:08:50Z")

</div>

Can anyone tell me how to create a tabbed interface? I tried using the  
Notebook control but I could not get it to work.

I’m trying to put a Grid on one of the Notebook pages.

Thanks,  
Trans

---

<div class="post-metadata">

**Author:** ![tcsnide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@tcsnide](https://www.ruby-forum.com/u/tcsnide)\
**Post date:** [March 16, 2009, 6:35pm UTC](https://www.ruby-forum.com/t/tabs/163016/2 "2009-03-16T18:35:14Z")

</div>

Luc T. a écrit :

> > [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> > DEFAULT\_POSITION,  
> > welcome\_text, “Welcome”,  
> > true,  
> > -1)
> 
> Hope it’s useful

Sorry about bad formatting… thunderbird messed it all

---

<div class="post-metadata">

**Author:** ![tcsnide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@tcsnide](https://www.ruby-forum.com/u/tcsnide)\
**Post date:** [March 16, 2009, 6:29pm UTC](https://www.ruby-forum.com/t/tabs/163016/3 "2009-03-16T18:29:56Z")

</div>

Trans a écrit :

> [http://rubyforge.org/mailman/listinfo/wxruby-users](http://rubyforge.org/mailman/listinfo/wxruby-users)

Here is some code I used in a small app:

# the tabbed interface

```
# create the notebook
@notebook = Notebook.new(
  @frame, # the parent frame
  1,
  DEFAULT_POSITION,
  DEFAULT_SIZE,
  0,
  'notebook')

welcome_text = StaticText.new(
  @notebook,
  2,
  "\nClick on a project node to open it or create a new project.",
  DEFAULT_POSITION,
  DEFAULT_SIZE,
  0,
  "welcomeText")

@notebook.add_page(
  welcome_text,
  "Welcome",
  true,
  -1)

```

Hope it’s useful

---

<div class="post-metadata">

**Author:** ![tcsnide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@tcsnide](https://www.ruby-forum.com/u/tcsnide)\
**Post date:** [March 16, 2009, 7:18pm UTC](https://www.ruby-forum.com/t/tabs/163016/4 "2009-03-16T19:18:06Z")

</div>

Trans wrote:

> [http://rubyforge.org/mailman/listinfo/wxruby-users](http://rubyforge.org/mailman/listinfo/wxruby-users)  
> It is fairly straightforward. I think the key is to attach the controls  
> to Wx::Panels, then add the panels to the notebook. See the sample code  
> below.

#!/usr/bin/env ruby

require ‘wx’  
include Wx

class MainFrame \< Frame

def initialize(title)

```
 super(nil, :title => title)
 panel_1 = Panel.new(self)
 box_1 = BoxSizer.new(VERTICAL)
 panel_1.sizer = box_1

 notebook = Notebook.new(panel_1, :style => NB_TOP)
 box_1.add(notebook, 0, ALIGN_LEFT | ALL, 10)

 panel_n1 = Panel.new(notebook)
 box_n1 = BoxSizer.new(VERTICAL)
 panel_n1.sizer = box_n1
 box_n1.add(TextCtrl.new(panel_n1), 0, ALIGN_LEFT | ALL, 10)
 box_n1.add(TextCtrl.new(panel_n1), 0, ALIGN_LEFT | ALL, 10)

 panel_n2 = Panel.new(notebook)
 box_n2 = BoxSizer.new(VERTICAL)
 panel_n2.sizer = box_n2
 grid_n2 = Grid.new(panel_n2, :size => [270, 140])
 grid_n2.create_grid(3,2)
 box_n2.add(grid_n2, 0, ALIGN_LEFT | ALL, 10)

 notebook.add_page(panel_n1, "Tab 1", true)
 notebook.add_page(panel_n2, "Tab 2", false)

```

end

end

Wx::App.run do  
self.app\_name = ‘TestNotebook’  
frame = MainFrame.new(“Test notebook”)  
frame.show  
end

–  
David Peoples [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
The Touring Cyclist [http://www.touringcyclist.com](http://www.touringcyclist.com)  
11816 St. Charles Rock Road, Bridgeton, MO 63044  
tel: 314-739-4648 fax: 314-739-4972
