# Equivalent to Perl's Tk::Tiler?

**URL:** <https://www.ruby-forum.com/t/equivalent-to-perls-tk-tiler/49527>\
**Category:** Ruby\
**Created:** [December 5, 2005, 6:18pm UTC](https://www.ruby-forum.com/t/equivalent-to-perls-tk-tiler/49527 "2005-12-05T18:18:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![fkc\_email-news](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/3d9bf3/32.png) [@fkc\_email-news](https://www.ruby-forum.com/u/fkc_email-news)\
**Post date:** [December 5, 2005, 6:18pm UTC](https://www.ruby-forum.com/t/equivalent-to-perls-tk-tiler/49527/1 "2005-12-05T18:18:52Z")

</div>

Hi All:

I making arbitrarily large forms and in doing similar in Perl, I’ve  
used Tk::Tiler, a scrollable frame. I’d just pack my various entries  
into the form, and set a max size, from which the form would  
automatically scroll if the contents were larger than the form size.

I’ve found a scrollable canvas sample I could use, but worry about  
the  
of resources it might take up. Any pointers?

Thanks.

Forrest

---

<div class="post-metadata">

**Author:** ![fkc\_email-news](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/3d9bf3/32.png) [@fkc\_email-news](https://www.ruby-forum.com/u/fkc_email-news)\
**Post date:** [December 7, 2005, 3:44am UTC](https://www.ruby-forum.com/t/equivalent-to-perls-tk-tiler/49527/2 "2005-12-07T03:44:23Z")

</div>

From: Forrest C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: [tk] Equivalent to Perl’s Tk::Tiler?  
Date: Tue, 6 Dec 2005 02:17:33 +0900  
Message-ID: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> I making arbitrarily large forms and in doing similar in Perl, I’ve  
> used Tk::Tiler, a scrollable frame. I’d just pack my various entries  
> into the form, and set a max size, from which the form would  
> automatically scroll if the contents were larger than the form size.
> 
> I’ve found a scrollable canvas sample I could use, but worry about the  
> of resources it might take up. Any pointers?

## I don’t know Perl’s Tk::Tiler. Is it the one like the following?

# 

# scrframe.rb

# 

require ‘tk’

class Tk::ScrollFrame \< TkFrame  
include TkComposite

DEFAULT\_WIDTH = 200  
DEFAULT\_HEIGHT = 200

def initialize\_composite(keys={})  
@frame.configure(:width=\>DEFAULT\_WIDTH, :height=\>DEFAULT\_HEIGHT)

```
# create scrollbars
@v_scroll = TkScrollbar.new(@frame, 'orient'=>'vertical')
@h_scroll = TkScrollbar.new(@frame, 'orient'=>'horizontal')

# create a canvas widget
@canvas = TkCanvas.new(@frame)

# allignment
TkGrid.rowconfigure(@frame, 0, 'weight'=>1, 'minsize'=>0)
TkGrid.columnconfigure(@frame, 0, 'weight'=>1, 'minsize'=>0)
@canvas.grid('row'=>0, 'column'=>0, 'sticky'=>'news')
@frame.grid_propagate(false)

# assign scrollbars
@canvas.xscrollbar(@h_scroll)
@canvas.yscrollbar(@v_scroll)

# scrollbars ON
vscroll(keys.delete('vscroll'){true})
hscroll(keys.delete('hscroll'){true})

# create base frame
@base = TkFrame.new(@canvas)

# embed base frame
@cwin = TkcWindow.new(@canvas, [0, 0], :window=>@base, 

```

:anchor=\>‘nw’)  
@canvas.scrollregion(@cwin.bbox)

```
# binding to reset scrollregion
@base.bind('Configure'){ @canvas.scrollregion(@cwin.bbox) }

# set default receiver of method calls
@path = @base.path

# please check the differences of the following definitions
option_methods(
  :scrollbarwidth
)

# set receiver widgets for configure methods (with alias)
delegate_alias('scrollbarrelief', 'relief', @h_scroll, @v_scroll)

# set receiver widgets for configure methods
delegate('DEFAULT', @base)
delegate('background', @frame, @base, @canvas, @h_scroll, @v_scroll)
delegate('width', @frame)
delegate('height', @frame)
delegate('activebackground', @h_scroll, @v_scroll)
delegate('troughcolor', @h_scroll, @v_scroll)
delegate('repeatdelay', @h_scroll, @v_scroll)
delegate('repeatinterval', @h_scroll, @v_scroll)
delegate('borderwidth', @frame)
delegate('relief', @frame)

# do configure
configure keys unless keys.empty?

```

end

# forbid to change binding of @base frame

def bind(\*args)  
@frame.bind(\*args)  
end  
def bind\_append(\*args)  
@frame.bind\_append(\*args)  
end  
def bind\_remove(\*args)  
@frame.bind\_remove(\*args)  
end  
def bindinfo(\*args)  
@frame.bindinfo(\*args)  
end

# set width of scrollbar

def scrollbarwidth(width = nil)  
if width  
@h\_scroll.width(width)  
@v\_scroll.width(width)  
else  
@h\_scroll.width  
end  
end

# vertical scrollbar : ON/OFF

def vscroll(mode)  
st = TkGrid.info(@v\_scroll)  
if mode && st.size == 0 then  
@v\_scroll.grid(‘row’=\>0, ‘column’=\>1, ‘sticky’=\>‘ns’)  
elsif !mode && st.size != 0 then  
@v\_scroll.ungrid  
end  
self  
end

# horizontal scrollbar : ON/OFF

def hscroll(mode)  
st = TkGrid.info(@h\_scroll)  
if mode && st.size == 0 then  
@h\_scroll.grid(‘row’=\>1, ‘column’=\>0, ‘sticky’=\>‘ew’)  
elsif !mode && st.size != 0 then  
@h\_scroll.ungrid  
end  
self  
end  
end

# test

if **FILE** == $0  
f = Tk::ScrollFrame.new(:scrollbarwidth=\>10, :width=\>300,  
:height=\>200)  
f.pack(:expand=\>true, :fill=\>:both)

TkButton.new(f, :text=\>‘foo bar button’, :command=\>proc{puts ‘foo  
bar’}).pack  
Tk.after(3000){TkText.new(f).pack(:expand=\>true, :fill=\>:both)}

Tk.mainloop  
end

---

<div class="post-metadata">

**Author:** ![fkc\_email-news](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/3d9bf3/32.png) [@fkc\_email-news](https://www.ruby-forum.com/u/fkc_email-news)\
**Post date:** [December 7, 2005, 9:08pm UTC](https://www.ruby-forum.com/t/equivalent-to-perls-tk-tiler/49527/3 "2005-12-07T21:08:22Z")

</div>

Hi:

```
    So I get the following error when running it (latest stable 1 

```

click installer on windows xp)

ruby scrframe.rb  
c:/ruby/lib/ruby/1.8/tk.rb:3630:in `grid_propagate': undefined method`propagete’ for TkGrid:Module (NoMethodError)  
from scrframe.rb:26:in `initialize_composite' from c:/ruby/lib/ruby/1.8/tk/composite.rb:20:in`initialize’  
from scrframe.rb:122:in `new’  
from scrframe.rb:122

Thanks

Forrest

---

<div class="post-metadata">

**Author:** ![fkc\_email-news](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/3d9bf3/32.png) [@fkc\_email-news](https://www.ruby-forum.com/u/fkc_email-news)\
**Post date:** [December 8, 2005, 3:20am UTC](https://www.ruby-forum.com/t/equivalent-to-perls-tk-tiler/49527/4 "2005-12-08T03:20:41Z")

</div>

From: Forrest C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [tk] Equivalent to Perl’s Tk::Tiler?  
Date: Thu, 8 Dec 2005 05:07:35 +0900  
Message-ID: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> ```
> So I get the following error when running it (latest stable 1 click installer on windows xp)
> 
> ```
> 
> ruby scrframe.rb  
> c:/ruby/lib/ruby/1.8/tk.rb:3630:in `grid_propagate': undefined method `propagete’ for TkGrid:Module (NoMethodError)

Oh, sorry. The method is available ruby-1.8.2 or later.  
Please replace

---

<div class="post-metadata">

**Author:** ![fkc\_email-news](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/3d9bf3/32.png) [@fkc\_email-news](https://www.ruby-forum.com/u/fkc_email-news)\
**Post date:** [December 9, 2005, 11:55pm UTC](https://www.ruby-forum.com/t/equivalent-to-perls-tk-tiler/49527/5 "2005-12-09T23:55:46Z")

</div>

Hidetoshi NAGAI [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> Hidetoshi NAGAI (removed\_email\_address@domain.invalid)  
> Now it displays a window briefly and then segfaults, both on win XP and  
> win 2K

* * *

c:/ruby/lib/ruby/1.8/tk.rb:1383: [BUG] Segmentation fault  
ruby 1.8.2 (2004-12-25) [i386-mswin32]

This application has requested the Runtime to terminate it in an unusual  
way.  
Please contact the application’s support team for more information.

---

<div class="post-metadata">

**Author:** ![fkc\_email-news](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/3d9bf3/32.png) [@fkc\_email-news](https://www.ruby-forum.com/u/fkc_email-news)\
**Post date:** [December 11, 2005, 4:36pm UTC](https://www.ruby-forum.com/t/equivalent-to-perls-tk-tiler/49527/6 "2005-12-11T16:36:10Z")

</div>

From: Forrest C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [tk] Equivalent to Perl’s Tk::Tiler?  
Date: Sat, 10 Dec 2005 07:52:36 +0900  
Message-ID: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> Now it displays a window briefly and then segfaults, both on win XP and win 2K

## When do you get SEGV? Before displaying Tk window? Or at about 3 seconds after running the sample? Even if replace

Tk.after(3000){TkText.new(f).pack(:expand=\>true, :fill=\>:both)}

---

<div class="post-metadata">

**Author:** ![fkc\_email-news](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/3d9bf3/32.png) [@fkc\_email-news](https://www.ruby-forum.com/u/fkc_email-news)\
**Post date:** [December 12, 2005, 10:40pm UTC](https://www.ruby-forum.com/t/equivalent-to-perls-tk-tiler/49527/7 "2005-12-12T22:40:50Z")

</div>

Hidetoshi NAGAI [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> When do you get SEGV? Before displaying Tk window?  
> Pretty much immediately after I see the tk window.

> ## Or at about 3 seconds after running the sample? Even if replace
> 
> ## Tk.after(3000){TkText.new(f).pack(:expand=\>true, :fill=\>:both)}
> 
> ## to
> 
> ## TkText.new(f).pack(:expand=\>true, :fill=\>:both)

If I replace with this, it seems stable as long as I don’t change the  
horizontal sizing or scrolling, i.e. moving the horizontal scrollbar  
crashes, or sizing it in the horizontal direction causes a crash.  
Vertical scrolling and sizing doesn’t crash it.

> ## , do you get SEGV? Can you try one of the later version (e.g. 1.8.3 or 1.8.4preview) ?

I’m using the 1 click installer, I’m not really setup to compile on  
XP, but if I find time I can try.

Thanks for your help thus far though

Forrest
