Forum: wxRuby a newbie with some question

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.
2aa32559134aa3d596fb749f8ffccde7?d=identicon&s=25 hendra kusuma (Guest)
on 2009-03-25 03:06
(Received via mailing list)
Hi, I'm new here

I'm planing to use wxruby to create a database program
with sqlite as backend
My system is Ubuntu 8.04, ruby 1.8.6 and wxruby-2.0.0
I choose to use xrc file as GUI definition
but somehow wxsugar didn't work with my system
(xrcise is not a known command)

So I write ruby code to load the xrc file manually (thanks google) and
it
works, with some problem though

so here is my question
1. Tab-navigation is not working (I pressed tab and the focus is not
moving
to next widget). How do I get this working?

2. I cannot get a menu-item widget to work

> @menu = @finder.call("menuItem_quit")
>
does not work

Thanks

here is my code :
###

require 'rubygems'
require 'wx'

class Frame < Wx::Frame
    def initialize()
        super()
        xml = Wx::XmlResource.get
        xml.flags = 2
        xml.init_all_handlers
        xml.load("siswa.xrc")
        xml.load_frame_subclass(self, parent, "Siswa")

        @finder = lambda do | x |
            int_id = Wx::xrcid(x)
            begin
                Wx::Window.find_window_by_id(int_id, self) ||
int_idvt_button(button_save) { save() }
            rescue RuntimeError
                int_id
            end
        end

        @txtNis = @finder.call("textCtrl_nis")
        @txtNama = @finder.call("textCtrl_nama")

        button_quit = @finder.call("button_quit")

         evt_button(button_quit) { quit() }

    end

    def quit()
        self.close()
    end
end

Wx::App.run do
  a = Frame.new().show
end


###
and this is the xrc file
###
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<resource xmlns="http://www.wxwindows.org/wxxrc" version="2.3.0.1">
    <object class="wxFrame" name="Siswa">
        <style>wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL</style>
        <size>480,640</size>
        <title>Siswa</title>
        <object class="wxMenuBar" name="menubar">
            <label>MenuBar</label>
            <object class="wxMenu" name="m_menu3">
                <label>_Operation</label>
                <object class="wxMenuItem" name="menuItem_quit">
                    <label>_Quit</label>
                    <help></help>
                </object>
            </object>
        </object>
        <object class="wxFlexGridSizer">
            <rows>2</rows>
            <cols>2</cols>
            <vgap>10</vgap>
            <hgap>10</hgap>
            <growablecols>0</growablecols>
            <growablerows></growablerows>
            <object class="sizeritem">
                <option>1</option>
                <flag>wxEXPAND</flag>
                <border>5</border>
                <object class="wxFlexGridSizer">
                    <rows>2</rows>
                    <cols>2</cols>
                    <vgap>5</vgap>
                    <hgap>5</hgap>
                    <growablecols>1</growablecols>
                    <growablerows></growablerows>
                    <object class="sizeritem">
                        <option>1</option>
                        <flag></flag>
                        <border>5</border>
                        <object class="wxStaticText"
name="staticText_nis">
                            <label>Nis</label>
                        </object>
                    </object>
                    <object class="sizeritem">
                        <option>1</option>
                        <flag>wxEXPAND</flag>
                        <border>5</border>
                        <object class="wxTextCtrl" name="textCtrl_nis">
                            <value></value>
                            <maxlength>0</maxlength>
                        </object>
                    </object>
                    <object class="sizeritem">
                        <option>1</option>
                        <flag></flag>
                        <border>5</border>
                        <object class="wxStaticText"
name="staticText_nama">
                            <label>Nama</label>
                        </object>
                    </object>
                    <object class="sizeritem">
                        <option>1</option>
                        <flag>wxEXPAND</flag>
                        <border>5</border>
                        <object class="wxTextCtrl" name="textCtrl_nama">
                            <value></value>
                            <maxlength>0</maxlength>
                        </object>
                    </object>
                </object>
            </object>
            <object class="sizeritem">
                <option>1</option>
                <flag></flag>
                <border>5</border>
                <object class="wxBoxSizer">
                    <orient>wxVERTICAL</orient>
                    <object class="sizeritem">
                        <option>1</option>
                        <flag>wxEXPAND</flag>
                        <border>5</border>
                        <object class="wxButton" name="button_quit">
                            <label>_Quit</label>
                            <default>0</default>
                        </object>
                    </object>
                </object>
            </object>
        </object>
    </object>
</resource>
This topic is locked and can not be replied to.