Hello All,
I''ve looked back through the wxruby-users archive, and found someone
else was having the same problem when it comes to Accessing XRC and
getting a GTK Error about GtkPizza. I don''t know what the problem is,
as what I''m using, is wxGlade to develop my user interface, and it
creates all the controls in what looks like it should be fine, but it''s
not working. The simplest of my program is:
begin
require ''wx''
rescue LoadError => no_wx_err
begin
require ''rubygems''
require ''wx''
rescue LoadError
raise no_wx_err
end
end
module XrcEnabled
def getXrcControl(id)
return find_window_by_id( Wx::xrcid(id) )
end
end
class ContactList < Wx::Frame
include XrcEnabled
def initialize()
super(nil,-1,"RubyIM")
$xml.load_frame_subclass(self,nil,"ContactList")
# Grab all the controls for what I''m creating
end
end
class RubyIMApp < Wx::App
def on_init
$xml = Wx::XmlResource.get();
$xml.init_all_handlers();
xrc_file = File.join( File.dirname(__FILE__), "xrc",
"ContactList.xrc")
$xml.load(xrc_file)
main = ContactList.new()
main.show(true)
end
end
RubyIMApp.new.main_loop()
The wxGlade xrc file source is:
<?xml version="1.0" encoding="UTF-8"?>
<!-- generated by wxGlade 0.5 on Sat Apr 28 09:32:20 2007 from
/home/eumario/Projects/RubyIM/RubyIM.wxg -->
<resource version="2.3.0.1">
<object class="wxFrame" name="ContactList"
subclass="ContactList">
<style>wxDEFAULT_FRAME_STYLE</style>
<title>Ruby IM - Contact List</title>
<size>297, 732</size>
<object class="wxMenuBar"
name="ContactList_menubar">
<object class="wxMenu" name="clFile">
<label>_File</label>
<object class="wxMenuItem"
name="clfConnect">
<label>_Connect</label>
<help>Connect to IM Server...</help>
</object>
<object class="wxMenuItem"
name="clfDisconnect">
<label>_Disconnect</label>
<help>Disconnect from Server</help>
</object>
<object class="separator"/>
<object class="wxMenuItem"
name="clfExit">
<label>E_xit</label>
<help>Exit from RubyIM</help>
</object>
</object>
<object class="wxMenu" name="clActions">
<label>_Actions</label>
<object class="wxMenu" name="claChat">
<label>_Chat</label>
<object class="wxMenuItem"
name="clacAdd">
<label>_Add</label>
<help>Add a Chatroom to your contact
list...</help>
</object>
<object class="wxMenuItem"
name="clacJoin">
<label>_Join</label>
<help>Join a Chat room</help>
</object>
<object class="wxMenuItem"
name="clacStart">
<label>_Start</label>
<help>Start a new chat...</help>
</object>
<object class="wxMenuItem"
name="clacList">
<label>_List</label>
<help>List Current Existing Chat
Rooms</help>
</object>
</object>
<object class="wxMenu"
name="claContacts">
<label>C_ontacts</label>
<object class="wxMenuItem"
name="claoAdd">
<label>_Add</label>
<help>Add a Contact to your contact
list...</help>
</object>
<object class="wxMenuItem"
name="claoEdit">
<label>_Edit</label>
<help>Edit an existing contact in your Contact
list...</help>
</object>
<object class="wxMenuItem"
name="claoRemove">
<label>_Remove</label>
<help>Remove an Existing contact....</help>
</object>
</object>
<object class="separator"/>
<object class="wxMenuItem"
name="claShowOffline">
<label>_Show Offline</label>
<help>Show Offline Contacts....</help>
<checkable>1</checkable>
</object>
<object class="wxMenuItem"
name="claShowEmpty">
<label>_Show Empty</label>
<help>Show empty groups in your contact
list</help>
<checkable>1</checkable>
</object>
</object>
<object class="wxMenu" name="clTools">
<label>_Tools</label>
<object class="wxMenuItem"
name="cltPrefs">
<label>_Preferences</label>
<help>Client Preferences...</help>
</object>
<object class="wxMenuItem"
name="cltPrivacy">
<label>P_rivacy</label>
<help>Privacy Options...</help>
</object>
<object class="wxMenuItem"
name="cltTransfers">
<label>_Transfers</label>
<help>View your current file
transfers....</help>
</object>
<object class="wxMenuItem"
name="cltDebug">
<label>_Debug</label>
<help>Client debug window...</help>
</object>
<object class="separator"/>
<object class="wxMenuItem"
name="cltMuteSounds">
<label>_Mute Sounds</label>
<help>Mute System Sounds</help>
<checkable>1</checkable>
</object>
</object>
<object class="wxMenu" name="clHelp">
<label>_Help</label>
<object class="wxMenuItem"
name="clhHelp">
<label>_Help</label>
<help>View Help File...</help>
</object>
<object class="wxMenuItem"
name="clhAbout">
<label>_About</label>
<help>About RubyIM...</help>
</object>
</object>
</object>
<object class="wxStatusBar"
name="ContactList_statusbar">
<fields>1</fields>
<style>wxST_SIZEGRIP</style>
<widths>-1</widths>
</object>
<object class="wxToolBar"
name="ContactList_toolbar">
<bitmapsize>32, 31</bitmapsize>
<style>wxTB_FLAT|wxTB_HORIZONTAL</style>
<object class="tool" name="tbAddContact">
<label>Add Contact</label>
<tooltip>Add a Contact</tooltip>
<longhelp>Add a contact to your contact
list</longhelp>
<bitmap>/home/eumario/Projects/RubyIM/images/add_contact.png</bitmap>
</object>
<object class="tool" name="tbAddChat">
<label>Add Chat</label>
<tooltip>Add Chat Room</tooltip>
<longhelp>Add a chat room to your contact
list</longhelp>
<bitmap>/home/eumario/Projects/RubyIM/images/add_chat.png</bitmap>
</object>
</object>
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<option>1</option>
<flag>wxALL|wxEXPAND</flag>
<object class="wxTreeCtrl"
name="Contacts">
<style>wxTR_HAS_BUTTONS|wxTR_NO_LINES|wxTR_HIDE_ROOT|wxTR_DEFAULT_STYLE|wxSUNKEN_BORDER</style>
</object>
</object>
</object>
</object>
</resource>
And like before, which according to the wxruby-users archive, this is
the same problem that Alex was dealing with back on wxruby2 0.0.37 back
in December. Any insight will be much appreciated.
Thanks,
Mario Steele
Mario Steele wrote:> Hello All, > > I''ve looked back through the wxruby-users archive, and found someone > else was having the same problem when it comes to Accessing XRC and > getting a GTK Error about GtkPizza. I don''t know what the problem is, > as what I''m using, is wxGlade to develop my user interface, and it > creates all the controls in what looks like it should be fine, but it''s > not working. The simplest of my program is: >I don''t have a chance to test it out on GTK right now, but does it help if you put a panel as the first and only child of the frame, and then make the toolbar and treectrl chidren of that? alex
Mario Steele wrote:> I''ve looked back through the wxruby-users archive, and found someone > else was having the same problem when it comes to Accessing XRC and > getting a GTK Error about GtkPizza.I''ve looked again at the wxWidgets docs and the way wxRuby is wrapping XmlResource. I think there is something not quite right in the wrapping that may possibly explain this bug, if my other suggestion doesn''t help. However I''ll need a day or three to try fixing it. For anyone interested - I think the wx LoadFrame method expects to receive a frame made with the no-args default constructor, but we''re passing it Frames that have been fully initialized. I''m guessing we need to re-jig initialisation of windows and dialogs from XRC. a
Alex Fenton wrote:> I don''t have a chance to test it out on GTK right now, but does it help > if you put a panel as the first and only child of the frame, and then > make the toolbar and treectrl chidren of that? >With wxGlade, it doesn''t give me the option to add it to like a wxSizerBox, like the normal Glade does. It is possible that this is a Bug more specifically with wxGlade, then with wxRuby. Unfortunately I don''t know of any other GUI designer that I personally like to use. Mario Steele -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20070429/f05b699a/attachment-0001.html
Alex Fenton wrote:> I don''t have a chance to test it out on GTK right now, but does it help > if you put a panel as the first and only child of the frame, and then > make the toolbar and treectrl chidren of that? > > alex >Hey Alex, I figured out a way around my problem. Instead of utilizing XmlResource#load_frame_subclass(), I just use XmlResource#load_frame, and when I get the Wx::Frame, I just extend it with a Module, which works just fine. Thanks anyways, Mario Steele -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20070429/bedd66be/attachment.html
Hi Mario> I figured out a way around my problem. Instead of utilizing > XmlResource#load_frame_subclass(), I just use XmlResource#load_frame, > and when I get the Wx::Frame, I just extend it with a Module, which > works just fine.I''m glad you found a workaround. You''ve helped pin down a longstanding bug that''s now fixed in subversion. The listbook.rb sample was misleading; the correct way to initialize a layout from XRC in a subclass of Frame is: class MyFrame < Wx::Frame def initialize(...) super() # note, no arguments to parent class constructor $xml.load_frame_subclass(self, nil, ''ID_FRAME'') This won''t work with 0.0.39 because the empty constructor for Wx::Frame isn''t available. But in future versions you''ll be able to use normal class inheritance with XRC + Frames. Thanks for the report alex
Alex Fenton wrote:> Hi Mario > >> I figured out a way around my problem. Instead of utilizing >> XmlResource#load_frame_subclass(), I just use XmlResource#load_frame, >> and when I get the Wx::Frame, I just extend it with a Module, which >> works just fine. >> > I''m glad you found a workaround. You''ve helped pin down a longstanding > bug that''s now fixed in subversion. > > The listbook.rb sample was misleading; the correct way to initialize a > layout from XRC in a subclass of Frame is: > > class MyFrame < Wx::Frame > def initialize(...) > super() # note, no arguments to parent class constructor > $xml.load_frame_subclass(self, nil, ''ID_FRAME'') > > This won''t work with 0.0.39 because the empty constructor for Wx::Frame > isn''t available. But in future versions you''ll be able to use normal > class inheritance with XRC + Frames. > > Thanks for the report > > alex >Not a problem, I''m glad to see that will be rolling around, cause that''ll make things easier. Not that my solution isn''t a good one, just makes it a bit more difficult, having to write modules, and extend the object directly. And I kinda figured that it won''t work with 0.0.39, cause I tried that before going the route that listbook.rb uses. And it did complain, no empty initialize method. So go figure. Thanks for the continued support. wxRuby2 is comming out to be a good re-vamp, and more stable with each release. Mario Steele -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20070501/53d94175/attachment.html