How to define the height of a ScrollableFrame inside a ScrolledWindow?

I want to put some (~30) CheckButtons inside a BWidget::ScrollableFrame
which is located inside a BWidget::ScrolledWindow. For testing purposes
I wanted to restrict the size of the ScrollableFrame to 100px by 100px.
I expected a ScrollableFrame, sized 100x100, with the ability to scroll
through all gridded CheckButtons, but the window is automatically
extended so that all CheckButtons fit into the TkRoot.

Here’s what I have tried:

#!/usr/bin/env ruby

require ‘tk’
require ‘tkextlib/bwidget’

class TestClass < TkRoot

attr_reader :checkbutton

def initialize(*args)
minsize(800, 400)

@checkbutton = []
for i in 0..29
  @checkbutton.push({:name => "checkbutton #{i}"})


def createGUI, :text => ‘first label’).grid({:column => 0, :row
=> 0, :sticky => ‘w’})

scrolledwindow ={:column

=> 0, :row => 1, :sticky => ‘w’})‘none’) # want to see if scrollbars are attached

scrollframe ={:column => 0,
:row => 0, :sticky => ‘w’})

# leads to error: /usr/lib/ruby/1.9.1/tk.rb:215:in `class_eval':

window name “frame” already exists in parent (RuntimeError)
#sftest = scrollframe.get_frame


@checkbutton.each_with_index { |cb, index|, :text => cb[:name]).grid({:column

=> 0, :row => index, :sticky => ‘w’})
}, :text => 'second label').grid({:column => 1, :row

=> 0, :sticky => ‘w’})

@test =

So… What’s wrong? Why it isn’t restricted to 100x100 pixel and
scrollable? From what I here:
it should be possible to retrieve a frame with
ScrollableFrame.get_frame, like this:

set a [$f getframe]

In ruby i would do it like this:

sftest = scrollframe.get_frame

The method get_frame doesn’t exist in my installation. But my above ruby
variant leads to the following error:

/usr/lib/ruby/1.9.1/tk.rb:215:in `class_eval’:
window name “frame” already exists in parent (RuntimeError)

I really have no clue why this error is thrown in this little script so
I can’t test if it’s possible to configure the height and width at this

How can I set a fixed height and width for the ScrollableFrame?

Update: The size is set correctly as long as no CheckButton was added.
The first time i add a CheckButton the ScrollableFrame is set to the
size the CheckButton needs. How can i prevent resizing?

Ok… It seems that there’s a problem with my used config, installation
or compatibility.

I tried the following:

#!/usr/bin/env ruby1.8

Then no error is thrown and the folling line works:

sftest = scrollframe.get_frame

Now it’s possible to add the CheckButtons to sftest and then i can
scroll through a list of Checkbuttons…



This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs