# Errors with TextCtrl.new!

**URL:** <https://www.ruby-forum.com/t/errors-with-textctrl-new/157227>\
**Category:** wxRuby\
**Created:** [January 8, 2009, 5:52pm UTC](https://www.ruby-forum.com/t/errors-with-textctrl-new/157227 "2009-01-08T17:52:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![enchanter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ce7236/32.png) [@enchanter](https://www.ruby-forum.com/u/enchanter)\
**Post date:** [January 8, 2009, 5:52pm UTC](https://www.ruby-forum.com/t/errors-with-textctrl-new/157227/1 "2009-01-08T17:52:14Z")

</div>

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:in`on\_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

---

<div class="post-metadata">

**Author:** ![enchanter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ce7236/32.png) [@enchanter](https://www.ruby-forum.com/u/enchanter)\
**Post date:** [January 8, 2009, 6:58pm UTC](https://www.ruby-forum.com/t/errors-with-textctrl-new/157227/2 "2009-01-08T18:58:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![enchanter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ce7236/32.png) [@enchanter](https://www.ruby-forum.com/u/enchanter)\
**Post date:** [January 8, 2009, 7:29pm UTC](https://www.ruby-forum.com/t/errors-with-textctrl-new/157227/3 "2009-01-08T19:29:41Z")

</div>

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 🙂

> 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

---

<div class="post-metadata">

**Author:** ![enchanter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ce7236/32.png) [@enchanter](https://www.ruby-forum.com/u/enchanter)\
**Post date:** [January 8, 2009, 8:04pm UTC](https://www.ruby-forum.com/t/errors-with-textctrl-new/157227/4 "2009-01-08T20:04:58Z")

</div>

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