Forum: Ruby Trying to get back into Tk

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Kenneth McDonald (Guest)
on 2008-12-02 22:50
(Received via mailing list)
After a hiatus of many years, I'm trying to get back into Tk via Ruby.
Unfortunately, my first attempt--a simple text box with attached
scroll bar--doesn't work very well. The scroll bar doesn't show up,
and the text box only gets so large; past that point, enlarging the
window doesn't enlarge the text box. I've copied in my code, and would
greatly appreciate it if someone could tell me where I'm going wrong.
It's been a long time since using Tk, and I've never used it with Ruby.


require 'tk'

ROOT = {title 'WIN'}

TEXT = {
     pack 'side' => 'left', 'fill' => 'both', 'expand' => 'true'
YSCROLL = do command {
      |first, last| TEXT.yview first, last
     pack 'side' => 'right', 'fill' => 'y'
TEXT.yscrollcommand {|first, last| YSCROLL.set(first, last) }
Hidetoshi NAGAI (Guest)
on 2008-12-03 01:05
(Received via mailing list)
From: Kenneth McDonald <removed_email_address@domain.invalid>
Subject: Trying to get back into Tk
Date: Wed, 3 Dec 2008 05:42:41 +0900
Message-ID: <removed_email_address@domain.invalid>
> YSCROLL = do command {
>       |first, last| TEXT.yview first, last
>      pack 'side' => 'right', 'fill' => 'y'
       ^^^ Here is the reason of your trouble.
> }
> end

The 'pack' method call is written in the callback of the scrollbar.
You have to write it at external of the callback.
For example,
This topic is locked and can not be replied to.