Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

another Tk question

10 views
Skip to first unread message

Joe Van Dyk

unread,
May 5, 2005, 4:52:10 PM5/5/05
to
In Tk, what's the best way to show a large table of data that gets
constantly updated?

Thanks,
Joe

Hidetoshi NAGAI

unread,
May 5, 2005, 9:31:37 PM5/5/05
to
From: Joe Van Dyk <joev...@gmail.com>
Subject: another Tk question
Date: Fri, 6 May 2005 05:52:10 +0900
Message-ID: <c715e6405050...@mail.gmail.com>

> In Tk, what's the best way to show a large table of data that gets
> constantly updated?

Use TkTable extension (http://sf.net/projects/tktable). :-)
Ruby/Tk's wrapper library for the extension is already included.
Please read ext/tk/lib/tkextlib/SUPPORT_STATUS.
And please see also ext/tk/sample/tkextlib/tktable.
--
Hidetoshi NAGAI (na...@ai.kyutech.ac.jp)


Joe Van Dyk

unread,
May 6, 2005, 7:54:49 PM5/6/05
to

Hi,

I can't find ext/tk/lib/tkextlib/SUPPORT_STATUS in Ruby's snapshot.
And I'm not able to run the samples in the tkextlib directory for some
reason (complains about not finding tcltklib or something).

G.Durga Prasad

unread,
May 7, 2005, 12:47:17 PM5/7/05
to
> > From: Joe Van Dyk <joev...@gmail.com>
> > Subject: another Tk question
> > Date: Fri, 6 May 2005 05:52:10 +0900
> I can't find ext/tk/lib/tkextlib/SUPPORT_STATUS in Ruby's snapshot.
> And I'm not able to run the samples in the tkextlib directory for some
> reason (complains about not finding tcltklib or something).
>
>
I got over this problem by installing tcl-devel tk-devel in linux.
Running "yum install tcl-devel" and "yum install tk-devel" commands
if I remember right.
Prasad

Hidetoshi NAGAI

unread,
May 8, 2005, 10:54:47 AM5/8/05
to
From: Joe Van Dyk <joev...@gmail.com>
Subject: Re: another Tk question
Date: Sat, 7 May 2005 08:54:49 +0900
Message-ID: <c715e6405050...@mail.gmail.com>

> I can't find ext/tk/lib/tkextlib/SUPPORT_STATUS in Ruby's snapshot.

Which version of Ruby do you use?
"Tcl/Tk extensions support" was introduced into Ruby-1.8.2.
Please use the latest CVS version of Ruby/Tk.

> And I'm not able to run the samples in the tkextlib directory for some
> reason (complains about not finding tcltklib or something).

Tcl/Tk extensions (e.g. TkTable) are not Tcl/Tk's standard libraries.
To use them, they must be installed on your Tcl/Tk environment.

# If use "ActiveTcl package", TkTable extension is already included.

If your Tcl/Tk can load an extension, Ruby/Tk can use the power of
the extension (however, sometimes needs to add the library path for
the extension to Tk::AUTO_PATH).
Libraries under 'tkextlib' directory are wrapper libraries for Tcl/Tk
extensions.
Even if there is no wrapper library, the extensions can be controlled
with some methods such like as Tk.tk_call().
--
Hidetoshi NAGAI (na...@ai.kyutech.ac.jp)


Joe Van Dyk

unread,
May 8, 2005, 6:14:46 PM5/8/05
to
On 5/8/05, Hidetoshi NAGAI <na...@ai.kyutech.ac.jp> wrote:
> From: Joe Van Dyk <joev...@gmail.com>
> Subject: Re: another Tk question
> Date: Sat, 7 May 2005 08:54:49 +0900
> Message-ID: <c715e6405050...@mail.gmail.com>
> > I can't find ext/tk/lib/tkextlib/SUPPORT_STATUS in Ruby's snapshot.
>
> Which version of Ruby do you use?
> "Tcl/Tk extensions support" was introduced into Ruby-1.8.2.
> Please use the latest CVS version of Ruby/Tk.
>

Ruby 1.8.2. The stable version.

> > And I'm not able to run the samples in the tkextlib directory for some
> > reason (complains about not finding tcltklib or something).
>
> Tcl/Tk extensions (e.g. TkTable) are not Tcl/Tk's standard libraries.
> To use them, they must be installed on your Tcl/Tk environment.
>
> # If use "ActiveTcl package", TkTable extension is already included.
>
> If your Tcl/Tk can load an extension, Ruby/Tk can use the power of
> the extension (however, sometimes needs to add the library path for
> the extension to Tk::AUTO_PATH).
> Libraries under 'tkextlib' directory are wrapper libraries for Tcl/Tk
> extensions.
> Even if there is no wrapper library, the extensions can be controlled
> with some methods such like as Tk.tk_call().

Thanks for the info. I'll see if I can get those Tk extensions installed.

Joe Van Dyk

unread,
May 9, 2005, 5:41:26 PM5/9/05
to
On 5/8/05, Joe Van Dyk <joev...@gmail.com> wrote:
>
> Thanks for the info. I'll see if I can get those Tk extensions installed.
>

Ok, got the TkTable extensions installed and can run the TkTable Ruby
demos! Hooray.

I'm not sure how to do the following though:

I have a Hash of Players. Each Player has a Hash called attribute_list.

I want to display each player's attribute list in the TkTable.

So, given the following class and code, how could I display its data
in the TkTable?

class Player
attr_accessor attribute_list
def initialize
@attribute_list = {}
@attribute_list[:player_id] = rand(100).to_s
@attribute_list[:x_position] = rand(100).to_s
@attribute_list[:y_position] = rand(100).to_s
end
end

players = []
3.times { players.push(Players.new) }

The resulting table would look something like (view in fixed font):

---------------------------------------
| player_id | x_position | y_position |
---------------------------------------
| 24 | 56 | 34 |
| 63 | 88 | 83 |
| 12 | 35 | 89 |
---------------------------------------

Would you use the :command feature of TkTable to do this?

Thanks,
Joe

Joe Van Dyk

unread,
May 9, 2005, 7:53:23 PM5/9/05
to

I figured it out. The way that worked for me was to use the :variable
key when creating the TkTable (and connect it to a TkVariable hash).

Another question! Does anyone know how to scale a Tk canvas image?

Thanks,
Joe

Joe Van Dyk

unread,
May 9, 2005, 8:56:05 PM5/9/05
to
On 5/9/05, Joe Van Dyk <joev...@gmail.com> wrote:
>
> Another question! Does anyone know how to scale a Tk canvas image?

To get more detailed...

I have a fairly large map image (10000x10000 pixels or so). I'd like
this to be displayed as the background on my canvas. The user should
be able to zoom in and out on the canvas and the map should change
accordingly when zooming. Also, the user should be able to move
around on the canvas by clicking.

I've got the zooming and moving part of my code working fine. What I
need to be able to do is scale an image to a certain width and height.
I looked at the zoom and subsample abilities, but those only seem to
use Integers as the scaling factor, not Floats.

Ideas are most welcomed,
Joe

Hidetoshi NAGAI

unread,
May 9, 2005, 9:24:07 PM5/9/05
to
From: Joe Van Dyk <joev...@gmail.com>
Subject: Re: another Tk question
Date: Tue, 10 May 2005 08:53:23 +0900
Message-ID: <c715e6405050...@mail.gmail.com>

> Another question! Does anyone know how to scale a Tk canvas image?

Do you talk about TkPhotoImage objects?
If so, maybe, BLT extension makes it easier.
However, BLT support on ruby-1.8.2 is very buggy and has no sample.
Please get latest BLT support libraries and samples from CVS.
'ext/tk/sample/tkextlib/blt/winop1.rb' is an exapmple of
image_resample (scaling), and 'ext/tk/sample/tkextlib/blt/winop2.rb'
is an exapmple of image_rotate.
--
Hidetoshi NAGAI (na...@ai.kyutech.ac.jp)


Joe Van Dyk

unread,
May 9, 2005, 10:03:10 PM5/9/05
to

Hm. Is there any way I could do this on ruby 1.8.2?

Thanks,
Joe

Joe Van Dyk

unread,
May 9, 2005, 10:04:01 PM5/9/05
to
On 5/9/05, Joe Van Dyk <joev...@gmail.com> wrote:

Would it be easier if I ported the application to FX-Ruby or something?

Hidetoshi NAGAI

unread,
May 9, 2005, 11:28:50 PM5/9/05
to
From: Joe Van Dyk <joev...@gmail.com>
Subject: Re: another Tk question
Date: Tue, 10 May 2005 11:03:10 +0900
Message-ID: <c715e6405050...@mail.gmail.com>

> > Do you talk about TkPhotoImage objects?
> > If so, maybe, BLT extension makes it easier.
> > However, BLT support on ruby-1.8.2 is very buggy and has no sample.
> > Please get latest BLT support libraries and samples from CVS.
> Hm. Is there any way I could do this on ruby 1.8.2?

Replace tkextlib/blt.rb and tkextlib/blt/* to the latest CVS files.
Probably work.
--
Hidetoshi NAGAI (na...@ai.kyutech.ac.jp)


Joe Van Dyk

unread,
May 11, 2005, 6:21:26 PM5/11/05
to
On 5/5/05, Joe Van Dyk <joev...@gmail.com> wrote:
> In Tk, what's the best way to show a large table of data that gets
> constantly updated?

Another TkTable question:

I want to have the ability to color in titles in a TkTable according
to some logic, so the titles on each row would be colored differently.

However, I can only seem to find an option to color all the titles one color:
@table.tag_configure('title', :bg=>"red", :fg=>"")

Does that ability exist in TkTable?

Thanks,
Joe


Joe Van Dyk

unread,
May 11, 2005, 8:49:22 PM5/11/05
to

Bah, figured it out.

I can use:
@table.tag_cell('tag name', [cell_x, cell_y])

And then do
@table.tag_configure('tag_name', :bg=>'something')


0 new messages