# Some error for Tk

**URL:** <https://www.ruby-forum.com/t/some-error-for-tk/70472>\
**Category:** Ruby\
**Created:** [February 19, 2006, 5:12pm UTC](https://www.ruby-forum.com/t/some-error-for-tk/70472 "2006-02-19T17:12:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cfc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e9a140/32.png) [@cfc](https://www.ruby-forum.com/u/cfc)\
**Post date:** [February 19, 2006, 5:12pm UTC](https://www.ruby-forum.com/t/some-error-for-tk/70472/1 "2006-02-19T17:12:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cfc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e9a140/32.png) [@cfc](https://www.ruby-forum.com/u/cfc)\
**Post date:** [February 19, 2006, 5:16pm UTC](https://www.ruby-forum.com/t/some-error-for-tk/70472/2 "2006-02-19T17:16:21Z")

</div>

DÅ?a NedeÄ¾a 19 FebruÃ¡r 2006 17:08 CFC napÃ­sal:

> 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.  
What line / in which method call? It’s hard to put the finger on this  
without  
that for people that don’t know Tk and SDL by heart without that.

David V.

---

<div class="post-metadata">

**Author:** ![cfc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e9a140/32.png) [@cfc](https://www.ruby-forum.com/u/cfc)\
**Post date:** [February 19, 2006, 5:22pm UTC](https://www.ruby-forum.com/t/some-error-for-tk/70472/3 "2006-02-19T17:22:29Z")

</div>

Follow up after skimming the code a few times, by lucky coincidence, I  
actually remember THAT much Tk…

DÅ?a NedeÄ¾a 19 FebruÃ¡r 2006 17:08 CFC napÃ­sal:

> TkEntry.new(“textvariable”=\>path).pack(“padx”=\>10)  
> TkButton.new(){  
> text “Play”  
> command {proc Play(path.value, -1)}

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) })

You or someone else misplaced a curly brace, I added the parentheses for  
clarity.

> }.pack(“padx”=\>10)  
> Tk.mainloop

(Why the heck is the #Play method in CamelCase anyway? Tsk-tsk-tsk, the  
sample  
author should get a lecture about naming conventions.)

David V.r

---

<div class="post-metadata">

**Author:** ![cfc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e9a140/32.png) [@cfc](https://www.ruby-forum.com/u/cfc)\
**Post date:** [February 20, 2006, 10:56am UTC](https://www.ruby-forum.com/t/some-error-for-tk/70472/4 "2006-02-20T10:56:50Z")

</div>

From: David V. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: Some error for Tk.  
Date: Mon, 20 Feb 2006 01:21:20 +0900  
Message-ID: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

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

---

<div class="post-metadata">

**Author:** ![cfc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e9a140/32.png) [@cfc](https://www.ruby-forum.com/u/cfc)\
**Post date:** [March 8, 2006, 11:14am UTC](https://www.ruby-forum.com/t/some-error-for-tk/70472/5 "2006-03-08T11:14:37Z")

</div>

Thanks a lot. 😃  
I’ve been solve this problem.  
Thanks again!!
