Thursday, November 18, 2010

Installing wxSugar

Installed wx_sugar.

$ sudo gem install wx_sugar
Successfully installed wx_sugar-0.1.22
1 gem installed
Installing ri documentation for wx_sugar-0.1.22...
Installing RDoc documentation for wx_sugar-0.1.22... 
$ sudo gem1.9.1 install wx_sugar
Successfully installed wx_sugar-0.1.22
1 gem installed
Installing ri documentation for wx_sugar-0.1.22...
Updating class cache with 2154 classes...
Installing RDoc documentation for wx_sugar-0.1.22...

Sunday, November 14, 2010

Installing wxRuby on Windows

1. Installation of wxRuby on Windows
>gem install wxruby
Successfully installed wxruby-2.0.1-x86-mingw32
1 gem installed
Installing ri documentation for wxruby-2.0.1-x86-mingw32...
Installing RDoc documentation for wxruby-2.0.1-x86-mingw32...

2. But it gets an error when running wxRuby in Ruby 1.9.2
C:\>irb
irb(main):001:0> require 'wx'
The error message window opens and says that msvcrt-ruby18.dll was not found.

3. I reinstall wxRuby using its an installer (in stead of gem install).
Download and execute:
mingw32-ruby-1.9.1-wxruby-2.0.1-setup.exe
from http://rubyforge.org/frs/?group_id=35. It automatically installs Ruby 1.9.1 with it.
C:\>ruby -v
ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32]
C:\>irb
irb(main):001:0> require 'wx'
=> true
irb(main):002:0> exit
So currently wxRuby is not ready for the latest Ruby (1.9.2), you have to use 1.9.1 for now. This is still better than the situation in Ubuntu as wxRuby in Ubuntu runs only in 1.8.7.

Installing Ruby1.9.2 on Windows (XP SP3)

1. Download installer from
http://files.rubyforge.vm.bytemark.co.uk/rubyinstaller/rubyinstaller-1.9.2-p0.exe

2. It installs with Mingw32.
>ruby -v
ruby 1.9.2p0 (2010-08-18) [i386-mingw32]

>gem -v
1.3.7

>irb
irb(main):001:0> 1+2
=> 3
irb(main):002:0> exit

>

Saturday, November 13, 2010

Programming wxRuby (2) - Add Menubar

1. I added a menu bar to the wxRuby program. This menu bar has only one menu (File) and one item (Exit).

#!/usr/bin/env ruby
# menu01.rb
#
require 'rubygems'
require 'wx'
 
class AppFrame < Wx::Frame

 def initialize
  super(nil)
  window_settings
  menu_settings
 end
 
 def window_settings
  set_title 'Testing Menubar'
  set_size 400,300
 end
 
 def menu_settings
  mbar = Wx::MenuBar.new
  file = Wx::Menu.new
  file.append( Wx::ID_EXIT, "E&xit\tAlt-X", "Quit" )
  mbar.append( file, "&File" )
  self.menu_bar = mbar
  evt_menu( Wx::ID_EXIT, :on_quit )
 end
 
 def on_quit
  close
 end
  
end
 
class MyApp < Wx::App
 def on_init
  @frame = AppFrame.new
  @frame.show
 end
end
 
app = MyApp.new
app.main_loop
 

2. Here is a resulted window with a menu bar.



3. References http://ruby.about.com/od/gui/a/wxrubymenu.htm

Friday, November 12, 2010

wxRuby Programming (1) - a simple window

1. My first program with wxRuby is just to display a simple window.
#!/usr/bin/env ruby
# window02.rb
#
require 'rubygems'
require 'wx'
 
class AppFrame < Wx::Frame
 
 def initialize
  super(nil)
  window_settings
 end
 
 def window_settings
  set_title 'Simple Window'
  set_size 400,300
 end
   
end
 
class MyApp < Wx::App
 def on_init
  @frame = AppFrame.new
  @frame.show
 end
end
 
app = MyApp.new
app.main_loop

2. This is the result.
3. References http://ruby.about.com/od/gui/qt/wxrubyworld.htm

Saturday, November 6, 2010

Installing wxWidgets

I installed wxWidgets lib after realizing that intallation of Code::Blocks and its wxSmith plugin did not install it. I got an error not finding while compiling in CB with a wxWidgets project.

1. Install wxwidgets lib for Ubuntu
    a. Open Synaptic
    b. Search for wx
    c. Install:
        libwxgtk2.8-dbg
        libwxgtk2-dev
        wx2.8-doc
        wx2.8-examples

2. Now try again to compile a sample program.

/***************************************************************
 * Name:      wx01App.h
 * Purpose:   Defines Application Class
 * Author:    socrateos ()
 * Created:   2010-11-06
 * Copyright: socrateos ()
 * License:
 **************************************************************/

#ifndef WX01APP_H
#define WX01APP_H

#include 

class wx01App : public wxApp
{
    public:
        virtual bool OnInit();
};

#endif // WX01APP_H

2. Here is an successful output
-------------- Build: Debug in wx01 ---------------

Compiling: wx01App.cpp
Compiling: wx01Main.cpp
Linking executable: bin/Debug/wx01
Output size is 275.88 KB
Process terminated with status 0 (0 minutes, 2 seconds)
0 errors, 0 warnings
 

Installing wxSmith plugin for Code::Block

I got an error saying wxSmith plugin is not installed when I tried to create a wxWidget project from Code::Block. So I installed wSmith plugin.

1. Open Synaptic.
2. Search for wxSmith.
3. Install codebocks-contrib, which in turn install libwxsmithlib0.

Friday, November 5, 2010

Installing wxRuby

1. Installation of wxRuby

$ sudo gem install wxruby
Successfully installed wxruby-2.0.1-x86-linux
1 gem installed
Installing ri documentation for wxruby-2.0.1-x86-linux...
Installing RDoc documentation for wxruby-2.0.1-x86-linux...
$ sudo gem1.9.1 install wxruby
Successfully installed wxruby-2.0.1-x86-linux
1 gem installed
Installing ri documentation for wxruby-2.0.1-x86-linux...
Installing RDoc documentation for wxruby-2.0.1-x86-linux...
socrateos@ubuntu-pc:~$ 

2. A Barebone App
$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'wx'
=> true
irb(main):003:0> include Wx
=> Object
irb(main):004:0> class MyApp < App
irb(main):005:1> def on_init
irb(main):006:2> Frame.new(nil, -1, "Test").show()
irb(main):007:2> end
irb(main):008:1> end
=> nil
irb(main):009:0> MyApp.new.main_loop





3. wxRuby fails to run with Ruby 1.9.1 in Ubuntu
$ irb1.9.1 
irb(main):001:0> require 'wx'
/var/lib/gems/1.9.1/gems/wxruby-2.0.1-x86-linux/lib/wxruby2.so: [BUG] unknown type 0x22 (0xc given)
ruby 1.9.1p378 (2010-01-10 revision 26273) [i486-linux]

-- control frame ----------
c:0028 p:-38277670 s:0097 b:0097 l:000096 d:000096 TOP   
c:0027 p:---- s:0095 b:0095 l:000094 d:000094 CFUNC  :require
c:0026 p:0011 s:0091 b:0091 l:000090 d:000090 TOP    /var/lib/gems/1.9.1/gems/wxruby-2.0.1-x86-linux/lib/wx.rb:12
c:0025 p:---- s:0088 b:0088 l:000087 d:000087 FINISH
c:0024 p:---- s:0086 b:0086 l:000085 d:000085 CFUNC  :require
c:0023 p:0011 s:0082 b:0082 l:001204 d:000081 EVAL   (irb):1
c:0022 p:---- s:0080 b:0080 l:000079 d:000079 FINISH
c:0021 p:---- s:0078 b:0078 l:000077 d:000077 CFUNC  :eval
c:0020 p:0027 s:0071 b:0071 l:000070 d:000070 METHOD /usr/lib/ruby/1.9.1/irb/workspace.rb:80
c:0019 p:0031 s:0064 b:0063 l:000062 d:000062 METHOD /usr/lib/ruby/1.9.1/irb/context.rb:218
c:0018 p:0030 s:0058 b:0058 l:001bb4 d:000057 BLOCK  /usr/lib/ruby/1.9.1/irb.rb:157
c:0017 p:0039 s:0050 b:0050 l:000049 d:000049 METHOD /usr/lib/ruby/1.9.1/irb.rb:271
c:0016 p:0011 s:0045 b:0045 l:001bb4 d:000044 BLOCK  /usr/lib/ruby/1.9.1/irb.rb:154
c:0015 p:0132 s:0041 b:0041 l:000024 d:000040 BLOCK  /usr/lib/ruby/1.9.1/irb/ruby-lex.rb:244
c:0014 p:---- s:0038 b:0038 l:000037 d:000037 FINISH
c:0013 p:---- s:0036 b:0036 l:000035 d:000035 CFUNC  :loop
c:0012 p:0009 s:0033 b:0033 l:000024 d:000032 BLOCK  /usr/lib/ruby/1.9.1/irb/ruby-lex.rb:230
c:0011 p:---- s:0031 b:0031 l:000030 d:000030 FINISH
c:0010 p:---- s:0029 b:0029 l:000028 d:000028 CFUNC  :catch
c:0009 p:0023 s:0025 b:0025 l:000024 d:000024 METHOD /usr/lib/ruby/1.9.1/irb/ruby-lex.rb:229
c:0008 p:0042 s:0022 b:0022 l:001bb4 d:001bb4 METHOD /usr/lib/ruby/1.9.1/irb.rb:153
c:0007 p:0011 s:0019 b:0019 l:00059c d:000018 BLOCK  /usr/lib/ruby/1.9.1/irb.rb:70
c:0006 p:---- s:0017 b:0017 l:000016 d:000016 FINISH
c:0005 p:---- s:0015 b:0015 l:000014 d:000014 CFUNC  :catch
c:0004 p:0174 s:0011 b:0011 l:00059c d:00059c METHOD /usr/lib/ruby/1.9.1/irb.rb:69
c:0003 p:0039 s:0006 b:0006 l:000a94 d:000784 EVAL   /usr/bin/irb1.9.1:12
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:000a94 d:000a94 TOP   
---------------------------
-- Ruby level backtrace information-----------------------------------------
/var/lib/gems/1.9.1/gems/wxruby-2.0.1-x86-linux/lib/wx.rb:12:in `require'
/var/lib/gems/1.9.1/gems/wxruby-2.0.1-x86-linux/lib/wx.rb:12:in `'
(irb):1:in `require'
(irb):1:in `irb_binding'
/usr/lib/ruby/1.9.1/irb/workspace.rb:80:in `eval'
/usr/lib/ruby/1.9.1/irb/workspace.rb:80:in `evaluate'
/usr/lib/ruby/1.9.1/irb/context.rb:218:in `evaluate'
/usr/lib/ruby/1.9.1/irb.rb:157:in `block (2 levels) in eval_input'
/usr/lib/ruby/1.9.1/irb.rb:271:in `signal_status'
/usr/lib/ruby/1.9.1/irb.rb:154:in `block in eval_input'
/usr/lib/ruby/1.9.1/irb/ruby-lex.rb:244:in `block (2 levels) in each_top_level_statement'
/usr/lib/ruby/1.9.1/irb/ruby-lex.rb:230:in `loop'
/usr/lib/ruby/1.9.1/irb/ruby-lex.rb:230:in `block in each_top_level_statement'
/usr/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `catch'
/usr/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `each_top_level_statement'
/usr/lib/ruby/1.9.1/irb.rb:153:in `eval_input'
/usr/lib/ruby/1.9.1/irb.rb:70:in `block in start'
/usr/lib/ruby/1.9.1/irb.rb:69:in `catch'
/usr/lib/ruby/1.9.1/irb.rb:69:in `start'
/usr/bin/irb1.9.1:12:in `
' -- C level backtrace information ------------------------------------------- 0xb777c929 /usr/lib/libruby-1.9.1.so.1.9(rb_vm_bugreport+0x69) [0xb777c929] 0xb769592f /usr/lib/libruby-1.9.1.so.1.9(+0x4692f) [0xb769592f] 0xb76959ca /usr/lib/libruby-1.9.1.so.1.9(rb_bug+0x3a) [0xb76959ca] 0xb7695f0c /usr/lib/libruby-1.9.1.so.1.9(rb_check_type+0xbc) [0xb7695f0c] 0xb6d41cdc /var/lib/gems/1.9.1/gems/wxruby-2.0.1-x86-linux/lib/wxruby2.so(Init_wxAboutDialogInfo+0x8c) [0xb6d41cdc] 0xb71791fb /var/lib/gems/1.9.1/gems/wxruby-2.0.1-x86-linux/lib/wxruby2.so(InitializeOtherModules+0xb) [0xb71791fb] 0xb717a109 /var/lib/gems/1.9.1/gems/wxruby-2.0.1-x86-linux/lib/wxruby2.so(Init_wxruby2+0x339) [0xb717a109] 0xb766c22a /usr/lib/libruby-1.9.1.so.1.9(dln_load+0x10a) [0xb766c22a] 0xb7699ae8 /usr/lib/libruby-1.9.1.so.1.9(+0x4aae8) [0xb7699ae8] 0xb77684ef /usr/lib/libruby-1.9.1.so.1.9(rb_vm_call_cfunc+0xaf) [0xb77684ef] 0xb769aad7 /usr/lib/libruby-1.9.1.so.1.9(rb_require_safe+0x5d7) [0xb769aad7] 0xb769ae06 /usr/lib/libruby-1.9.1.so.1.9(rb_f_require+0x26) [0xb769ae06] 0xb7769af3 /usr/lib/libruby-1.9.1.so.1.9(+0x11aaf3) [0xb7769af3] 0xb7769e84 /usr/lib/libruby-1.9.1.so.1.9(+0x11ae84) [0xb7769e84] 0xb777617c /usr/lib/libruby-1.9.1.so.1.9(+0x12717c) [0xb777617c] 0xb7770673 /usr/lib/libruby-1.9.1.so.1.9(+0x121673) [0xb7770673] 0xb7773b46 /usr/lib/libruby-1.9.1.so.1.9(+0x124b46) [0xb7773b46] 0xb7773f0a /usr/lib/libruby-1.9.1.so.1.9(rb_iseq_eval+0x12a) [0xb7773f0a] 0xb7699c8d /usr/lib/libruby-1.9.1.so.1.9(rb_load+0x18d) [0xb7699c8d] 0xb769ab18 /usr/lib/libruby-1.9.1.so.1.9(rb_require_safe+0x618) [0xb769ab18] 0xb769ae06 /usr/lib/libruby-1.9.1.so.1.9(rb_f_require+0x26) [0xb769ae06] 0xb7769af3 /usr/lib/libruby-1.9.1.so.1.9(+0x11aaf3) [0xb7769af3] 0xb7769e84 /usr/lib/libruby-1.9.1.so.1.9(+0x11ae84) [0xb7769e84] 0xb777617c /usr/lib/libruby-1.9.1.so.1.9(+0x12717c) [0xb777617c] 0xb7770673 /usr/lib/libruby-1.9.1.so.1.9(+0x121673) [0xb7770673] 0xb7773b46 /usr/lib/libruby-1.9.1.so.1.9(+0x124b46) [0xb7773b46] 0xb7774b1f /usr/lib/libruby-1.9.1.so.1.9(+0x125b1f) [0xb7774b1f] 0xb777514c /usr/lib/libruby-1.9.1.so.1.9(rb_f_eval+0xdc) [0xb777514c] 0xb7769b18 /usr/lib/libruby-1.9.1.so.1.9(+0x11ab18) [0xb7769b18] 0xb7769e84 /usr/lib/libruby-1.9.1.so.1.9(+0x11ae84) [0xb7769e84] 0xb777617c /usr/lib/libruby-1.9.1.so.1.9(+0x12717c) [0xb777617c] 0xb7770673 /usr/lib/libruby-1.9.1.so.1.9(+0x121673) [0xb7770673] 0xb7773b46 /usr/lib/libruby-1.9.1.so.1.9(+0x124b46) [0xb7773b46] 0xb7775640 /usr/lib/libruby-1.9.1.so.1.9(+0x126640) [0xb7775640] 0xb7697379 /usr/lib/libruby-1.9.1.so.1.9(rb_rescue2+0x169) [0xb7697379] 0xb776b70c /usr/lib/libruby-1.9.1.so.1.9(+0x11c70c) [0xb776b70c] 0xb7769afd /usr/lib/libruby-1.9.1.so.1.9(+0x11aafd) [0xb7769afd] 0xb7769e84 /usr/lib/libruby-1.9.1.so.1.9(+0x11ae84) [0xb7769e84] 0xb777617c /usr/lib/libruby-1.9.1.so.1.9(+0x12717c) [0xb777617c] 0xb7770673 /usr/lib/libruby-1.9.1.so.1.9(+0x121673) [0xb7770673] 0xb7773b46 /usr/lib/libruby-1.9.1.so.1.9(+0x124b46) [0xb7773b46] 0xb7774146 /usr/lib/libruby-1.9.1.so.1.9(+0x125146) [0xb7774146] 0xb7774912 /usr/lib/libruby-1.9.1.so.1.9(+0x125912) [0xb7774912] 0xb7769b18 /usr/lib/libruby-1.9.1.so.1.9(+0x11ab18) [0xb7769b18] 0xb7769e84 /usr/lib/libruby-1.9.1.so.1.9(+0x11ae84) [0xb7769e84] 0xb777617c /usr/lib/libruby-1.9.1.so.1.9(+0x12717c) [0xb777617c] 0xb7770673 /usr/lib/libruby-1.9.1.so.1.9(+0x121673) [0xb7770673] 0xb7773b46 /usr/lib/libruby-1.9.1.so.1.9(+0x124b46) [0xb7773b46] 0xb7774146 /usr/lib/libruby-1.9.1.so.1.9(+0x125146) [0xb7774146] 0xb7774912 /usr/lib/libruby-1.9.1.so.1.9(+0x125912) [0xb7774912] 0xb7769b18 /usr/lib/libruby-1.9.1.so.1.9(+0x11ab18) [0xb7769b18] 0xb7769e84 /usr/lib/libruby-1.9.1.so.1.9(+0x11ae84) [0xb7769e84] 0xb777617c /usr/lib/libruby-1.9.1.so.1.9(+0x12717c) [0xb777617c] 0xb7770673 /usr/lib/libruby-1.9.1.so.1.9(+0x121673) [0xb7770673] 0xb7773b46 /usr/lib/libruby-1.9.1.so.1.9(+0x124b46) [0xb7773b46] 0xb7773dbb /usr/lib/libruby-1.9.1.so.1.9(rb_iseq_eval_main+0xab) [0xb7773dbb] 0xb7697c77 /usr/lib/libruby-1.9.1.so.1.9(ruby_exec_node+0xb7) [0xb7697c77] 0xb7699276 /usr/lib/libruby-1.9.1.so.1.9(ruby_run_node+0x56) [0xb7699276] 0x80487c8 irb1.9.1(main+0x68) [0x80487c8] 0xb748cbd6 /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6) [0xb748cbd6] 0x80486c1 irb1.9.1() [0x80486c1] [NOTE] You may encounter a bug of Ruby interpreter. Bug reports are welcome. For details: http://www.ruby-lang.org/bugreport.html Aborted

Tuesday, November 2, 2010

Installing devhelp

Installed devhelp, GTK library reference tool.

1. Open Synaptic.
2. Find and install devhelp.