Forum: wxRuby Initializing a Frame seems to fail...

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
907f29cb608004d2156d5ce88240f09b?d=identicon&s=25 Tim Mcd (zonbi)
on 2009-01-14 23:53
/usr/bin/ruby -w /Users/Tim/wxrmc.rb
/Users/Tim/wxrmc.rb:9:in `new': Error initializing #<Wx::Frame:0x74ecf8>
(ArgumentError)
 : Wrong arguments for overloaded method 'wxFrame.new'.
Possible C/C++ prototypes are:
    wxFrame.new()
    wxFrame.new(wxWindow *parent, wxWindowID id, wxString const &title,
wxPoint const &pos, wxSize const &size, long style, wxString const
&name)

Correct parameters for Wxruby2::Frame.new are:
:id => (Fixnum)
:title => (String)
:pos => (Wxruby2::Point)
:size => (Wxruby2::Size)
:style => (Fixnum)
:name => (String)
  from /Users/Tim/wxrmc.rb:9:in `on_init'
  from /Users/Tim/wxrmc.rb:21:in `main_loop'
  from /Users/Tim/wxrmc.rb:21

Compilation exited abnormally with code 1 at Wed Jan 14 15:46:45

Thats the error for this line:
    @frame = Frame.new(nil, -1, "Ruby Mud Client", DEFAULT_POSITION,
Point.new(300, 875))
of this code:

http://pastie.org/360951

Anyone know what it means by 'Wrong Arguments'? I'm fairly certain that
those arguments are correct...
06f6780c99d4a8dd71f2b474082ea9ce?d=identicon&s=25 Alex Fenton (Guest)
on 2009-01-15 00:39
(Received via mailing list)
Tim Mcd wrote:
>
>
....
> Thats the error for this line:
>     @frame = Frame.new(nil, -1, "Ruby Mud Client", DEFAULT_POSITION,
> Point.new(300, 875))
>

Check again: you should be passing a Wx::Size here, not a Wx::Point -
you've already passed in the position with DEFAULT_POSITION.

It's often easier and less error-prone to use named arguments for these
constructors:

Wx::Frame.new(nil, :title => 'Ruby Mud Client', :pos => [300, 875] )

The other values will get the defaults eg -1, DEFAULT_POSITION

a
3396e4a3df8a840faec520af8555a400?d=identicon&s=25 Mario Steele (Guest)
on 2009-01-15 00:41
(Received via mailing list)
Here is your problem

@frame = Frame.new(nil, -1, "Ruby Mud Client", DEFAULT_POSITION,
Point.new(300, 875))

^^^^^^^^^^^^^^^^^^^

That actually needs to be Size.new(300,875), or you can just pass
[300,875],
and that will work as well.
907f29cb608004d2156d5ce88240f09b?d=identicon&s=25 Tim Mcd (zonbi)
on 2009-01-15 00:45
Mario Steele wrote:
> Here is your problem
>
> @frame = Frame.new(nil, -1, "Ruby Mud Client", DEFAULT_POSITION,
> Point.new(300, 875))
>
> ^^^^^^^^^^^^^^^^^^^
>
> That actually needs to be Size.new(300,875), or you can just pass
> [300,875],
> and that will work as well.

Hey, thanks you two! I thought that it only put in the Defaults for
things you dont specify, and you had to specify in order.
907f29cb608004d2156d5ce88240f09b?d=identicon&s=25 Tim Mcd (zonbi)
on 2009-01-15 00:47
Tim Mcd wrote:
> Mario Steele wrote:
>> Here is your problem
>>
>> @frame = Frame.new(nil, -1, "Ruby Mud Client", DEFAULT_POSITION,
>> Point.new(300, 875))
>>
>> ^^^^^^^^^^^^^^^^^^^
>>
>> That actually needs to be Size.new(300,875), or you can just pass
>> [300,875],
>> and that will work as well.
>
> Hey, thanks you two! I thought that it only put in the Defaults for
> things you dont specify, and you had to specify in order.

Meep! Now it runs really slowly... Like the inputbar and textview don't
even initialize...
907f29cb608004d2156d5ce88240f09b?d=identicon&s=25 Tim Mcd (zonbi)
on 2009-01-15 00:51

This is after I had .shows for everything, mind you.
7072e83a8e7cd851fd941b1a830dfdd2?d=identicon&s=25 Toti B. (toti_b)
on 2014-09-02 09:49
I am new to Ruby and WxRuby.

I am trying the sample code below:

require 'wx'
include Wx

class MyFrame < Frame
  def initialize()
    super(nil, -1, 'My Frame Title')
  end
end
app = MyFrame.new('New')
app.main_loop

When I mouse over the line "super(nil, -1, 'My Frame Title') I am
getting the following error:

Found 1 extra argument(s). Required: 2, log)

I hope someone out there can help correct this error.

Thanks.
This topic is locked and can not be replied to.