From mario at ruby-im.net Sat Dec 1 08:30:30 2007 From: mario at ruby-im.net (Mario Steele) Date: Sat, 1 Dec 2007 07:30:30 -0600 Subject: [wxruby-users] Tearing in my buffered animation test script... In-Reply-To: <839490bc0711302028v35a8d9d5lb959762b17f115e8@mail.gmail.com> References: <839490bc0711302028v35a8d9d5lb959762b17f115e8@mail.gmail.com> Message-ID: On 11/30/07, Jay McGavren wrote: > > OK, I have a basic blit demo working (thanks to Alex Fenton for his > reply, which I finally saw). > > However, there's a great deal of "tearing" on the screen - flickering > grey lines in the black background. It looks like the blit isn't > always complete when the screen refreshes. > > Can anyone look at this and tell me what I might be doing wrong? Any > help would be most appreciated! > > -Jay McGavren > http://jay.mcgavren.com/zyps > Hey Jay, I've actually looked over the demo, and tested it out on my computer. According to what I see here, there should be no problems with it. And I've tested it on Linux, and I have no flickering, or tears in it. I would suggest, for the final "blit" operation, that instead of waiting for a Paint Event, you switch to using DC#draw_bitmap() instead of using DC#blit() This will take a lot of the computation off of wxRuby, which it must do to ensure that everything is within bounds, and there is not a programmer error (Which is often raised by a Message box error, or a segfault). Especially considering that your drawing the entire buffer that you have offscreen. Two other things. 1.) If your doing the actual painting when evt_paint() is called, then you do not need to create a ClientDC (Which is what window.paint does) 2.) You can skip evt_paint() and window.refresh/window.update all together, and just call window.paint, to paint to the window, when your finished with the painting on the Buffer. Just a couple of suggestions for ya, which should take care of the flicker and tearing. Mario Steele -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071201/11f399a5/attachment.html From mario at ruby-im.net Sat Dec 1 08:47:55 2007 From: mario at ruby-im.net (Mario Steele) Date: Sat, 1 Dec 2007 07:47:55 -0600 Subject: [wxruby-users] Tearing in my buffered animation test script... In-Reply-To: References: <839490bc0711302028v35a8d9d5lb959762b17f115e8@mail.gmail.com> Message-ID: On 12/1/07, Mario Steele wrote: > > Two other things. > 1.) If your doing the actual painting when evt_paint() is called, then you > do not need to create a ClientDC (Which is what window.paint does) > 2.) You can skip evt_paint() and window.refresh /window.update all > together, and just call window.paint, to paint to the window, when your > finished with the painting on the Buffer. > > Just a couple of suggestions for ya, which should take care of the flicker > and tearing. > > Mario Steele > Just a quick follow up. What I meant to say, was that you need to use one, or the other, as your basically creating two DC's within a single event, which would be causing the flicker. So, you need to either create a Thread to draw it, or you need to take out the paint and draw within the evt_paint() proc. Sorry if that didn't make sense earlier. ;-) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071201/c139d9fe/attachment-0001.html From jay at mcgavren.com Sat Dec 1 15:55:10 2007 From: jay at mcgavren.com (Jay McGavren) Date: Sat, 1 Dec 2007 13:55:10 -0700 Subject: [wxruby-users] Tearing in my buffered animation test script... Message-ID: <839490bc0712011255w7994f2f6ub869ec8b34202ab1@mail.gmail.com> Excellent, excellent! All tearing is now gone on Windows. (I meant to mention my platform before, but forgot.) I kept evt_paint, which I need just in case the window needs redrawing (or at least, I will in my final application). But I created a separate routine that just calls Window.paint, and that's what I use in my main animation loop (as well as evt_paint). And draw_bitmap is a lot cleaner, as well, so thanks for pointing that out. Revised code is below. You've saved me days of headaches, so many thanks! -Jay McGavren http://jay.mcgavren.com/zyps require 'rubygems' require 'wx' class MyApp < Wx::App def on_init #Containing frame. frame = Wx::Frame.new(nil, :size => [300, 300]) frame.show #Offscreen drawing buffer. buffer = Wx::Bitmap.new(300, 300) #Displays drawing. window = Wx::Window.new(frame, :size => [300, 300]) window.evt_paint do |event| update_window(window, buffer) end #Animate. (1..40).each do |i| #Clear screen. buffer.draw do |surface| surface.pen = Wx::Pen.new(Wx::Colour.new(0, 0, 0), 0) surface.brush = Wx::BLACK_BRUSH surface.draw_rectangle(0, 0, 300, 300) end #Draw line. buffer.draw do |surface| surface.pen = Wx::Pen.new( Wx::Colour.new(128, 255, 128), 3 ) surface.pen.cap = Wx::CAP_ROUND surface.draw_line(i, 0, i+100, 100) end #Update screen. update_window(window, buffer) sleep 0.1 end end def update_window(window, buffer) window.paint do |dc| #Copy the buffer to the viewable window. dc.draw_bitmap(buffer, 0, 0, false) end end end app = MyApp.new app.main_loop > On 12/1/07, Mario Steele wrote: > > Two other things. > > 1.) If your doing the actual painting when evt_paint() is called, then you > > do not need to create a ClientDC (Which is what window.paint does) > > 2.) You can skip evt_paint() and window.refresh /window.update all > > together, and just call window.paint, to paint to the window, when your > > finished with the painting on the Buffer. > > > > Just a couple of suggestions for ya, which should take care of the flicker > > and tearing. > > > > Mario Steele > > Just a quick follow up. What I meant to say, was that you need to use one, > or the other, as your basically creating two DC's within a single event, > which would be causing the flicker. So, you need to either create a Thread > to draw it, or you need to take out the paint and draw within the > evt_paint() proc. Sorry if that didn't make sense earlier. ;-) From jari.williamsson at mailbox.swipnet.se Tue Dec 4 11:28:41 2007 From: jari.williamsson at mailbox.swipnet.se (Jari Williamsson) Date: Tue, 04 Dec 2007 17:28:41 +0100 Subject: [wxruby-users] Hooking up wxRuby in other applications Message-ID: <47558039.20900@mailbox.swipnet.se> Is there a way (class?) to be able to use wxRuby for subwindows in a host application? (Windows and OSX platforms) Best regards, Jari Williamsson From alex at pressure.to Tue Dec 4 11:37:38 2007 From: alex at pressure.to (Alex Fenton) Date: Tue, 04 Dec 2007 16:37:38 +0000 Subject: [wxruby-users] Hooking up wxRuby in other applications In-Reply-To: <47558039.20900@mailbox.swipnet.se> References: <47558039.20900@mailbox.swipnet.se> Message-ID: <47558252.2080906@pressure.to> Hi Jari Jari Williamsson wrote: > Is there a way (class?) to be able to use wxRuby for subwindows in a > host application? (Windows and OSX platforms) > Not exactly, so far as I know. You can get a platform-native handle for a Wx::Window (such as a host frame) by using Window#get_handle. I guess it should be possible to use this to directly interact with the native OS using Win32API or RubyCocoa. If it were possible to host the application in wxRuby, and then pass a handle to an external app to draw upon, it might work. This is done regularly in C++ wxWidgets but I've never seen it tried in wxRuby. Yet ;) best alex From bureaux.sebastien at neuf.fr Fri Dec 7 12:24:44 2007 From: bureaux.sebastien at neuf.fr (sebastien) Date: Fri, 7 Dec 2007 18:24:44 +0100 Subject: [wxruby-users] html window Message-ID: <000601c838f6$10f01960$0201a8c0@sebastien> Salut Alex. Je ne n'arrive pas ? comprendre ? quoi sert r?ellement: "HW_NO_SELECTION" Est-ce que tu peut m'expliquez un peu plus en d?tail. merci sebastien http://beusse.liveror.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071207/2d51264b/attachment.html From alex at pressure.to Fri Dec 7 16:38:13 2007 From: alex at pressure.to (Alex Fenton) Date: Fri, 07 Dec 2007 21:38:13 +0000 Subject: [wxruby-users] html window In-Reply-To: <000601c838f6$10f01960$0201a8c0@sebastien> References: <000601c838f6$10f01960$0201a8c0@sebastien> Message-ID: <4759BD45.9050200@pressure.to> Salut sebastien wrote: > Je ne n'arrive pas ? comprendre ? quoi sert r?ellement: "HW_NO_SELECTION" > Est-ce que tu peut m'expliquez un peu plus en d?tail. [I'm not sure I understand what the style flag Wx::HW_NO_SELECTION does - could you explain a bit more] Si un Wx::HtmlWindow est cr?? avec ce style, l'usager ne pourra pas s?lectionner le texte qu'affiche le HtmlWindow. Donc, il ne pourra pas le (copier?calquer?) afin de le coller dans une autre application. Je l'ai essay? sur GTK/Linux et il marchait comme j'ai d?crit. [If a Wx::HtmlWindow is created with this style, the user won't be able to select the text which the window displays. So, s/he won't be able to copy it to paste into another application. I've tried this on GTK/Linux and it works as described] cheers alex From echobinary at gmail.com Fri Dec 7 23:20:17 2007 From: echobinary at gmail.com (EchoB) Date: Fri, 07 Dec 2007 23:20:17 -0500 Subject: [wxruby-users] Windows or Cross-Platform System Tray Message-ID: <475A1B81.4010508@gmail.com> I am new to Ruby, and am trying out wxRuby, is there a place to find examples of code to make system tray icons with left and right click menus? Cross platform is ideal, but win32 specific if necc... thanks! From mario at ruby-im.net Fri Dec 7 23:43:28 2007 From: mario at ruby-im.net (Mario Steele) Date: Fri, 7 Dec 2007 22:43:28 -0600 Subject: [wxruby-users] Windows or Cross-Platform System Tray In-Reply-To: <475A1B81.4010508@gmail.com> References: <475A1B81.4010508@gmail.com> Message-ID: Hello EchoB, On 12/7/07, EchoB wrote: > > I am new to Ruby, and am trying out wxRuby, is there a place to find > examples of code to make system tray icons with left and right click > menus? > Cross platform is ideal, but win32 specific if necc... > thanks! If you look at the samples/bigdemo/bigdemo.rb, it implements Wx::TaskBarIcon, which you can find as DemoTaskBarIcon Class, starting at line 736 of the bigdemo.rb. That will show you how to do a TaskBarIcon AKA System Tray Icon. L8ers, Mario Steele -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071207/6a62565e/attachment.html From alex at pressure.to Sat Dec 8 05:46:41 2007 From: alex at pressure.to (Alex Fenton) Date: Sat, 08 Dec 2007 10:46:41 +0000 Subject: [wxruby-users] Problems installing/running svn-code In-Reply-To: <474D9CA4.4070906@xs4all.nl> References: <474D9CA4.4070906@xs4all.nl> Message-ID: <475A7611.2070208@pressure.to> Hi Jonathan Thanks for the reports, sorry to be slow in following up. Jonathan Maasland wrote: > The first hurdle was that the rake install target doesn't work. It fails > on rakewx.rb:145. Looking into it I found that $target_lib wasn't set to > anything. Searching the sources I couldn't find where it is supposed to > be set. > Should now be fixed in SVN. With most people using gems, we've kind of slipped on maintenance of the tar.gz/install route, so please do report any probs. > I couldn't find anything, it's just a wee bit too complex for me to > handle right now. Don't think this is useful for the developers but just > in case it might be this is the error I got: undefined symbol: > _Z10wxOnAssertPKwiPKcS0_S0_ > Hmm, I think I've seen that error if I've mistakenly compiled a debug wxRuby against a release wxWidgets, or vice versa. I think all the object files in wxRuby need to have been compiled with the "WXRUBY_DEBUG" environment variable set. The configuration for wxWidgets looks appropriate for this. cheers alex From bureaux.sebastien at neuf.fr Mon Dec 10 03:48:21 2007 From: bureaux.sebastien at neuf.fr (sebastien) Date: Mon, 10 Dec 2007 09:48:21 +0100 Subject: [wxruby-users] kernel#system Message-ID: <000601c83b09$6bb249d0$0201a8c0@sebastien> Salut Alex. Dans mon application, j'ouvre IE7 avec kernel#system et j'aimerai pouvoir maximizer IE7 ? l'ouverture. Il faut que je passe qu'elle commande ? kernel#system pour pouvoir le maximizer? merci sebastien http://beusse.liveror.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071210/9ba41f85/attachment.html From lists at ruby-forum.com Mon Dec 10 05:20:34 2007 From: lists at ruby-forum.com (Christian Kerth) Date: Mon, 10 Dec 2007 11:20:34 +0100 Subject: [wxruby-users] Popup Window Message-ID: <465f5aa4b9fc6e8192b1069dfacd5927@ruby-forum.com> Hey! I would need a popup window like this (not necessarily associated to a taskbaricon): http://www.venraiker.com/wp-content/uploads/2006/03/libnotifyvx.png I should be possible to show such a window for a certain time, displaying a certain message. Is a similar thing possible with wx? Are there oder options? thx ck -- Posted via http://www.ruby-forum.com/. From mario at ruby-im.net Mon Dec 10 05:51:26 2007 From: mario at ruby-im.net (Mario Steele) Date: Mon, 10 Dec 2007 04:51:26 -0600 Subject: [wxruby-users] Popup Window In-Reply-To: <465f5aa4b9fc6e8192b1069dfacd5927@ruby-forum.com> References: <465f5aa4b9fc6e8192b1069dfacd5927@ruby-forum.com> Message-ID: Hey Ck, On 12/10/07, Christian Kerth wrote: > > Hey! > I would need a popup window like this (not necessarily associated to a > taskbaricon): > > http://www.venraiker.com/wp-content/uploads/2006/03/libnotifyvx.png Graphically wise, no, that's something that you would have to specifically setup to be drawn. But, window popup wise, yes, you can setup a Wx::MiniFrame to create the said popup window. And by utilizing Wx:: SystemSettings.get_metric(Wx::SYS_SCREEN_X) and Wx:: SystemSettings.get_metric(Wx::SYS_SCREEN_Y) you should be able to determine the size of the screen to position your "popup notification" to show, and hide. A quick and dirty example would be: class MyPopupWin < Wx::MiniFrame def initialize(parent,timeout) super(parent) @timer = Timer.new(self,10001) evt_timer(10001) do { @timer.stop; self.show(false); } self.show(true) @timer.start(timeout) end end Note, this is not tested code, just quick spur of the moment type design, but general idea should be there for you to use. L8ers, Mario Steele I should be possible to show such a window for a certain time, > displaying a certain message. > > Is a similar thing possible with wx? Are there oder options? > > thx ck > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071210/2ac765be/attachment-0001.html From mario at ruby-im.net Mon Dec 10 10:38:27 2007 From: mario at ruby-im.net (Mario Steele) Date: Mon, 10 Dec 2007 09:38:27 -0600 Subject: [wxruby-users] IRC Chat Room Message-ID: Hello All, I don't know about many on here, but I personally like to talk in Real Time format, when discussing things about wxRuby, therefore I've started the room #wxRuby on irc.freenode.net, since this is where the official Ruby-Lang chat room is. If your looking for help, or support, feel free to drop by. Also, keep in mind, of the following rules: 1.) Be nice to others, keep things below PG-13 Rule, including language! 2.) Paste code snipplets to http://rafb.net/paste (This is in the Room Topic) 3.) Enjoy yourself, and have fun! For now, I'll be the only developer there for the wxRuby Project, unless Alex or Sean decide they want to stop by. See you all in the chat room! Mario Steele -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071210/c035cb76/attachment.html From lists at ruby-forum.com Mon Dec 10 11:26:31 2007 From: lists at ruby-forum.com (Christian Kerth) Date: Mon, 10 Dec 2007 17:26:31 +0100 Subject: [wxruby-users] Popup Window In-Reply-To: References: <465f5aa4b9fc6e8192b1069dfacd5927@ruby-forum.com> Message-ID: <69f19b480b8139b81942abc81354c651@ruby-forum.com> Mario Steele wrote: > class MyPopupWin < Wx::MiniFrame > def initialize(parent,timeout) > super(parent) > @timer = Timer.new(self,10001) > evt_timer(10001) do { @timer.stop; self.show(false); } > self.show(true) > @timer.start(timeout) > end > end Does a Wx::MiniFrame need a parent window? I doesn't have a parent window, just a taskbaricon. When i pass nil to the constructor it generates an error. greets ck -- Posted via http://www.ruby-forum.com/. From mario at ruby-im.net Mon Dec 10 11:42:48 2007 From: mario at ruby-im.net (Mario Steele) Date: Mon, 10 Dec 2007 10:42:48 -0600 Subject: [wxruby-users] Popup Window In-Reply-To: <69f19b480b8139b81942abc81354c651@ruby-forum.com> References: <465f5aa4b9fc6e8192b1069dfacd5927@ruby-forum.com> <69f19b480b8139b81942abc81354c651@ruby-forum.com> Message-ID: Wx::MiniFrame does need a Parent Window in order to be created, but not shown. You can create a Simple Window, for the Parent, but that window should not need to be shown in order for the Wx::MiniFrame to be shown. L8ers, Mario Steele On 12/10/07, Christian Kerth wrote: > > Mario Steele wrote: > > > class MyPopupWin < Wx::MiniFrame > > def initialize(parent,timeout) > > super(parent) > > @timer = Timer.new(self,10001) > > evt_timer(10001) do { @timer.stop; self.show(false); } > > self.show(true) > > @timer.start(timeout) > > end > > end > > Does a Wx::MiniFrame need a parent window? I doesn't have a parent > window, just a taskbaricon. When i pass nil to the constructor it > generates an error. > > greets ck > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071210/65fe8a3c/attachment.html From mario at ruby-im.net Mon Dec 10 13:40:39 2007 From: mario at ruby-im.net (Mario Steele) Date: Mon, 10 Dec 2007 12:40:39 -0600 Subject: [wxruby-users] Problems installing/running svn-code In-Reply-To: <475A7611.2070208@pressure.to> References: <474D9CA4.4070906@xs4all.nl> <475A7611.2070208@pressure.to> Message-ID: Hello Jonathan, I've ran into the same problem myself, compiling from SVN on Linux, using wxGTK, and Ruby 1.8.6. I was able to get wxRuby and wxGTK to compile with Debug support, and from what I can see, running through gdb (Which was a trick and a half), it shows that it's segfaulting on rb_hash_aref(), which is comming from /usr/lib/libruby.so.1.8 So I have a couple of questions for you. 1.) Which Distro are you using? 2.) Did you install Ruby from Source, or from your Distro's Package Manager? 3.) Do you have the same problems if you take out the --with-opengl? These are just a few questions / ideas to get an idea of where the problem lies. L8ers, Mario Steele On 12/8/07, Alex Fenton wrote: > > Hi Jonathan > > Thanks for the reports, sorry to be slow in following up. > > Jonathan Maasland wrote: > > The first hurdle was that the rake install target doesn't work. It fails > > on rakewx.rb:145. Looking into it I found that $target_lib wasn't set to > > anything. Searching the sources I couldn't find where it is supposed to > > be set. > > > Should now be fixed in SVN. With most people using gems, we've kind of > slipped on maintenance of the tar.gz/install route, so please do report > any probs. > > I couldn't find anything, it's just a wee bit too complex for me to > > handle right now. Don't think this is useful for the developers but just > > in case it might be this is the error I got: undefined symbol: > > _Z10wxOnAssertPKwiPKcS0_S0_ > > > Hmm, I think I've seen that error if I've mistakenly compiled a debug > wxRuby against a release wxWidgets, or vice versa. I think all the > object files in wxRuby need to have been compiled with the > "WXRUBY_DEBUG" environment variable set. > > The configuration for wxWidgets looks appropriate for this. > > cheers > alex > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071210/5902ec4b/attachment.html From erubin at valcom.com Wed Dec 12 10:45:55 2007 From: erubin at valcom.com (Eric Rubin) Date: Wed, 12 Dec 2007 10:45:55 -0500 Subject: [wxruby-users] Question about running other threads in a WxRuby app In-Reply-To: Message-ID: <004501c83cd6$154e4ca0$a10ba8c0@valcom.com> I've put together a GUI with WxRuby that works fine (under Windows XP). Now I'm adding another component, a UDP server, which runs in a separate thread. What I'm seeing is that the UDP server runs for a little while when I do something in the GUI, but then stops processing UDP packets until I do something else on the GUI. My UDP server thread spends most of its time waiting for a UDP packet, so it should be able to run at a high priority without interfering with the GUI operation. So what do I need to know about the interaction between WxRuby and other Ruby threads? Does WxRuby have threads running to implement GUI events? Are there known problems with running other threads in a WxRuby app? Thanks, Eric Rubin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071212/a03e85ce/attachment.html From alex at pressure.to Wed Dec 12 11:05:11 2007 From: alex at pressure.to (Alex Fenton) Date: Wed, 12 Dec 2007 16:05:11 +0000 Subject: [wxruby-users] Question about running other threads in a WxRuby app In-Reply-To: <004501c83cd6$154e4ca0$a10ba8c0@valcom.com> References: <004501c83cd6$154e4ca0$a10ba8c0@valcom.com> Message-ID: <476006B7.4070402@pressure.to> Hi Eric Eric Rubin wrote: > > I?ve put together a GUI with WxRuby that works fine (under Windows > XP). Now I?m adding another component, a UDP server, which runs in a > separate thread. What I?m seeing is that the UDP server runs for a > little while when I do something in the GUI, but then stops processing > UDP packets until I do something else on the GUI. My UDP server thread > spends most of its time waiting for a UDP packet, so it should be able > to run at a high priority without interfering with the GUI operation. > > So what do I need to know about the interaction between WxRuby and > other Ruby threads? Does WxRuby have threads running to implement GUI > events? Are there known problems with running other threads in a > WxRuby app? > As with other GUI toolkits, wxRuby doesn't play so well with Ruby 1.8's lightweight threads. The main GUI event loop runs constantly, and when it's in there (in C-based code) Ruby's thread scheduler won't switch execution to subsidiary threads. Fortunately, it's not hard to work around by using a Wx::Timer to schedule switches of Ruby's thread execution. The recommended workaround is described here: http://rubyforge.org/pipermail/wxruby-users/2007-April/003055.html You will probably want to tweak the parameter to Timer#start to get the best responsiveness off your UDP server whilst still keeping the GUI reactive. hth alex From mario at ruby-im.net Wed Dec 12 12:28:18 2007 From: mario at ruby-im.net (Mario Steele) Date: Wed, 12 Dec 2007 11:28:18 -0600 Subject: [wxruby-users] Question about running other threads in a WxRuby app In-Reply-To: <476006B7.4070402@pressure.to> References: <004501c83cd6$154e4ca0$a10ba8c0@valcom.com> <476006B7.4070402@pressure.to> Message-ID: Hello Eric, As pointed out by Alex, it is a bit of a side trip to get things to work properly for wxRuby, with Ruby's Soft-Threading control. As mentioned above, Timer + Thread.pass is the best method in which to do this. You should be able to find in the SVN an example of a wxRuby program utilizing Sockets within Threads, that I created myself. http://wxruby.rubyforge.org/svn/trunk/wxruby2/samples/sockets/ is the url to the svn lookup, and you should look at wxServer.rb. This is geared for Connection Based sockets, not Connectionless Sockets like what your Implementing. I would actually like to look at your code, once you've implemented the Timer + Thread.pass, to get an Idea of how UDP Sockets would work with the method, so that I can further investigate creating a library that will do this for us. Thanks, Mario Steele On 12/12/07, Alex Fenton wrote: > > Hi Eric > > Eric Rubin wrote: > > > > I've put together a GUI with WxRuby that works fine (under Windows > > XP). Now I'm adding another component, a UDP server, which runs in a > > separate thread. What I'm seeing is that the UDP server runs for a > > little while when I do something in the GUI, but then stops processing > > UDP packets until I do something else on the GUI. My UDP server thread > > spends most of its time waiting for a UDP packet, so it should be able > > to run at a high priority without interfering with the GUI operation. > > > > So what do I need to know about the interaction between WxRuby and > > other Ruby threads? Does WxRuby have threads running to implement GUI > > events? Are there known problems with running other threads in a > > WxRuby app? > > > > As with other GUI toolkits, wxRuby doesn't play so well with Ruby 1.8's > lightweight threads. The main GUI event loop runs constantly, and when > it's in there (in C-based code) Ruby's thread scheduler won't switch > execution to subsidiary threads. > > Fortunately, it's not hard to work around by using a Wx::Timer to > schedule switches of Ruby's thread execution. The recommended workaround > is described here: > > http://rubyforge.org/pipermail/wxruby-users/2007-April/003055.html > > You will probably want to tweak the parameter to Timer#start to get the > best responsiveness off your UDP server whilst still keeping the GUI > reactive. > > hth > alex > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071212/4c56b814/attachment-0001.html From alex at pressure.to Wed Dec 12 13:22:27 2007 From: alex at pressure.to (Alex Fenton) Date: Wed, 12 Dec 2007 18:22:27 +0000 Subject: [wxruby-users] kernel#system In-Reply-To: <000601c83b09$6bb249d0$0201a8c0@sebastien> References: <000601c83b09$6bb249d0$0201a8c0@sebastien> Message-ID: <476026E3.9090605@pressure.to> sebastien wrote: > Dans mon application, j'ouvre IE7 avec kernel#system et j'aimerai > pouvoir maximizer IE7 ? l'ouverture. > Il faut que je passe qu'elle commande ? kernel#system pour pouvoir le > maximizer? [Sebastien asked: in my application I open IE7 with Kernel#system, and would like to be able to maximise it at opening. Is there a command I can use for this?] Je ne sais pas. Peut-etre tu pourrais se servir de "Win32OLE" qui permet beaucoup plus controle sur des autres applications. Par exemple, je pense que "watir" utilise Win32OLE avec IE7. Ceci n'est pas une question de wxRuby - donc, je crois que tu trouveras d'aide dans un forum general de ruby francais. best wishes alex From erubin at valcom.com Thu Dec 13 10:05:42 2007 From: erubin at valcom.com (Eric Rubin) Date: Thu, 13 Dec 2007 10:05:42 -0500 Subject: [wxruby-users] Question about running other threads in a WxRubyapp In-Reply-To: Message-ID: <000001c83d99$a1a16a20$a10ba8c0@valcom.com> Alex's fix did the trick. Thanks. Here's the relevant part of my code. The UDP server, VIP102Comm, has to receive on a multicast address. I found some code for this online, but had to make a couple of changes to get it to run under Windows. One is that Socket::IP_ADD_MEMBERSHIP is not defined in Windows. Also in Windows the setsockopt call has to come after the bind call. (It the code I copied it came before and produced an error.) There also seems to be a problem with recvfrom. (Don't know if it's only in Windows.) When I used recvfrom it worked, but each recvfrom call took about 5 seconds. The problem went away when I switched to recv (but now I can't get the source IP address). Eric require "soft_phone_frame" require "vip102comm" class SoftPhoneApp < App def on_init tmr = Wx::Timer.new(self, 55) evt_timer(55) { Thread.pass } tmr.start(100) frame = SoftPhoneFrame.new() Thread.new { VIP102Comm.new(frame) } end end SoftPhoneApp.new.main_loop class VIP102Comm def initialize(parent) Thread.current.priority = 100 @parent = parent # soft_phone_frame @control_addr = "239.1.1.2" @control_port = 4097 begin ip = IPAddr.new(@control_addr).hton + IPAddr.new("0.0.0.0").hton @sock = UDPSocket.new @sock.bind(Socket::INADDR_ANY, @control_port) # in Windows setsockopt must follow bind if Socket::const_defined?('IP_ADD_MEMBERSHIP') @sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP, ip) else # workaround for Ruby bug where Socket::IP_ADD_MEMBERSHIP is not defined in Windows @sock.setsockopt(Socket::IPPROTO_IP, 12, ip) end rescue ArgumentError => a puts "Argument error: " + a rescue Exception => e puts "error: " + e end loop do packet = @sock.recv(1350) # packet, sender = @sock.recvfrom(1350) # srcIPAddr = sender[3] process_packet(packet) end end -----Original Message----- From: wxruby-users-bounces at rubyforge.org [mailto:wxruby-users-bounces at rubyforge.org] On Behalf Of Mario Steele Sent: Wednesday, December 12, 2007 12:28 PM To: General discussion of wxRuby Subject: Re: [wxruby-users] Question about running other threads in a WxRubyapp Hello Eric, As pointed out by Alex, it is a bit of a side trip to get things to work properly for wxRuby, with Ruby's Soft-Threading control. As mentioned above, Timer + Thread.pass is the best method in which to do this. You should be able to find in the SVN an example of a wxRuby program utilizing Sockets within Threads, that I created myself. http://wxruby.rubyforge.org/svn/trunk/wxruby2/samples/sockets/ is the url to the svn lookup, and you should look at wxServer.rb. This is geared for Connection Based sockets, not Connectionless Sockets like what your Implementing. I would actually like to look at your code, once you've implemented the Timer + Thread.pass, to get an Idea of how UDP Sockets would work with the method, so that I can further investigate creating a library that will do this for us. Thanks, Mario Steele On 12/12/07, Alex Fenton wrote: Hi Eric Eric Rubin wrote: > > I've put together a GUI with WxRuby that works fine (under Windows > XP). Now I'm adding another component, a UDP server, which runs in a > separate thread. What I'm seeing is that the UDP server runs for a > little while when I do something in the GUI, but then stops processing > UDP packets until I do something else on the GUI. My UDP server thread > spends most of its time waiting for a UDP packet, so it should be able > to run at a high priority without interfering with the GUI operation. > > So what do I need to know about the interaction between WxRuby and > other Ruby threads? Does WxRuby have threads running to implement GUI > events? Are there known problems with running other threads in a > WxRuby app? > As with other GUI toolkits, wxRuby doesn't play so well with Ruby 1.8's lightweight threads. The main GUI event loop runs constantly, and when it's in there (in C-based code) Ruby's thread scheduler won't switch execution to subsidiary threads. Fortunately, it's not hard to work around by using a Wx::Timer to schedule switches of Ruby's thread execution. The recommended workaround is described here: http://rubyforge.org/pipermail/wxruby-users/2007-April/003055.html You will probably want to tweak the parameter to Timer#start to get the best responsiveness off your UDP server whilst still keeping the GUI reactive. hth alex _______________________________________________ wxruby-users mailing list wxruby-users at rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071213/9e4f29f5/attachment.html From echobinary at gmail.com Mon Dec 17 22:47:02 2007 From: echobinary at gmail.com (EchoB) Date: Mon, 17 Dec 2007 22:47:02 -0500 Subject: [wxruby-users] Dynamic Task Bar Menu Items Message-ID: <476742B6.1060104@gmail.com> Am looking for a way to dynamically add menu items to a task bar icon menu. And then once selected - I would like to get the title of the menu item. The general idea is to read a text file: Project1 Project2 Project3 ===== Add those to the task bar menu, and when i select (for example) Project2, I want to pass the string "Project2" to the code. Also - Am wondering about how to get the menu to respond to the left mouse button click - as opposed to the right one by default. From rsteckly at wharton.upenn.edu Tue Dec 18 00:41:10 2007 From: rsteckly at wharton.upenn.edu (Steckly, Ron) Date: Tue, 18 Dec 2007 00:41:10 -0500 Subject: [wxruby-users] New to This, having problems installing Message-ID: <4F02738675184C4698863BB9E93B3FF601271F13@RITTENHOUSE.wharton.upenn.edu> Hi all, I am having problems getting wxruby to work on my Ubuntu installation. I used sudo ruby gem install wxruby to get it, but when I do: require 'rubygems' gem 'wxruby' require "wxruby" include Wx It throws an error saying there is no such file to be found. Any thoughts on what I'm doing wrong? Thanks, Ron From alex at pressure.to Tue Dec 18 03:55:58 2007 From: alex at pressure.to (Alex Fenton) Date: Tue, 18 Dec 2007 08:55:58 +0000 Subject: [wxruby-users] New to This, having problems installing In-Reply-To: <4F02738675184C4698863BB9E93B3FF601271F13@RITTENHOUSE.wharton.upenn.edu> References: <4F02738675184C4698863BB9E93B3FF601271F13@RITTENHOUSE.wharton.upenn.edu> Message-ID: <47678B1E.3040309@pressure.to> Hi Steckly, Ron wrote: > I am having problems getting wxruby to work on my Ubuntu installation. I used sudo ruby gem install wxruby to get it, but when I do: > require 'rubygems' > gem 'wxruby' > require "wxruby" > This should be: require "wx". Doing: require "rubygems" require "wx" should be sufficient - I don't think the "gem" call is needed hth alex From alex at pressure.to Tue Dec 18 04:25:32 2007 From: alex at pressure.to (Alex Fenton) Date: Tue, 18 Dec 2007 09:25:32 +0000 Subject: [wxruby-users] Dynamic Task Bar Menu Items In-Reply-To: <476742B6.1060104@gmail.com> References: <476742B6.1060104@gmail.com> Message-ID: <4767920C.9060000@pressure.to> Hi Firstly, take a look at the sample "bigdemo/bigdemo.rb" and look for the class DemoTaskBarIcon. I think it demonstrates most of what you want to do. EchoB wrote: > Am looking for a way to dynamically add menu items to a task bar icon > menu. Define a method "create_popup_menu" in your TaskBarIcon subclass. This will be called on each occasion that the menu is shown, so simply create the menu with the appropriate items at any given time. > And then once selected - I would like to get the title of the menu > item. Use evt_menu to get the menu item selected, then use Wx::Menu#get_label to get the text string for that item. Imagine that in create_popup_menu you store the menu as an instance variable @menu, you could do the following in your TaskBarIcon initialize method to capture all menu events and show the text label. evt_menu(Wx::ID_ANY) do | event | puts @menu.label(event.id) end > Also - Am wondering about how to get the menu to respond to the left > mouse button click - as opposed to the right one by default. use evt_taskbar_left_down or evt_taskbar_left_up. Take a look at the TaskBarIcon and Menu documentation - I think this should all be covered, but please get in touch if anything's not clear. http://wxruby.rubyforge.org/doc/taskbaricon.html http://wxruby.rubyforge.org/doc/menu.html cheers alex From billdoe1 at comcast.net Tue Dec 18 20:23:43 2007 From: billdoe1 at comcast.net (Bill K) Date: Tue, 18 Dec 2007 19:23:43 -0600 Subject: [wxruby-users] Menu Bar KeyBoard Shortcuts. Message-ID: <001401c841dd$cbb984d0$7500a8c0@billdoe> Hello, I'm trying to use a wxMenuBar from XRC built with DialogBlocks on Windows. My first example had the menu being called from the Frame because I couldn't figure out how to call the menu from my XRC. Shortcuts worked nicely. Example 1: menu.append(Wx::ID_EXIT, "E&xit\tAlt-X", "Quit this program") tool.append(Wx::ID_PHOTO, "&MS Picture Manager\tAlt-B", "MS Picture Manager") Now that I've figured this out, I lost the ability to have my Keyboard shortcuts as a parameter. Example 2 : @menubar = self.get_menu_bar.find_menu('ID_MENUBAR1') # This only accepts 1 argument @menu_quit = self.get_menu_bar.find_menu_item("File","Quit") # This only accepts 2 arguments or evt_menu(self.get_menu_bar.find_menu_item("Tools","MS Picture Manager")) do open_ex end Is there a way to use the Keyboard Shortcuts with XRIC? Thank you, Bill -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071218/4ea45fee/attachment.html From alex at pressure.to Wed Dec 19 20:53:36 2007 From: alex at pressure.to (Alex Fenton) Date: Thu, 20 Dec 2007 01:53:36 +0000 Subject: [wxruby-users] Menu Bar KeyBoard Shortcuts. In-Reply-To: <001401c841dd$cbb984d0$7500a8c0@billdoe> References: <001401c841dd$cbb984d0$7500a8c0@billdoe> Message-ID: <4769CB20.8090706@pressure.to> Hi Bill Bill K wrote: > > I'm trying to use a wxMenuBar from XRC built with DialogBlocks on Windows. ... > tool.append(Wx::ID_PHOTO, "&MS Picture Manager\tAlt-B", "MS Picture > Manager") > ... > > Is there a way to use the Keyboard Shortcuts with XRIC? > You can create keyboard shortcuts in XRC by adding, for example, "\tCtrl+x"at the end of the label, in the same way as you'd set a keyboard shortcut if creating the menu directly in Ruby. I just tried this out in DialogBlocks on OS X and it seems to work correctly, and the sample project includes a frame with this in it. Let me know if this isn't working, or if I've not understood your question. cheers alex From echobinary at gmail.com Thu Dec 27 02:18:43 2007 From: echobinary at gmail.com (EchoB) Date: Thu, 27 Dec 2007 02:18:43 -0500 Subject: [wxruby-users] Wx::SplashScreen, and events Message-ID: <477351D3.5080705@gmail.com> I have the following code: #time = 7000 class TimeSplash < Wx::SplashScreen PATH_MAIN = 1 PATH_SETUP = 0 def initialize(time, path=PATH_MAIN) splash_bitmap = Wx::Bitmap.new('timefly.png', Wx::BITMAP_TYPE_PNG) super(splash_bitmap, Wx::SPLASH_CENTRE_ON_SCREEN|Wx::SPLASH_TIMEOUT, time, nil, -1) evt_close() {|evt| on_close_window(evt, path)} end def on_close_window(evt, path) if path == PATH_MAIN print "main app!" elsif path == PATH_SETUP print "setup!" end self.destroy() end end ======================================= Now I'm stuck - If I click the splash screen while it is being displayed it calls the evt_close() event and prints a message. However - if I wait for it to timeout - it fades away and then nothing happens. What event is triggered at the timeout? How can I trap it? Where are these events documented? :) From alex at pressure.to Thu Dec 27 09:22:40 2007 From: alex at pressure.to (Alex Fenton) Date: Thu, 27 Dec 2007 14:22:40 +0000 Subject: [wxruby-users] Wx::SplashScreen, and events In-Reply-To: <477351D3.5080705@gmail.com> References: <477351D3.5080705@gmail.com> Message-ID: <4773B530.5000407@pressure.to> EchoB wrote: > Now I'm stuck - If I click the splash screen while it is being displayed > it calls the evt_close() event and prints a message. However - if I wait > for it to timeout - it fades away and then nothing happens. What event > is triggered at the timeout? How can I trap it? I don't know how you can. But I don't know why you would? Code execution continues after the call to SplashScreen.new, allowing you to do time-consuming initialisation while the splash is visible and entertaining the user. Once the initialisation is done you can let the Splash timeout, let the user close it, or explicitly close it yourself using a standard close call. > Where are these events > documented? :) In a slightly scattered way: per-control event hooks (eg TreeEvent, CommandEvent, GridEvent) are listed with the control; non-command GUI event hooks (eg MenuEvent, SizeEvent, CloseEvent) are listed in the event class. The comprehensive list is very long (see lib/wx/classes/evthandler.rb for a full alphabetic list), but hte list of Event classes in the doc homepage is not a bad place to start. alex From rwa000 at gmail.com Thu Dec 27 14:06:36 2007 From: rwa000 at gmail.com (Robert Anderson) Date: Thu, 27 Dec 2007 11:06:36 -0800 Subject: [wxruby-users] build problems Message-ID: <9af502e50712271106n18b98cc7j9fe980bf0a69f222@mail.gmail.com> I am running on a redhat linux box. I could not use the binary package because I do not have libXinerama, and installing it is a nightmare of dependencies (and I am not root, so I can't use the package manager). So I am trying to install from source. I installed wxGTK-2.8.7. I downloaded wxruby-1.9.2, and issued "rake", and got: rake aborted! WIN32 has been removed, use CURRENT instead Huh? With much poking around, I made a change in rakepackage.rb, to change the GEM_PLATFORMS to just: 'linux' => [ Gem::Platform::CURRENT, '.so' ] That is pretty clearly not the right change, but I don't know what the right change is. This got me a little further: rake aborted! can't convert nil into String [...]/wxruby-1.9.2/rakefile:48 which with more tracing and pondering, it appears that (something like) this change needs to be made in rakewx.rb: -stc_lib = $wx_libs[/\S+libwx\S+_stc\S+/] +stc_lib = $wx_libs[/\S+lwx\S+_stc\S+/] since wx_libs has strings of the form -lwx_gtk2_*. There is no "lib" in there. The build is now proceeding. Stay tuned. Is the rakefile system unmaintained or something? Adoption will be a problem if wxruby is unbuildable out of the box in the "stable" release. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071227/f03a2a5b/attachment.html From rwa000 at gmail.com Thu Dec 27 14:53:56 2007 From: rwa000 at gmail.com (Robert Anderson) Date: Thu, 27 Dec 2007 11:53:56 -0800 Subject: [wxruby-users] build problems, part II Message-ID: <9af502e50712271153t230ed9a6ld111e40c8fc100f0@mail.gmail.com> This is a follow-up from a recent email where I described problems in the rakefile system. I got the library to build, but it has problems with unresolved symbols. Here is the list of symbols that are unresolved from wx: undefined symbol: _ZN12wxStringBase8InitWithEPKcjj (/home/rwa/linux-packages/ruby-1.8.6 /lib/ruby/site_ruby/1.8/i686-linux/wxruby2.so) undefined symbol: _ZNK8wxString3CmpEPKc (/home/rwa/linux-packages/ruby-1.8.6 /lib/ruby/site_ruby/1.8/i686-linux/wxruby2.so) undefined symbol: _ZNK8wxString9CmpNoCaseEPKc (/home/rwa/linux-packages/ruby-1.8.6 /lib/ruby/site_ruby/1.8/i686-linux/wxruby2.so) undefined symbol: _ZN12wxStringBaseaSEPKc (/home/rwa/linux-packages/ruby-1.8.6 /lib/ruby/site_ruby/1.8/i686-linux/wxruby2.so) undefined symbol: _ZN5wxLog18IsAllowedTraceMaskEPKc (/home/rwa/linux-packages/ruby-1.8.6 /lib/ruby/site_ruby/1.8/i686-linux/wxruby2.so) undefined symbol: _ZN12wxWizardPageC2EP8wxWizardRK8wxBitmapPKc (/home/rwa/linux-packages/ruby-1.8.6 /lib/ruby/site_ruby/1.8/i686-linux/wxruby2.so) undefined symbol: _ZN12wxWizardPage6CreateEP8wxWizardRK8wxBitmapPKc (/home/rwa/linux-packages/ruby-1.8.6 /lib/ruby/site_ruby/1.8/i686-linux/wxruby2.so) undefined symbol: _ZN13wxXmlResource8GetXRCIDEPKci (/home/rwa/linux-packages/ruby-1.8.6 /lib/ruby/site_ruby/1.8/i686-linux/wxruby2.so) undefined symbol: _Z12wxLogMessagePKcz (/home/rwa/linux-packages/ruby-1.8.6 /lib/ruby/site_ruby/1.8/i686-linux/wxruby2.so) undefined symbol: _Z11wxLogStatusPKcz (/home/rwa/linux-packages/ruby-1.8.6 /lib/ruby/site_ruby/1.8/i686-linux/wxruby2.so) undefined symbol: _Z11wxLogStatusP7wxFramePKcz (/home/rwa/linux-packages/ruby-1.8.6 /lib/ruby/site_ruby/1.8/i686-linux/wxruby2.so) undefined symbol: _Z12wxLogWarningPKcz (/home/rwa/linux-packages/ruby-1.8.6 /lib/ruby/site_ruby/1.8/i686-linux/wxruby2.so) undefined symbol: _Z10wxLogErrorPKcz (/home/rwa/linux-packages/ruby-1.8.6 /lib/ruby/site_ruby/1.8/i686-linux/wxruby2.so) undefined symbol: _Z14wxFileSelectorPKcS0_S0_S0_S0_iP8wxWindowii (/home/rwa/linux-packages/ruby-1.8.6 /lib/ruby/site_ruby/1.8/i686-linux/wxruby2.so) undefined symbol: _ZN5wxApp10InitializeERiPPc (/home/rwa/linux-packages/ruby-1.8.6 /lib/ruby/site_ruby/1.8/i686-linux/wxruby2.so) undefined symbol: _ZN8wxWindow12ApplyToolTipEP12_GtkTooltipsPKc (/home/rwa/linux-packages/ruby-1.8.6 /lib/ruby/site_ruby/1.8/i686-linux/wxruby2.so) undefined symbol: _ZN9wxListBox12ApplyToolTipEP12_GtkTooltipsPKc (/home/rwa/linux-packages/ruby-1.8.6 /lib/ruby/site_ruby/1.8/i686-linux/wxruby2.so) undefined symbol: _ZN8wxColour10FromStringEPKc (/home/rwa/linux-packages/ruby-1.8.6 /lib/ruby/site_ruby/1.8/i686-linux/wxruby2.so) undefined symbol: _ZN5wxLog5DoLogEmPKcl (/home/rwa/linux-packages/ruby-1.8.6 /lib/ruby/site_ruby/1.8/i686-linux/wxruby2.so) undefined symbol: _ZN5wxLog11DoLogStringEPKcl (/home/rwa/linux-packages/ruby-1.8.6 /lib/ruby/site_ruby/1.8/i686-linux/wxruby2.so) undefined symbol: _ZN10wxRadioBox12ApplyToolTipEP12_GtkTooltipsPKc (/home/rwa/linux-packages/ruby-1.8.6 /lib/ruby/site_ruby/1.8/i686-linux/wxruby2.so) I built wxGTK 2.8.7 from source using the recommended flags from the installation instructions. Any ideas on what's going on here? The gtk libraries were statically linked into the library, and I nm'ed them and indeed these symbols are not defined in them, but slight variations are. For example, there is the missing symbol: Z12wxLogMessagePKcz and I have: nm libwx*.a | grep wxLogMessage 000002ac T _Z12wxLogMessagePKwz (notice 'wz' not 'cz' on the end) Is this a version mismatch with wxGtk possibly, with small changes to the interface? Do I need to go to specifically 2.8.6, not 2.8.7? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071227/e3bbed2e/attachment-0001.html From rwa000 at gmail.com Thu Dec 27 16:54:09 2007 From: rwa000 at gmail.com (Robert Anderson) Date: Thu, 27 Dec 2007 13:54:09 -0800 Subject: [wxruby-users] build problems, part III, and runtime problems, part I Message-ID: <9af502e50712271354w384dd336h6739f07b5d1b5067@mail.gmail.com> After decoding the unresolved symbols from wxruby2.so using c++filt, and comparing with the symbols provided by wxGTK, it became clear that wxGTK was using wchar_t whereas wxruby2.so was using char. So I rebuilt wxGTK, turning off unicode. That worked. No more unresolved symbols. What gives? Should the wxruby code have been built using wchar_t, and if so, how? However, now I get the following: % ruby -rubygems nothing.rb /home/rwa/linux-packages/ruby-1.8.6/lib/ruby/site_ruby/1.8/i686-linux/wxruby2.so: [BUG] Segmentation fault the crash is in rb_hash_aref. I saw that I was not the only one to run into this from recent mailing list discussion. The issue appears to be that swig_ruby_trackings has a bogus value. In my case it always happens to be 4. It appears it is supposed to point to valid storage. The relevant function appears to be this one: SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) where swig_ruby_trackings is looked up, and if it comes back nil, a new one is created. Except that, for reasons I don't understand, it comes back 4, not 0. When this gets dereferenced after a series of calls from Init_wxRubyConstants, segfault. Any help? This seems like a real bug, and I'm starting to wonder if this package is usable at all. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071227/527c62bb/attachment.html From alex at pressure.to Thu Dec 27 17:18:51 2007 From: alex at pressure.to (Alex Fenton) Date: Thu, 27 Dec 2007 22:18:51 +0000 Subject: [wxruby-users] build problems In-Reply-To: <9af502e50712271106n18b98cc7j9fe980bf0a69f222@mail.gmail.com> References: <9af502e50712271106n18b98cc7j9fe980bf0a69f222@mail.gmail.com> Message-ID: <477424CB.2050009@pressure.to> Hi Robert Thanks for the feedback. Robert Anderson wrote: > rake aborted! > WIN32 has been removed, use CURRENT instead ... > That is pretty clearly not the right change, but I don't know what the > right change is. This got me a little further: This is already fixed in svn. Rubygems developers, in the rush to get a 1.0 version to go with Ruby 1.9.0 have made many backwards-incompatible changes between 0.9.3 (which was current when we released 1.9.2) and now. The error you got is one of several problems the rubygems changes have caused us. The price of progress, but things should be a little more settled from now. > which with more tracing and pondering, it appears that (something > like) this change needs to be made in rakewx.rb: > > -stc_lib = $wx_libs[/\S+libwx\S+_stc\S+/] > +stc_lib = $wx_libs[/\S+lwx\S+_stc\S+/] > > since wx_libs has strings of the form -lwx_gtk2_*. There is no "lib" > in there. I'm not sure this is quite right. The links to the standard wx libs are in the form you describe (eg -lwxregexud-2.8), but the links to the "extra" libs like stc are given as paths to files, at least on my Linux/GTK (Ubuntu 7.10) and on OS X, eg "/usr/local/lib/libwx_macud_stc-2.8.a". The rakefile's looking for the stc file to test whether it exists and so should be built into wxruby. Could you post what `wx-config --libs std,stc` returns on your system please? If you could also post the full error backtrace from this error (try running rake --trace) that would help. > Is the rakefile system unmaintained or something? Adoption will be a > problem if wxruby is unbuildable out of the box in the "stable" release. The rakefile's maintained. Your help in getting it wxRuby to build on all the different Linux systems out there is appreciated cheers alex From alex at pressure.to Thu Dec 27 17:36:02 2007 From: alex at pressure.to (Alex Fenton) Date: Thu, 27 Dec 2007 22:36:02 +0000 Subject: [wxruby-users] build problems, part III, and runtime problems, part I In-Reply-To: <9af502e50712271354w384dd336h6739f07b5d1b5067@mail.gmail.com> References: <9af502e50712271354w384dd336h6739f07b5d1b5067@mail.gmail.com> Message-ID: <477428D2.6060506@pressure.to> Robert Anderson wrote: > So I rebuilt wxGTK, turning off unicode. That worked. No more > unresolved symbols. What gives? Should the wxruby code have been > built using wchar_t, and if so, how? I'm sorry but I don't understand this. Unfortunately I'm away and don't have a Linux box here - but, wxruby2 should *only* work with a unicode build; all of the conversions from wxString to ruby Strings assume that wxGTK has been built with unicode support. > However, now I get the following: > > % ruby -rubygems nothing.rb > /home/rwa/linux-packages/ruby-1.8.6/lib/ruby/site_ruby/1.8/i686-linux/wxruby2.so: > [BUG] Segmentation fault > > the crash is in rb_hash_aref. I saw that I was not the only one to > run into this from recent mailing list discussion. Could you refer me the discussion please? > > The issue appears to be that swig_ruby_trackings has a bogus value. > In my case it always happens to be 4. It appears it is supposed to > point to valid storage. > > The relevant function appears to be this one: > > SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) This is code that's generated by SWIG, not immediately part of wxRuby. What version of SWIG are you using? (`swig -version`) The most recently released version of SWIG came out after wxRuby 1.9.2 in November and hasn't yet been tested with it. I'd strongly suggest using version 1.3.31 for now. > This seems like a real bug, and I'm starting to wonder if this package > is usable at all. Clearly not for you, clearly yes for lots of other people. There's something that's different about your environment that's causes serious bugs; let's figure out what it is. alex From rwa000 at gmail.com Thu Dec 27 17:40:31 2007 From: rwa000 at gmail.com (Robert Anderson) Date: Thu, 27 Dec 2007 14:40:31 -0800 Subject: [wxruby-users] build problems In-Reply-To: <477424CB.2050009@pressure.to> References: <9af502e50712271106n18b98cc7j9fe980bf0a69f222@mail.gmail.com> <477424CB.2050009@pressure.to> Message-ID: <9af502e50712271440p5615ca88tb854924127e6a6e0@mail.gmail.com> On Dec 27, 2007 2:18 PM, Alex Fenton wrote: > Hi Robert > > Thanks for the feedback. > > Robert Anderson wrote: > > rake aborted! > > WIN32 has been removed, use CURRENT instead > This is already fixed in svn. Ok. If you could cut a new tarball to replace 1.9.2, that might save some headaches. I think people are generally more afraid of a svn repo than a tarball. If I can't get the tarball to work, I'm likely to think the svn repo is going to be worse. I am not always all complaints, so bear with me... > Rubygems developers, in the rush to get a > 1.0 version to go with Ruby 1.9.0 have made many backwards-incompatible > changes between 0.9.3 (which was current when we released 1.9.2) and > now. Ok. > > > which with more tracing and pondering, it appears that (something > > like) this change needs to be made in rakewx.rb: > > > > -stc_lib = $wx_libs[/\S+libwx\S+_stc\S+/] > > +stc_lib = $wx_libs[/\S+lwx\S+_stc\S+/] > > > > since wx_libs has strings of the form -lwx_gtk2_*. There is no "lib" > > in there. > I'm not sure this is quite right. The links to the standard wx libs are > in the form you describe (eg -lwxregexud-2.8), but the links to the > "extra" libs like stc are given as paths to files, at least on my > Linux/GTK (Ubuntu 7.10) and on OS X, eg > "/usr/local/lib/libwx_macud_stc-2.8.a". The rakefile's looking for the > stc file to test whether it exists and so should be built into wxruby. Ok, I think I see what's going on here. When you compile with the monolithic flag (as recommended), you do indeed get the full paths. But when you compile without the monolithic flags, you get the -lwx* strings from wx-config. Maybe in the interest of robustness, you could just ignore the -l or lib part, so it would work either way. Looking at the svn rakewx.rb, it looks like this is completely re-written anyway, so maybe it doesn't matter. The rakefile's maintained. Your help in getting it wxRuby to build on > all the different Linux systems out there is appreciated Ok, your help and support appreciated as well. I'm a little grumpy today, so please bear with me. Bob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071227/1c28de42/attachment.html From rwa000 at gmail.com Thu Dec 27 17:52:10 2007 From: rwa000 at gmail.com (Robert Anderson) Date: Thu, 27 Dec 2007 14:52:10 -0800 Subject: [wxruby-users] build problems, part III, and runtime problems, part I In-Reply-To: <477428D2.6060506@pressure.to> References: <9af502e50712271354w384dd336h6739f07b5d1b5067@mail.gmail.com> <477428D2.6060506@pressure.to> Message-ID: <9af502e50712271452r7890d025j8baa3ecbcf605455@mail.gmail.com> On Dec 27, 2007 2:36 PM, Alex Fenton wrote: > Robert Anderson wrote: > > So I rebuilt wxGTK, turning off unicode. That worked. No more > > unresolved symbols. What gives? Should the wxruby code have been > > built using wchar_t, and if so, how? > I'm sorry but I don't understand this. Unfortunately I'm away and don't > have a Linux box here - but, wxruby2 should *only* work with a unicode > build; all of the conversions from wxString to ruby Strings assume that > wxGTK has been built with unicode support. Somehow my build is configured otherwise. I don't understand the mechanisms for how this is configure, so I don't know how it got out of whack. Here's the evidence: nm obj/App.o | grep wxStringBase8InitWithEPK | c++filt U wxStringBase::InitWith(char const*, unsigned int, unsigned int) whereas I would assume a unicode build would be using wchar_t instead of char. > > > However, now I get the following: > > > > % ruby -rubygems nothing.rb > > /home/rwa/linux-packages/ruby-1.8.6 > /lib/ruby/site_ruby/1.8/i686-linux/wxruby2.so: > > [BUG] Segmentation fault > > > > the crash is in rb_hash_aref. I saw that I was not the only one to > > run into this from recent mailing list discussion. > Could you refer me the discussion please? Sure, here's a link: http://rubyforge.org/pipermail/wxruby-users/2007-December/003497.html > > > > > The issue appears to be that swig_ruby_trackings has a bogus value. > > In my case it always happens to be 4. It appears it is supposed to > > point to valid storage. > > > > The relevant function appears to be this one: > > > > SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) > This is code that's generated by SWIG, not immediately part of wxRuby. > What version of SWIG are you using? (`swig -version`) The most recently > released version of SWIG came out after wxRuby 1.9.2 in November and > hasn't yet been tested with it. I'd strongly suggest using version > 1.3.31 for now. % swig -version SWIG Version 1.3.33 Should I downgrade? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071227/ffbca2f1/attachment.html From alex at pressure.to Thu Dec 27 18:04:32 2007 From: alex at pressure.to (Alex Fenton) Date: Thu, 27 Dec 2007 23:04:32 +0000 Subject: [wxruby-users] build problems In-Reply-To: <9af502e50712271440p5615ca88tb854924127e6a6e0@mail.gmail.com> References: <9af502e50712271106n18b98cc7j9fe980bf0a69f222@mail.gmail.com> <477424CB.2050009@pressure.to> <9af502e50712271440p5615ca88tb854924127e6a6e0@mail.gmail.com> Message-ID: <47742F80.90402@pressure.to> Robert Anderson wrote: > > Ok. If you could cut a new tarball to replace 1.9.2, that might save > some headaches. I think people are generally more afraid of a svn > repo than a tarball. If I can't get the tarball to work, I'm likely > to think the svn repo is going to be worse. Me too. We'll be cutting a 1.9.3 version shortly (shortly after new year, I hope). We normally release a bit more regularly but had a lot of features to integrate. > > > which with more tracing and pondering, it appears that (something > > like) this change needs to be made in rakewx.rb: > > > > -stc_lib = $wx_libs[/\S+libwx\S+_stc\S+/] > > +stc_lib = $wx_libs[/\S+lwx\S+_stc\S+/] > > > > since wx_libs has strings of the form -lwx_gtk2_*. There is no > "lib" > > in there. > I'm not sure this is quite right. The links to the standard wx > libs are > in the form you describe (eg - lwxregexud-2.8), but the links to the > "extra" libs like stc are given as paths to files, at least on my > Linux/GTK (Ubuntu 7.10) and on OS X, eg > "/usr/local/lib/libwx_macud_stc-2.8.a". The rakefile's looking for > the > stc file to test whether it exists and so should be built into wxruby. > > > Ok, I think I see what's going on here. When you compile with the > monolithic flag (as recommended), you do indeed get the full paths. > But when you compile without the monolithic flags, you get the -lwx* > strings from wx-config. Maybe in the interest of robustness, you > could just ignore the -l or lib part, so it would work either way. > Looking at the svn rakewx.rb, it looks like this is completely > re-written anyway, so maybe it doesn't matter. It's mostly moved to rakeunixish. Unfortunately I think we want the path to libwx_stc b/c we're interested in finding whether the file exists - IIRC wx-config will return something even if it doesn't. It shouldn't really matter whether monolithic or not - but I'm curious what your wx-config --libs std,stc returns so we can work with either. > The rakefile's maintained. Your help in getting it wxRuby to build on > > all the different Linux systems out there is appreciated > > > Ok, your help and support appreciated as well. I'm a little grumpy > today, so please bear with me. No worries. Thanks for your patience. It bugs me when other packages don't build too .... alex From alex at pressure.to Thu Dec 27 18:12:11 2007 From: alex at pressure.to (Alex Fenton) Date: Thu, 27 Dec 2007 23:12:11 +0000 Subject: [wxruby-users] build problems, part III, and runtime problems, part I In-Reply-To: <9af502e50712271452r7890d025j8baa3ecbcf605455@mail.gmail.com> References: <9af502e50712271354w384dd336h6739f07b5d1b5067@mail.gmail.com> <477428D2.6060506@pressure.to> <9af502e50712271452r7890d025j8baa3ecbcf605455@mail.gmail.com> Message-ID: <4774314B.7040801@pressure.to> Robert Anderson wrote: > > Somehow my build is configured otherwise. I don't understand the > mechanisms for how this is configure, so I don't know how it got out > of whack. wxRuby doesn't even try to configure this; it simply depends on there being a unicode not ANSI build. I am wondering whether SWIG is the issue here... > > Here's the evidence: > > nm obj/App.o | grep wxStringBase8InitWithEPK | c++filt > U wxStringBase::InitWith(char const*, unsigned int, unsigned int) > > whereas I would assume a unicode build would be using wchar_t instead > of char. > > So would I; here's what my build (OS X) says: Abaddon:wxruby2 alex$ nm obj/App.o | grep wxStringBase8InitWithEPK | c++filt U wxStringBase::InitWith(wchar_t const*, unsigned long, unsigned long) > > > http://rubyforge.org/pipermail/wxruby-users/2007-December/003497.html Thanks. Will follow this up. > > % swig -version > > SWIG Version 1.3.33 > > Should I downgrade? Yes, definitely, to 1.3.31 please. SWIG versions are notoriously incompatible even between minor versions, and wxRuby hincludesas numerous hacks to work around SWIG bugs. Then you should be able to do rake reswig && rake If this improves things I will update the wiki to make it clearer that there is the specific version dependency Thanks alex From rwa000 at gmail.com Thu Dec 27 18:49:14 2007 From: rwa000 at gmail.com (Robert Anderson) Date: Thu, 27 Dec 2007 15:49:14 -0800 Subject: [wxruby-users] build problems, part III, and runtime problems, part I In-Reply-To: <4774314B.7040801@pressure.to> References: <9af502e50712271354w384dd336h6739f07b5d1b5067@mail.gmail.com> <477428D2.6060506@pressure.to> <9af502e50712271452r7890d025j8baa3ecbcf605455@mail.gmail.com> <4774314B.7040801@pressure.to> Message-ID: <9af502e50712271549s59cfb570u6a17aeb8282b291e@mail.gmail.com> On Dec 27, 2007 3:12 PM, Alex Fenton wrote: > > > > % swig -version > > > > SWIG Version 1.3.33 > > > > Should I downgrade? > > Yes, definitely, to 1.3.31 please. SWIG versions are notoriously > incompatible even between minor versions, and wxRuby hincludesas > numerous hacks to work around SWIG bugs. > > Then you should be able to do > rake reswig && rake > > If this improves things I will update the wiki to make it clearer that > there is the specific version dependency > Unfortunately this gives the same result for the 1.9.2 tarball: segfault in rb_hash_aref, when the hash has address 0x4. I tried to build the svn sources, but ended up here: g++ -c -I/home/rwa/linux-packages/wxGTK-2.8.7-static/lib/wx/include/gtk2- ansi-release-static-2.8 -I/home/rwa/linux-packages/wxGTK-2.8.7-static /include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D_LARGEFILE_SOURCE=1 -D__WXGTK__ -g -O2 -Wno-unused-function -I /home/rwa/linux-packages/gems/rake-0.8.0/bin -I /home/rwa/linux-packages/gems/rake-0.8.0/lib -I /home/rwa/linux-packages/ruby-1.8.6/lib/ruby/site_ruby/1.8 -I /home/rwa/linux-packages/ruby-1.8.6/lib/ruby/site_ruby/1.8/i686-linux -I /home/rwa/linux-packages/ruby-1.8.6/lib/ruby/site_ruby -I /home/rwa/linux-packages/ruby-1.8.6/lib/ruby/1.8 -I /home/rwa/linux-packages/ruby-1.8.6/lib/ruby/1.8/i686-linux -I . -I /home/rwa/Distributions/wxruby-svn/doc/lib -o obj/URLDataObject.o src/URLDataObject.cpp In file included from src/URLDataObject.cpp:2092: src/URLDataObject.h:19: base `Swig::Director' with only non-default constructor in class without a constructor rake aborted! Command failed with status (1): [g++ -c -I/home/rwa/linux-packages/wxGTK-...] -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071227/7f8f67a3/attachment.html From rwa000 at gmail.com Thu Dec 27 20:04:01 2007 From: rwa000 at gmail.com (Robert Anderson) Date: Thu, 27 Dec 2007 17:04:01 -0800 Subject: [wxruby-users] more problems with 1.9.2 Message-ID: <9af502e50712271704i2f4925c1i3d4d5ba59d75cf9@mail.gmail.com> The files: wx/accessors.rb wx/keyword_ctors.rb wx/keyword_defs.rb do not exist in the tarball: % pwd /home/rwa/Distributions/test/wxruby-1.9.2 % find . -name accessors.rb % but are required in wx.rb: % tail wx.rb Dir.glob(class_files) do | class_file | require 'wx/classes/' + class_file[/\w+\.rb$/] end # Load in syntax sweetner require 'wx/accessors' require 'wx/keyword_ctors' require 'wx/keyword_defs' These files do appear in the svn sources. If I copy the files from the svn sources, I can now run the examples. Unfortunately, I've done too much mucking around to know exactly where the segfault issue went away. Grr. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071227/8586bb0f/attachment.html From alex at pressure.to Thu Dec 27 20:43:24 2007 From: alex at pressure.to (Alex Fenton) Date: Fri, 28 Dec 2007 01:43:24 +0000 Subject: [wxruby-users] more problems with 1.9.2 In-Reply-To: <9af502e50712271704i2f4925c1i3d4d5ba59d75cf9@mail.gmail.com> References: <9af502e50712271704i2f4925c1i3d4d5ba59d75cf9@mail.gmail.com> Message-ID: <477454BC.9050904@pressure.to> Robert Anderson wrote: > > The files: > > wx/accessors.rb > wx/keyword_ctors.rb > wx/keyword_defs.rb > > do not exist in the tarball: > Yes, sorry. 90+% of our distribution is binary gems which the developers build from SVN, and we messed up with the tarball in 1.9.2. The script that builds the tarball is already fixed in SVN, but thanks for the report. > Unfortunately, I've done too much mucking around to know exactly where > the segfault issue went away. Grr. Maybe there was a stale source created by SWIG 1.3.33 kicking around. I've just tried building HEAD + SWIG 1.3.33 + gcc + Wx 2.8.7 unicode and it builds but will segfault early on loading the first Wx class/module, with a poss bad value for the tracking hash. If the segfault issue is resolved, can I check you've now got a working 1.9.2 built with SWIG 1.3.31? I'll look into the gcc build error on Linux in URLDataObject.cpp when I have access to a machine next week. What gcc version is on your distro please? thanks again alex From rwa000 at gmail.com Thu Dec 27 21:13:58 2007 From: rwa000 at gmail.com (Robert Anderson) Date: Thu, 27 Dec 2007 18:13:58 -0800 Subject: [wxruby-users] more problems with 1.9.2 In-Reply-To: <477454BC.9050904@pressure.to> References: <9af502e50712271704i2f4925c1i3d4d5ba59d75cf9@mail.gmail.com> <477454BC.9050904@pressure.to> Message-ID: <9af502e50712271813m600ce1d8g4bf9e16ef869541@mail.gmail.com> On Dec 27, 2007 5:43 PM, Alex Fenton wrote: > Robert Anderson wrote: > > > > The files: > > > > wx/accessors.rb > > wx/keyword_ctors.rb > > wx/keyword_defs.rb > > > > do not exist in the tarball: > > > Yes, sorry. 90+% of our distribution is binary gems which the developers > build from SVN, and we messed up with the tarball in 1.9.2. The script > that builds the tarball is already fixed in SVN, but thanks for the > report. > > Unfortunately, I've done too much mucking around to know exactly where > > the segfault issue went away. Grr. > Maybe there was a stale source created by SWIG 1.3.33 kicking around. > I've just tried building HEAD + SWIG 1.3.33 + gcc + Wx 2.8.7 unicode and > it builds but will segfault early on loading the first Wx class/module, > with a poss bad value for the tracking hash. > > If the segfault issue is resolved, can I check you've now got a working > 1.9.2 built with SWIG 1.3.31? Correct. I had to do some more mucking around related to wxUSE_MEDIACTRL in the wx configuration - it was off by default and didn't seem to respect the configuration flag --enable-mediactrl as it was supposed to. I went in and hardwired the setting to turn that on and it corrected some undefined preprocessor symbol issues. > I'll look into the gcc build error on Linux in URLDataObject.cpp when I > have access to a machine next week. What gcc version is on your distro > please? % gcc --version gcc (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-59) As for the values of wx-config --libs std, stc , once I rebuilt with monolithic I was seeing the full paths, and didn't want to go back and reconfigure and build to verify the old problem. Sorry. Thanks for your help. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071227/08fe7435/attachment.html From rwa000 at gmail.com Thu Dec 27 21:13:58 2007 From: rwa000 at gmail.com (Robert Anderson) Date: Thu, 27 Dec 2007 18:13:58 -0800 Subject: [wxruby-users] more problems with 1.9.2 In-Reply-To: <477454BC.9050904@pressure.to> References: <9af502e50712271704i2f4925c1i3d4d5ba59d75cf9@mail.gmail.com> <477454BC.9050904@pressure.to> Message-ID: <9af502e50712271813m600ce1d8g4bf9e16ef869541@mail.gmail.com> On Dec 27, 2007 5:43 PM, Alex Fenton wrote: > Robert Anderson wrote: > > > > The files: > > > > wx/accessors.rb > > wx/keyword_ctors.rb > > wx/keyword_defs.rb > > > > do not exist in the tarball: > > > Yes, sorry. 90+% of our distribution is binary gems which the developers > build from SVN, and we messed up with the tarball in 1.9.2. The script > that builds the tarball is already fixed in SVN, but thanks for the > report. > > Unfortunately, I've done too much mucking around to know exactly where > > the segfault issue went away. Grr. > Maybe there was a stale source created by SWIG 1.3.33 kicking around. > I've just tried building HEAD + SWIG 1.3.33 + gcc + Wx 2.8.7 unicode and > it builds but will segfault early on loading the first Wx class/module, > with a poss bad value for the tracking hash. > > If the segfault issue is resolved, can I check you've now got a working > 1.9.2 built with SWIG 1.3.31? Correct. I had to do some more mucking around related to wxUSE_MEDIACTRL in the wx configuration - it was off by default and didn't seem to respect the configuration flag --enable-mediactrl as it was supposed to. I went in and hardwired the setting to turn that on and it corrected some undefined preprocessor symbol issues. > I'll look into the gcc build error on Linux in URLDataObject.cpp when I > have access to a machine next week. What gcc version is on your distro > please? % gcc --version gcc (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-59) As for the values of wx-config --libs std, stc , once I rebuilt with monolithic I was seeing the full paths, and didn't want to go back and reconfigure and build to verify the old problem. Sorry. Thanks for your help. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071227/08fe7435/attachment-0001.html From rwa000 at gmail.com Thu Dec 27 21:20:48 2007 From: rwa000 at gmail.com (Robert Anderson) Date: Thu, 27 Dec 2007 18:20:48 -0800 Subject: [wxruby-users] controls within a wxTreeCtrl Message-ID: <9af502e50712271820k440aef68n8c67bbb5c37e586c@mail.gmail.com> What I'd like to be able to do is use a wxTreeCtrl to manage a tree layout of not only text, but several buttons which would line up adjacent to the text in the tree items. I've googled around a bit on this and it doesn't seem straightforward, if it is possible at all. Can anyone provide any pointers for attempting this? In a simple ASCI schematic, it would be like this: + RootItem A B C + TreeItem1 A B C + TreeItem2 A B C where RootItem and TreeItem(s) are text labels, and A, B, and C, are simple buttons with icons on them. I am starting to think that I will have to synthesize the entire thing using sizers. Would it even be possible in the wx model to dynamically add/remove items and spacers to create a tree-like behavior? Thoughts? Thanks, Bob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071227/4ed56135/attachment-0001.html From alex at pressure.to Thu Dec 27 21:36:10 2007 From: alex at pressure.to (Alex Fenton) Date: Fri, 28 Dec 2007 02:36:10 +0000 Subject: [wxruby-users] more problems with 1.9.2 In-Reply-To: <9af502e50712271813m600ce1d8g4bf9e16ef869541@mail.gmail.com> References: <9af502e50712271704i2f4925c1i3d4d5ba59d75cf9@mail.gmail.com> <477454BC.9050904@pressure.to> <9af502e50712271813m600ce1d8g4bf9e16ef869541@mail.gmail.com> Message-ID: <4774611A.6040606@pressure.to> Robert Anderson wrote: > I had to do some more mucking around related to wxUSE_MEDIACTRL in the > wx configuration - it was off by default and didn't seem to respect > the configuration flag --enable-mediactrl as it was supposed to. I > went in and hardwired the setting to turn that on and it corrected > some undefined preprocessor symbol issues. On Windows and OS X, --enable-mediactrl is enough because there's a system media player (Windows Media/Quicktime). On Linux it requires Gstreamer and a bunch of other libraries. The ones I had to install are listed on the HowToBuildWxWidgets wiki page, but this will vary by distro. The reliable (if painful) way is to repeatedly run wxWidgets's configure with --enable-mediactrl, then look at the detail of config.log to see why wxMediaCtrl was skipped (which library was missing). Anyway, I think to avoid making the 1.9.3 build too taxing on Linux (Wx::MediaCtrl is only in SVN) we'll make wxRuby detect if wxWidgets supports MediaCtrl, and skip that class if not. Unfortunately it's fiddly b/c the preprocessor symbols aren't available to Rake, but I have a workaround to check in. Thanks for all the feedback alex From alex at pressure.to Thu Dec 27 21:50:38 2007 From: alex at pressure.to (Alex Fenton) Date: Fri, 28 Dec 2007 02:50:38 +0000 Subject: [wxruby-users] controls within a wxTreeCtrl In-Reply-To: <9af502e50712271820k440aef68n8c67bbb5c37e586c@mail.gmail.com> References: <9af502e50712271820k440aef68n8c67bbb5c37e586c@mail.gmail.com> Message-ID: <4774647E.5070607@pressure.to> Robert Anderson wrote: > > What I'd like to be able to do is use a wxTreeCtrl to manage a tree > layout of not only text, but several buttons which would line up > adjacent to the text in the tree items. I've googled around a bit on > this and it doesn't seem straightforward, if it is possible at all. > > Can anyone provide any pointers for attempting this? This comes up frequently in C++ wxWidgets. There's no core class in wxWidgets which does this, and hence nothing in wxRuby. But there are numerous user-contributed classes on eg wxCode which have multi-column TreeCtrls. But at present these are only in C++, and I have no experience of trying to wrap third-party C++ extensions in Ruby. For some classes this should not be too hard using SWIG - but TreeCtrl is one of the most complex wrappings in wxRuby. > I am starting to think that I will have to synthesize the entire thing > using sizers. Would it even be possible in the wx model to > dynamically add/remove items and spacers to create a tree-like > behavior? Thoughts? One possibility might be to have two sibling controls, a TreeCtrl on the left, and a Panel on the right where the buttons are drawn. Use TreeCtrl#get_bounding_rect to find the position of each of the visible tree items, and place Wx::Buttons at an appropriate height on the right. Or you can draw directly control-like things upon the panel with a DeviceContext (DC), possibly using RendererNative to get the right look and feel for your platform. Either way, update the Panel's contents as tree items are collapsed and expanded (with event handlers). This would mean that there would be a gap between the text labels and the associated buttons. Closer to what you want would be to try drawing directly on top of the TreeCtrl, again using get_bounding_rect to find where the label is positioned. But I am not sure how well drawing directly on top of a native control will work - be sure to test on any platform you want to use. hth alex From alex at pressure.to Thu Dec 27 22:10:14 2007 From: alex at pressure.to (Alex Fenton) Date: Fri, 28 Dec 2007 03:10:14 +0000 Subject: [wxruby-users] controls within a wxTreeCtrl In-Reply-To: <4774647E.5070607@pressure.to> References: <9af502e50712271820k440aef68n8c67bbb5c37e586c@mail.gmail.com> <4774647E.5070607@pressure.to> Message-ID: <47746916.4070705@pressure.to> Alex Fenton wrote: > Use TreeCtrl#get_bounding_rect to find the position of each of the visible > tree items PS - I guess no-one's ever wanted to use this method before - it works OK for me but in an un-rubyish way. You have to create an empty Wx::Rect object, then pass it in as a parameter to have its values updated with the x,y,w,h values. We'll add something more ruby-ish which accepts an id and returns a bounding rect for 1.9.3 alex From rwa000 at gmail.com Fri Dec 28 01:43:22 2007 From: rwa000 at gmail.com (Robert Anderson) Date: Thu, 27 Dec 2007 22:43:22 -0800 Subject: [wxruby-users] wxSizerItem show() method Message-ID: <9af502e50712272243v6349c532kf89ec6fb7d212ade@mail.gmail.com> It appears from the wx 2.8.7 documentation that a wxSizerItem has a show() method. But when I try to invoke it through wxruby, I get: tasks.rb:56:in `do_btn3': undefined method `show' for # (NoMethodError) Is this just something that hasn't been added because people don't manipulate wxSizerItems much, or is it something deeper than that? Or am I doing something stupid? The reason this comes up is that I am trying to use spacers in a dynamic way, "collapsing" them with show(false) when needed. Thanks, Bob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071227/2e99e456/attachment.html From echobinary at gmail.com Fri Dec 28 03:03:16 2007 From: echobinary at gmail.com (EchoB) Date: Fri, 28 Dec 2007 03:03:16 -0500 Subject: [wxruby-users] Wx:Wizard, Wx::WizardPageSimple Message-ID: <4774ADC4.70801@gmail.com> Ok, here is my class: #==================================== class SetupWizard < Wx::Wizard def initialize(timefly, title) setup_image = Wx::Bitmap.new("wizard_side.png", Wx::BITMAP_TYPE_PNG) super(nil, -1, title, setup_image) @timefly = timefly step_one = Wx::WizardPageSimple.new() setup_page_one(step_one) step_two = Wx::WizardPageSimple.new(nil, step_one) step_one.set_next(step_two) setup_page_two(step_two) run_wizard(step_one) #self.show(true) end def setup_page_one(step) intro_label = "some text here" Wx::StaticText.new(step, :label => intro_label) end def setup_page_two(step) label = "more text here" Wx::StaticText.new(step, :label => label) txt = Wx::TextCtrl.new(step, :id => 21, :value => @timefly.running_path+"log", :style => Wx::TE_READONLY, :size => Wx::Size.new(270,-1), :pos => Wx::Point.new(0, 140), :name => "step2path") btn_change_path = Wx::Button.new(step, :id =>22, :label => 'Change', :pos => Wx::Point.new(0, 163), :name => "btn_change_path") evt_button(22) {|evt| on_change_logpath(evt)} btn_default_path = Wx::Button.new(step, :id =>22, :label => 'Default', :pos => Wx::Point.new(80, 163), :name => "btn_default_path") end def on_change_logpath(evt) print "change logpath!" end end #==================================== #here is the call from within another class: #==================================== .... SetupWizard.new(@timefly, "TimeFly Setup") .... #==================================== I got the splash screen working with a timer :) (see previous post: Wx::SplashScreen, and events) Let me qualify the above code by saying that it originally inherited from Wx::Frame, and I made a new Wx:Wizard with the self (Wx::Frme) as parent. But I was having a problem where NO events were firing when I intereacted with the controls on each WizardPageSimple. --- So I decided to try and see if making the whole thing inherit Wx::Wizard and set parent window to nil works any better. Well - now I see the wizard for just under half a second, and it never comes back. The ruby runtime continues though - and I get no error messages. What did I miss? HALP! From mario at ruby-im.net Fri Dec 28 03:06:59 2007 From: mario at ruby-im.net (Mario Steele) Date: Fri, 28 Dec 2007 02:06:59 -0600 Subject: [wxruby-users] wxSizerItem show() method In-Reply-To: <9af502e50712272243v6349c532kf89ec6fb7d212ade@mail.gmail.com> References: <9af502e50712272243v6349c532kf89ec6fb7d212ade@mail.gmail.com> Message-ID: Hello Robert, Actually, the best thing to do, is for you to use the Root Sizer, EG: BoxSizer, FlexGridSizer, Etc, etc, to utilize the #layout() method, to update the controls being displayed, and utilize the Window#show() method on the actual control, instead of the sizer item. An example would be: def on_click_hide() @my_control.show(false) self.sizer.layout() end This will cause the control to be hidden, and to call layout() to re-size all of the children controls that have been added to the Sizer. L8ers, Mario Steele On 12/28/07, Robert Anderson wrote: > > > It appears from the wx 2.8.7 documentation that a wxSizerItem has a show() > method. But when I try to invoke it through wxruby, I get: > > tasks.rb:56:in `do_btn3': undefined method `show' for > # (NoMethodError) > > Is this just something that hasn't been added because people don't > manipulate wxSizerItems much, or is it something deeper than that? Or am I > doing something stupid? > > The reason this comes up is that I am trying to use spacers in a dynamic > way, "collapsing" them with show(false) when needed. > > Thanks, > Bob > > > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071228/2fb9468f/attachment.html From rwa000 at gmail.com Fri Dec 28 03:19:49 2007 From: rwa000 at gmail.com (Robert Anderson) Date: Fri, 28 Dec 2007 00:19:49 -0800 Subject: [wxruby-users] wxSizerItem show() method In-Reply-To: References: <9af502e50712272243v6349c532kf89ec6fb7d212ade@mail.gmail.com> Message-ID: <9af502e50712280019k3c1e8d8er1a3506dd592be799@mail.gmail.com> On Dec 28, 2007 12:06 AM, Mario Steele wrote: > Hello Robert, > > Actually, the best thing to do, is for you to use the Root Sizer, EG: > BoxSizer, FlexGridSizer, Etc, etc, to utilize the #layout() method, to > update the controls being displayed, and utilize the Window#show() method on > the actual control, instead of the sizer item. > Mario, If I am using the add() method on the sizer which adds a spacer, is there a control at all? *wxSizerItem ** *Add*(*int **width*, *int **height*, *int **proportion = 0*, *int **flag = 0*, *int **border = 0*, *wxObject* **userData = NULL*); Thanks, Bob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071228/9aa0edaf/attachment.html From mario at ruby-im.net Fri Dec 28 05:25:48 2007 From: mario at ruby-im.net (Mario Steele) Date: Fri, 28 Dec 2007 04:25:48 -0600 Subject: [wxruby-users] wxSizerItem show() method In-Reply-To: <9af502e50712280019k3c1e8d8er1a3506dd592be799@mail.gmail.com> References: <9af502e50712272243v6349c532kf89ec6fb7d212ade@mail.gmail.com> <9af502e50712280019k3c1e8d8er1a3506dd592be799@mail.gmail.com> Message-ID: Robert, I don't believe there is an actual control returned from #add() method that is utitlized to add a spacer. It is more then nothing an internal data structure in which to show that something occupies that space, but nothing is actually drawn for that space itself. If you need to dynamically add/remove spacers, I would suggest utilizing #remove() to remove it. wxSizerItem is not employed within wxRuby, as it's of more use internally, then externally. On 12/28/07, Robert Anderson wrote: > > > On Dec 28, 2007 12:06 AM, Mario Steele wrote: > > > Hello Robert, > > > > Actually, the best thing to do, is for you to use the Root Sizer, EG: > > BoxSizer, FlexGridSizer, Etc, etc, to utilize the #layout() method, to > > update the controls being displayed, and utilize the Window#show() method on > > the actual control, instead of the sizer item. > > > > Mario, > > If I am using the add() method on the sizer which adds a spacer, is there > a control at all? > > * wxSizerItem > ** *Add*(*int **width*, *int **height*, *int **proportion = 0*, *int **flag > = 0*, *int **border = 0*, * wxObject* > **userData = NULL*); > > Thanks, > Bob > > > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071228/bd9b668e/attachment-0001.html From alex at pressure.to Fri Dec 28 09:43:35 2007 From: alex at pressure.to (Alex Fenton) Date: Fri, 28 Dec 2007 14:43:35 +0000 Subject: [wxruby-users] Wx:Wizard, Wx::WizardPageSimple In-Reply-To: <4774ADC4.70801@gmail.com> References: <4774ADC4.70801@gmail.com> Message-ID: <47750B97.10109@pressure.to> Hi EchoB wrote: > I got the splash screen working with a timer :) (see previous post: > Wx::SplashScreen, and events) > > Cool. > Let me qualify the above code by saying that it originally inherited > from Wx::Frame, and I made a new Wx:Wizard with the self (Wx::Frme) as > parent. ... > So I decided to try and see if making the whole thing inherit Wx::Wizard > and set parent window to nil works any better. Generally, take a look at the bundled samples/etc/wizard.rb. This illustrates how to set up a simple wizard and how to handle the events that are fired as the user proceeds through the pages. It appears that from the documentation, Wx::Wizard must have valid parent Frame; unlike some other top-level windows, nil is not permitted. Note that the parent frame doesn't necessarily have to be shown, if you want to run through a wizard without anything else appearing at that point (eg for an initial setup routine). More importantly, using the debug build, I get failures unless each WizardPageSimple constructor is passed the containing wizard (self) as its first parameter. With that done, your sample works fine for me. I am not sure why the current wxWidgets documentation seems to suggest that nil is allowed for a WPS parent. > Well - now I see the > wizard for just under half a second, and it never comes back. The ruby > runtime continues though - and I get no error messages. > There are some mistakes in Wx programming that are flagged as assertion failures, but only show up in a debug build of wxWidgets; in a release build they either just don't work or occasionally segfault. However the debug build is much bigger and slower than the release build, so we base all the distributed gems on release. If something isn't quite working, take a second look at the docs and samples, and you're very welcome to ask on here. best wishes aelx From lists at ruby-forum.com Fri Dec 28 12:35:22 2007 From: lists at ruby-forum.com (Claudio Petasecca donati) Date: Fri, 28 Dec 2007 18:35:22 +0100 Subject: [wxruby-users] Cannot install wxruby on Leopard Message-ID: <4fb22297940a91f2983e6db09c689362@ruby-forum.com> I'd like to try wxruby on my MacBook Pro with Leopard (10.5.1) But I have troubles with gem. I can see the gem is in rubyforge: $ gem list wxruby -r *** REMOTE GEMS *** wxruby (1.9.2, 1.9.1, 1.9.0) wxrubylayouts (0.0.3, 0.0.2, 0.0.1) but when I try to install it: $ sudo gem install wxruby -r Password: ERROR: could not find wxruby locally or in a repository Any suggestion? Thanks in advance -- Posted via http://www.ruby-forum.com/. From rwa000 at gmail.com Fri Dec 28 14:42:31 2007 From: rwa000 at gmail.com (Robert Anderson) Date: Fri, 28 Dec 2007 11:42:31 -0800 Subject: [wxruby-users] wxSizerItem show() method In-Reply-To: References: <9af502e50712272243v6349c532kf89ec6fb7d212ade@mail.gmail.com> <9af502e50712280019k3c1e8d8er1a3506dd592be799@mail.gmail.com> Message-ID: <9af502e50712281142g3db73d9fted80787bed3618d7@mail.gmail.com> Mario, Thanks for your suggestions. I worked around this issue by using wxPanel as a "dummy" item in the sizer. Then I have something concrete to hide/show. Thanks, Bob On Dec 28, 2007 2:25 AM, Mario Steele wrote: > Robert, > > I don't believe there is an actual control returned from #add() method > that is utitlized to add a spacer. It is more then nothing an internal data > structure in which to show that something occupies that space, but nothing > is actually drawn for that space itself. If you need to dynamically > add/remove spacers, I would suggest utilizing #remove() to remove it. > wxSizerItem is not employed within wxRuby, as it's of more use internally, > then externally. > > On 12/28/07, Robert Anderson wrote: > > > > > On Dec 28, 2007 12:06 AM, Mario Steele wrote: > > > > > Hello Robert, > > > > > > Actually, the best thing to do, is for you to use the Root Sizer, EG: > > > BoxSizer, FlexGridSizer, Etc, etc, to utilize the #layout() method, to > > > update the controls being displayed, and utilize the Window#show() method on > > > the actual control, instead of the sizer item. > > > > > > > Mario, > > > > If I am using the add() method on the sizer which adds a spacer, is > > there a control at all? > > > > * wxSizerItem > > ** *Add*(*int **width*, *int **height*, *int **proportion = 0*, *int **flag > > = 0*, *int **border = 0*, * wxObject* > > **userData = NULL*); > > > > Thanks, > > Bob > > > > > > > > _______________________________________________ > > wxruby-users mailing list > > wxruby-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/wxruby-users > > > > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071228/2b0d6a94/attachment.html From rwa000 at gmail.com Fri Dec 28 14:59:40 2007 From: rwa000 at gmail.com (Robert Anderson) Date: Fri, 28 Dec 2007 11:59:40 -0800 Subject: [wxruby-users] static box sizing problems Message-ID: <9af502e50712281159p609c2788lc37f4fa71f29157e@mail.gmail.com> Hi, I tried this one over on the main wx-users list as well, but thought I would try it here since I am using wxRuby: I am using wxWidgets 2.8.7 on a linux box using the GTK build. I have pared down my issue to the simplest case: I am trying to use a horizontal BoxSizer to split a frame into two sections: a left and right side. I want the left side to stretch proportionally and I want the right side to be of a fixed width. Moreover, I want to enclose the right side in a wxStaticBox. I happen to be using wxRuby, but the code should be understandable to C++ programmers. This is in the constructor of my frame subclass: lr_sizer = BoxSizer.new( HORIZONTAL ) txt = StaticText.new (self, -1, "Text Left") lr_sizer.add(txt, 1, EXPAND | ALL, 4) static_box = StaticBox.new(self, -1, "Static Box") right_sizer = StaticBoxSizer.new( static_box, VERTICAL ) lr_sizer.add(right_sizer, 0, EXPAND | ALL, 4) set_sizer(lr_sizer) layout() This code runs and gives almost what I want. The text appears on the left and the static box on the right. However, the static box is a tiny sliver. What I want is to fix the width of the static box. So I try adding a size argument to the static box constructor: static_box = StaticBox.new(self, -1, "Static Box", :size => [100, 40] ) But now I get something very unexpected to me. The static box is indeed wider, but it has the same left hand screen coordinate as it did when it was a sliver, so that the static box is mostly out of the frame. I only see a tiny slice of it. Resizing the frame moves the whole box, so it is always mostly out of the frame. It is as if the static box were positioned according to the minimum size, and then grown to the right, to respect the requested box size. But this is clearly not what I want. I want the box to be sized as requested, and then fit using the spacers. How do I do that? Note that I tried using a panel inside my frame and adding everything to the panel, but I got the exact same result. Thanks for any help. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071228/ecf330e5/attachment.html From bureaux.sebastien at neuf.fr Fri Dec 28 18:48:42 2007 From: bureaux.sebastien at neuf.fr (sebastien) Date: Sat, 29 Dec 2007 00:48:42 +0100 Subject: [wxruby-users] checklistbox/html windows Message-ID: <000601c849ac$2dc69250$0201a8c0@sebastien> Bonsoir Alex. Je voulais savoir, si pour la prochaine version de wxruby, vous comptiez apportez deux am?liorations ? "checklistbox", qui sont: - de pouvoir changez le contenu de la checklistbox sans avoir besoin de fermer et r?ouvrir l'application pour effectuer le changement du contenu? - de mettre l'option "HSCROLL"?, car la barre appara?t mais ?a ne marche pas. Pour "htmlwindow", je voulais savoir si il peut-?tre possible de ne pas afficher "ART_MISSING_IMAGE", quand le format d'image n'est pas pris en charge. Si je pose cette question, c'est tout simplement que quand j'affiche une page avec "htmlwindow" et que "ART_MISSING_IMAGE" appara?t, cel? donne un peu l'impression que l'application n'est pas fini. En fait je pense que cela aurai ?t? une bonne id?e de ne pas afficher cette image quand certain formats d'image ne sont pas pris en charge. Voil? les options qu'il me manque pour que je puisse mettre mon application en t?l?chargement, donc si vous pouviez faire un petit effort au moins pour "checklistbox", pour la prochaine version de wxruby, ce serai cool. Meilleurs voeux ? tous et bonnes f?tes. sebastien http://beusse.liveror.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071229/bf330901/attachment.html From mario at ruby-im.net Fri Dec 28 20:03:38 2007 From: mario at ruby-im.net (Mario Steele) Date: Fri, 28 Dec 2007 19:03:38 -0600 Subject: [wxruby-users] Cannot install wxruby on Leopard In-Reply-To: <4fb22297940a91f2983e6db09c689362@ruby-forum.com> References: <4fb22297940a91f2983e6db09c689362@ruby-forum.com> Message-ID: Hello Claudio, First off, what version of RubyGems do you have installed? If you have 0.9.3, try updating to 1.0.3 by doing gem update --system, this will cause RubyGems to update itself to the latest version of RubyGems, which I belive is 1.0.3, and allow you to install wxruby 1.9.2. L8ers, Mario Steele On 12/28/07, Claudio Petasecca donati wrote: > > I'd like to try wxruby on my MacBook Pro with Leopard ( 10.5.1) > > But I have troubles with gem. > > I can see the gem is in rubyforge: > > $ gem list wxruby -r > > *** REMOTE GEMS *** > > wxruby (1.9.2, 1.9.1, 1.9.0) > wxrubylayouts (0.0.3, 0.0.2, 0.0.1) > > but when I try to install it: > > $ sudo gem install wxruby -r > Password: > ERROR: could not find wxruby locally or in a repository > > Any suggestion? > Thanks in advance > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071228/153d87d5/attachment.html From mario at ruby-im.net Fri Dec 28 20:12:18 2007 From: mario at ruby-im.net (Mario Steele) Date: Fri, 28 Dec 2007 19:12:18 -0600 Subject: [wxruby-users] static box sizing problems In-Reply-To: <9af502e50712281159p609c2788lc37f4fa71f29157e@mail.gmail.com> References: <9af502e50712281159p609c2788lc37f4fa71f29157e@mail.gmail.com> Message-ID: Hello Robert, >From reading what you have described here, it sounds as though you would need to change the right_sizer addition to the lr_sizer. What I would suggest, is trying this: lr_sizer.add(right_sizer,1,EXPAND|ALL,4) In order, the parameters are: Sizer/Window, Proportion, Flags, Border Everything else is pretty self explanitory, except for the Proportion. This is often not well known, or understood. Proprotion gives the sizer/control being added to the sizer, and propotional view of how it should resize itself when layout() is called. Specifically, 0 means that it will use what it can, and nothing else. 1 means that if you have 2 controls in the sizer, it will use 1/2 of the sizer's dimensions when re-sizing / layout(). The main thing to note here, is that if you want to get more specifics of how to design the layout, will allow you to expand the sizes of items included, by proportional values. Check that out, you may need to do some twinking here and there between the controls you add, to get the spacing you want. TTFN, Mario Steele On 12/28/07, Robert Anderson wrote: > > > Hi, > > I tried this one over on the main wx-users list as well, but thought I > would try it here since I am using wxRuby: > > I am using wxWidgets 2.8.7 on a linux box using the GTK build. > > I have pared down my issue to the simplest case: I am trying to use a > horizontal BoxSizer to split a frame into two sections: a left and right > side. I want the left side to stretch proportionally and I want the right > side to be of a fixed width. Moreover, I want to enclose the right side in > a wxStaticBox. > > I happen to be using wxRuby, but the code should be understandable to C++ > programmers. This is in the constructor of my frame subclass: > > lr_sizer = BoxSizer.new( HORIZONTAL ) > > txt = StaticText.new (self, -1, "Text Left") > lr_sizer.add(txt, 1, EXPAND | ALL, 4) > > static_box = StaticBox.new(self, -1, "Static Box") > right_sizer = StaticBoxSizer.new( static_box, VERTICAL ) > > lr_sizer.add(right_sizer, 0, EXPAND | ALL, 4) > set_sizer(lr_sizer) > layout() > > > This code runs and gives almost what I want. The text appears on the left > and the static box on the right. However, the static box is a tiny sliver. > What I want is to fix the width of the static box. So I try adding a size > argument to the static box constructor: > > static_box = StaticBox.new(self, -1, "Static Box", :size => [100, 40] ) > > But now I get something very unexpected to me. The static box is indeed > wider, but it has the same left hand screen coordinate as it did when it was > a sliver, so that the static box is mostly out of the frame. I only see a > tiny slice of it. Resizing the frame moves the whole box, so it is always > mostly out of the frame. It is as if the static box were positioned > according to the minimum size, and then grown to the right, to respect the > requested box size. But this is clearly not what I want. I want the box to > be sized as requested, and then fit using the spacers. > > How do I do that? Note that I tried using a panel inside my frame and > adding everything to the panel, but I got the exact same result. > > Thanks for any help. > > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071228/6094e8ef/attachment-0001.html From rwa000 at gmail.com Fri Dec 28 21:34:12 2007 From: rwa000 at gmail.com (Robert Anderson) Date: Fri, 28 Dec 2007 18:34:12 -0800 Subject: [wxruby-users] static box sizing problems In-Reply-To: References: <9af502e50712281159p609c2788lc37f4fa71f29157e@mail.gmail.com> Message-ID: <9af502e50712281834r648eb8b4pae63208d7f889165@mail.gmail.com> Mario, I think I have a pretty reasonable understanding of the proportional flag. I do not want the right_sizer to be proportional at all. I want it to be of fixed size. Therefore proportional_flag should be 0, correct? If I change it to 1, it changes size when the frame changes size. This is not what I want. I was able to work around this apparent bug (in wxWidgets) by adding a dummy spacer of height 0 to the StaticBoxSizer that is of the fixed width that I want. I don't see any reason why that should work whereas setting the size of the StaticBoxSizer does not. Thanks, Bob On Dec 28, 2007 5:12 PM, Mario Steele wrote: > Hello Robert, > > From reading what you have described here, it sounds as though you would > need to change the right_sizer addition to the lr_sizer. > > What I would suggest, is trying this: > > lr_sizer.add(right_sizer,1,EXPAND|ALL,4) > > In order, the parameters are: Sizer/Window, Proportion, Flags, Border > > Everything else is pretty self explanitory, except for the Proportion. > This is often not well known, or understood. Proprotion gives the > sizer/control being added to the sizer, and propotional view of how it > should resize itself when layout() is called. Specifically, 0 means that it > will use what it can, and nothing else. 1 means that if you have 2 controls > in the sizer, it will use 1/2 of the sizer's dimensions when re-sizing / > layout(). The main thing to note here, is that if you want to get more > specifics of how to design the layout, will allow you to expand the sizes of > items included, by proportional values. > > Check that out, you may need to do some twinking here and there between > the controls you add, to get the spacing you want. > > TTFN, > > Mario Steele > > > On 12/28/07, Robert Anderson wrote: > > > > > Hi, > > > > I tried this one over on the main wx-users list as well, but thought I > > would try it here since I am using wxRuby: > > > > I am using wxWidgets 2.8.7 on a linux box using the GTK build. > > > > I have pared down my issue to the simplest case: I am trying to use a > > horizontal BoxSizer to split a frame into two sections: a left and right > > side. I want the left side to stretch proportionally and I want the right > > side to be of a fixed width. Moreover, I want to enclose the right side in > > a wxStaticBox. > > > > I happen to be using wxRuby, but the code should be understandable to > > C++ programmers. This is in the constructor of my frame subclass: > > > > lr_sizer = BoxSizer.new( HORIZONTAL ) > > > > txt = StaticText.new (self, -1, "Text Left") > > lr_sizer.add(txt, 1, EXPAND | ALL, 4) > > > > static_box = StaticBox.new(self, -1, "Static Box") > > right_sizer = StaticBoxSizer.new( static_box, VERTICAL ) > > > > lr_sizer.add(right_sizer, 0, EXPAND | ALL, 4) > > set_sizer(lr_sizer) > > layout() > > > > > > This code runs and gives almost what I want. The text appears on the > > left and the static box on the right. However, the static box is a tiny > > sliver. What I want is to fix the width of the static box. So I try adding > > a size argument to the static box constructor: > > > > static_box = StaticBox.new(self, -1, "Static Box", :size => [100, 40] > > ) > > > > But now I get something very unexpected to me. The static box is indeed > > wider, but it has the same left hand screen coordinate as it did when it was > > a sliver, so that the static box is mostly out of the frame. I only see a > > tiny slice of it. Resizing the frame moves the whole box, so it is always > > mostly out of the frame. It is as if the static box were positioned > > according to the minimum size, and then grown to the right, to respect the > > requested box size. But this is clearly not what I want. I want the box to > > be sized as requested, and then fit using the spacers. > > > > How do I do that? Note that I tried using a panel inside my frame and > > adding everything to the panel, but I got the exact same result. > > > > Thanks for any help. > > > > > > _______________________________________________ > > wxruby-users mailing list > > wxruby-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/wxruby-users > > > > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071228/64dab86a/attachment.html From alex at pressure.to Fri Dec 28 22:09:55 2007 From: alex at pressure.to (Alex Fenton) Date: Sat, 29 Dec 2007 03:09:55 +0000 Subject: [wxruby-users] static box sizing problems In-Reply-To: <9af502e50712281159p609c2788lc37f4fa71f29157e@mail.gmail.com> References: <9af502e50712281159p609c2788lc37f4fa71f29157e@mail.gmail.com> Message-ID: <4775BA83.8060100@pressure.to> Robert Anderson wrote: > I am trying to use a horizontal BoxSizer to split a frame into two > sections: a left and right side. I want the left side to stretch > proportionally and I want the right side to be of a fixed width. > Moreover, I want to enclose the right side in a wxStaticBox. > Perhaps it would help if you add some actual widgets to the right hand panel and see then if it sizes as you want. I think that Wx::StaticBox itself doesn't have a minimum notional size - it's a grouping for other widgets. I tried adding a Panel to the right hand size like: something = Wx::Panel.new(self, :size => [100, 100]) right_sizer.add(something) And then it gives the effect you desire: a fixed size on one size, a variable on the other. You might also have a look at splitter window or sash layouts, to see if that's what you're looking for. alex From rwa000 at gmail.com Fri Dec 28 23:52:46 2007 From: rwa000 at gmail.com (Robert Anderson) Date: Fri, 28 Dec 2007 20:52:46 -0800 Subject: [wxruby-users] static box sizing problems In-Reply-To: <4775BA83.8060100@pressure.to> References: <9af502e50712281159p609c2788lc37f4fa71f29157e@mail.gmail.com> <4775BA83.8060100@pressure.to> Message-ID: <9af502e50712282052h2baf113bgdb139f8eaacb8c72@mail.gmail.com> On Dec 28, 2007 7:09 PM, Alex Fenton wrote: > Robert Anderson wrote: > > I am trying to use a horizontal BoxSizer to split a frame into two > > sections: a left and right side. I want the left side to stretch > > proportionally and I want the right side to be of a fixed width. > > Moreover, I want to enclose the right side in a wxStaticBox. > > > Perhaps it would help if you add some actual widgets to the right hand > panel and see then if it sizes as you want. I think that Wx::StaticBox > itself doesn't have a minimum notional size - it's a grouping for other > widgets. Yeah, that's what I ended up doing and it does work. But this is a bug IMO. My wxStaticBox houses a dynamic number of widgets with zero being the minimum number. But I always have to make sure there's an invisible dummy widget in there to get the behavior right, which is awkward at best. Thanks, Bob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071228/c229c51f/attachment.html From lists at ruby-forum.com Sat Dec 29 07:38:10 2007 From: lists at ruby-forum.com (Claudio Petasecca donati) Date: Sat, 29 Dec 2007 13:38:10 +0100 Subject: [wxruby-users] Cannot install wxruby on Leopard In-Reply-To: References: <4fb22297940a91f2983e6db09c689362@ruby-forum.com> Message-ID: Hello Mario First, thanks for your suggestion > First off, what version of RubyGems do you have installed? If you have > 0.9.3, try updating to 1.0.3 by doing gem update --system, this will > cause RubyGems to update itself to the latest version of RubyGems, which I > belive is 1.0.3, and allow you to install wxruby 1.9.2. I had version 1.0.1 of gem, since I had updated it recently. $ gem --version 1.0.1 but as you suggested, I updated gem as well: $ sudo gem update --system Password: Updating RubyGems... Updating metadata for 40 gems from http://gems.rubyforge.org ........................................ complete Attempting remote update of rubygems-update Successfully installed rubygems-update-1.0.1 1 gem installed Updating version of RubyGems to 1.0.1 Installing RubyGems 1.0.1 install -c -m 0644 rbconfig/datadir.rb /Library/Ruby/Site/1.8/rbconfig/datadir.rb install -c -m 0644 rubygems/builder.rb /Library/Ruby/Site/1.8/rubygems/builder.rb install -c -m 0644 rubygems/command.rb /Library/Ruby/Site/1.8/rubygems/command.rb ........ (I omit part of the log) ... install -c -m 0644 rubygems/version.rb /Library/Ruby/Site/1.8/rubygems/version.rb install -c -m 0644 rubygems/version_option.rb /Library/Ruby/Site/1.8/rubygems/version_option.rb install -c -m 0644 rubygems.rb /Library/Ruby/Site/1.8/rubygems.rb install -c -m 0644 ubygems.rb /Library/Ruby/Site/1.8/ubygems.rb cp gem /tmp/gem install -c -m 0755 /tmp/gem /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/gem rm /tmp/gem cp update_rubygems /tmp/update_rubygems install -c -m 0755 /tmp/update_rubygems /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/update_rubygems rm /tmp/update_rubygems rm /Library/Ruby/Gems/1.8/source_cache Removing old RubyGems RDoc and ri... rm -rf /Library/Ruby/Gems/1.8/doc/rubygems-1.0.1 Installing rubygems-1.0.1 ri into /Library/Ruby/Gems/1.8/doc/rubygems-1.0.1/ri... Installing rubygems-1.0.1 rdoc into /Library/Ruby/Gems/1.8/doc/rubygems-1.0.1/rdoc... As of RubyGems 0.8.0, library stubs are no longer needed. Searching $LOAD_PATH for stubs to optionally delete (may take a while)... ...done. No library stubs found. RubyGems system software updated but installing wxruby shows me the same problem: $ sudo gem install wxruby -r Bulk updating Gem source index for: http://gems.rubyforge.org ERROR: could not find wxruby locally or in a repository and strangely the gem version seems not to have changed: $ gem --version 1.0.1 I add that I'm not behind a firewall (but I have the standard OSX protections), and I never experimented problems with internet. -- Posted via http://www.ruby-forum.com/. From sean.m.long at gmail.com Sat Dec 29 15:11:37 2007 From: sean.m.long at gmail.com (Sean Long) Date: Sat, 29 Dec 2007 12:11:37 -0800 Subject: [wxruby-users] Cannot install wxruby on Leopard In-Reply-To: References: <4fb22297940a91f2983e6db09c689362@ruby-forum.com> Message-ID: For now you can try downloading the gem directly and installing it from the local download. http://rubyforge.org/frs/?group_id=35 wxruby-1.9.2-i686-darwin8.8.2.gem (Intel) wxruby-1.9.2-powerpc-darwin8.10.0.gem (PowerPC) The gem system sure seems to have gotten flaky over the last year or so. Sean On Dec 29, 2007 4:38 AM, Claudio Petasecca donati wrote: > Hello Mario > > First, thanks for your suggestion > > > First off, what version of RubyGems do you have installed? If you have > > 0.9.3, try updating to 1.0.3 by doing gem update --system, this will > > cause RubyGems to update itself to the latest version of RubyGems, which I > > belive is 1.0.3, and allow you to install wxruby 1.9.2. > > I had version 1.0.1 of gem, since I had updated it recently. > > $ gem --version > 1.0.1 > > but as you suggested, I updated gem as well: > > $ sudo gem update --system > Password: > Updating RubyGems... > Updating metadata for 40 gems from http://gems.rubyforge.org > ........................................ > complete > Attempting remote update of rubygems-update > Successfully installed rubygems-update-1.0.1 > 1 gem installed > Updating version of RubyGems to 1.0.1 > Installing RubyGems 1.0.1 > install -c -m 0644 rbconfig/datadir.rb > /Library/Ruby/Site/1.8/rbconfig/datadir.rb > install -c -m 0644 rubygems/builder.rb > /Library/Ruby/Site/1.8/rubygems/builder.rb > install -c -m 0644 rubygems/command.rb > /Library/Ruby/Site/1.8/rubygems/command.rb > ........ (I omit part of the log) ... > install -c -m 0644 rubygems/version.rb > /Library/Ruby/Site/1.8/rubygems/version.rb > install -c -m 0644 rubygems/version_option.rb > /Library/Ruby/Site/1.8/rubygems/version_option.rb > install -c -m 0644 rubygems.rb /Library/Ruby/Site/1.8/rubygems.rb > install -c -m 0644 ubygems.rb /Library/Ruby/Site/1.8/ubygems.rb > cp gem /tmp/gem > install -c -m 0755 /tmp/gem > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/gem > rm /tmp/gem > cp update_rubygems /tmp/update_rubygems > install -c -m 0755 /tmp/update_rubygems > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/update_rubygems > rm /tmp/update_rubygems > rm /Library/Ruby/Gems/1.8/source_cache > Removing old RubyGems RDoc and ri... > rm -rf /Library/Ruby/Gems/1.8/doc/rubygems-1.0.1 > Installing rubygems-1.0.1 ri into > /Library/Ruby/Gems/1.8/doc/rubygems-1.0.1/ri... > Installing rubygems-1.0.1 rdoc into > /Library/Ruby/Gems/1.8/doc/rubygems-1.0.1/rdoc... > As of RubyGems 0.8.0, library stubs are no longer needed. > Searching $LOAD_PATH for stubs to optionally delete (may take a > while)... > ...done. > No library stubs found. > RubyGems system software updated > > but installing wxruby shows me the same problem: > > $ sudo gem install wxruby -r > Bulk updating Gem source index for: http://gems.rubyforge.org > ERROR: could not find wxruby locally or in a repository > > and strangely the gem version seems not to have changed: > > $ gem --version > 1.0.1 > > I add that I'm not behind a firewall (but I have the standard OSX > protections), and I never experimented problems with internet. > > -- > > Posted via http://www.ruby-forum.com/. > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > From jay at mcgavren.com Sat Dec 29 19:30:12 2007 From: jay at mcgavren.com (Jay McGavren) Date: Sat, 29 Dec 2007 17:30:12 -0700 Subject: [wxruby-users] Drawing thread not getting enough time from scheduler? Message-ID: <839490bc0712291630o41a76b8br9018ed8df39c2c61@mail.gmail.com> Need some assistance with animation again... When I run the drawing code in a separate thread, it's slow as heck. I think it may be because the drawing thread isn't getting enough time from the thread scheduler. I was able to reproduce the problem in my little sample program simply by increasing the number of lines it draws per update. I'm lucky to get one frame every three seconds with this. If I "thread.join" or "thread.priority += 1" the speed greatly increases, but then the GUI becomes unresponsive. (Similar problems with threads have been discussed previously on the wxRuby mailing list.) require 'rubygems' require 'wx' class MyApp < Wx::App def on_init #Animate every 33 milliseconds. t = Wx::Timer.new(self, 55) evt_timer(55) { Thread.pass } t.start(33) #Containing frame. frame = Wx::Frame.new(nil, :size => [300, 300]) frame.show #Offscreen drawing buffer. buffer = Wx::Bitmap.new(300, 300) #Displays drawing. window = Wx::Window.new(frame, :size => [300, 300]) #Animate. thread = Thread.new do 300.times do |i| #Clear screen. buffer.draw do |surface| surface.pen = Wx::Pen.new(Wx::Colour.new(0, 0, 0), 0) surface.brush = Wx::BLACK_BRUSH surface.draw_rectangle(0, 0, 300, 300) end #Draw lines. 30.times do |j| x = i + j buffer.draw do |surface| surface.pen = Wx::Pen.new( Wx::Colour.new(128, 255, 128), 3 ) surface.pen.cap = Wx::CAP_ROUND surface.draw_line(x, 0, x+100, 100) end end #Update screen. update_window(window, buffer) end end end def update_window(window, buffer) window.paint do |dc| #Copy the buffer to the viewable window. dc.draw_bitmap(buffer, 0, 0, false) end end end app = MyApp.new app.main_loop I ran it through ruby-prof... Am I right in thinking these results mean the drawing thread is getting a fraction of the time that the main loop is? Thread ID: 59174940 Total: 0.01 %self total self wait child calls name 1250.00 30.45 0.13 2.02 28.31 11 Integer#times-1 160.00 2.86 0.02 2.84 0.00 3391 Wxruby2::Colour#initialize 160.00 0.02 0.02 0.00 0.00 3378 Wxruby2::DC#draw_line 0.00 0.05 0.00 0.05 0.00 11 Wxruby2::Window#paint ... Thread ID: 42518340 Total: 32.594 %self total self wait child calls name 96.59 31.72 31.48 0.00 0.24 1 Wxruby2::App#main_loop 2.01 0.77 0.66 0.00 0.11 42 Kernel#gem_original_require-1 0.19 0.06 0.06 0.00 0.00 28 #[] ... My actual program (a game) is going to be doing even more drawing operations than this, so I need to boost the speed wherever I can. Any advice would be most appreciated! -Jay McGavren http://jay.mcgavren.com/zyps From mario at ruby-im.net Sat Dec 29 21:18:58 2007 From: mario at ruby-im.net (Mario Steele) Date: Sat, 29 Dec 2007 20:18:58 -0600 Subject: [wxruby-users] Drawing thread not getting enough time from scheduler? In-Reply-To: <839490bc0712291630o41a76b8br9018ed8df39c2c61@mail.gmail.com> References: <839490bc0712291630o41a76b8br9018ed8df39c2c61@mail.gmail.com> Message-ID: Hello Jay, Well, one optimization that I can see just by skimming the code, is that your creating a DC Buffer each time you loop to draw a line. The grabbing of a DC weither it's an On-Screen Control, or an Off Screen Bitmap. The better way to do this, is to go this route here: --Code-- buffer.draw do |surface| surface.pen = Wx::Pen.new( Wx::Colour.new(128, 255, 128), 3 ) 30.times do |j| x = i + j surface.pen.cap = Wx::CAP_ROUND surface.draw_line(x, 0, x+100, 100) end end --end code-- If you would also notice, I'm not constantly re-creating the Wx::Pen either. Since it's created once, and your using the same colour, and size for the Pen, there's no reason to be re-creating it for each and every line you draw. Whenever it comes to drawing, the main things you need to keep in mind, as far as performance is concerned, is that everytime you create a DC, it takes the Underlying OS a bit to load up the DC, the same to release the DC. Also, you will want to create your primary pens first, that your going to use most often, and avoid trying to create them everytime an iteration of a loop occurs, as this also takes time away from which you can do stuff with. I believe, that with these simple modifications, you would easily get up to 50~ FPS on the game. Let me know how it goes, Mario Steele On 12/29/07, Jay McGavren wrote: > > Need some assistance with animation again... When I run the drawing > code in a separate thread, it's slow as heck. I think it may be > because the drawing thread isn't getting enough time from the thread > scheduler. > > I was able to reproduce the problem in my little sample program simply > by increasing the number of lines it draws per update. I'm lucky to > get one frame every three seconds with this. If I "thread.join" or > "thread.priority += 1" the speed greatly increases, but then the GUI > becomes unresponsive. (Similar problems with threads have been > discussed previously on the wxRuby mailing list.) > > > require 'rubygems' > require 'wx' > > class MyApp < Wx::App > > def on_init > > #Animate every 33 milliseconds. > t = Wx::Timer.new(self, 55) > evt_timer(55) { Thread.pass } > t.start(33) > > #Containing frame. > frame = Wx::Frame.new(nil, :size => [300, 300]) > frame.show > > #Offscreen drawing buffer. > buffer = Wx::Bitmap.new(300, 300) > > #Displays drawing. > window = Wx::Window.new(frame, :size => [300, 300]) > > #Animate. > thread = Thread.new do > 300.times do |i| > #Clear screen. > buffer.draw do |surface| > surface.pen = Wx::Pen.new(Wx::Colour.new(0, 0, 0), 0) > surface.brush = Wx::BLACK_BRUSH > surface.draw_rectangle(0, 0, 300, 300) > end > #Draw lines. > 30.times do |j| > x = i + j > buffer.draw do |surface| > surface.pen = Wx::Pen.new( > Wx::Colour.new(128, 255, 128), > 3 > ) > surface.pen.cap = Wx::CAP_ROUND > surface.draw_line(x, 0, x+100, 100) > end > end > #Update screen. > update_window(window, buffer) > end > end > > end > > def update_window(window, buffer) > window.paint do |dc| > #Copy the buffer to the viewable window. > dc.draw_bitmap(buffer, 0, 0, false) > end > end > > end > > app = MyApp.new > app.main_loop > > > I ran it through ruby-prof... Am I right in thinking these results > mean the drawing thread is getting a fraction of the time that the > main loop is? > > > Thread ID: 59174940 > Total: 0.01 > > %self total self wait child calls name > 1250.00 30.45 0.13 2.02 28.31 11 Integer#times-1 > 160.00 2.86 0.02 2.84 0.00 3391 > Wxruby2::Colour#initialize > 160.00 0.02 0.02 0.00 0.00 > 3378 Wxruby2::DC#draw_line > 0.00 0.05 0.00 0.05 0.00 > 11 Wxruby2::Window#paint > ... > > Thread ID: 42518340 > Total: 32.594 > > %self total self wait child calls name > 96.59 31.72 31.48 0.00 0.24 > 1 Wxruby2::App#main_loop > 2.01 0.77 0.66 0.00 0.11 42 > Kernel#gem_original_require-1 > 0.19 0.06 0.06 0.00 0.00 28 #[] > ... > > > My actual program (a game) is going to be doing even more drawing > operations than this, so I need to boost the speed wherever I can. > Any advice would be most appreciated! > > -Jay McGavren > http://jay.mcgavren.com/zyps > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20071229/5f402a23/attachment.html From jay at mcgavren.com Sun Dec 30 03:22:21 2007 From: jay at mcgavren.com (Jay McGavren) Date: Sun, 30 Dec 2007 01:22:21 -0700 Subject: [wxruby-users] Drawing thread not getting enough time from scheduler? Message-ID: <839490bc0712300022r27e10f7v87fbd9d99241653b@mail.gmail.com> Thanks for looking at the code, Mario. I made those modifications (to my prototype as well as my game library, where I had been re-using a DC but had *not* been caching pens). It did speed things up a bit, but it still runs many times faster (55 seconds vs. 5 seconds) if I join the animation thread. thread = Thread.new do black_pen = Wx::Pen.new(Wx::Colour.new(0, 0, 0), 0) green_pen = Wx::Pen.new(Wx::Colour.new(128, 255, 128), 3) 300.times do |i| buffer.draw do |surface| #Clear screen. surface.pen = black_pen surface.brush = Wx::BLACK_BRUSH surface.draw_rectangle(0, 0, 300, 300) #Draw lines. 30.times do |j| x = i + j surface.pen = green_pen surface.pen.cap = Wx::CAP_ROUND surface.draw_line(x, 0, x+100, 100) end end #Update screen. update_window(window, buffer) end end #Makes GUI unresponsive if uncommented. # thread.join Any idea how I can get the thread scheduler to devote a bit more time to animation, without completely freezing the GUI? -Jay McGavren http://jay.mcgavren.com/zyps Mario Steele wrote: > Well, one optimization that I can see just by skimming the code, is that > your creating a DC Buffer each time you loop to draw a line. The grabbing > of a DC weither it's an On-Screen Control, or an Off Screen Bitmap. ... > If you would also notice, I'm not constantly re-creating the Wx::Pen > either. Since it's created once, and your using the same colour, and size > for the Pen, there's no reason to be re-creating it for each and every line > you draw. ... > I believe, that with these simple modifications, you would easily get up to > 50~ FPS on the game. From echobinary at gmail.com Sun Dec 30 04:19:41 2007 From: echobinary at gmail.com (EchoB) Date: Sun, 30 Dec 2007 04:19:41 -0500 Subject: [wxruby-users] ReOrdering Wx::TreeCtrl Items Message-ID: <477762AD.608@gmail.com> Given the following hash: #... @project_list = { 'Contract0' => nil, 'Contract1' => { 'Project1' => nil, 'Project2' => nil, 'Project3' => { 'task1' => nil, 'task2' => nil, 'task3' => nil } }, 'Contract3' => { 'Project1' => nil }, 'Contract4' => nil, 'Contract5' => nil, 'Contract6long contract with Characters ~!!@#$!@$%#$&$^&(^&()' => nil, 'Contract7' => nil, 'Contract8' => nil, 'Contract9' => nil } #... #And Given the following code: #... @tc_project_list = Wx::TreeCtrl.new(self, :size => Wx::Size.new(175, 150), :style => Wx::TR_HIDE_ROOT | Wx::TR_EDIT_LABELS | Wx::TR_HAS_BUTTONS | Wx::TR_LINES_AT_ROOT) tcr_project_root = @tc_project_list.add_root("Project List") populate_project_tree(@project_list, tcr_project_root) #... #... def populate_project_tree(h_project_list, parent_node) h_project_list.each {|key, value| tree_node = @tc_project_list.append_item(parent_node, key.to_s) if value.class.to_s == "Hash" populate_project_tree(value, tree_node) end } end #... #================================== The big picture is to be able to populate the tree control and then re-order (NOT sorting) the items in the tree control. Is this possible? I have looked in the examples and haven't found anything like this. I suspect it is possible with the get sibling functions, but I haven't been able to piece together a way to accomplish this yet. Anyone have any ideas? Also I am noticing an odd thing (and I'm sure this must be something I'm doing) - When looking at my TreeCtrl - Contract0/Contract1 show up at the _bottom_ of the list, not at the top. Contract3 is at the top.