Forum: wxRuby Tabs

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
45196398e9685000d195ec626d477f0e?d=identicon&s=25 Thomas Sawyer (7rans)
on 2009-03-16 18:08
(Received via mailing list)
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
43a95279874adcdd785a067b40e9dea3?d=identicon&s=25 Luc Traonmilin (Guest)
on 2009-03-16 18:29
(Received via mailing list)
Trans a écrit :
> 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
43a95279874adcdd785a067b40e9dea3?d=identicon&s=25 Luc Traonmilin (Guest)
on 2009-03-16 18:35
(Received via mailing list)
Luc Traonmilin a écrit :
>> wxruby-users@rubyforge.org
>      DEFAULT_POSITION,
>      welcome_text,      "Welcome",
>      true,
>      -1)
>
> Hope it's useful
>
Sorry about bad formatting... thunderbird messed it all
251086a67766003b417ef869c0121c7e?d=identicon&s=25 David Peoples (Guest)
on 2009-03-16 19:18
(Received via mailing list)
Trans wrote:
> 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  davidp@touringcyclist.com
The Touring Cyclist  http://www.touringcyclist.com
11816 St. Charles Rock Road, Bridgeton, MO 63044
tel: 314-739-4648  fax: 314-739-4972
This topic is locked and can not be replied to.