Thanks,
Joe
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)
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).
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)
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.
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
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
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)
Hm. Is there any way I could do this on ruby 1.8.2?
Thanks,
Joe
Would it be easier if I ported the application to FX-Ruby or something?
Replace tkextlib/blt.rb and tkextlib/blt/* to the latest CVS files.
Probably work.
--
Hidetoshi NAGAI (na...@ai.kyutech.ac.jp)
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
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')