Equivalent to Perl's Tk::Tiler?

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

From: Forrest C. [email protected]
Subject: [tk] Equivalent to Perl’s Tk::Tiler?
Date: Tue, 6 Dec 2005 02:17:33 +0900
Message-ID: [email protected]

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

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 methodpropagete’ for TkGrid:Module (NoMethodError)
from scrframe.rb:26:in initialize_composite' from c:/ruby/lib/ruby/1.8/tk/composite.rb:20:ininitialize’
from scrframe.rb:122:in `new’
from scrframe.rb:122

Thanks

Forrest

From: Forrest C. [email protected]
Subject: Re: [tk] Equivalent to Perl’s Tk::Tiler?
Date: Thu, 8 Dec 2005 05:07:35 +0900
Message-ID: [email protected]

    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

Hidetoshi NAGAI [email protected] writes:

Hidetoshi NAGAI ([email protected])
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.

From: Forrest C. [email protected]
Subject: Re: [tk] Equivalent to Perl’s Tk::Tiler?
Date: Sat, 10 Dec 2005 07:52:36 +0900
Message-ID: [email protected]

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)}

Hidetoshi NAGAI [email protected] 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