Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Ruby (http://www.velocityreviews.com/forums/f66-ruby.html)
-   -   Some error for Tk. (http://www.velocityreviews.com/forums/t828832-some-error-for-tk.html)

CFC 02-19-2006 04:07 PM

Some error for Tk.
 
Hi.
When I was running my program, and click the button, it will show the
following message:
ArgumentError: wrong number of arguments (1 for 0)

But, I have been read some samples..

and here is my code:

require 'tk'
require 'sdl'

def Play(path, times)
music=SDL::Mixer::Music.load(path)
SDL::Mixer.playMusic(music,-1)
end
SDL::init(SDL::INIT_AUDIO)
SDL::Mixer.open
path=TkVariable.new
TkEntry.new("textvariable"=>path).pack("padx"=>10)
TkButton.new(){
text "Play"
command {proc Play(path.value, -1)}
}.pack("padx"=>10)
Tk.mainloop

Does it have any error in the code?
Could anyone help me?
Thank you a lot.


David Vallner 02-19-2006 04:16 PM

Re: Some error for Tk.
 
D=C5=88a Nede=C4=BEa 19 Febru=C3=A1r 2006 17:08 CFC nap=C3=ADsal:
> Hi.
> When I was running my program, and click the button, it will show the
> following message:
> ArgumentError: wrong number of arguments (1 for 0)
>


You botched something or the API changed a bit since the samples were made.=
=20
What line / in which method call? It's hard to put the finger on this witho=
ut=20
that for people that don't know Tk and SDL by heart without that.

David Vallner



Hidetoshi NAGAI 02-20-2006 09:55 AM

Re: Some error for Tk.
 
From: David Vallner <david@vallner.net>
Subject: Re: Some error for Tk.
Date: Mon, 20 Feb 2006 01:21:20 +0900
Message-ID: <200602191721.01248.david@vallner.net>
> IIRC, the #command method takes a Proc object as an argument, not a block. The
> above line should most probably be:
> command(proc { Play(path.value, -1) })


A block is available for #command method on current Ruby/Tk.
So,

command { Play(path.value, -1) }

is acceptable.
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)



CFC 03-08-2006 10:12 AM

Re: Some error for Tk.
 
Thanks a lot. :D
I've been solve this problem.
Thanks again!!



All times are GMT. The time now is 04:41 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57