Some error for Tk.

Discussion in 'Ruby' started by CFC, Feb 19, 2006.

  1. CFC

    CFC Guest

    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.
     
    CFC, Feb 19, 2006
    #1
    1. Advertising

  2. 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
     
    David Vallner, Feb 19, 2006
    #2
    1. Advertising

  3. From: David Vallner <>
    Subject: Re: Some error for Tk.
    Date: Mon, 20 Feb 2006 01:21:20 +0900
    Message-ID: <>
    > 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 ()
     
    Hidetoshi NAGAI, Feb 20, 2006
    #3
  4. CFC

    CFC Guest

    Thanks a lot. :D
    I've been solve this problem.
    Thanks again!!
     
    CFC, Mar 8, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    0
    Views:
    692
    Guest
    Feb 25, 2004
  2. Eric
    Replies:
    2
    Views:
    1,530
    Tommy
    Feb 13, 2004
  3. ad
    Replies:
    2
    Views:
    735
  4. =?Utf-8?B?bWF2cmlja18xMDE=?=

    SetAuthCookie works some times and fails some times?

    =?Utf-8?B?bWF2cmlja18xMDE=?=, Mar 23, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    532
    =?Utf-8?B?bWF2cmlja18xMDE=?=
    Mar 23, 2006
  5. Good Night Moon
    Replies:
    9
    Views:
    294
    Rick DeNatale
    Jul 25, 2007
Loading...

Share This Page