Errors with TextCtrl.new!


#1

Here is my code:

require ‘rubygems’
require ‘wx’
include Wx

class GuiMudClientApp < App
def on_init
frame = Frame.new(nil, -1, “GMC: Incoming”).show
test = TextCtrl.new(frame, -1, “-----Mud stuff here-----”,
Point.new(500, 500), Size.new(500, 500), TE_READONLY)
test.append_text “Pfft!”
end
end

nowai = GuiMudClientApp.new

nowai.main_loop

I get this error:

guimc.rb:8:in new': Error initializing #<Wx::TextCtrl:0x74e3c0> (TypeError) : Expected argument 1 of type wxWindow *, but got TrueClass true in SWIG method 'wxTextCtrl' Correct parameters for Wxruby2::TextCtrl.new are: :id => (Fixnum) :value => (String) :pos => (Wxruby2::Point) :size => (Wxruby2::Size) :style => (Fixnum) :validator => (Wxruby2::Validator) :name => (String) from guimc.rb:8:inon_init’
from guimc.rb:15:in `main_loop’
from guimc.rb:15
Before, I could use a ‘Frame’ class as the parent window, but now its
having issues. I’ve followed it right off of the API docs. Any idea
whats wrong/how to fix it?

Thanks in advance,
Zonbidesu


#2

Addition: I’m on Mac OS 10.5(.9?)-- That’s Leopard. Its a PPC, upgraded
PowerBook G4.


#3

Hi

Tim M. wrote:

frame = Frame.new(nil, -1, "GMC: Incoming").show

You’re assigning the return value of show() to the variable frame.
show() returns a boolean true/false.

test = TextCtrl.new(frame, -1, "-----Mud stuff here-----",

Point.new(500, 500), Size.new(500, 500), TE_READONLY)

Now you’re passing that variable containing ‘true’ as the first arg to
TextCtrl.new

guimc.rb:8:in `new’: Error initializing #Wx::TextCtrl:0x74e3c0
(TypeError)
: Expected argument 1 of type wxWindow *, but got TrueClass true
in SWIG method ‘wxTextCtrl’

so you get this error :slight_smile:

Before, I could use a ‘Frame’ class as the parent window, but now its
having issues. I’ve followed it right off of the API docs. Any idea
whats wrong/how to fix it?

frame = Wx::Frame.new(…)
frame.show
text = Wx::TextCtrl.new(frame, …)

cheers
a


#4

Ahahaha, thanks. I thought it was something silly like that…