another Tk question

J

Joe Van Dyk

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

Thanks,
Joe
 
H

Hidetoshi NAGAI

From: Joe Van Dyk <[email protected]>
Subject: another Tk question
Date: Fri, 6 May 2005 05:52:10 +0900
Message-ID: said:
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.
 
J

Joe Van Dyk

From: Joe Van Dyk <[email protected]>
Subject: another Tk question
Date: Fri, 6 May 2005 05:52:10 +0900


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.

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

G.Durga Prasad

From: Joe Van Dyk said:
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
 
H

Hidetoshi NAGAI

From: Joe Van Dyk <[email protected]>
Subject: Re: another Tk question
Date: Sat, 7 May 2005 08:54:49 +0900
Message-ID: said:
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().
 
J

Joe Van Dyk

From: Joe Van Dyk <[email protected]>
Subject: Re: another Tk question
Date: Sat, 7 May 2005 08:54:49 +0900


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.
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.
 
J

Joe Van Dyk

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
 
J

Joe Van Dyk

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

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
 
J

Joe Van Dyk

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
 
H

Hidetoshi NAGAI

From: Joe Van Dyk <[email protected]>
Subject: Re: another Tk question
Date: Tue, 10 May 2005 08:53:23 +0900
Message-ID: said:
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.
 
J

Joe Van Dyk

From: Joe Van Dyk <[email protected]>
Subject: Re: another Tk question
Date: Tue, 10 May 2005 08:53:23 +0900


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.

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

Thanks,
Joe
 
H

Hidetoshi NAGAI

From: Joe Van Dyk <[email protected]>
Subject: Re: another Tk question
Date: Tue, 10 May 2005 11:03:10 +0900
Message-ID: said:
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.
 
J

Joe Van Dyk

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 colo=
r:
@table.tag_configure('title', :bg=3D>"red", :fg=3D>"")

Does that ability exist in TkTable?

Thanks,
Joe
 
J

Joe Van Dyk

=20
Another TkTable question:
=20
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.
=20
However, I can only seem to find an option to color all the titles one co= lor:
@table.tag_configure('title', :bg=3D>"red", :fg=3D>"")
=20
Does that ability exist in TkTable?

Bah, figured it out. =20

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

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,172
Messages
2,570,933
Members
47,472
Latest member
blackwatermelon

Latest Threads

Top