T
Tomas Na
I am very new to ruby and am trying to create a form using fxRuby. There
will be a lot of forms so instead of putting them all in one file in
their own classes I am trying to make them all separate files, placing
them in the /Forms directory from where the main app is.
The trouble I am having is that when I make, for example "LoginForm.rb"
and then require it in my main code, I get the error:
test.rb:10:in `initialize': wrong number of arguments (1 for 0)
(ArgumentError
)
from test.rb:10:in `new'
from test.rb:10
However if I copy and paste the code from LoginForm.rb to test.rb then
everything runs with no problems. Like so:
#require 'Forms/LoginForm.rb'
require 'fox16'
include Fox
#-- Login Form
class LoginForm < FXMainWindow
def initialize(anApp)
# Initialize base class first
super(anApp, "testapp", pts => DECOR_ALL, :width => 400, :height
=> 300)
# Place the list in a sunken frame
sunkenFrame = FXVerticalFrame.new(self,
LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK, adding =>
0)
end
def create
super
show(PLACEMENT_SCREEN)
end
end
#-- End Login Form
xaApp = FXApp.new("testapp", "FXRuby")
LoginForm.new(xaApp)
xaApp.create
xaApp.run
The above code works, but if I move the code between the Login Form
quotes to Forms/LoginForm.rb and uncomment the top require, then I get
the error that I posted above. I dont understand what the difference
would be. Can anyone help me out?
will be a lot of forms so instead of putting them all in one file in
their own classes I am trying to make them all separate files, placing
them in the /Forms directory from where the main app is.
The trouble I am having is that when I make, for example "LoginForm.rb"
and then require it in my main code, I get the error:
test.rb:10:in `initialize': wrong number of arguments (1 for 0)
(ArgumentError
)
from test.rb:10:in `new'
from test.rb:10
However if I copy and paste the code from LoginForm.rb to test.rb then
everything runs with no problems. Like so:
#require 'Forms/LoginForm.rb'
require 'fox16'
include Fox
#-- Login Form
class LoginForm < FXMainWindow
def initialize(anApp)
# Initialize base class first
super(anApp, "testapp", pts => DECOR_ALL, :width => 400, :height
=> 300)
# Place the list in a sunken frame
sunkenFrame = FXVerticalFrame.new(self,
LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK, adding =>
0)
end
def create
super
show(PLACEMENT_SCREEN)
end
end
#-- End Login Form
xaApp = FXApp.new("testapp", "FXRuby")
LoginForm.new(xaApp)
xaApp.create
xaApp.run
The above code works, but if I move the code between the Login Form
quotes to Forms/LoginForm.rb and uncomment the top require, then I get
the error that I posted above. I dont understand what the difference
would be. Can anyone help me out?