[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

wxRuby: How to add a scrollbar to a Wx::Notebook tab

Stephan Kämper

10/21/2004 12:53:00 PM

Hi all,

having just started to work with wxRuby, I would like to
- display a Wx::Notebook
- with several widgets in each row
- where the text field in the row horizontally fills the frame/window.
- and with a scrollbar in case the list gets too long to fit into
the available space

Now I condensed the code I started with into this example (with faked
data to fill the tabs):

--- code begin ---

require 'wxruby'

class TabScroller < Wx::App

def on_init
frame = Wx::Frame.new( nil, -1, 'Matices in tabs' )
frame.set_client_size( Wx::Size.new( 400, 120 ) )
sizer = Wx::BoxSizer.new( Wx::VERTICAL )

notebook = Wx::Notebook.new( frame, -1 )

fill_tabbook( notebook )

frame.show
end

def fill_tabbook( notebook )
@sl = [ { :header => "Header 1",
:list =>[ ["CB1", "Additional text1 "],
["CB2", "ding"],
["text2", "dong"] ]
},
{ :header => "Third" ,
:list => [ ["3rd check 1", "..." ],
["3rd check 2", "..." ],
["3rd check 3", "..." ],
["3rd check 4", "..." ] ]
}
]

@sl.each_with_index{ | line, idx |
panel = Wx::Panel.new( notebook, -1 )
sizer = Wx::FlexGridSizer.new( 2, 0, 2 )
panel.set_sizer sizer

header = Wx::StaticText.new( panel, -1, line[:header] )
sizer.add( header, 0, Wx::ALIGN_LEFT )
sizer.add( Wx::StaticText.new( panel, -1, '' ), 0,
Wx::ALIGN_LEFT )

line[:list].each { | item |
checker = Wx::CheckBox.new( panel, -1, item[0] )
sizer.add( checker, 0, Wx::ALIGN_LEFT )

notes = Wx::TextCtrl.new( panel, -1, item[1] )
sizer.add( notes, 1)

sizer.add( Wx::StaticText.new( panel, -1, '' ), 0,
Wx::ALIGN_LEFT )
sizer.add( Wx::StaticText.new( panel, -1, '' ), 0,
Wx::ALIGN_LEFT )
}
notebook.add_page( panel, "Tab No #{idx + 1}" )
}
end

end

if __FILE__ == $0
TabScroller.new.main_loop()
end

--- code end ---

These are my questions:
How would I introduce a Wx::ScrolledWindow (if that's what is needed)
into this to add a scrollbar to each tab (so the user can use the scroll
bar to reach all the widgets)?

How can I make the Wx::TextCrtl fill the available space to the right?

Any help would be greatly appreciated.

Happy rubying

Stephan

3 Answers

Curt Hibbs

10/21/2004 2:04:00 PM

0

I'm going to cross-post this to the wxRuby ML because I know of at least one
wxRuby expert who does not subscribe to ruby-talk.

Curt

Stephan Kämper [mailto:Stephan.Kaemper@Schleswig-Holstein.de]
>
> Hi all,
>
> having just started to work with wxRuby, I would like to
> - display a Wx::Notebook
> - with several widgets in each row
> - where the text field in the row horizontally fills the frame/window.
> - and with a scrollbar in case the list gets too long to fit into
> the available space
>
> Now I condensed the code I started with into this example (with faked
> data to fill the tabs):
>
> --- code begin ---
>
> require 'wxruby'
>
> class TabScroller < Wx::App
>
> def on_init
> frame = Wx::Frame.new( nil, -1, 'Matices in tabs' )
> frame.set_client_size( Wx::Size.new( 400, 120 ) )
> sizer = Wx::BoxSizer.new( Wx::VERTICAL )
>
> notebook = Wx::Notebook.new( frame, -1 )
>
> fill_tabbook( notebook )
>
> frame.show
> end
>
> def fill_tabbook( notebook )
> @sl = [ { :header => "Header 1",
> :list =>[ ["CB1", "Additional text1 "],
> ["CB2", "ding"],
> ["text2", "dong"] ]
> },
> { :header => "Third" ,
> :list => [ ["3rd check 1", "..." ],
> ["3rd check 2", "..." ],
> ["3rd check 3", "..." ],
> ["3rd check 4", "..." ] ]
> }
> ]
>
> @sl.each_with_index{ | line, idx |
> panel = Wx::Panel.new( notebook, -1 )
> sizer = Wx::FlexGridSizer.new( 2, 0, 2 )
> panel.set_sizer sizer
>
> header = Wx::StaticText.new( panel, -1, line[:header] )
> sizer.add( header, 0, Wx::ALIGN_LEFT )
> sizer.add( Wx::StaticText.new( panel, -1, '' ), 0,
> Wx::ALIGN_LEFT )
>
> line[:list].each { | item |
> checker = Wx::CheckBox.new( panel, -1, item[0] )
> sizer.add( checker, 0, Wx::ALIGN_LEFT )
>
> notes = Wx::TextCtrl.new( panel, -1, item[1] )
> sizer.add( notes, 1)
>
> sizer.add( Wx::StaticText.new( panel, -1, '' ), 0,
> Wx::ALIGN_LEFT )
> sizer.add( Wx::StaticText.new( panel, -1, '' ), 0,
> Wx::ALIGN_LEFT )
> }
> notebook.add_page( panel, "Tab No #{idx + 1}" )
> }
> end
>
> end
>
> if __FILE__ == $0
> TabScroller.new.main_loop()
> end
>
> --- code end ---
>
> These are my questions:
> How would I introduce a Wx::ScrolledWindow (if that's what is needed)
> into this to add a scrollbar to each tab (so the user can use the scroll
> bar to reach all the widgets)?
>
> How can I make the Wx::TextCrtl fill the available space to the right?
>
> Any help would be greatly appreciated.
>
> Happy rubying
>
> Stephan
>
>
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.g...).
> Version: 6.0.775 / Virus Database: 522 - Release Date: 10/8/2004
>



Stephan Kämper

10/21/2004 2:52:00 PM

0

Curt Hibbs wrote:

> I'm going to cross-post this to the wxRuby ML because I know of at least one
> wxRuby expert who does not subscribe to ruby-talk.
>
> Curt

Thanks! (I'm going to subscribe to the wxRuby ML, too.)

Happy rubying

Stephan

Zach Dennis

10/21/2004 4:23:00 PM

0

The only thing that appears to be in the wxRuby arsenal to handle
something Scrollable is Wx::ScrolledWindow, but whenever it is attempted
to be implemented it complains that there is no on_draw method. I
haven't done any digging to see if it's got any subclasses successfully
implemented in wxRuby.

Kevin, Nick, any thoughts?

Zach



Curt Hibbs wrote:

>I'm going to cross-post this to the wxRuby ML because I know of at least one
>wxRuby expert who does not subscribe to ruby-talk.
>
>Curt
>
>Stephan Kämper [mailto:Stephan.Kaemper@Schleswig-Holstein.de]
>
>
>>Hi all,
>>
>>having just started to work with wxRuby, I would like to
>>- display a Wx::Notebook
>>- with several widgets in each row
>>- where the text field in the row horizontally fills the frame/window.
>>- and with a scrollbar in case the list gets too long to fit into
>> the available space
>>
>>Now I condensed the code I started with into this example (with faked
>>data to fill the tabs):
>>
>>--- code begin ---
>>
>>require 'wxruby'
>>
>>class TabScroller < Wx::App
>>
>> def on_init
>> frame = Wx::Frame.new( nil, -1, 'Matices in tabs' )
>> frame.set_client_size( Wx::Size.new( 400, 120 ) )
>> sizer = Wx::BoxSizer.new( Wx::VERTICAL )
>>
>> notebook = Wx::Notebook.new( frame, -1 )
>>
>> fill_tabbook( notebook )
>>
>> frame.show
>> end
>>
>> def fill_tabbook( notebook )
>> @sl = [ { :header => "Header 1",
>> :list =>[ ["CB1", "Additional text1 "],
>> ["CB2", "ding"],
>> ["text2", "dong"] ]
>> },
>> { :header => "Third" ,
>> :list => [ ["3rd check 1", "..." ],
>> ["3rd check 2", "..." ],
>> ["3rd check 3", "..." ],
>> ["3rd check 4", "..." ] ]
>> }
>> ]
>>
>> @sl.each_with_index{ | line, idx |
>> panel = Wx::Panel.new( notebook, -1 )
>> sizer = Wx::FlexGridSizer.new( 2, 0, 2 )
>> panel.set_sizer sizer
>>
>> header = Wx::StaticText.new( panel, -1, line[:header] )
>> sizer.add( header, 0, Wx::ALIGN_LEFT )
>> sizer.add( Wx::StaticText.new( panel, -1, '' ), 0,
>> Wx::ALIGN_LEFT )
>>
>> line[:list].each { | item |
>> checker = Wx::CheckBox.new( panel, -1, item[0] )
>> sizer.add( checker, 0, Wx::ALIGN_LEFT )
>>
>> notes = Wx::TextCtrl.new( panel, -1, item[1] )
>> sizer.add( notes, 1)
>>
>> sizer.add( Wx::StaticText.new( panel, -1, '' ), 0,
>> Wx::ALIGN_LEFT )
>> sizer.add( Wx::StaticText.new( panel, -1, '' ), 0,
>> Wx::ALIGN_LEFT )
>> }
>> notebook.add_page( panel, "Tab No #{idx + 1}" )
>> }
>> end
>>
>>end
>>
>>if __FILE__ == $0
>> TabScroller.new.main_loop()
>>end
>>
>>--- code end ---
>>
>>These are my questions:
>>How would I introduce a Wx::ScrolledWindow (if that's what is needed)
>>into this to add a scrollbar to each tab (so the user can use the scroll
>>bar to reach all the widgets)?
>>
>>How can I make the Wx::TextCrtl fill the available space to the right?
>>
>>Any help would be greatly appreciated.
>>
>>Happy rubying
>>
>>Stephan
>>
>>
>>---
>>Incoming mail is certified Virus Free.
>>Checked by AVG anti-virus system (http://www.g...).
>>Version: 6.0.775 / Virus Database: 522 - Release Date: 10/8/2004
>>
>>
>>
>
>
>
>
>
>