From lucaslevin at gmail.com Mon Jun 2 06:52:20 2008 From: lucaslevin at gmail.com (Lucas Levin) Date: Mon, 02 Jun 2008 20:52:20 +1000 Subject: [wxruby-users] Add TextCtrl to toolbar Message-ID: <1212403940.14113.2.camel@lucascomputer> Hi, How can I add a textctrl to a toolbar? I tried toolbar.add_control(TextCtrl.new(self, ID_ANY)), but that returns false and the control gets placed wherever. Thanks From alex at pressure.to Mon Jun 2 06:57:16 2008 From: alex at pressure.to (Alex Fenton) Date: Mon, 02 Jun 2008 11:57:16 +0100 Subject: [wxruby-users] Add TextCtrl to toolbar In-Reply-To: <1212403940.14113.2.camel@lucascomputer> References: <1212403940.14113.2.camel@lucascomputer> Message-ID: <4843D20C.9040704@pressure.to> Lucas Levin wrote: > How can I add a textctrl to a toolbar? > I tried toolbar.add_control(TextCtrl.new(self, ID_ANY)), but that > returns false and the control gets placed wherever. toolbar.add_control( TextCtrl.new(toolbar, ID_ANY) ) cheers alex From alex at pressure.to Mon Jun 2 07:32:21 2008 From: alex at pressure.to (Alex Fenton) Date: Mon, 02 Jun 2008 12:32:21 +0100 Subject: [wxruby-users] App#process_message In-Reply-To: <1051f8d6d901efeb2b4a0a438a0ee705@ruby-forum.com> References: <70c77d4350e549c47a3411f9312ae84f@ruby-forum.com> <483C6714.1030700@pressure.to> <1051f8d6d901efeb2b4a0a438a0ee705@ruby-forum.com> Message-ID: <4843DA45.6090807@pressure.to> Gabriel Rios wrote: > Alex Fenton wrote: > >> Could you explain a bit more about what you want. I read the wxWidgets >> documentation for this method but I don't know what a "Windows message" >> is, or how you get one in Windows. We can't wrap the method if we don't >> know what argument type it should take in Ruby. >> >> alex >> > > Hi alex, > > Our problem consist in communicate with an external device which connect > through the ethernet port. we need to receive the messages sent by it so > we can handle. > > (those messages are events like keydown, keyup, mouse movement and etc.) > > hope u can give me any direction. This isn't a wxRuby question I think. wxRuby provides a cross-platform abstraction (Wx::Event etc) over GUI events, but if you want to access native Windows messages, you should probably use ruby's Win32API library. http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/143459 alex From lists at ruby-forum.com Tue Jun 3 09:42:38 2008 From: lists at ruby-forum.com (Gabriel Rios) Date: Tue, 3 Jun 2008 15:42:38 +0200 Subject: [wxruby-users] App#process_message In-Reply-To: <4843DA45.6090807@pressure.to> References: <70c77d4350e549c47a3411f9312ae84f@ruby-forum.com> <483C6714.1030700@pressure.to> <1051f8d6d901efeb2b4a0a438a0ee705@ruby-forum.com> <4843DA45.6090807@pressure.to> Message-ID: Alex Fenton wrote: > Gabriel Rios wrote: >> Hi alex, >> >> Our problem consist in communicate with an external device which connect >> through the ethernet port. we need to receive the messages sent by it so >> we can handle. >> >> (those messages are events like keydown, keyup, mouse movement and etc.) >> >> hope u can give me any direction. > This isn't a wxRuby question I think. wxRuby provides a cross-platform > abstraction (Wx::Event etc) over GUI events, but if you want to access > native Windows messages, you should probably use ruby's Win32API > library. > > http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/143459 > > alex thx for that answer alex, this give us a light but im still curious about one thing. You said that this isnt a wxRuby question, but at the documentation there's the App#process_message[1] that appear to be what we need on our project. But i a have a doubt related to it. It's implemented at the wxRuby or we should write it and then the wxRuby main_loop will always call it? (is it already implemented at wxRuby?) gabriel (file:///home/gabriel/wxruby.rubyforge.org/doc/app.html#App_processmessage) -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Jun 3 09:43:53 2008 From: lists at ruby-forum.com (Gabriel Rios) Date: Tue, 3 Jun 2008 15:43:53 +0200 Subject: [wxruby-users] App#process_message In-Reply-To: References: <70c77d4350e549c47a3411f9312ae84f@ruby-forum.com> <483C6714.1030700@pressure.to> <1051f8d6d901efeb2b4a0a438a0ee705@ruby-forum.com> <4843DA45.6090807@pressure.to> Message-ID: <01e893c1ae9f38fb7243bdbcd9d51761@ruby-forum.com> ops, i put the link wrong it's: http://wxruby.rubyforge.org/doc/app.html#App_processmessage -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Tue Jun 3 10:00:47 2008 From: alex at pressure.to (Alex Fenton) Date: Tue, 03 Jun 2008 15:00:47 +0100 Subject: [wxruby-users] App#process_message In-Reply-To: References: <70c77d4350e549c47a3411f9312ae84f@ruby-forum.com> <483C6714.1030700@pressure.to> <1051f8d6d901efeb2b4a0a438a0ee705@ruby-forum.com> <4843DA45.6090807@pressure.to> Message-ID: <48454E8F.6080606@pressure.to> Gabriel Rios wrote: > Alex Fenton wrote: > >> This isn't a wxRuby question I think. wxRuby provides a cross-platform >> abstraction (Wx::Event etc) over GUI events, but if you want to access >> native Windows messages, you should probably use ruby's Win32API >> library. >> >> You said that this isnt a wxRuby question, but at the documentation >> there's the App#process_message[1] that appear to be what we need on our >> project. But i a have a doubt related to it. >> >> It's implemented at the wxRuby or we should write it and then the wxRuby >> main_loop will always call it? (is it already implemented at wxRuby?) >> It's not currently implemented and should be deleted from the docs. It's %ignored in this file which generates theWx:: App class in ruby: http://wxruby.rubyforge.org/svn/trunk/wxruby2/swig/classes/App.i I don't know how it would work - but methods that work by being defined in Ruby and then called as required by wxRuby (for example, Wx::App#filter_event) normally correspond to methods declared as "virtual" in the C++ API docs. The C++ method wxApp::ProcessMessage isn't so I wonder if it in fact does what you think it does? If you can set up a compiler toolchair (I recommend trying MingW) you could try it out, and if it works, I'd consider a patch. However it doesn't seem to be a specifically GUI problem, which is why I'd recommend pursuing Win32API first. alex From marlessonsa at gmail.com Thu Jun 5 10:16:27 2008 From: marlessonsa at gmail.com (Marlesson Santana) Date: Thu, 5 Jun 2008 11:16:27 -0300 Subject: [wxruby-users] App#process_message In-Reply-To: <48454E8F.6080606@pressure.to> References: <70c77d4350e549c47a3411f9312ae84f@ruby-forum.com> <483C6714.1030700@pressure.to> <1051f8d6d901efeb2b4a0a438a0ee705@ruby-forum.com> <4843DA45.6090807@pressure.to> <48454E8F.6080606@pressure.to> Message-ID: <2e1c95d50806050716o2f59ec5m4c74ee93f238e39@mail.gmail.com> What would be the function equal to MSWWindowProc() ( http://www.wxwidgets.org/docs/faqmsw.htm#handlewm) to wxruby? 2008/6/3 Alex Fenton : > Gabriel Rios wrote: > >> Alex Fenton wrote: >> >> >>> This isn't a wxRuby question I think. wxRuby provides a cross-platform >>> abstraction (Wx::Event etc) over GUI events, but if you want to access >>> native Windows messages, you should probably use ruby's Win32API library. >>> You said that this isnt a wxRuby question, but at the documentation >>> there's the App#process_message[1] that appear to be what we need on our >>> project. But i a have a doubt related to it. >>> >>> It's implemented at the wxRuby or we should write it and then the wxRuby >>> main_loop will always call it? (is it already implemented at wxRuby?) >>> >>> >> > It's not currently implemented and should be deleted from the docs. It's > %ignored in this file which generates theWx:: App class in ruby: > http://wxruby.rubyforge.org/svn/trunk/wxruby2/swig/classes/App.i > > I don't know how it would work - but methods that work by being defined in > Ruby and then called as required by wxRuby (for example, > Wx::App#filter_event) normally correspond to methods declared as "virtual" > in the C++ API docs. The C++ method wxApp::ProcessMessage isn't so I wonder > if it in fact does what you think it does? > > If you can set up a compiler toolchair (I recommend trying MingW) you could > try it out, and if it works, I'd consider a patch. However it doesn't seem > to be a specifically GUI problem, which is why I'd recommend pursuing > Win32API first. > > alex > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -- Marlesson R. O. de Santana Graduando em Ci?ncias da Computa??o - UESC Programador Web -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex at pressure.to Thu Jun 5 11:19:30 2008 From: alex at pressure.to (Alex Fenton) Date: Thu, 05 Jun 2008 16:19:30 +0100 Subject: [wxruby-users] App#process_message In-Reply-To: <2e1c95d50806050716o2f59ec5m4c74ee93f238e39@mail.gmail.com> References: <70c77d4350e549c47a3411f9312ae84f@ruby-forum.com> <483C6714.1030700@pressure.to> <1051f8d6d901efeb2b4a0a438a0ee705@ruby-forum.com> <4843DA45.6090807@pressure.to> <48454E8F.6080606@pressure.to> <2e1c95d50806050716o2f59ec5m4c74ee93f238e39@mail.gmail.com> Message-ID: <48480402.9090205@pressure.to> Marlesson Santana wrote: > What would be the function equal to MSWWindowProc() > (http://www.wxwidgets.org/docs/faqmsw.htm#handlewm) to wxruby? I don't believe there is an equivalent. Again, if you're looking to deal with Windows=specific features, I would say the various Win32 libraries out there for ruby would be a better place to look. wxRuby doesn't aim to be a complete re-implementation of wxWidgets in Ruby. Rather it aims to provide a native, cross-platform GUI toolkit for Ruby by using parts of wxWidgets. So a lot of non-GUI and cross-platform stuff is omitted. alex From mario at ruby-im.net Thu Jun 5 15:36:26 2008 From: mario at ruby-im.net (Mario Steele) Date: Thu, 5 Jun 2008 14:36:26 -0500 Subject: [wxruby-users] App#process_message In-Reply-To: <48480402.9090205@pressure.to> References: <70c77d4350e549c47a3411f9312ae84f@ruby-forum.com> <483C6714.1030700@pressure.to> <1051f8d6d901efeb2b4a0a438a0ee705@ruby-forum.com> <4843DA45.6090807@pressure.to> <48454E8F.6080606@pressure.to> <2e1c95d50806050716o2f59ec5m4c74ee93f238e39@mail.gmail.com> <48480402.9090205@pressure.to> Message-ID: Hello Marlesson, The best suggestion that we can truely make, is to use the Wx::Window#get_handle() method, to retrive the actual native HWND of the window, and use that in cooperation of the Win32 libraries. You would need to be able to get he Current WndProc of the Window (Which is the wxWidget's Window Procedure that is executed for the Main Loop), and create your own Custom WndProc to handle messages comming in to the window. If it's a message that you need, then you process it like normal, in your own code, otherwise, you call the WndProc that was originally associated with the Window (The wxWidgets WndProc), with the un-modified values for HWND, iMsg, wParam, lParam. Now, this is the only thing we can suggest. This is very much untested, and no garuntee's that it would work in any case. For us to wrap MSWWindowProc(), would only be useful on Windows. We'd rather only port Methods that are useful across all platforms. And I must stress this, there is no garuntee this would work, and may have un-desired results. We cannot officially support this method in any way possible, outside of showing you the option. The details of the implementation is entirely up to you, and you will have to look through the documentation for the Win32 libraries, to see if you can find what you want to make this work. Sorry we can't be of much more help then this, L8ers, On Thu, Jun 5, 2008 at 10:19 AM, Alex Fenton wrote: > Marlesson Santana wrote: > >> What would be the function equal to MSWWindowProc() ( >> http://www.wxwidgets.org/docs/faqmsw.htm#handlewm) to wxruby? >> > I don't believe there is an equivalent. Again, if you're looking to deal > with Windows=specific features, I would say the various Win32 libraries out > there for ruby would be a better place to look. > > wxRuby doesn't aim to be a complete re-implementation of wxWidgets in Ruby. > Rather it aims to provide a native, cross-platform GUI toolkit for Ruby by > using parts of wxWidgets. So a lot of non-GUI and cross-platform stuff is > omitted. > > > alex > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -- Mario Steele http://www.trilake.net http://www.ruby-im.net http://rubyforge.org/projects/wxruby/ http://rubyforge.org/projects/wxride/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Fri Jun 6 17:05:54 2008 From: lists at ruby-forum.com (Joseph Edelstein) Date: Fri, 6 Jun 2008 23:05:54 +0200 Subject: [wxruby-users] GenericDirCtrl problem Message-ID: I am having a problem getting any event to happen when I activate a selection on GenericDirCtrl i.e. double click on it. Could anyone help me out. thanks in advance. Joe Attachments: http://www.ruby-forum.com/attachment/2123/Random.rb -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Jun 6 17:07:13 2008 From: lists at ruby-forum.com (Joseph Edelstein) Date: Fri, 6 Jun 2008 23:07:13 +0200 Subject: [wxruby-users] GenericDirCtrl problem In-Reply-To: References: Message-ID: Joseph Edelstein wrote: > I am having a problem getting any event to happen when I activate a > selection on GenericDirCtrl i.e. double click on it. > > Could anyone help me out. > > thanks in advance. > > Joe Attachments: http://www.ruby-forum.com/attachment/2124/random.xrc -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Jun 6 17:07:27 2008 From: lists at ruby-forum.com (Joseph Edelstein) Date: Fri, 6 Jun 2008 23:07:27 +0200 Subject: [wxruby-users] GenericDirCtrl problem In-Reply-To: References: Message-ID: <16f5ceddc21f3125dad0f10c77629647@ruby-forum.com> Joseph Edelstein wrote: > Joseph Edelstein wrote: >> I am having a problem getting any event to happen when I activate a >> selection on GenericDirCtrl i.e. double click on it. >> >> Could anyone help me out. >> >> thanks in advance. >> >> Joe Attachments: http://www.ruby-forum.com/attachment/2125/random_frame.rb -- Posted via http://www.ruby-forum.com/. From mario at ruby-im.net Fri Jun 6 17:24:40 2008 From: mario at ruby-im.net (Mario Steele) Date: Fri, 6 Jun 2008 16:24:40 -0500 Subject: [wxruby-users] GenericDirCtrl problem In-Reply-To: <16f5ceddc21f3125dad0f10c77629647@ruby-forum.com> References: <16f5ceddc21f3125dad0f10c77629647@ruby-forum.com> Message-ID: Hey Joseph, The problem, is that GenericDirCtrl doesn't forward events that are used in the TreeCtrl (Which is what GenericDirCtrl is), what you need to do, is create an intermediate go between class, in order to get it, or do an Instance Evaluation on the object. Since your using XRC, my suggestion would be the latter. What you would do, is: @dirtree.instance_eval do # self is now @dirtree evt_tree_item_selected(self) do |evt| puts "Item has been selected, Item Text: #{self.get_item_text(evt.get_item)}" end end I've used this method, only using Inheriting from a GenericDirCtrl in my own custom class, for wxRIDE, to handle File System stuff. Hope this helps. On Fri, Jun 6, 2008 at 4:07 PM, Joseph Edelstein wrote: > Joseph Edelstein wrote: > > Joseph Edelstein wrote: > >> I am having a problem getting any event to happen when I activate a > >> selection on GenericDirCtrl i.e. double click on it. > >> > >> Could anyone help me out. > >> > >> thanks in advance. > >> > >> Joe > > > Attachments: > http://www.ruby-forum.com/attachment/2125/random_frame.rb > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -- Mario Steele http://www.trilake.net http://www.ruby-im.net http://rubyforge.org/projects/wxruby/ http://rubyforge.org/projects/wxride/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From bureaux.sebastien at neuf.fr Sat Jun 7 04:31:08 2008 From: bureaux.sebastien at neuf.fr (sebastien) Date: Sat, 7 Jun 2008 10:31:08 +0200 Subject: [wxruby-users] Gauge Message-ID: <8D4DD8CA8C884CAEB93E5ADCE457FF06@sebastien> Bonjour. Est-il possible de changer la couleur? sebastien http://beusse.liveror.com/ -------------- section suivante -------------- Une pi?ce jointe HTML a ?t? nettoy?e... URL: From amandus at gmail.com Tue Jun 10 14:27:21 2008 From: amandus at gmail.com (Albin Holmgren) Date: Tue, 10 Jun 2008 20:27:21 +0200 Subject: [wxruby-users] application using wxRuby: Albuin (OT?) Message-ID: <3a94ba0806101127l12d3c3a1p9188d163bba58a5d@mail.gmail.com> Hi. Just wanted to tell you that I've just uploaded Albuin - a music player I've been working on - to RubyForge. Albuin is heavily inspired by Muine - a music player for GNOME with a really nice and simple UI. As I'm stuck on windows (photoshop, autocad, archicad...) Albuin is my attempt to "port" Muine to windows. Using Ruby and WxRuby as a bonus it's (or rather: "will be") cross plattform. It is not a straight port and I have only glanced at Muines' C# source - it's the UI and not the code that has been stolen... ;-) Here's a screen shot: http://www.albinholmgren.se/albuin.png Please note that this is pre-alpha software. It's far from feature complete and only tested on windows with Ruby 1.8.6 and wxruby 1.9.7 on one machine. (As a side note 1.9.7 seems a lot more stable than 1.9.4 which crashed sporadicly - 1.9.7 has never crashed yet) Reports of problems on this or any other platform is welcome. The source is available from svn at rubyforge. Here's the project page: http://rubyforge.org/projects/albuin/ Check out doc/readme.txt for dependencies and a few random notes. Sorry if this is OT, but I thought that it might interest you to see your hard work getting used. Best regards, Albin Holmgren http://www.albinholmgren.se/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From sean.m.long at gmail.com Tue Jun 10 17:24:41 2008 From: sean.m.long at gmail.com (Sean Long) Date: Tue, 10 Jun 2008 14:24:41 -0700 Subject: [wxruby-users] application using wxRuby: Albuin (OT?) In-Reply-To: <3a94ba0806101127l12d3c3a1p9188d163bba58a5d@mail.gmail.com> References: <3a94ba0806101127l12d3c3a1p9188d163bba58a5d@mail.gmail.com> Message-ID: Albin thanks for the note about your app. I do not consider it off topic, now if you wrote every time you did a minor release that may be considered OT, a once in a while announcement is fine by me. Good to hear that 1.9.7 is more stable than 1.9.4, that is the goal! Alex and Mario have been working hard on reducing segfaults and memory leaks. The screen shot looks good, I will have to give it a go when I get some time. Sean On Tue, Jun 10, 2008 at 11:27 AM, Albin Holmgren wrote: > Hi. > > Just wanted to tell you that I've just uploaded Albuin - a music player > I've been working on - to RubyForge. > Albuin is heavily inspired by Muine - a music player for GNOME with a really > nice and simple UI. > As I'm stuck on windows (photoshop, autocad, archicad...) Albuin is my > attempt to "port" Muine to windows. > Using Ruby and WxRuby as a bonus it's (or rather: "will be") cross > plattform. It is not a straight port and I have only > glanced at Muines' C# source - it's the UI and not the code that has been > stolen... ;-) > > Here's a screen shot: http://www.albinholmgren.se/albuin.png > > Please note that this is pre-alpha software. It's far from feature complete > and only tested on windows with Ruby 1.8.6 and wxruby 1.9.7 on one machine. > (As a side note 1.9.7 seems a lot more stable than 1.9.4 which crashed > sporadicly - 1.9.7 has never crashed yet) > Reports of problems on this or any other platform is welcome. > > The source is available from svn at rubyforge. Here's the project > page:http://rubyforge.org/projects/albuin/ > Check out doc/readme.txt for dependencies and a few random notes. > > Sorry if this is OT, but I thought that it might interest you to see your > hard work getting used. > > Best regards, > Albin Holmgren > http://www.albinholmgren.se/ > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > From alex at pressure.to Wed Jun 11 06:21:10 2008 From: alex at pressure.to (Alex Fenton) Date: Wed, 11 Jun 2008 11:21:10 +0100 Subject: [wxruby-users] application using wxRuby: Albuin (OT?) In-Reply-To: <3a94ba0806101127l12d3c3a1p9188d163bba58a5d@mail.gmail.com> References: <3a94ba0806101127l12d3c3a1p9188d163bba58a5d@mail.gmail.com> Message-ID: <484FA716.5030907@pressure.to> Hi Albin Albin Holmgren wrote: > Just wanted to tell you that I've just uploaded Albuin - a music > player I've been working on - to RubyForge. > Albuin is heavily inspired by Muine - a music player for GNOME with a > really nice and simple UI. > As I'm stuck on windows (photoshop, autocad, archicad...) Albuin is my > attempt to "port" Muine to windows. > Using Ruby and WxRuby as a bonus it's (or rather: "will be") cross > plattform. It is not a straight port and I have only > glanced at Muines' C# source - it's the UI and not the code that has > been stolen... ;-) > > Here's a screen shot: http://www.albinholmgren.se/albuin.png Thanks for posting about this; I like what you have done with the UI. You might be interested in this: http://rubyonwindows.blogspot.com/2007/10/windows-xp-visual-style-controls-with.html > Please note that this is pre-alpha software. It's far from feature > complete and only tested on windows with Ruby 1.8.6 and wxruby 1.9.7 > on one machine. > (As a side note 1.9.7 seems a lot more stable than 1.9.4 which crashed > sporadicly - 1.9.7 has never crashed yet) Good to know that things are moving in the right direction in some places at least! Also nice to see that you're able to use some of the newer features eg drag and drop. > Reports of problems on this or any other platform is welcome. I tried to run the application from SVN but I got the following error: INFO MusicDatabase: Checking for existing tables WARN MusicDatabase: Creating new tables D:/WORK/Writing/rb/trunk/lib/MusicDatabase.rb:38:in `setup_datasets': undefined method `set_row_proc' for # (NoMethodError) from D:/WORK/Writing/rb/trunk/lib/MusicDatabase.rb:31:in `initialize' from D:/bin/ruby/lib/ruby/1.8/singleton.rb:95:in `new' from D:/bin/ruby/lib/ruby/1.8/singleton.rb:95:in `instance' from albuin.rb:31 My sequel version is the latest from rubygems, 2.0.1 > Sorry if this is OT, but I thought that it might interest you to see > your hard work getting used. Not at all; it's helpful to see what people are using wxRuby for. We have a page on the wiki listing real-life applications which can help people find sample code etc. I've added Albuin but you might want to edit the entry to provide more information http://wxruby.rubyforge.org/wiki/wiki.pl?OnlineCodeExamples best alex From lists at ruby-forum.com Thu Jun 12 04:00:19 2008 From: lists at ruby-forum.com (=?utf-8?Q?=c5=81ukasz_=c5=81api=c5=84ski?=) Date: Thu, 12 Jun 2008 10:00:19 +0200 Subject: [wxruby-users] Background thread - entension code - switch contexts Message-ID: <1f7eafca516a6f4c4f0fc0ced18235c9@ruby-forum.com> Hi, I am using wxRuby 1.9.7 and Ruby 1.8.6. I have built an extension in C++ and used swig to load it into Ruby interpreter, which works great. The extension is an often long executing algorithm, and I've noticed that if I fork a new Ruby thread in button clicked event, and in this thread run the algorithm the application freezes for the time of execution. I have looked through the archive and found that in the wxRuby main thread I need to use timer, but that does not work for the "algorithm thread", I dont know how to stop it or keep GUI responsive? Can anyone suggest what should I do. I know about Green Threads, and possibly that interpreter can not switch context when extension is running, so what should I do maybe use a thread at the side of extension (in c++ code) or maybe try to use the same mechanizm with timer as wxRuby does (but how to implement that). My code is simple: require 'wx' require 'cppapp' #myextension class MFrame < Wx::Frame STEPS = 100 def initialize super(nil,-1,"Title") set_client_size(Wx::Size.new(300,300)) panel = Wx::Panel.new(self) sizer = Wx::BoxSizer.new(Wx::VERTICAL) btn = Wx::Button.new(panel, -1, "Click me") sizer.add(btn, 0, Wx::GROW|Wx::ALL,2) evt_button(btn.get_id){ Thread.abort_on_exception = true #that does not work @th = Thread.new do Wx::Timer.every(20) do Thread.pass end method1 end } panel.set_sizer(sizer) sizer.fit(panel) end def method1 alg = Cppapp::Algorithm.new alg.form = Cppapp::Form.new alg.algorithmize end end class MApp < Wx::App def on_init MFrame.new.show Wx::Timer.every(20) {Thread.pass} end end MApp.new.main_loop -- Posted via http://www.ruby-forum.com/. From mario at ruby-im.net Thu Jun 12 07:39:37 2008 From: mario at ruby-im.net (Mario Steele) Date: Thu, 12 Jun 2008 06:39:37 -0500 Subject: [wxruby-users] Background thread - entension code - switch contexts In-Reply-To: <1f7eafca516a6f4c4f0fc0ced18235c9@ruby-forum.com> References: <1f7eafca516a6f4c4f0fc0ced18235c9@ruby-forum.com> Message-ID: Hey Lukasz, I looked over the code, and it looks good. Now you said you developed the C++ Extension yourself, so that gives you a bit more control then most. The problem is, Ruby's threads are green, and if you use an extension that doesn't recognize that Ruby is Green Threaded, and yield control back to it, it'll effectivly do as you are seeing, freezing. With the examples we've given, we're using Ruby's core code, or using Sockets, with key point select() calls. Ruby's core code, and select() are specifically programmed to allow for Green Threads to be used. When you use select() in Ruby, it's not a "true" call to the os level select. It's timed to be used within Ruby's Threads itself. What you will need to do, is make your C++ Extension aware of Ruby Threads. You will need to look at how to add rb_thread_yield() to your swig'ed code, to allow when an interation through your algorithim is completed, it will call rb_thread_yield(), to allow a pass from the C/C++ Code, back to Ruby code, so that it can do it's iteration/processing, before giving control back to your C/C++ Extension. That, unfortunatly, is the only way you will be able to improve upon the problem you are facing. Hope this helps, Mario Steele On Thu, Jun 12, 2008 at 3:00 AM, ?ukasz ?api?ski wrote: > Hi, > > I am using wxRuby 1.9.7 and Ruby 1.8.6. I have built an extension in C++ > and used swig to load it into Ruby interpreter, which works great. The > extension is an often long executing algorithm, and I've noticed that if > I fork a new Ruby thread in button clicked event, and in this thread run > the algorithm the application freezes for the time of execution. I have > looked through the archive and found that in the wxRuby main thread I > need to use timer, but that does not work for the "algorithm thread", I > dont know how to stop it or keep GUI responsive? Can anyone suggest what > should I do. I know about Green Threads, and possibly that interpreter > can not switch context when extension is running, so what should I do > maybe use a thread at the side of extension (in c++ code) or maybe try > to use the same mechanizm with timer as wxRuby does (but how to > implement that). > > > My code is simple: > > > require 'wx' > require 'cppapp' #myextension > > class MFrame < Wx::Frame > STEPS = 100 > def initialize > super(nil,-1,"Title") > set_client_size(Wx::Size.new(300,300)) > panel = Wx::Panel.new(self) > sizer = Wx::BoxSizer.new(Wx::VERTICAL) > > btn = Wx::Button.new(panel, -1, "Click me") > sizer.add(btn, 0, Wx::GROW|Wx::ALL,2) > > evt_button(btn.get_id){ > > Thread.abort_on_exception = true > #that does not work > @th = Thread.new do > Wx::Timer.every(20) do > Thread.pass > end > method1 > end > > } > panel.set_sizer(sizer) > sizer.fit(panel) > end > > def method1 > alg = Cppapp::Algorithm.new > alg.form = Cppapp::Form.new > alg.algorithmize > end > end > > class MApp < Wx::App > def on_init > MFrame.new.show > Wx::Timer.every(20) {Thread.pass} > end > end > MApp.new.main_loop > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -- Mario Steele http://www.trilake.net http://www.ruby-im.net http://rubyforge.org/projects/wxruby/ http://rubyforge.org/projects/wxride/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Thu Jun 12 12:52:47 2008 From: lists at ruby-forum.com (=?utf-8?Q?=c5=81ukasz_=c5=81api=c5=84ski?=) Date: Thu, 12 Jun 2008 18:52:47 +0200 Subject: [wxruby-users] Background thread - entension code - switch contexts In-Reply-To: References: <1f7eafca516a6f4c4f0fc0ced18235c9@ruby-forum.com> Message-ID: Mario Steele wrote: > You will need to look at how to add rb_thread_yield() to your swig'ed > code, > to allow when an interation through your algorithim is completed, it > will > call rb_thread_yield(), to allow a pass from the C/C++ Code, back to > Ruby > code, so that it can do it's iteration/processing, before giving control > back to your C/C++ Extension. That, unfortunatly, is the only way you > will > be able to improve upon the problem you are facing. > > Hope this helps, > > Mario Steele Thank you, I believe that is the only and good direction :). Now I will investigate that. If I could use some tips of yours :) I think I should place it somewhere here (the algorithm function) SWIGINTERN VALUE _wrap_Algorithm_algorithmize(int argc, VALUE *argv, VALUE self) { Algorithm *arg1 = (Algorithm *) 0 ; void *argp1 = 0 ; int res1 = 0 ; if ((argc < 0) || (argc > 0)) { rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; } res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_Algorithm, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "Algorithm *","algorithmize", 1, self )); } arg1 = reinterpret_cast< Algorithm * >(argp1); #HERE CREATE A THREAD FROM algorithmize function? (arg1)->algorithmize(); return Qnil; fail: return Qnil; } I still don't know where to get the ruby thread that I should pass to rb_thread_yield(VALUE arg, rb_thread_t th) Should I create it or get current ruby thread in the place marked above in the code and then pass it to the algorithmize(rb_thread_t th) and then in this function void Algorithm::algorithmize(rb_thread_t th) { time_t seconds; seconds = time (NULL); time_t tmp = 0; int nb = 0; //iterations while((tmp = time(NULL) - seconds) < 4) { if(tmp > nb) { nb++; #THIS GOES IN THE ITERATION rb_thread_yield(some_VALUE, rh); } } } Kind regards, ?ukasz ?api?ski -- Posted via http://www.ruby-forum.com/. From mario at ruby-im.net Fri Jun 13 01:25:54 2008 From: mario at ruby-im.net (Mario Steele) Date: Fri, 13 Jun 2008 00:25:54 -0500 Subject: [wxruby-users] Background thread - entension code - switch contexts In-Reply-To: References: <1f7eafca516a6f4c4f0fc0ced18235c9@ruby-forum.com> Message-ID: Hello again Lukasz, On Thu, Jun 12, 2008 at 11:52 AM, ?ukasz ?api?ski wrote: > Thank you, I believe that is the only and good direction :). Now I will > investigate that. > No problem. > > If I could use some tips of yours :) > > I think I should place it somewhere here (the algorithm function) > I'm sorry, I meant the use of rb_thread_pass(), instead of rb_thread_yield(). rb_thread_yield() is pretty much like the internal rb_yield(), which yields control back to Ruby, with some variable passed. Generally meant for Blocks. Where as rb_thread_pass() is meant to pass control back to the Ruby Thread Scheduler, and on to the next thread in the list of threads. > Should I create it or get current ruby thread in the place marked above > in the code and then pass it to the algorithmize(rb_thread_t th) and > then in this function > You are partly right, again rb_thread_yield() is not the method to go with, my apologizes, but your idea for Algorithim::algorithmize() would be the best solution, only replace rb_thread_yield() with rb_thread_pass(). The main thing you need to look at, is allowing Ruby's Thread Scheduler back control, so that it can give processing time to other Ruby Threads. If you don't do that, then all other threads will freeze till your C/C++ routine is completed. And that is not what you want. > void Algorithm::algorithmize(rb_thread_t th) { > > time_t seconds; > > seconds = time (NULL); > time_t tmp = 0; > int nb = 0; > > //iterations > while((tmp = time(NULL) - seconds) < 4) > { > if(tmp > nb) > { > nb++; > #THIS GOES IN THE ITERATION > rb_thread_yield(some_VALUE, rh); > } > } > } > Good luck, Mario Steele > > Kind regards, > ?ukasz ?api?ski > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -- Mario Steele http://www.trilake.net http://www.ruby-im.net http://rubyforge.org/projects/wxruby/ http://rubyforge.org/projects/wxride/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Fri Jun 13 05:19:26 2008 From: lists at ruby-forum.com (=?utf-8?Q?=c5=81ukasz_=c5=81api=c5=84ski?=) Date: Fri, 13 Jun 2008 11:19:26 +0200 Subject: [wxruby-users] Background thread - entension code - switch contexts In-Reply-To: References: <1f7eafca516a6f4c4f0fc0ced18235c9@ruby-forum.com> Message-ID: <4b44f2e504d5d9f3a1c249a69b71e189@ruby-forum.com> Hi, thanks for help, Finally I have used void rb_thread_schedule() function which is not static and I can declare it to be extern in my C++ extension, what I did is extern "C" { extern void rb_thread_schedule(); } using namespace std; void Algorithm::algorithmize() { time_t seconds; seconds = time (NULL); time_t tmp = 0; float nb = 0; //iterations while((tmp = time(NULL) - seconds) < 5) { if(tmp > nb) { cout< After I ran my program through Rubyscript2exe, the Random.exe file that it created is causing the following error: D:\Ruby projects>random.exe C:\DOCUME~1\JEDELS~1\eee\eee.Random.exe.2\app\Random.rb:59: undefined method 'ru n' for Wxruby2::App (NoMethodError) from C:\DOCUME~1\JEDELS~1\eee\eee.Random.exe.2\bootstrap.rb:77:in `load' from C:\DOCUME~1\JEDELS~1\eee\eee.Random.exe.2\bootstrap.rb:77 The program runs fine when run from the Random.rb file. I want to create an exe for others that do not have Ruby installed on their Computer. I am attaching my Ruby code: begin require 'rubygems' rescue LoadError end require 'rubyscript2exe' require 'Wx' include Wx require 'random_frame.rb' RUBYSCRIPT2EXE.bin = ["random.xrc"] RUBYSCRIPT2EXE.bin = ["random_frame.rb"] def random_process file = @file_path.split("\\") @file_path = file.join("\\\\") @file_path << "\\Random.txt" random_file = File.new(@file_path , "w") i = 0 max = @max_number.to_i b = 10 ** (@number_of_digits.to_i - 1) random_seed = 10 ** (@number_of_digits.to_i) g = 0 g_max =100 @progress_guage.set_value(0) while i < max a = rand(random_seed) if (a > b) then random_file.puts a i = i + 1 while ((i/max) * 100) > (@progress_guage.get_value()) @progress_guage.pulse() sleep(0.08) end#gauge while end #if end #while end#def class RandomFrame < RandomBase def initialize super evt_button(start_button) {|event| on_start(event)} end def on_start(event) path = @dirtree.get_path() if location_textbox.get_value().length == 0 then @location_textbox.clear @location_textbox.append_text(path) end @max_number = number_of_random_textbox.get_value() @number_of_digits = number_of_digits_textbox.get_value() @file_path = location_textbox.get_value() if (@number_of_digits.to_i == 0) or (@max_number.to_i == 0) then elsif path.length == 0 then else random_process end#if end end App.run do RandomFrame.new.show end Attachments: http://www.ruby-forum.com/attachment/2182/random.xrc -- Posted via http://www.ruby-forum.com/. From mario at ruby-im.net Fri Jun 13 18:26:49 2008 From: mario at ruby-im.net (Mario Steele) Date: Fri, 13 Jun 2008 17:26:49 -0500 Subject: [wxruby-users] Rubyscript2exe undefined 'run' method In-Reply-To: <324047a382e85d6c102425148e6ec1c0@ruby-forum.com> References: <324047a382e85d6c102425148e6ec1c0@ruby-forum.com> Message-ID: Hello Joesph, Yeah, Rubyscript2exe has this problem, the only thing that we can suggest, is to change the code: App.run do RandomFrame.new.show end Into: class RandomApp < App def on_init() RandomFrame.new.show end end RandomApp.new.main_loop() RubyScript2EXE does not like the App.run method for some reason, and I can't personally figure out why, Alex may know, but that will allow your app to run. L8ers, Mario Steele On Fri, Jun 13, 2008 at 5:20 PM, Joseph Edelstein wrote: > After I ran my program through Rubyscript2exe, the Random.exe file that > it created is causing the following error: > D:\Ruby projects>random.exe > C:\DOCUME~1\JEDELS~1\eee\eee.Random.exe.2\app\Random.rb:59: undefined > method 'ru > n' for Wxruby2::App (NoMethodError) > from > C:\DOCUME~1\JEDELS~1\eee\eee.Random.exe.2\bootstrap.rb:77:in `load' > > from C:\DOCUME~1\JEDELS~1\eee\eee.Random.exe.2\bootstrap.rb:77 > > The program runs fine when run from the Random.rb file. I want to > create an exe for others that do not have Ruby installed on their > Computer. > > > I am attaching my Ruby code: > > > begin > require 'rubygems' > rescue LoadError > end > > require 'rubyscript2exe' > require 'Wx' > include Wx > require 'random_frame.rb' > RUBYSCRIPT2EXE.bin = ["random.xrc"] > RUBYSCRIPT2EXE.bin = ["random_frame.rb"] > def random_process > file = @file_path.split("\\") > @file_path = file.join("\\\\") > @file_path << "\\Random.txt" > random_file = File.new(@file_path , "w") > i = 0 > max = @max_number.to_i > b = 10 ** (@number_of_digits.to_i - 1) > random_seed = 10 ** (@number_of_digits.to_i) > g = 0 > g_max =100 > @progress_guage.set_value(0) > while i < max > a = rand(random_seed) > if (a > b) then > random_file.puts a > i = i + 1 > while ((i/max) * 100) > (@progress_guage.get_value()) > > @progress_guage.pulse() > sleep(0.08) > end#gauge while > end #if > end #while > end#def > > class RandomFrame < RandomBase > def initialize > super > evt_button(start_button) {|event| on_start(event)} > end > def on_start(event) > path = @dirtree.get_path() > if location_textbox.get_value().length == 0 then > @location_textbox.clear > @location_textbox.append_text(path) > end > @max_number = number_of_random_textbox.get_value() > @number_of_digits = number_of_digits_textbox.get_value() > @file_path = location_textbox.get_value() > if (@number_of_digits.to_i == 0) or (@max_number.to_i == 0) then > elsif path.length == 0 then > else > random_process > end#if > end > end > App.run do > RandomFrame.new.show > end > > Attachments: > http://www.ruby-forum.com/attachment/2182/random.xrc > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -- Mario Steele http://www.trilake.net http://www.ruby-im.net http://rubyforge.org/projects/wxruby/ http://rubyforge.org/projects/wxride/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Fri Jun 13 18:47:29 2008 From: lists at ruby-forum.com (Joseph Edelstein) Date: Sat, 14 Jun 2008 00:47:29 +0200 Subject: [wxruby-users] Rubyscript2exe undefined 'run' method In-Reply-To: References: <324047a382e85d6c102425148e6ec1c0@ruby-forum.com> Message-ID: <7a2fa0fdec4e6d916c71eb71ab925d62@ruby-forum.com> Mario, That code fixed the problem with load. However it shows a problem know with Gauge. Does it also not like a gauge? C:/DOCUME~1/JEDELS~1/eee/eee.Random.exe.2/lib/random_frame.rb:26:in `find_window _by_id': Error wrapping object; class `wxGauge95' is not supported in wxRuby (No tImplementedError) from C:/DOCUME~1/JEDELS~1/eee/eee.Random.exe.2/lib/random_frame.rb:26:in `initialize' from C:/DOCUME~1/JEDELS~1/eee/eee.Random.exe.2/lib/random_frame.rb:39:in `call' from C:/DOCUME~1/JEDELS~1/eee/eee.Random.exe.2/lib/random_frame.rb:39:in `initialize' from C:\DOCUME~1\JEDELS~1\eee\eee.Random.exe.2\app\Random.rb:39:in `init ialize' from C:\DOCUME~1\JEDELS~1\eee\eee.Random.exe.2\app\Random.rb:60:in `new' from C:\DOCUME~1\JEDELS~1\eee\eee.Random.exe.2\app\Random.rb:60:in `on_i nit' from C:\DOCUME~1\JEDELS~1\eee\eee.Random.exe.2\app\Random.rb:64:in `main _loop' from C:\DOCUME~1\JEDELS~1\eee\eee.Random.exe.2\app\Random.rb:64 from C:\DOCUME~1\JEDELS~1\eee\eee.Random.exe.2\bootstrap.rb:77:in `load' from C:\DOCUME~1\JEDELS~1\eee\eee.Random.exe.2\bootstrap.rb:77 Mario Steele wrote: -- Posted via http://www.ruby-forum.com/. From mario at ruby-im.net Fri Jun 13 19:01:53 2008 From: mario at ruby-im.net (Mario Steele) Date: Fri, 13 Jun 2008 18:01:53 -0500 Subject: [wxruby-users] Rubyscript2exe undefined 'run' method In-Reply-To: <7a2fa0fdec4e6d916c71eb71ab925d62@ruby-forum.com> References: <324047a382e85d6c102425148e6ec1c0@ruby-forum.com> <7a2fa0fdec4e6d916c71eb71ab925d62@ruby-forum.com> Message-ID: Hey Joesph, I knew I had seen this error before. The problem lies with XRC being genereated by what I belive is Dialog Blocks that your using. It attempts to create the Guage that is "Platform" specific. What you need to do, is go into your generated XRC file, change any instances of wxGuage95, into just wxGuage, that will allow Ruby to correctly create the guage, without the trouble. Hope this helps, Mario Steele On Fri, Jun 13, 2008 at 5:47 PM, Joseph Edelstein wrote: > Mario, > > That code fixed the problem with load. However it shows a problem know > with Gauge. > > Does it also not like a gauge? > > C:/DOCUME~1/JEDELS~1/eee/eee.Random.exe.2/lib/random_frame.rb:26:in > `find_window > _by_id': Error wrapping object; class `wxGauge95' is not supported in > wxRuby (No > tImplementedError) > from > C:/DOCUME~1/JEDELS~1/eee/eee.Random.exe.2/lib/random_frame.rb:26:in > `initialize' > from > C:/DOCUME~1/JEDELS~1/eee/eee.Random.exe.2/lib/random_frame.rb:39:in > `call' > from > C:/DOCUME~1/JEDELS~1/eee/eee.Random.exe.2/lib/random_frame.rb:39:in > `initialize' > from > C:\DOCUME~1\JEDELS~1\eee\eee.Random.exe.2\app\Random.rb:39:in `init > ialize' > from > C:\DOCUME~1\JEDELS~1\eee\eee.Random.exe.2\app\Random.rb:60:in `new' > > from > C:\DOCUME~1\JEDELS~1\eee\eee.Random.exe.2\app\Random.rb:60:in `on_i > nit' > from > C:\DOCUME~1\JEDELS~1\eee\eee.Random.exe.2\app\Random.rb:64:in `main > _loop' > from C:\DOCUME~1\JEDELS~1\eee\eee.Random.exe.2\app\Random.rb:64 > from > C:\DOCUME~1\JEDELS~1\eee\eee.Random.exe.2\bootstrap.rb:77:in `load' > > from C:\DOCUME~1\JEDELS~1\eee\eee.Random.exe.2\bootstrap.rb:77 > > Mario Steele wrote: > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -- Mario Steele http://www.trilake.net http://www.ruby-im.net http://rubyforge.org/projects/wxruby/ http://rubyforge.org/projects/wxride/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Fri Jun 13 19:17:38 2008 From: lists at ruby-forum.com (Joseph Edelstein) Date: Sat, 14 Jun 2008 01:17:38 +0200 Subject: [wxruby-users] Rubyscript2exe undefined 'run' method In-Reply-To: References: <324047a382e85d6c102425148e6ec1c0@ruby-forum.com> <7a2fa0fdec4e6d916c71eb71ab925d62@ruby-forum.com> Message-ID: <82043619c46c95f451f60f339fc6f800@ruby-forum.com> I just checked my XRC file. The file had wxGuage listed already with no mention of wxGuage95. I did create the XRC with Dialog Blocks however. Mario Steele wrote: > Hey Joesph, > > I knew I had seen this error before. The problem lies with XRC being > genereated by what I belive is Dialog Blocks that your using. It > attempts > to create the Guage that is "Platform" specific. What you need to do, > is go > into your generated XRC file, change any instances of wxGuage95, into > just > wxGuage, that will allow Ruby to correctly create the guage, without the > trouble. > > Hope this helps, > > Mario Steele > > On Fri, Jun 13, 2008 at 5:47 PM, Joseph Edelstein Attachments: http://www.ruby-forum.com/attachment/2183/random.xrc -- Posted via http://www.ruby-forum.com/. From mario at ruby-im.net Fri Jun 13 19:51:05 2008 From: mario at ruby-im.net (Mario Steele) Date: Fri, 13 Jun 2008 18:51:05 -0500 Subject: [wxruby-users] Rubyscript2exe undefined 'run' method In-Reply-To: <82043619c46c95f451f60f339fc6f800@ruby-forum.com> References: <324047a382e85d6c102425148e6ec1c0@ruby-forum.com> <7a2fa0fdec4e6d916c71eb71ab925d62@ruby-forum.com> <82043619c46c95f451f60f339fc6f800@ruby-forum.com> Message-ID: Okay, After doing some research, and digging up some of the old bugs, I found this to be a bug that we use to have in the 1.9.3 -> 1.9.4 releases of wxRuby. Are you using a version of wxRuby previous to 1.9.4/1.9.5? It's recommended that you be using 1.9.7 of wxRuby, as that is the most recent, and most stable version of wxRuby. On Fri, Jun 13, 2008 at 6:17 PM, Joseph Edelstein wrote: > I just checked my XRC file. The file had wxGuage listed already with no > mention of wxGuage95. I did create the XRC with Dialog Blocks however. > > Mario Steele wrote: > > Hey Joesph, > > > > I knew I had seen this error before. The problem lies with XRC being > > genereated by what I belive is Dialog Blocks that your using. It > > attempts > > to create the Guage that is "Platform" specific. What you need to do, > > is go > > into your generated XRC file, change any instances of wxGuage95, into > > just > > wxGuage, that will allow Ruby to correctly create the guage, without the > > trouble. > > > > Hope this helps, > > > > Mario Steele > > > > On Fri, Jun 13, 2008 at 5:47 PM, Joseph Edelstein > > > Attachments: > http://www.ruby-forum.com/attachment/2183/random.xrc > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -- Mario Steele http://www.trilake.net http://www.ruby-im.net http://rubyforge.org/projects/wxruby/ http://rubyforge.org/projects/wxride/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Mon Jun 16 11:53:49 2008 From: lists at ruby-forum.com (Joseph Edelstein) Date: Mon, 16 Jun 2008 17:53:49 +0200 Subject: [wxruby-users] Rubyscript2exe undefined 'run' method In-Reply-To: References: <324047a382e85d6c102425148e6ec1c0@ruby-forum.com> <7a2fa0fdec4e6d916c71eb71ab925d62@ruby-forum.com> <82043619c46c95f451f60f339fc6f800@ruby-forum.com> Message-ID: First, Thank you for all the research you have done. I double-checked and I am using the 1.9.7 version of WxRuby. I also did a little research and found that if I comment out everything about the gauge I get another NoMethodError, this time for the 'acquire_id' for the button. Seems to me that something is not getting added to the Random.exe that I am trying to create. Any idea on what I am doing wrong? Joe Mario Steele wrote: > Okay, > > After doing some research, and digging up some of the old bugs, I found > this > to be a bug that we use to have in the 1.9.3 -> 1.9.4 releases of > wxRuby. > Are you using a version of wxRuby previous to 1.9.4/1.9.5? It's > recommended > that you be using 1.9.7 of wxRuby, as that is the most recent, and most > stable version of wxRuby. > > On Fri, Jun 13, 2008 at 6:17 PM, Joseph Edelstein -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Tue Jun 17 04:19:30 2008 From: alex at pressure.to (Alex Fenton) Date: Tue, 17 Jun 2008 09:19:30 +0100 Subject: [wxruby-users] Rubyscript2exe undefined 'run' method In-Reply-To: References: <324047a382e85d6c102425148e6ec1c0@ruby-forum.com> <7a2fa0fdec4e6d916c71eb71ab925d62@ruby-forum.com> <82043619c46c95f451f60f339fc6f800@ruby-forum.com> Message-ID: <48577392.2070608@pressure.to> Joseph Edelstein wrote: > First, Thank you for all the research you have done. > > I double-checked and I am using the 1.9.7 version of WxRuby. I also did > a little research and found that if I comment out everything about the > gauge I get another NoMethodError, this time for the 'acquire_id' for > the button. Seems to me that something is not getting added to the > Random.exe that I am trying to create. > The errors about "wxGauge95" and "acquire_id" would both occur if some parts of the wxRuby library written in Ruby weren't included. The relevant parts should be in lib/wx/classes - in this case, lib/wx/classes/gauge.rb and lib/wx/classes/evthandler.rb. The rubyscript2exe pages have info about unpacking and examining the contents of an executable. Could you try unpacking the generated executable and see if those components are there in the right place please? The structure should be something like lib/wx.rb ... lib/wx/classes/gauge.rb alex From alex at pressure.to Tue Jun 17 04:36:40 2008 From: alex at pressure.to (Alex Fenton) Date: Tue, 17 Jun 2008 09:36:40 +0100 Subject: [wxruby-users] Gauge In-Reply-To: <8D4DD8CA8C884CAEB93E5ADCE457FF06@sebastien> References: <8D4DD8CA8C884CAEB93E5ADCE457FF06@sebastien> Message-ID: <48577798.70804@pressure.to> sebastien wrote: > Est-il possible de changer la couleur? [Is it possible to change the colour of a Wx::Gauge?] Pas partout; gauge est un widget natif, est donc, il porte la couleur donn?e par le syst?me [Not everywhere; gauge is a native widget, and so it takes the colour given by the OS] alex From lists at ruby-forum.com Wed Jun 25 16:39:40 2008 From: lists at ruby-forum.com (Joseph Edelstein) Date: Wed, 25 Jun 2008 22:39:40 +0200 Subject: [wxruby-users] xrc xrcsie new user question Message-ID: <57f70f9fef48c44e54cc9d8750e2650b@ruby-forum.com> I am doing something wrong or missing a step. I am trying to get a panel that I made in DialogBlocks to come up in wxRuby. I made the XRC and ran xrcise on it. I am getting an error when trying to start it. Ruby code: begin require 'rubygems' rescue LoadError end require 'wx' include Wx require 'bogus_panel.rb' class BogusPanel < Bogus_panel def initialize(parent) super(parent) end#def initialize end class BogusFrame < Wx::Frame def initialize super BogusPanel.new(self).set_focus end#def initialize end#end Class class BogusApp < App def on_init() BogusFrame.new.show end end BogusApp.new.main_loop() xrcsie generated code: # This class was automatically generated from XRC source. It is not # recommended that this file is edited directly; instead, inherit from # this class and extend its behaviour there. # # Source file: bogus_panel.xrc # Generated at: Tue Jun 24 09:27:40 -0700 2008 begin require 'rubygems' rescue LoadError end require 'wx' include Wx class Bogus_panel < Wx::Panel attr_reader :num_of_fields_textbox, :ddid_textbox, :company_textbox, :first_name_textbox, :last_name_textbox, :add1_textbox, :add2_textbox, :city_textbox, :state_textbox, :zip_textbox, :country_textbox, :email_textbox, :phone_textbox, :fax_textbox, :title_textbox, :source_textbox, :source_button, :result_textbox, :result_button, :gauge_box, :preview_button, :start_button def initialize(parent = nil) super() xml = Wx::XmlResource.get xml.flags = 2 # Wx::XRC_NO_SUBCLASSING xml.init_all_handlers xml.load("bogus_panel.xrc") xml.load_panel_subclass(self, parent, "Bogus_panel") finder = lambda do | x | int_id = Wx::xrcid(x) begin Wx::Window.find_window_by_id(int_id, self) || int_id # Temporary hack to work around regression in 1.9.2; remove # begin/rescue clause in later versions rescue RuntimeError int_id end end @num_of_fields_textbox = finder.call("num_of_fields_textbox") @ddid_textbox = finder.call("ddid_textbox") @company_textbox = finder.call("company_textbox") @first_name_textbox = finder.call("first_name_textbox") @last_name_textbox = finder.call("last_name_textbox") @add1_textbox = finder.call("add1_textbox") @add2_textbox = finder.call("add2_textbox") @city_textbox = finder.call("city_textbox") @state_textbox = finder.call("state_textbox") @zip_textbox = finder.call("zip_textbox") @country_textbox = finder.call("country_textbox") @email_textbox = finder.call("email_textbox") @phone_textbox = finder.call("phone_textbox") @fax_textbox = finder.call("fax_textbox") @title_textbox = finder.call("title_textbox") @source_textbox = finder.call("source_textbox") @source_button = finder.call("source_button") @result_textbox = finder.call("Result_textbox") @result_button = finder.call("result_button") @gauge_box = finder.call("gauge_box") @preview_button = finder.call("preview_BUTTON") @start_button = finder.call("start_button") if self.class.method_defined? "on_init" self.on_init() end end end Attachments: http://www.ruby-forum.com/attachment/2251/bogus_panel.xrc -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Jun 25 23:44:51 2008 From: lists at ruby-forum.com (Zhimin Zhan) Date: Thu, 26 Jun 2008 05:44:51 +0200 Subject: [wxruby-users] Wx::ArrayTreeItemIds not exists Message-ID: Hi, Wx::ArrayTreeItemIds used in Wx::TreeCtrl#get_selections unsigned int get_selections(ArrayTreeItemIds selection) wxRuby version: wxruby-1.9.6-x86-mingw32. Thanks in advance. Regards, Zhimin -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Thu Jun 26 13:26:51 2008 From: alex at pressure.to (Alex Fenton) Date: Thu, 26 Jun 2008 18:26:51 +0100 Subject: [wxruby-users] xrc xrcsie new user question In-Reply-To: <57f70f9fef48c44e54cc9d8750e2650b@ruby-forum.com> References: <57f70f9fef48c44e54cc9d8750e2650b@ruby-forum.com> Message-ID: <4863D15B.6060009@pressure.to> Hi Joseph Joseph Edelstein wrote: > I am doing something wrong or missing a step. I am trying to get a > panel that I made in DialogBlocks to come up in wxRuby. I made the XRC > and ran xrcise on it. I am getting an error when trying to start it. > Thanks for the report. You turned up a problem in wxRuby which means that the current version isn't able to load a Wx::Panel subclass from XRC. I have fixed this in our source repository, but for now you could get round this by starting from a top-level window type of "Frame" in your GUI editor, instead of Panel. In DialogBlocks, it should be straightforward to drag and drop your Panel layout into a new "Frame" class. You also missed a step, which is that you must set the "name" of the XRC class you're loading to be Bogus_panel, instead of the default ID_PANEL1, as in the attachment you posted. Thanks again alex From alex at pressure.to Thu Jun 26 13:42:21 2008 From: alex at pressure.to (Alex Fenton) Date: Thu, 26 Jun 2008 18:42:21 +0100 Subject: [wxruby-users] Wx::ArrayTreeItemIds not exists In-Reply-To: References: Message-ID: <4863D4FD.9000004@pressure.to> Hi Zhimin Zhimin Zhan wrote: > Wx::ArrayTreeItemIds used in Wx::TreeCtrl#get_selections > > unsigned int get_selections(ArrayTreeItemIds selection) > Thank you for the report. This bug is now fixed in Subversion for the next release. alex From amandus at gmail.com Sat Jun 28 13:22:08 2008 From: amandus at gmail.com (Albin Holmgren) Date: Sat, 28 Jun 2008 19:22:08 +0200 Subject: [wxruby-users] catch all key events in frame? Message-ID: <3a94ba0806281022k7669fc8cp570e3cba6e8317d1@mail.gmail.com> Hi. How do I best capture *all* key events in a frame. Specifically: In Albuin I want to delete selected songs in the playlist when the user presses 'del' - no matter what control in the frame happens to be in focused atm. What event should I bind to and to which control? (as a side note, the latest svn of albuin fixed the alexs' problem with sequel-2.x - never, ever, use depreched methods... :-) Thanks, Albin Holmgren -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex at pressure.to Sat Jun 28 17:50:16 2008 From: alex at pressure.to (Alex Fenton) Date: Sat, 28 Jun 2008 22:50:16 +0100 Subject: [wxruby-users] catch all key events in frame? In-Reply-To: <3a94ba0806281022k7669fc8cp570e3cba6e8317d1@mail.gmail.com> References: <3a94ba0806281022k7669fc8cp570e3cba6e8317d1@mail.gmail.com> Message-ID: <4866B218.9070507@pressure.to> Hi Albin Albin Holmgren wrote: > How do I best capture *all* key events in a frame. Specifically: In > Albuin I want to delete selected songs in the playlist when the user > presses 'del' - no matter what control in the frame happens to be in > focused atm. What event should I bind to and to which control? For that sort of thing you could use an accelerator table, which creates keyboard shortcuts for menu items. This example makes the 'backspace' key a shortcut for the Wx::ID_EXIT menu item (assuming self is a Wx::Frame) tbl = Wx::AcceleratorTable.new [Wx::ACCEL_NORMAL, Wx::K_BACK, Wx::ID_EXIT ] self.accelerator_table = tbl The code for del is Wx::K_DEL. As an aside, Mac laptops don't generally have a 'del' key so it may not be the best choice for a shortcut. > (as a side note, the latest svn of albuin fixed the alexs' problem > with sequel-2.x - never, ever, use depreched methods... :-) Thanks; I'll give it a whirl when I get a moment. alex From therion at ninth-art.de Mon Jun 30 06:41:19 2008 From: therion at ninth-art.de (Georg Bege) Date: Mon, 30 Jun 2008 12:41:19 +0200 Subject: [wxruby-users] Issue with Wx::Image class, especially set_data Message-ID: <4868B84F.8090300@ninth-art.de> Hello Hopefully some developer will see this too. I've problems using set_data method for example with wxruby 1.9.7/ruby 1.8.6 on mswin32. It always crashes: ..../classes/bitmap.rb:17: [BUG] segmentation fault On my Linux it works fine (thats no suprise of course). Probably somebody has a clue - I exported this raw data also with get_data, I guess this should be platform independent or not? cheers -- Georg 'Therion' Bege http://coruscant.info http://www.ninth-art.de therion at ninth-art.de !DSPAM:4868b85f132156216567211! From alex at pressure.to Mon Jun 30 07:04:02 2008 From: alex at pressure.to (Alex Fenton) Date: Mon, 30 Jun 2008 12:04:02 +0100 Subject: [wxruby-users] Issue with Wx::Image class, especially set_data In-Reply-To: <4868B84F.8090300@ninth-art.de> References: <4868B84F.8090300@ninth-art.de> Message-ID: <4868BDA2.9070002@pressure.to> Georg Bege wrote: > Hopefully some developer will see this too. > I've problems using set_data method for example with wxruby 1.9.7/ruby > 1.8.6 on mswin32. > It always crashes: > ..../classes/bitmap.rb:17: [BUG] segmentation fault > > On my Linux it works fine (thats no suprise of course) Thanks for the report. I developed it on OS X and tried it on Linux, and I've not had any problems. Could you post a minimal sample of the code you're using that reproduces the fault, and also give us an idea of what you're trying to achieve? > Probably somebody has a clue - I exported this raw data also with > get_data, I guess this should be platform independent or not? Yes - Wx::Bitmap is a platform-dependent image, Wx::Image is platform independent thanks alex From lists at ruby-forum.com Mon Jun 30 07:27:07 2008 From: lists at ruby-forum.com (Lc Yeap) Date: Mon, 30 Jun 2008 13:27:07 +0200 Subject: [wxruby-users] Drawing state diagram with wxruby Message-ID: Greetings, I am just started to use wxruby to create GUI for my project. i need to draw a state diagram based on some summary file. May i know is there any way in wxruby that allow people to draw circle and add text on it? Thanks a lot. -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Mon Jun 30 07:32:16 2008 From: alex at pressure.to (Alex Fenton) Date: Mon, 30 Jun 2008 12:32:16 +0100 Subject: [wxruby-users] Drawing state diagram with wxruby In-Reply-To: References: Message-ID: <4868C440.5010706@pressure.to> Lc Yeap wrote: > I am just started to use wxruby to create GUI for my project. i need to > draw a state diagram based on some summary file. May i know is there any > way in wxruby that allow people to draw circle and add text on it? > Yes, there is. Have a look at the documentation for "device contexts" http://wxruby.rubyforge.org/doc/#device_contexts And also the samples in the samples/drawing hth alex From lists at ruby-forum.com Mon Jun 30 10:47:50 2008 From: lists at ruby-forum.com (Gabriel Rios) Date: Mon, 30 Jun 2008 16:47:50 +0200 Subject: [wxruby-users] Printing Problem: text very small Message-ID: <9d7d67e9bb450c2bed55d8cdc4009d05@ruby-forum.com> hi people, Im trying to print some report but the text is too small, so as im not understanding much of the code of the printing example, i would like to know if there is any other reference i could read to solve that problem. thanks -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Mon Jun 30 14:08:19 2008 From: alex at pressure.to (Alex Fenton) Date: Mon, 30 Jun 2008 19:08:19 +0100 Subject: [wxruby-users] Printing Problem: text very small In-Reply-To: <9d7d67e9bb450c2bed55d8cdc4009d05@ruby-forum.com> References: <9d7d67e9bb450c2bed55d8cdc4009d05@ruby-forum.com> Message-ID: <48692113.8070407@pressure.to> Hi Gabriel Rios wrote: > Im trying to print some report but the text is too small, so as im not > understanding much of the code of the printing example, i would like to > know if there is any other reference i could read to solve that problem. Take a look at: http://docs.wxwidgets.org/stable/wx_printingoverview.html#printingoverview In particular Wx::Printout has some methods to get scaling from screen to print dimensions http://docs.wxwidgets.org/stable/wx_wxprintout.html#wxprintout In Wx they have recently added helper methods to map sizes - I've added a tracker item for us to add these to wxRuby too. Lastly, you could look into using HtmlEasyPrinting which makes printing a lot easier if your report format makes sense as simple HTML. hth alex From lists at ruby-forum.com Mon Jun 30 20:25:00 2008 From: lists at ruby-forum.com (Lc Yeap) Date: Tue, 1 Jul 2008 02:25:00 +0200 Subject: [wxruby-users] Drawing state diagram with wxruby In-Reply-To: <4868C440.5010706@pressure.to> References: <4868C440.5010706@pressure.to> Message-ID: <4d0fb842c1b931539dc83033d96df5bc@ruby-forum.com> Alex Fenton wrote: > Lc Yeap wrote: >> I am just started to use wxruby to create GUI for my project. i need to >> draw a state diagram based on some summary file. May i know is there any >> way in wxruby that allow people to draw circle and add text on it? >> > Yes, there is. Have a look at the documentation for "device contexts" > > http://wxruby.rubyforge.org/doc/#device_contexts > > And also the samples in the samples/drawing > > hth > alex Hi Alex, thanks for the useful information provided. :) I am expecting the code will generate the drawing automatically based on the information in a text file. Will continue to work on it. Hope it won't be hard.. -- Posted via http://www.ruby-forum.com/.