[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

another Tk question

Joe Van Dyk

5/5/2005 8:52:00 PM

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

Thanks,
Joe



14 Answers

Hidetoshi NAGAI

5/6/2005 1:32:00 AM

0

Joe Van Dyk

5/6/2005 11:55:00 PM

0

On 5/5/05, Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> wrote:
> From: Joe Van Dyk <joevandyk@gmail.com>
> Subject: another Tk question
> Date: Fri, 6 May 2005 05:52:10 +0900
> Message-ID: <c715e6405050513513418bb61@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/projec...). :-)
> 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.Durga Prasad

5/7/2005 4:47:00 PM

0

> > From: Joe Van Dyk <joevandyk@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

5/8/2005 2:55:00 PM

0

Joe Van Dyk

5/8/2005 10:15:00 PM

0

On 5/8/05, Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> wrote:
> From: Joe Van Dyk <joevandyk@gmail.com>
> Subject: Re: another Tk question
> Date: Sat, 7 May 2005 08:54:49 +0900
> Message-ID: <c715e6405050616543c0eef9d@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

5/9/2005 9:41:00 PM

0

On 5/8/05, Joe Van Dyk <joevandyk@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

5/9/2005 11:53:00 PM

0

On 5/9/05, Joe Van Dyk <joevandyk@gmail.com> wrote:
> On 5/8/05, Joe Van Dyk <joevandyk@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
>

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

5/10/2005 12:56:00 AM

0

On 5/9/05, Joe Van Dyk <joevandyk@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

5/10/2005 1:24:00 AM

0

Joe Van Dyk

5/10/2005 2:03:00 AM

0

On 5/9/05, Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> wrote:
> From: Joe Van Dyk <joevandyk@gmail.com>
> Subject: Re: another Tk question
> Date: Tue, 10 May 2005 08:53:23 +0900
> Message-ID: <c715e640505091653687a505c@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.

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

Thanks,
Joe