From eliben at gmail.com Fri Feb 1 02:30:10 2008 From: eliben at gmail.com (Eli Bendersky) Date: Fri, 1 Feb 2008 09:30:10 +0200 Subject: [wxruby-users] wxruby2 problems Message-ID: <95cf475a0801312330vd4721f4g726cc575d467ee8f@mail.gmail.com> Hello, I've recently installed wxruby2 (version 1.9.4) from a precompiled mswin32 gem. It seems to work fine, and the samples in the distribution all work, but I have a couple of peculiar problems: 1) When I package a trivial wxruby script with rubyscript2exe, the executable is huge - 8.5 MB. With previous versions of wxruby (prior to wxruby2, I think) it was much smaller. Less than 3 MB. Is this how much the new wxruby takes, or am I doing something wrong ? Note: Alex Fenton answered in the Ruby list that it's a script2exe bug. Could you please elaborate on the steps needed to reduce the exe size ? 2) [warning: this is bizarre!] While running a script with a wxruby GUI, my mouse (trackball, actually) becomes much slower. It's configured to be quite fast because I have a large script, but slows down (by a factor of 2, at least) while the script is running. When the script exits, the cursor regains its original speed. This does not happen with simple ruby scripts (those without wxruby) This simple hello world app (from the website) causes the problem as well: require "wx" include Wx class HelloWorld < App # a new class which derives from the Wx::App class def on_init # we're defining what the application is going to do when it starts helloframe = Frame.new(nil, -1, "Hello World") # it's going to make a frame entitled "Hello World" StaticText.new(helloframe,-1,"Hello World") # it's going to put the text "Hello World" in that frame helloframe.show() # and then it's going to make the window appear end end HelloWorld.new.main_loop # and this line makes it actually do it! Please help, Eli -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080201/a2bdf0f8/attachment.html From alex at pressure.to Fri Feb 1 06:04:12 2008 From: alex at pressure.to (Alex Fenton) Date: Fri, 01 Feb 2008 11:04:12 +0000 Subject: [wxruby-users] wxruby2 problems In-Reply-To: <95cf475a0801312330vd4721f4g726cc575d467ee8f@mail.gmail.com> References: <95cf475a0801312330vd4721f4g726cc575d467ee8f@mail.gmail.com> Message-ID: <47A2FCAC.3060700@pressure.to> Eli Bendersky wrote: > > 1) When I package a trivial wxruby script with rubyscript2exe, the > executable is huge - 8.5 MB. With previous versions of wxruby (prior > to wxruby2, I think) it was much smaller. Less than 3 MB. Is this how > much the new wxruby takes, or am I doing something wrong ? > > Note: Alex Fenton answered in the Ruby list that it's a script2exe > bug. Could you please elaborate on the steps needed to reduce the exe > size ? > (Plain text is preferred on this list, please) 1) Create the .exe file using rubyscript2exe as normal rubyscript2exe my_app.rb 2) Run the newly-created .exe file with the argument --eee-justextract my_app.exe --eee-justextract 3) Edit the file "myapp/app.eee". Delete the line reading "f bin\wxruby2.so" 4) Change into the directory and repack the executable cd my_app eee.exe app.eee ../my_new_app.exe 5) Test that my_new_app.exe works. It should be about 3-4MB smaller than the original I have reported this bug to the maintainer of rs2exe, but haven't had any response. > 2) [warning: this is bizarre!] While running a script with a wxruby > GUI, my mouse (trackball, actually) becomes much slower. It's > configured to be quite fast because I have a large script, but slows > down (by a factor of 2, at least) while the script is running. When > the script exits, the cursor regains its original speed. This does not > happen with simple ruby scripts (those without wxruby) > Strange, I have never seen this before. Do you have any special software for your trackball, or are you just using your standard system settings to make it fast? Does is slow down across the whole system, or just when you're in the wxRuby app? alex From eliben at gmail.com Fri Feb 1 08:19:47 2008 From: eliben at gmail.com (Eli Bendersky) Date: Fri, 1 Feb 2008 15:19:47 +0200 Subject: [wxruby-users] wxruby2 problems Message-ID: <95cf475a0802010519o4a22a918t71bc795698eb5979@mail.gmail.com> Thanks for the repacking directions with rs2exe ! > 2) [warning: this is bizarre!] While running a script with a wxruby > GUI, my mouse (trackball, actually) becomes much slower. It's > configured to be quite fast because I have a large script, but slows > down (by a factor of 2, at least) while the script is running. When > the script exits, the cursor regains its original speed. This does not > happen with simple ruby scripts (those without wxruby) > |Strange, I have never seen this before. Do you have any special software |for your trackball, or are you just using your standard system settings |to make it fast? Does is slow down across the whole system, or just when |you're in the wxRuby app? I'm not using any special software, just the usual Windows mouse settings. It slows down only when I'm in the wxRuby app. It also happens in apps packed by rs2exe. Interestingly, it doesn't happen with apps written in the previous version of wxRuby. Eli From echobinary at gmail.com Sun Feb 3 23:13:55 2008 From: echobinary at gmail.com (EchoB) Date: Sun, 03 Feb 2008 23:13:55 -0500 Subject: [wxruby-users] Grid vs GridTableBase| + Sequel + SQLite3 Message-ID: <47A69103.8090508@gmail.com> Hey all, Wondering if i could get an example of working code that ties Sequel (or any other database layer) into a GridTableBase and then into a Grid. I am just now trying it and i cant seem to get it to work - no errors (well - sometimes) but it is also not displaying anything. Code follows: class TimeFrame < Wx::Frame def initialize() .... .... @time_grid = Wx::Grid.new(self, -1) @time_grid_table = TimeTableBase.new()** ... end def on_go_button_pressed(evt) ..... .... # define a recordset that can contain 0 or more rows (0 rows will not make it nil) if recordset != nil column_no = 1 p recordset.columns @time_grid_table.append_cols(recordset.columns.length) recordset.columns.each {|column| @time_grid_table.set_col_label_value(column_no, column.to_s) column_no = column_no +1 } @time_grid_table.insert_rows(2) @time_grid.set_table(@time_grid_table) end end ################## ** class TimeTableBase < Wx::GridTableBase def initialize super() end def get_attr row, col, attr_kind ## end def get_number_rows super.get_number_rows() end def get_number_cols super.get_number_cols() end def get_col_label_value col super.get_col_label_value(col) end def is_empty_cell row, col super.is_empty_cell(row, col) end def get_value row, col super.get_value(row, col) end end From alex at pressure.to Tue Feb 5 07:49:08 2008 From: alex at pressure.to (Alex Fenton) Date: Tue, 05 Feb 2008 12:49:08 +0000 Subject: [wxruby-users] Grid vs GridTableBase| + Sequel + SQLite3 In-Reply-To: <47A69103.8090508@gmail.com> References: <47A69103.8090508@gmail.com> Message-ID: <47A85B44.1040201@pressure.to> EchoB wrote: > Hey all, > Wondering if i could get an example of working code that ties Sequel (or > any other database layer) into a GridTableBase and then into a Grid. > It depends what your'e trying to do with the database. I couldn't work out what your sample code was meant to do. There's nothing that says if you're working with a SQL db, you must use GridTableBase. If you simply want to display results from a SQL query as rows in a Grid, it might well be easier to populate the Grid with create_table and set_cell_value, and not mess around with GridTable. GridTable is probably useful if: 1) You have a huge dataset, and want to avoid loading it all at once. GridTable will only load cell values as they are visible. 2) There is a tight connection between a cell's value and a stored value; then you can overload set_value in your GridTable class and write any changes straight back to the database. > I am just now trying it and i cant seem to get it to work - no errors > (well - sometimes) but it is also not displaying anything. A couple of things stick out: - you should call Grid#set_table, once, immediately after initialising the grid, not in an event handler. - you must return valid values (not call super) for the methods listed in the GridTableBase documentation (get_number_cols, is_empty_cell etc) alex From lists at ruby-forum.com Wed Feb 6 09:33:23 2008 From: lists at ruby-forum.com (Echo Binary) Date: Wed, 6 Feb 2008 15:33:23 +0100 Subject: [wxruby-users] Grid vs GridTableBase| + Sequel + SQLite3 In-Reply-To: <47A85B44.1040201@pressure.to> References: <47A69103.8090508@gmail.com> <47A85B44.1040201@pressure.to> Message-ID: Alex Fenton wrote: > It depends what your'e trying to do with the database. I couldn't work > out what your sample code was meant to do. I get that a lot :-D > There's nothing that says if you're working with a SQL db, you must use > GridTableBase. If you simply want to display results from a SQL query as > rows in a Grid, it might well be easier to populate the Grid with > create_table and set_cell_value, and not mess around with GridTable. I thought about it, and thats what I was initially trying to do, but GridTable _sounds_ nicer. I want to do things like sorting, and grouping, and other stuff on the fly. Are there any working examples of how to use GridTableBase? >From http://wxruby.rubyforge.org/doc/gridtablebase.html I get that in order to use the class I have to at least override: * get_attr- "May be overridden to handle attributes directly in the table." * get_number_cols- "Should return the total number of columns in the grid. You must override this functions in a derived table class." * get_number_rows- "Should return the total number of rows in the grid. You must override these functions in a derived table class." * get_value- "Should return the content of the specified cell as a Ruby string. You must override this function in a derived table class." * is_empty_cell- "Should return true if a cell is empty. You must override this function in a derived table class." To me this seems to say that the gridtablebase is depending on the grid (which is depending on the gridtablebase for information) for information. (That made my head hurt) Perhaps an updated version of bigdemo.rb? :-D Anyways, thanks for bearing with me! :EchoBinary -- Posted via http://www.ruby-forum.com/. From sven612wr at suska.org Mon Feb 11 05:40:54 2008 From: sven612wr at suska.org (Sven Suska) Date: Mon, 11 Feb 2008 11:40:54 +0100 Subject: [wxruby-users] chart extension for wxRuby? In-Reply-To: References: <47A22486.3080303@pressure.to> Message-ID: <200802111140.54367.sven612wr@suska.org> Hello, sounds interesting. A chart extension would be very useful for me. Any news yet? Sven Am Donnerstag, 2008-Januar-31 20:47:04 schrieb Ellis, Peter: > That's fantastic! I'll definitely took a closer look at this. > > P > > -----Original Message----- > From: wxruby-users-bounces at rubyforge.org > [mailto:wxruby-users-bounces at rubyforge.org] On Behalf Of Alex Fenton > Sent: Thursday, January 31, 2008 12:42 PM > To: General discussion of wxRuby > Subject: Re: [wxruby-users] chart extension for wxRuby? > > Ellis, Peter wrote: > > Thanks, Alex. > > > > I was hoping that we wouldn't have to create our own, but we might do > > it > > > if that turns out to be the best solution. I'll keep the list posted. > > Following your earlier message I had a closer look at Scruffy and Gruff. > > Scruffy has the drawing code very nicely separated from the logic that > organises the chart elements. So in about 20 mins I was able to replace > enough of the svg-based drawing code with dc-based code to get it to > draw the chart background, title, frame, axis and labels in a Wx::Window > > (see below for the app code) > > It's a fairly mechanical job of replacing calls to svg.text with > dc.draw_text, svg.line with dc.draw_line etc in scruffy/components and > scruffy/layers. I'm sure the individual chart types would need a little > more work, but each is still only a couple of calls to the same basic > methods. I would recommend looking into it. > > hth > alex > > __ > require 'scruffy' > require 'wx' > > class Chart < Wx::Window > attr_reader :graph > def initialize(*args) > super > evt_paint :on_paint > @graph = Scruffy::Graph.new(:title => "Monthly Profits") > graph.add(:line, 'John', [100, -20, 30, 60]) > graph.add(:line, 'Sara', [120, 50, -80, 20]) > end > > def on_paint > paint do | dc | > graph.render(dc, :width => size.width, :height => size.height) > end > end > end > > > Wx::App.run do > frame = Wx::Frame.new(nil, :title => 'chart demo') > chart = Chart.new(frame) > frame.show > end > > > > _______________________________________________ > 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 From alec at arlross.demon.co.uk Mon Feb 11 09:56:53 2008 From: alec at arlross.demon.co.uk (Alec Ross) Date: Mon, 11 Feb 2008 14:56:53 +0000 Subject: [wxruby-users] [OT] Rice 1.0.0 - Ruby Interface for C++ Extensions Message-ID: I guess that some folks might not have seen: http://tinyurl.com/2uzh4k yet, but would be interested. Regards, Alec -- Alec Ross From jacekwiktor at gmail.com Sun Feb 17 11:15:28 2008 From: jacekwiktor at gmail.com (Jacek Nowak) Date: Sun, 17 Feb 2008 17:15:28 +0100 Subject: [wxruby-users] A bug in wxRuby. Segmentation fault in random situations. Message-ID: <570d9b010802170815p2750966br89e5d65ce70584f3@mail.gmail.com> Hello, I wrote an application in wxRuby: ruby 1.8.6 wxruby 1.9.4 installed from gem windows xp sp2 After several minutes of running it crashes with the following error: "c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27: [BUG] Segmentation fault ruby 1.8.6 (2007-03-13) [i386-mswin32] This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information." The biggest problem is that it is extremely difficult for me to find the cause of the error because: 1. I don't get the normal exception so I cannot find the line of code which causes the error - the application merely crashes with the message cited above 2. the crash occurs randomly in different situations, basicly when an event like pressing a button, opening a window, changing focus, etc. occurs (it doesn't occur when I don't touch the mouse/keyboard) - but I am unable to reproduce any of the crashes - when it crashes for instance after clicking button X, next time I can click button X a hundred of times and everything works perfectly until it crashes on pressing button Y, I think you know what I mean The application has already about 160kb of source code and I have completely no idea what causes the crash. Anyway I think I should get an exception, not a crash so I assume this is a bug in wxRuby. I thought that maybe the crash occurs on first garbage collection but it's not the case - when I run GC manually somewhere in my application (ObjectSpace.garbage_collect) it doesn't crash. What can I do in this situation? I have an application which is almost finished but completely useless because of those random crashes :( Can someone help me? How can I debug the application to actually see the reason of the crash? -- Jacek Nowak jacekwiktor at gmail.com From mario at ruby-im.net Sun Feb 17 12:26:49 2008 From: mario at ruby-im.net (Mario Steele) Date: Sun, 17 Feb 2008 11:26:49 -0600 Subject: [wxruby-users] A bug in wxRuby. Segmentation fault in random situations. In-Reply-To: <570d9b010802170815p2750966br89e5d65ce70584f3@mail.gmail.com> References: <570d9b010802170815p2750966br89e5d65ce70584f3@mail.gmail.com> Message-ID: Hello Jacek, Well, the first thing you can try, to see if it's a Garbage Collection problem, is to add to the top of your application GC.disable. Now, this will cause increased memory usage by your program, cause objects will not be destroyed / recycled. This is just to see if this is truely a Garbage Collection problem or not. The next thing that is helpful for us for tracking down these problems, is some basic information about the program, what is it's main purpose, what Wx classes are you implementing in your program, this would allow us to be able to trace where the problem may be occuring. You don't have to list every single control you have created in the app, just a overview of controls, like TextCtrl, StyledTextCtrl, Menu, Button, Grid, like that. This way we can also check and see if there's already an open bug concerning the segmentation fault due to a certian class. Lastly, tracking down random crashes is very hard to track, even for us. When a Segmentation Fault occurs, there is no "Rescue" mode for us to be able to throw an Exception. (Atleast not to my knowledge, Maybe Alex or Sean know something I don't.) Basically, when random crashes occur, the best thing we can suggest, is utilizing gdb, but that is only available on Linux and Mac OS X, so tracking down this kind of problem is very hard to trace on Windows XP. Like I said, Alex or Sean may have something up their sleves, but for now, try doing what I suggested here, and give us a report on what you find out, and we'll try to go from there. Thanks, Mario Steele On 2/17/08, Jacek Nowak wrote: > > Hello, > > I wrote an application in wxRuby: > ruby 1.8.6 > wxruby 1.9.4 installed from gem > windows xp sp2 > > After several minutes of running it crashes with the following error: > > "c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27: [BUG] > Segmentation fault > ruby 1.8.6 (2007-03-13) [i386-mswin32] > > This application has requested the Runtime to terminate it in an unusual > way. > Please contact the application's support team for more information." > > > The biggest problem is that it is extremely difficult for me to find > the cause of the error because: > 1. I don't get the normal exception so I cannot find the line of code > which causes the error - the application merely crashes with the > message cited above > 2. the crash occurs randomly in different situations, basicly when an > event like pressing a button, opening a window, changing focus, etc. > occurs (it doesn't occur when I don't touch the mouse/keyboard) - but > I am unable to reproduce any of the crashes - when it crashes for > instance after clicking button X, next time I can click button X a > hundred of times and everything works perfectly until it crashes on > pressing button Y, I think you know what I mean > > The application has already about 160kb of source code and I have > completely no idea what causes the crash. > Anyway I think I should get an exception, not a crash so I assume this > is a bug in wxRuby. > > I thought that maybe the crash occurs on first garbage collection but > it's not the case - when I run GC manually somewhere in my application > (ObjectSpace.garbage_collect) it doesn't crash. > > What can I do in this situation? > I have an application which is almost finished but completely useless > because of those random crashes :( > Can someone help me? > How can I debug the application to actually see the reason of the crash? > > -- > Jacek Nowak > jacekwiktor at gmail.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/ http://rubyforge.org/projects/vwmc/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080217/f4f34140/attachment.html From lists at ruby-forum.com Sun Feb 17 18:59:25 2008 From: lists at ruby-forum.com (Tim Ferrell) Date: Mon, 18 Feb 2008 00:59:25 +0100 Subject: [wxruby-users] problem with Gauge on windows xp... Message-ID: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com> I am new to wxRuby and just built a simple app with a frame containing a static text control and two gauges ... I used DialogBlocks to design the ui, and wx_sugar to generate a base class via xrcise, etc... All of this works peachy on my development box (Mac OSX ~ Leopard) with the latest gems... However, I tried running this little app on my Windows XP box and got the following exception: ./stream_downloader_gui.rb:25:in `find_window_by_id': Error wrapping object; cla ss `wxGauge95' is not supported in wxRuby (NotImplementedError) from ./stream_downloader_gui.rb:25:in `initialize' from ./stream_downloader_gui.rb:34:in `call' from ./stream_downloader_gui.rb:34:in `initialize' from E:/stream_downloader/stream_downloader.rb:25:in `initialize' from E:/stream_downloader/stream_downloader.rb:58:in `new' from E:/stream_downloader/stream_downloader.rb:58:in `initialize' from E:/stream_downloader/stream_downloader.rb:191:in `new' from E:/stream_downloader/stream_downloader.rb:191:in `on_init' from E:/stream_downloader/stream_downloader.rb:201:in `main_loop' from E:/stream_downloader/stream_downloader.rb:201 I figure this has something to do with the gem trying to instantiate a Gauge95 instead of a GaugeMSW or a Gauge, but I see nothing in the docs that suggests a solution... Any ideas? Thanks much, Tim -- Posted via http://www.ruby-forum.com/. From mario at ruby-im.net Sun Feb 17 23:19:42 2008 From: mario at ruby-im.net (Mario Steele) Date: Sun, 17 Feb 2008 22:19:42 -0600 Subject: [wxruby-users] problem with Gauge on windows xp... In-Reply-To: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com> References: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com> Message-ID: Hello Tim, Yes, you are correct in your assumption, that wxRuby is trying to initialize wxGuage95, and not finding it. Dialog Blocks has a bad habbit of trying to create a unique Class for C++ Code Generation, in which it creates a Sub-Class of the main class. What you would want to do, is edit your xml file, and change Guage95 into just Guage. This will allow wxRuby to correctly interpret the class you are actually trying to create. I have found, that Dialog Blocks is a bit of an encumberance when dealing with creating GUI's for wxRuby myself. Others have had excellent success, so it's all in your point of view. I would suggest checking out wxFormBuilder as an alternative to Dialog Blocks. The website is: http://www.wxformbuilder.org/ I find I have a lot more success with this RAD Tool, then any other I have ran into. Let me know if you try it out, and what you think of it, same with your problem to. L8ers, Mario Steele On 2/17/08, Tim Ferrell wrote: > > > I am new to wxRuby and just built a simple app with a frame containing a > static text control and two gauges ... I used DialogBlocks to design the > ui, and wx_sugar to generate a base class via xrcise, etc... All of this > works peachy on my development box (Mac OSX ~ Leopard) with the latest > gems... > > However, I tried running this little app on my Windows XP box and got > the following exception: > > ./stream_downloader_gui.rb:25:in `find_window_by_id': Error wrapping > object; cla > ss `wxGauge95' is not supported in wxRuby (NotImplementedError) > from ./stream_downloader_gui.rb:25:in `initialize' > from ./stream_downloader_gui.rb:34:in `call' > from ./stream_downloader_gui.rb:34:in `initialize' > from E:/stream_downloader/stream_downloader.rb:25:in > `initialize' > from E:/stream_downloader/stream_downloader.rb:58:in `new' > from E:/stream_downloader/stream_downloader.rb:58:in > `initialize' > from E:/stream_downloader/stream_downloader.rb:191:in `new' > from E:/stream_downloader/stream_downloader.rb:191:in `on_init' > from E:/stream_downloader/stream_downloader.rb:201:in > `main_loop' > from E:/stream_downloader/stream_downloader.rb:201 > > I figure this has something to do with the gem trying to instantiate a > Gauge95 instead of a GaugeMSW or a Gauge, but I see nothing in the docs > that suggests a solution... Any ideas? > > Thanks much, > Tim > -- > 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/ http://rubyforge.org/projects/vwmc/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080217/83777a81/attachment.html From sven612wr at suska.org Mon Feb 18 08:14:32 2008 From: sven612wr at suska.org (Sven Suska) Date: Mon, 18 Feb 2008 14:14:32 +0100 Subject: [wxruby-users] chart extension for wxRuby? In-Reply-To: <47A22486.3080303@pressure.to> References: <47A22486.3080303@pressure.to> Message-ID: <200802181414.32395.sven612wr@suska.org> Am Donnerstag, 2008-Januar-31 20:41:58 schrieb Alex Fenton: > So in about 20 mins I was able to replace > enough of the svg-based drawing code with dc-based code to get it to > draw the chart background, title, frame, axis and labels in a Wx::Window > (see below for the app code) > > It's a fairly mechanical job of replacing calls to svg.text with > dc.draw_text, svg.line with dc.draw_line etc in scruffy/components and > scruffy/layers. I'm sure the individual chart types would need a little > more work, but each is still only a couple of calls to the same basic > methods. I would recommend looking into it. > I had a look at it, but it still looks too complex for me. Can anybody provide some concrete code pieces? Any help appreciated. Sven > __ > require 'scruffy' > require 'wx' > > class Chart < Wx::Window > attr_reader :graph > def initialize(*args) > super > evt_paint :on_paint > @graph = Scruffy::Graph.new(:title => "Monthly Profits") > graph.add(:line, 'John', [100, -20, 30, 60]) > graph.add(:line, 'Sara', [120, 50, -80, 20]) > end > > def on_paint > paint do | dc | > graph.render(dc, :width => size.width, :height => size.height) > end > end > end > > > Wx::App.run do > frame = Wx::Frame.new(nil, :title => 'chart demo') > chart = Chart.new(frame) > frame.show > end > > > From lists at ruby-forum.com Mon Feb 18 09:01:18 2008 From: lists at ruby-forum.com (Tim Ferrell) Date: Mon, 18 Feb 2008 15:01:18 +0100 Subject: [wxruby-users] problem with Gauge on windows xp... In-Reply-To: References: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com> Message-ID: <71e9fa0e205b3fc18cbd8510e2be02d6@ruby-forum.com> Mario Steele wrote: > Hello Tim, Hey Mario... > > Yes, you are correct in your assumption, that wxRuby is trying to > initialize > wxGuage95, and not finding it. Dialog Blocks has a bad habbit of trying > to > create a unique Class for C++ Code Generation, in which it creates a > Sub-Class of the main class. What you would want to do, is edit your > xml > file, and change Guage95 into just Guage. This will allow wxRuby to > correctly interpret the class you are actually trying to create. > That thought did occur to me and I looked into it... Here is the relevant snippet from the xrc: current file progress 0 100 and I saw no direct reference to Gauge95... At this point I wondering if it is just a problem with the way the wxWidgets part of the binary gem was compiled... I may try stepping back to the 1.9.3 gem and see how things behave, or maybe just try building it myself... Thanks for the tip about wxFormBuilder ... I'll look into that as well. :-) Cheers, Tim -- Posted via http://www.ruby-forum.com/. From zpeng1 at yahoo.com Mon Feb 18 09:29:27 2008 From: zpeng1 at yahoo.com (Zhang Peng) Date: Mon, 18 Feb 2008 06:29:27 -0800 (PST) Subject: [wxruby-users] hang on leopard Message-ID: <407545.7956.qm@web59304.mail.re1.yahoo.com> Hello ... I'm a newbie to ruby and wxruby. I'm trying to create 1 frame (the app) that creates 2 dialog boxes. Each dialog box has wxtextctrl, and 1 dialog class has 1 thread and the other has 2 threads. At first, I suspect the problem is with the thread interaction between ruby and wxwidget. I spent countless hours to try to figure out why the hang. Yes, I know the trick to use the Timer class to work ... Just out of curiosity, I tried to run the same code with no changes on Windows XP running under Parallels on my Leopard, and to my surprise, it works like a champ ..... Any advise on what I might be doing wrong? Thanks in advance! ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080218/a8174b05/attachment.html From alex at pressure.to Mon Feb 18 09:42:15 2008 From: alex at pressure.to (Alex Fenton) Date: Mon, 18 Feb 2008 14:42:15 +0000 Subject: [wxruby-users] hang on leopard In-Reply-To: <407545.7956.qm@web59304.mail.re1.yahoo.com> References: <407545.7956.qm@web59304.mail.re1.yahoo.com> Message-ID: <47B99947.70608@pressure.to> Hi Zhang Peng wrote: > I'm a newbie to ruby and wxruby. Welcome > > I'm trying to create 1 frame (the app) that creates 2 dialog boxes. > Each dialog box has wxtextctrl, and 1 dialog class has 1 thread and > the other has 2 threads. Why are you using separate threads - what sort of work is being done in the subordinate threads? Is it the GUI that is hanging, or the non-GUI tasks? I would definitely not advise running wxRuby GUI code outside the main GUI thread. > Just out of curiosity, I tried to run the same code with no changes on > Windows XP running under Parallels on my Leopard, and to my surprise, > it works like a champ ..... > > Any advise on what I might be doing wrong? Hard to say anything further without seeing a short working example. cheers alex From zpeng1 at yahoo.com Mon Feb 18 12:01:33 2008 From: zpeng1 at yahoo.com (Zhang Peng) Date: Mon, 18 Feb 2008 09:01:33 -0800 (PST) Subject: [wxruby-users] hang on leopard Message-ID: <766633.62283.qm@web59301.mail.re1.yahoo.com> Hi Alex, Thanks for the quick reply. I appreciate it. My apps has 3 user threads: 1. A dialog box that shows numbers in flashing fashion. This dialog has a number thread that shows a number, sleep, show next number, sleep, .... 2. A dialog box that shows running time (one thread), and another thread running waiting for the number thread to finish showing the numbers, and wait for a user to type in the result of adding up those numbers. BTW, at one point, my code is working fine on leopard, but it keeps giving me the following error once every 5 tries or so: *** Exception handlers were not properly removed. Some code has jumped or returned out of an NS_DURING...NS_HANDLER region without using the NS_VOIDRETURN or NS_VALUERETURN macros. And, I was trying to so many things to try to get rid of that error, and I'm now in a state where when I run the code, it works like a champ in the 1st try, but when I try it again for the second time, the whole thing hang .... I.e., beach ball spinning, and I have to kill the process to get out of it. Note that as I said in my original post, the same code runs fine on Windows XP .... I could be wrong, but I don't think I run GUI thread ... I have a dialog based class, and I create a thread or two inside the class. In other words, I do not use Thread.new to initiate the dialog class. I tried to make smaller example, but the problem did not show up. The project itself is not big since I'm trying things out. only 4 small ruby files. I do not mind sending the files if you are interested in seeing and running it. Sincerely ... Zhang Peng ----- Original Message ---- From: Alex Fenton To: General discussion of wxRuby Sent: Monday, February 18, 2008 8:42:15 AM Subject: Re: [wxruby-users] hang on leopard Hi Zhang Peng wrote: > I'm a newbie to ruby and wxruby. Welcome > > I'm trying to create 1 frame (the app) that creates 2 dialog boxes. > Each dialog box has wxtextctrl, and 1 dialog class has 1 thread and > the other has 2 threads. Why are you using separate threads - what sort of work is being done in the subordinate threads? Is it the GUI that is hanging, or the non-GUI tasks? I would definitely not advise running wxRuby GUI code outside the main GUI thread. > Just out of curiosity, I tried to run the same code with no changes on > Windows XP running under Parallels on my Leopard, and to my surprise, > it works like a champ ...... > > Any advise on what I might be doing wrong? Hard to say anything further without seeing a short working example. cheers alex _______________________________________________ wxruby-users mailing list wxruby-users at rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080218/efe880ae/attachment.html From alex at pressure.to Mon Feb 18 12:24:21 2008 From: alex at pressure.to (Alex Fenton) Date: Mon, 18 Feb 2008 17:24:21 +0000 Subject: [wxruby-users] hang on leopard In-Reply-To: <766633.62283.qm@web59301.mail.re1.yahoo.com> References: <766633.62283.qm@web59301.mail.re1.yahoo.com> Message-ID: <47B9BF45.5020204@pressure.to> Zhang Zhang Peng wrote: > 1. A dialog box that shows numbers in flashing fashion. This dialog > has a number thread that shows a number, sleep, show next number, > sleep, .... > > 2. A dialog box that shows running time (one thread), and another > thread running waiting for the number thread to finish showing the > numbers, and wait for a user to type in the result of adding up those > numbers. It sounds like you are using the Threads just to time events rather than carry out more complex background tasks. In this case I would strongly recommend that you use Wx::Timer directly. This will give you more accurate timing than using threads and sleep, and will avoid the complexity of using threads as well. As of 1.9.4, there's simple idioms for using Timer: Wx::Timer.every(milliseconds) do # repeated event end Wx::Timer.after(milliseconds) do # delayed event end There's an example of a ticking clock in bigdemo/wxStatusBar.rbw in the samples, which uses Wx::Timer. This might be helpful. cheers alex From lists at ruby-forum.com Mon Feb 18 12:42:00 2008 From: lists at ruby-forum.com (Tim Ferrell) Date: Mon, 18 Feb 2008 18:42:00 +0100 Subject: [wxruby-users] problem with Gauge on windows xp... In-Reply-To: <71e9fa0e205b3fc18cbd8510e2be02d6@ruby-forum.com> References: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com> <71e9fa0e205b3fc18cbd8510e2be02d6@ruby-forum.com> Message-ID: <3c12d9b081e028f0cf6a8eba5c7b72e4@ruby-forum.com> Well, figuring that this had something to do with loading from an xrc, I redid my code to just create the dialog by hand... I get a dialog now, without error, but something seems messed up with event handling... I cannot move or close the dialog, the Cancel button does not paint... the gauges work though :-p Again, this all works fine for me on my Mac - I only see this weirdness on Windows (XP) ... I'm sure it is some detail I am overlooking or, being so new to this, something I am misinterpreting... Attached is my code in hopes that someone will spot something... (this is just a small app to parse an m3u playlist and download the mp3s found there) ---- here be code ------ #!/usr/bin/env ruby # stdlib require 'fileutils' require 'open-uri' require 'tmpdir' # gems require 'rubygems' require 'wx' # # StreamDownloaderProgress class # # progress dialog for the downloads... # class StreamDownloaderProgress < Wx::Frame attr_accessor :status_label, :progress_item, :progress_all, :cancel_button attr_accessor :cancelled def initialize super(nil, -1, StreamDownloader::TITLE, Wx::DEFAULT_POSITION, Wx::Size.new(350, 120), Wx::MINIMIZE_BOX | Wx::SYSTEM_MENU | Wx::CAPTION | Wx::CLOSE_BOX) sizer = Wx::BoxSizer.new(Wx::VERTICAL) # label @status_label = Wx::StaticText.new(self, -1, "Preparing downloads... please wait.", Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE) sizer.add(@status_label, 1, Wx::GROW | Wx::ALL | Wx::ALIGN_LEFT | Wx::FIXED_MINSIZE, 2) # item progress @progress_item = Wx::Gauge.new(self, -1, 100, Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE, Wx::GA_HORIZONTAL) @progress_item.set_tool_tip("current item progress") @progress_item.value = 0 sizer.add(@progress_item, 1, Wx::GROW | Wx::HORIZONTAL, 2) # all progress @progress_all = Wx::Gauge.new(self, -1, 100, Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE, Wx::GA_HORIZONTAL) @progress_all.set_tool_tip("overall progress") @progress_all.value = 0 sizer.add(@progress_all, 1, Wx::GROW | Wx::HORIZONTAL, 2) # cancel button @cancel_button = Wx::Button.new(self, -1, 'Cancel', Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE) @cancel_button.set_tool_tip("cancel downloads") sizer.add(@cancel_button, 1, Wx::ALIGN_CENTER_HORIZONTAL, 2) self.set_sizer(sizer) # on close simply set var to show intention evt_close { |e| @cancelled = true } evt_button(@cancel_button) { |e| @cancelled = true } # set up location/controls self.center(Wx::BOTH) self.layout end end # # StreamDownloader class # # main class where all the work is donw # class StreamDownloader attr_accessor :destdir attr_reader :urls attr :m3ufile attr :dialog NAME = 'Stream Downloader' VERSION = '1.0.0' TITLE = "#{NAME} #{VERSION}" def initialize # init our progress dialog @dialog = StreamDownloaderProgress.new Wx::get_app.yield # set up our destdir based on platform if RUBY_PLATFORM =~ /mswin32/ @destdir = File.join("C:/Documents and Settings", ENV['USERNAME'], 'Desktop') elsif RUBY_PLATFORM =~ /darwin/ @destdir = File.join(ENV['HOME'], 'Desktop') else @destdir = File.expand_path(File.dirname(__FILE__)) end end def ask fd = Wx::FileDialog.new(@dialog, 'Select the playlist to process...', @destdir, "", "Playlist files (*.m3u)|*.m3u", Wx::FD_OPEN | Wx::FD_FILE_MUST_EXIST, Wx::DEFAULT_POSITION ) if fd.show_modal == Wx::ID_OK return(fd.get_path) else exit end end def file=(m3u) # ok ... assign and parse @m3ufile = m3u @urls = parse if @m3ufile end def file return @m3ufile end def parse(file = @m3ufile) found = [] if File.exist?(file) File.open(file) { |f| while line = f.gets found.push(line.chomp) if line =~ /\.mp3$/i end } end return found end def grab progress = 0 if @urls.size > 0 @dialog.show Wx::get_app.yield @urls.each_index { |idx| url = @urls[idx] fname = File.basename(url) @dialog.status_label.label = "Downloading #{idx + 1} of #{@urls.size}: #{fname}" @dialog.progress_all.value = (100 * (idx/@urls.size.to_f)).to_i begin size = 0 @dialog.progress_item.value = 0 # reset File.open(File.join(Dir::tmpdir, fname), 'wb') { |ofile| open(url, :content_length_proc => lambda {|total| size = total }, :progress_proc => lambda { |current| @dialog.progress_item.value = (100 * (current/size.to_f)).to_i if size > 0 Wx::get_app.yield # update gui... raise "operation cancelled by user" if @dialog.cancelled } ) { |urlreader| urlreader.binmode ofile.write(urlreader.read) } } rename(File.join(Dir::tmpdir, fname)) rescue => err @dialog.hide unless @dialog.cancelled md = Wx::MessageDialog.new(@dialog, "An error occurred while downloading!\n#{url}", TITLE, Wx::OK | Wx::ICON_ERROR, Wx::DEFAULT_POSITION) md.show_modal end File.unlink(File.join(Dir::tmpdir, fname)) @dialog.destroy exit(1) end } @dialog.progress_all.value = 100 sleep(1) @dialog.hide md = Wx::MessageDialog.new(@dialog, 'Download(s) complete!', TITLE, Wx::OK, Wx::DEFAULT_POSITION) md.show_modal else unless @m3ufile.empty? md = Wx::MessageDialog.new(@dialog, 'No supported media files found to download!', TITLE, Wx::OK | Wx::ICON_EXCLAMATION, Wx::DEFAULT_POSITION) md.show_modal end end @dialog.destroy # and exit... end def rename(file) newname = "#{@destdir}/#{File.basename(@m3ufile, File.extname(@m3ufile))}/#{File.basename(file)}" FileUtils.mkdir_p(File.dirname(newname)) FileUtils.mv(file, newname) end end # StreamDownloader class # # StreamDownloaderApp class # # entry point for the app # class StreamDownloaderApp < Wx::App def on_init @sd = StreamDownloader.new begin playlist = (ARGV.first || @sd.ask) rescue => err $stdout.puts(err) end if playlist @sd.file = playlist @sd.grab end end end StreamDownloaderApp.new.main_loop -- Posted via http://www.ruby-forum.com/. From zpeng1 at yahoo.com Mon Feb 18 17:04:56 2008 From: zpeng1 at yahoo.com (Zhang Peng) Date: Mon, 18 Feb 2008 14:04:56 -0800 (PST) Subject: [wxruby-users] hang on leopard Message-ID: <356715.53364.qm@web59301.mail.re1.yahoo.com> Hi Alex, Thanks. I'll look into it. BTW, just an FYI: The "hang" problem disappears after I restart my leopard machine, and I'm back to my original issues where I kept getting the following message at random times (the code works, however): 2008-02-18 16:00:06.129 ruby[686:10b] *** Exception handlers were not properly removed. Some code has jumped or returned out of an NS_DURING...NS_HANDLER region without using the NS_VOIDRETURN or NS_VALUERETURN macros. Mon Feb 18 16:00:06 djonli-djonlis-macbook-pro-17.local ruby[686] : CGContextRestoreGState: invalid context What could I had done wrong? Regards ... Djonli. ----- Original Message ---- From: Alex Fenton To: General discussion of wxRuby Sent: Monday, February 18, 2008 11:24:21 AM Subject: Re: [wxruby-users] hang on leopard Zhang Zhang Peng wrote: > 1. A dialog box that shows numbers in flashing fashion. This dialog > has a number thread that shows a number, sleep, show next number, > sleep, ..... > > 2. A dialog box that shows running time (one thread), and another > thread running waiting for the number thread to finish showing the > numbers, and wait for a user to type in the result of adding up those > numbers. It sounds like you are using the Threads just to time events rather than carry out more complex background tasks. In this case I would strongly recommend that you use Wx::Timer directly. This will give you more accurate timing than using threads and sleep, and will avoid the complexity of using threads as well. As of 1.9.4, there's simple idioms for using Timer: Wx::Timer.every(milliseconds) do # repeated event end Wx::Timer.after(milliseconds) do # delayed event end There's an example of a ticking clock in bigdemo/wxStatusBar.rbw in the samples, which uses Wx::Timer. This might be helpful. cheers alex _______________________________________________ wxruby-users mailing list wxruby-users at rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080218/c9da6cb7/attachment.html From lists at ruby-forum.com Mon Feb 18 18:59:15 2008 From: lists at ruby-forum.com (Lionel Landwerlin) Date: Tue, 19 Feb 2008 00:59:15 +0100 Subject: [wxruby-users] A bug in wxRuby. Segmentation fault in random situations In-Reply-To: <570d9b010802170815p2750966br89e5d65ce70584f3@mail.gmail.com> References: <570d9b010802170815p2750966br89e5d65ce70584f3@mail.gmail.com> Message-ID: <4eac74b186ef28c98cfe8d5bd85f559a@ruby-forum.com> Jacek Nowak wrote: > Hello, > > I wrote an application in wxRuby: > ruby 1.8.6 > wxruby 1.9.4 installed from gem > windows xp sp2 > > After several minutes of running it crashes with the following error: > > "c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27: [BUG] > Segmentation fault > ruby 1.8.6 (2007-03-13) [i386-mswin32] > > This application has requested the Runtime to terminate it in an unusual > way. > Please contact the application's support team for more information." Hi, I'm experiencing exactly the same problem. I'm using : - windows xp sp2 - ruby-gtk2 binding (one click installer) - ruby 1.8.6 (last one click installer released) My application is not really big, ~1800 lines and I can't reproduce the bug with linux. For now the only way to fix my problem is to run manually the garbage collector for time to time inside the application. If I don't run the garbage collector, my application ends up by crashing after some time (could it be when garbage collecting is triggered?) or crashs when I close it (when freeing memory?). So I don't think the problem comes from wxruby or gtk+, but we our applications are running out of memory... Good luck, Lionel -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Mon Feb 18 19:50:18 2008 From: alex at pressure.to (Alex Fenton) Date: Tue, 19 Feb 2008 00:50:18 +0000 Subject: [wxruby-users] A bug in wxRuby. Segmentation fault in random situations. In-Reply-To: <570d9b010802170815p2750966br89e5d65ce70584f3@mail.gmail.com> References: <570d9b010802170815p2750966br89e5d65ce70584f3@mail.gmail.com> Message-ID: <47BA27CA.4000108@pressure.to> Hi Jacek Jacek Nowak wrote: > After several minutes of running it crashes with the following error: > > "c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27: [BUG] > Segmentation fault > ruby 1.8.6 (2007-03-13) [i386-mswin32] > > THanks for the report, and I'm sorry that you're running into this crash. The top development priority for wxRuby at the moment is identifying and fixing such bugs as remain - but as you say, isolating them is not easy. I've got some detailed suggestions below which should help, however. > 1. I don't get the normal exception so I cannot find the line of code > which causes the error - the application merely crashes with the > message cited above > 2. the crash occurs randomly in different situations, basicly when an > event like pressing a button, opening a window, changing focus, etc. > occurs (it doesn't occur when I don't touch the mouse/keyboard) - but > I am unable to reproduce any of the crashes - when it crashes for > instance after clicking button X, next time I can click button X a > hundred of times and everything works perfectly until it crashes on > pressing button Y, I think you know what I mean > A line number or triggering event will probably be spurious. As Mario said, it's very likely a garbage collection error in an unrelated object - The wxRuby SWIG bindings are either deleting an object still needed by wxWidgets, or trying to delete one wxWidgets has already disposed of. The trigger is just Ruby creating a new event object which happens to cause enough memory to have been allocated to force GC to run. > What can I do in this situation? > I have an application which is almost finished but completely useless > because of those random crashes :( > Can someone help me? > How can I debug the application to actually see the reason of the crash? > Ouch - I feel your frustration... There's a few steps you can take which should help isolate it. Two are pretty simple - Think if there's a particular feature you added before which this crash didn't occur - Check that the crash hasn't been introduced in an upgrade to your wxRuby version (I hope not!) The next step is to try to force a crash much closer in time to the code that is causing it; this is not hard to try and often yields good results. There is a method gc_stress in Wx::App which is designed for this; it is documented in lib/wx/classes/app.rb. If you call this method (typically in on_init/run) it will force Ruby's GC to run much more frequently - exactly how often can be customised by passing a number of milliseconds. 1-5s might be a good start. Add this call, then run your application and observe what you did shortly before a crash happened. Within a few runs it may well be possible to identify what is causing the crash. Things to look out for might be: - opening a new window of some sort - closing a particular kind of window or dialog - assigning some kind of Wx object to another in an event handler - eg adding an item to a list, or an attribute to a grid cell Hopefully you can then pin it down to a particular Dialog, Frame or piece of event handling code and can post that to us. The last "gold standard" way is to use a compiled-code debugger. Microsoft's is available free (search for "microsoft debugger"). In short, you use this by starting your app, then choosing "attach to process" (F6) in the debugger and finding the ruby process. Then you "run app" in the debugger (F5) and proceed to work with your wxRuby application. When it crashes, the debugger will capture a lot of information, including, most importantly, a stack trace of where in the C++ code the crash actually occurred. This can be posted. However, I'm not certain what results you'll get with the debugger and the wxRuby gem releases as these have much debugging information stripped out to reduce the download file size. If you are able to provide access to your source code I would be happy to try running it under a debugger and debug build on Windows - contact me off-list. I hope this helps - keep us posted alex From alex at pressure.to Mon Feb 18 19:52:12 2008 From: alex at pressure.to (Alex Fenton) Date: Tue, 19 Feb 2008 00:52:12 +0000 Subject: [wxruby-users] problem with Gauge on windows xp... In-Reply-To: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com> References: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com> Message-ID: <47BA283C.8000803@pressure.to> Tim Ferrell wrote: > I am new to wxRuby and just built a simple app with a frame containing a > static text control and two gauges ... I used DialogBlocks to design the > ui, and wx_sugar to generate a base class via xrcise, etc... All of this > works peachy on my development box (Mac OSX ~ Leopard) with the latest > gems... > > However, I tried running this little app on my Windows XP box and got > the following exception: > > ./stream_downloader_gui.rb:25:in `find_window_by_id': Error wrapping > object; cla > ss `wxGauge95' is not supported in wxRuby (NotImplementedError) Could you post the XRC for this dialog please? It could be a problem with the XRC that DialogBlocks is generating, or with the way that's interpreted by wxRuby or wxWidgets. Thanks alex From lists at ruby-forum.com Mon Feb 18 19:56:10 2008 From: lists at ruby-forum.com (Tim Ferrell) Date: Tue, 19 Feb 2008 01:56:10 +0100 Subject: [wxruby-users] problem with Gauge on windows xp... In-Reply-To: <47BA283C.8000803@pressure.to> References: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com> <47BA283C.8000803@pressure.to> Message-ID: Alex Fenton wrote: > Tim Ferrell wrote: >> object; cla >> ss `wxGauge95' is not supported in wxRuby (NotImplementedError) > > Could you post the XRC for this dialog please? It could be a problem > with the XRC that DialogBlocks is generating, or with the way that's > interpreted by wxRuby or wxWidgets. > > Thanks > alex Sure ... here you go ... and thanks! --- here be the xrc --- Stream Downloader 1 wxVERTICAL wxALIGN_LEFT|wxALL|wxFIXED_MINSIZE 5 wxGROW|wxALL 5 current file progress 0 100 wxGROW|wxALL 5 overall progress 0 100 wxALIGN_CENTER_HORIZONTAL|wxALL 5 cancel downloading -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Mon Feb 18 20:00:50 2008 From: alex at pressure.to (Alex Fenton) Date: Tue, 19 Feb 2008 01:00:50 +0000 Subject: [wxruby-users] problem with Gauge on windows xp... In-Reply-To: <3c12d9b081e028f0cf6a8eba5c7b72e4@ruby-forum.com> References: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com> <71e9fa0e205b3fc18cbd8510e2be02d6@ruby-forum.com> <3c12d9b081e028f0cf6a8eba5c7b72e4@ruby-forum.com> Message-ID: <47BA2A42.2010908@pressure.to> Tim Ferrell wrote: > Well, figuring that this had something to do with loading from an xrc, I > redid my code to just create the dialog by hand... I get a dialog now, > without error, but something seems messed up with event handling... I > cannot move or close the dialog, the Cancel button does not paint... the > gauges work though :-p > > Again, this all works fine for me on my Mac - I only see this weirdness > on Windows (XP) ... I'm sure it is some detail I am overlooking or, > being so new to this, something I am misinterpreting... > I will look to try this out on XP in the next few days, but in the meantime: > Attached is my code in hopes that someone will spot something... (this > is just a small app to parse an m3u playlist and download the mp3s found > there) > > def grab > progress = 0 > if @urls.size > 0 > @dialog.show > Wx::get_app.yield > I have never tried using Wx::App#yield so I'm not sure whether it will work correctly within a ruby context on all platforms. You might try an alternate strategy of using one or more Ruby threads within which to run the downloads. Include something like Wx::Timer.every(50) { Thread.pass } in your App#on_init to ensure the download threads get some time. Then, inside the worker downloader threads, update some shared variable with the progress at each step; inside the main GUI thread, have the progress bar read this variable. I am not sure this will solve it, but it has certainly worked for me doing long-running file-based tasks (eg tokenising and parsing) in the background while updating to a GUI representation of that. Take a look at the etc/threaded.rb sample for a simple example of this; Mario's excellent chat client sample shows the use of Threads with network operations, but it is more complex. hth alex From zpeng1 at yahoo.com Tue Feb 19 00:52:52 2008 From: zpeng1 at yahoo.com (Zhang Peng) Date: Mon, 18 Feb 2008 21:52:52 -0800 (PST) Subject: [wxruby-users] hang on leopard Message-ID: <867999.69058.qm@web59312.mail.re1.yahoo.com> Hi Alex, An update: The error messages do not happen if I do not do show/hide the 2 dialog boxes. Is there anything that I should do before calling show(false) and show(true)? Thanks in advance! ----- Original Message ---- From: Zhang Peng To: General discussion of wxRuby Sent: Monday, February 18, 2008 4:04:56 PM Subject: Re: [wxruby-users] hang on leopard Hi Alex, Thanks. I'll look into it. BTW, just an FYI: The "hang" problem disappears after I restart my leopard machine, and I'm back to my original issues where I kept getting the following message at random times (the code works, however): 2008-02-18 16:00:06.129 ruby[686:10b] *** Exception handlers were not properly removed. Some code has jumped or returned out of an NS_DURING...NS_HANDLER region without using the NS_VOIDRETURN or NS_VALUERETURN macros. Mon Feb 18 16:00:06 djonli-djonlis-macbook-pro-17.local ruby[686] : CGContextRestoreGState: invalid context What could I had done wrong? Regards ... Djonli. ----- Original Message ---- From: Alex Fenton To: General discussion of wxRuby Sent: Monday, February 18, 2008 11:24:21 AM Subject: Re: [wxruby-users] hang on leopard Zhang Zhang Peng wrote: > 1. A dialog box that shows numbers in flashing fashion. This dialog > has a number thread that shows a number, sleep, show next number, > sleep, ...... > > 2. A dialog box that shows running time (one thread), and another > thread running waiting for the number thread to finish showing the > numbers, and wait for a user to type in the result of adding up those > numbers. It sounds like you are using the Threads just to time events rather than carry out more complex background tasks. In this case I would strongly recommend that you use Wx::Timer directly. This will give you more accurate timing than using threads and sleep, and will avoid the complexity of using threads as well. As of 1.9.4, there's simple idioms for using Timer: Wx::Timer.every(milliseconds) do # repeated event end Wx::Timer.after(milliseconds) do # delayed event end There's an example of a ticking clock in bigdemo/wxStatusBar.rbw in the samples, which uses Wx::Timer. This might be helpful. cheers alex _______________________________________________ wxruby-users mailing list wxruby-users at rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. -----Inline Attachment Follows----- _______________________________________________ wxruby-users mailing list wxruby-users at rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080218/ea80be44/attachment-0001.html From alex at pressure.to Tue Feb 19 03:46:12 2008 From: alex at pressure.to (Alex Fenton) Date: Tue, 19 Feb 2008 08:46:12 +0000 Subject: [wxruby-users] hang on leopard In-Reply-To: <867999.69058.qm@web59312.mail.re1.yahoo.com> References: <867999.69058.qm@web59312.mail.re1.yahoo.com> Message-ID: <47BA9754.20302@pressure.to> Zhang Peng wrote: > The error messages do not happen if I do not do show/hide the 2 dialog > boxes. > > Is there anything that I should do before calling show(false) and > show(true)? Not that I can think of. It might be worth checking the first argument to Dialog.new - I would recommend that the Dialogs are given the frame as the parent, not nil. You may be doing this already. > 2008-02-18 16:00:06.129 ruby[686:10b] *** Exception handlers were not > properly removed. Some code has jumped or returned out of an > NS_DURING...NS_HANDLER region without using the NS_VOIDRETURN or > NS_VALUERETURN macros. I haven't seen this error message before. If you're able to isolate the error, please post the code as I use Leopard as my main OS and could give try it out. thanks alex From jacekwiktor at gmail.com Tue Feb 19 06:19:28 2008 From: jacekwiktor at gmail.com (Jacek Nowak) Date: Tue, 19 Feb 2008 12:19:28 +0100 Subject: [wxruby-users] A bug in wxRuby. Segmentation fault in random situations. In-Reply-To: <47BA27CA.4000108@pressure.to> References: <570d9b010802170815p2750966br89e5d65ce70584f3@mail.gmail.com> <47BA27CA.4000108@pressure.to> Message-ID: <570d9b010802190319r3cb8cfc7gc9bfdf4b51e5bef2@mail.gmail.com> Hi, Thanks a lot for all your answers. It's a very nice support on this mailing list. Here are my observations as for today (most are things Mario suggested me to do as I had yet no time to do things suggested by Alex, so expect another report in the next couple of days): 1. I added GC.disable in the beginning of my application and it seems that it doesn't crash right now. 2. I installed my application on Linux (Ubuntu 7.04) and there the same random crashes occur (with GC enabled): "/usr/lib/ruby/1.8/rubygems/custom_require.rb:27: [BUG] Segmentation fault ruby 1.8.5 (2006-08-25) [i486-linux] Aborted (core dumped)" 3. The same crashes occured with wxRuby 1.9.0 (in fact I was using 1.9.0 and I upgraded to the newest version 1.9.4 a couple of days ago in order to find a solution for my crashes) 4. The crash occurs sooner if I do a lot of "clicking" in my application (a lot of opening/closing windows or dialogs or more generally when a lot of events occur). 5. The purpose of the program is to manage a shop (it logs transactions, prints receipts, prepares documents for tax purposes, etc). It's a typical database client. It's a MDI application. The most used control is ListCtrl (in LC_REPORT mode) - it's used for displaying results of SQL queries. Other controls used: Button,TextCtrl,StaticText,MDIParentFrame,MDIChildFrame, Menu,MenuBar,ComboBox,Dialog,MessageDialog, BoxSizer,PrintData,Printer,Printout I hope I haven't forgotten about something. (I'm also using mysql-ruby module but I don't think it causes the error) I will try to do what Alex suggested. I don't mind sending you the source code but the installation of my application is a bit complicated as you must set up the MySQL database, import data from an old CLIPPER database (in fact what I'm doing is the rewrite of an old DOS application written in CLIPPER to something cross-platform and more functional), etc. Recently I found a way to reproduce this bug in one place of the application so I will try to strip as much of the code as possible and I will send you a piece of code easier to handle and debug. Thanks again for all your help. In a couple of days I will provide a more detailed report. -- Jacek Nowak jacekwiktor at gmail.com From alex at pressure.to Tue Feb 19 07:06:00 2008 From: alex at pressure.to (Alex Fenton) Date: Tue, 19 Feb 2008 12:06:00 +0000 Subject: [wxruby-users] A bug in wxRuby. Segmentation fault in random situations. In-Reply-To: <570d9b010802190319r3cb8cfc7gc9bfdf4b51e5bef2@mail.gmail.com> References: <570d9b010802170815p2750966br89e5d65ce70584f3@mail.gmail.com> <47BA27CA.4000108@pressure.to> <570d9b010802190319r3cb8cfc7gc9bfdf4b51e5bef2@mail.gmail.com> Message-ID: <47BAC628.7060409@pressure.to> Jacek Nowak wrote: > 2. I installed my application on Linux (Ubuntu 7.04) and there the > same random crashes occur (with GC enabled): > > "/usr/lib/ruby/1.8/rubygems/custom_require.rb:27: [BUG] Segmentation fault > ruby 1.8.5 (2006-08-25) [i486-linux] > > Aborted (core dumped)" > If you have Linux available it might be easier to get started with a debugger (gdb). Run it like this: gdb --args ruby [script.rb] At the gdb prompt, type 'r' to run the program Then, when it crashes, type 'whe' to get a backtrace, which can be copied and pasted to the list > 4. The crash occurs sooner if I do a lot of "clicking" in my > application (a lot of opening/closing windows or dialogs or more > generally when a lot of events occur). > Doing more events will create more objects, which will cause Ruby's GC to run sooner. > It's a typical database client. It's a MDI application. > The most used control is ListCtrl (in LC_REPORT mode) - it's used for > displaying results of SQL queries. > Other controls used: > Button,TextCtrl,StaticText,MDIParentFrame,MDIChildFrame, > Menu,MenuBar,ComboBox,Dialog,MessageDialog, > BoxSizer,PrintData,Printer,Printout There's already some fixees in SVN to one or two of these classes, but may well be something new > In a couple of days I will provide a more detailed report. > Great, look forward to it; thanks for your patience alex From alex at pressure.to Tue Feb 19 07:35:03 2008 From: alex at pressure.to (Alex Fenton) Date: Tue, 19 Feb 2008 12:35:03 +0000 Subject: [wxruby-users] problem with Gauge on windows xp... In-Reply-To: References: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com> <47BA283C.8000803@pressure.to> Message-ID: <47BACCF7.60306@pressure.to> Tim Ferrell wrote: > Sure ... here you go ... and thanks! > Seems there's an inconsistency on the wxWidgets side where the C++ class of a Gauge on windows is reported as wxGauge95, a class which wxRuby has never heard about. I found that adding something like this before the main app code fixed the problem: Wx::Gauge95 = Wx::Gauge I'll add something similar to the wxRuby core library for the next release so this won't be a problem in the future. Thanks for the report. alex From lists at ruby-forum.com Tue Feb 19 09:06:55 2008 From: lists at ruby-forum.com (Tim Ferrell) Date: Tue, 19 Feb 2008 15:06:55 +0100 Subject: [wxruby-users] problem with Gauge on windows xp... In-Reply-To: <47BA2A42.2010908@pressure.to> References: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com> <71e9fa0e205b3fc18cbd8510e2be02d6@ruby-forum.com> <3c12d9b081e028f0cf6a8eba5c7b72e4@ruby-forum.com> <47BA2A42.2010908@pressure.to> Message-ID: Alex Fenton wrote: > I have never tried using Wx::App#yield so I'm not sure whether it will > work correctly within a ruby context on all platforms. You might try an > alternate strategy of using one or more Ruby threads within which to run > the downloads. That does seem to be the issue... #yield doesn't behave the same under Windows as it does on OS X :-/ I'll work on using a separate thread for the downloads and see how that fares... Thanks for the help with the xrc issue - I really didn't want to have to code my interfaces by hand :-p Cheers, Tim -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Feb 19 09:14:22 2008 From: lists at ruby-forum.com (Tim Ferrell) Date: Tue, 19 Feb 2008 15:14:22 +0100 Subject: [wxruby-users] make frame dynamically size to contents? Message-ID: <01da593ba3e8801bb013c2ce47e80304@ruby-forum.com> What magic and/or code should I use to cause a frame to adjust to fit the contents? When I change label text, for example... The docs led me to believe this is done automatically but that doesn't seem to be the case... Surely I've missed something. :-) I'm using sizers for the layout and loading from an xrc, BTW... Thanks! Tim -- Posted via http://www.ruby-forum.com/. From jacekwiktor at gmail.com Tue Feb 19 10:17:37 2008 From: jacekwiktor at gmail.com (Jacek Nowak) Date: Tue, 19 Feb 2008 16:17:37 +0100 Subject: [wxruby-users] A bug in wxRuby. Segmentation fault in random situations. In-Reply-To: <47BAC628.7060409@pressure.to> References: <570d9b010802170815p2750966br89e5d65ce70584f3@mail.gmail.com> <47BA27CA.4000108@pressure.to> <570d9b010802190319r3cb8cfc7gc9bfdf4b51e5bef2@mail.gmail.com> <47BAC628.7060409@pressure.to> Message-ID: <570d9b010802190717x78573832j58331e50fb953a8e@mail.gmail.com> > Then, when it crashes, type 'whe' to get a backtrace, which can be > copied and pasted to the list Here you are: Program received signal SIGSEGV, Segmentation fault. [Switching to Thread -1211454640 (LWP 6540)] 0xb724e51c in GC_mark_wxWindow () from /var/lib/gems/1.8/gems/wxruby-1.9.4-x86-linux/lib/wxruby2.so (gdb) whe #0 0xb724e51c in GC_mark_wxWindow () from /var/lib/gems/1.8/gems/wxruby-1.9.4-x86-linux/lib/wxruby2.so #1 0xb7ea0070 in ?? () from /usr/lib/libruby1.8.so.1.8 #2 0x084a9cf0 in ?? () #3 0x00016112 in ?? () #4 0x085b90e8 in ?? () #5 0xb7e82a25 in ?? () from /usr/lib/libruby1.8.so.1.8 #6 0x00016112 in ?? () #7 0x00000001 in ?? () #8 0xbfdb0938 in ?? () #9 0xbfdb0918 in ?? () #10 0xb7e9fad4 in ruby_stack_check () from /usr/lib/libruby1.8.so.1.8 #11 0xb6f1efda in wxRubyApp::mark_iterate () from /var/lib/gems/1.8/gems/wxruby-1.9.4-x86-linux/lib/wxruby2.so #12 0xb7e95bb8 in ?? () from /usr/lib/libruby1.8.so.1.8 #13 0xb418b8e8 in ?? () #14 0x00000004 in ?? () #15 0xb7ca79f4 in ?? () #16 0xb7e8ae18 in ?? () from /usr/lib/libruby1.8.so.1.8 #17 0x00000040 in ?? () #18 0x00000001 in ?? () #19 0x00000030 in ?? () #20 0xb7ca79f4 in ?? () #21 0xb418b8e8 in ?? () #22 0xb418b94c in ?? () #23 0x00000000 in ?? () (gdb) -- Jacek Nowak jacekwiktor at gmail.com From mario at ruby-im.net Tue Feb 19 17:07:29 2008 From: mario at ruby-im.net (Mario Steele) Date: Tue, 19 Feb 2008 16:07:29 -0600 Subject: [wxruby-users] A bug in wxRuby. Segmentation fault in random situations. In-Reply-To: <570d9b010802190717x78573832j58331e50fb953a8e@mail.gmail.com> References: <570d9b010802170815p2750966br89e5d65ce70584f3@mail.gmail.com> <47BA27CA.4000108@pressure.to> <570d9b010802190319r3cb8cfc7gc9bfdf4b51e5bef2@mail.gmail.com> <47BAC628.7060409@pressure.to> <570d9b010802190717x78573832j58331e50fb953a8e@mail.gmail.com> Message-ID: Thanks Jacek, It looks as though your libruby1.8.so.1.8 has been stripped of all debugging information. Which is often the practice of the Distro, to conserve bandwidth and storage on public servers, where they host their packages. Unfortunatly, for us, this leaves very little for us to figure out on where it is crashing specifically. Only thing I can tell from this debug output, is that ruby_stack_check() is being called, which is checking the stack of objects to see what is clear to be deleted/recycled, and what isn't. Infact, it's actually running through wxRuby's objects at the point and time, simply case of wxRubyApp::mark_iterate() is being called. To better understand what is going on, I would ask, that you uninstall the Ruby package, through your Distro's Package Manager (Usually YUM for Red Hat/Fedora, Synaptic for Mandrivia/Ubuntu, Portage for Gentoo, you get the idea), then download Ruby from ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p111.tar.gz, and follow the following instructions: Bring up a Terminal (Terminal/Konsole/rxte/etc/etc) cd ~/directory_where/you_have_ruby/downloaded_to tar -xzf ruby-1.8.6-p111.tar.gz cd ruby-1.8.6-p111 ./configure --prefix=/usr make sudo make install Ofcourse, replace ~/directory_where/you_have_ruby/downloaded_to to where you actually downloaded the file to. Generally, that's ~/Desktop on most systems, sometimes that is just ~ (Which is your home directory) Once you compiled and installed Ruby through the instructions up above, then try running gdb against your application, and type in whe. You will find that you'll get a lot more information from it, instead of a lot of lines that have ?? in them. Already, from your report that GC.disable works for the application, and prevents the segmentation fault, means that it is a Garbage Collection problem. So, now we just need to figure out where in this process, our bug lies in. Also, if your brave enough to compile from SVN for wxRuby, and test out the SVN code against your application, to see if the bug has been fixed or not, make sure you have SVN installed, and follow these instructions: Download wxGTK from http://prdownloads.sourceforge.net/wxwindows/wxGTK-2.8.7.tar.gz Utilize the same instructions above for cd and tar, then utilize the following command to build wxGTK. cd wxGTK-2.8.7/build ../configure --disable-shared --with-gtk --enable-monolithic \ --enable-unicode --disable-debug --enable-catch_segvs --enable-graphics_ctx \ --enable-mediactrl --with-opengl --with-libjpeg=builtin --with-libpng=builtin \ --with-libtiff=builtin --with-zlib=builtin --with-expat=builtin --enable-gui \ --enable-xrc --enable-mdi --enable-gif \ --enable-pcx --enable-iff --enable-pnm --enable-xpm make sudo make install cd contrib/src/stc make sudo make install Then ensure that you have SWIG 1.3.31, which can be downloaded from: http://prdownloads.sourceforge.net/swig/swig-1.3.31.tar.gz Same procedure as before cd swig-1.3.31 ./configure --prefix=/usr make sudo make install And ensure that you have Rake installed. If you have Ruby Gems installed, which it looks like you do, simply run: sudo gem install rake Once you have all of this done, simply run SVN like so: svn co svn://rubyforge.org/var/svn/wxruby/trunk/wxruby2 Then run: cd wxruby2 rake sudo rake install With luck, all of these instructions, will give you a Fresh SVN Copy of wxRuby to test out. Quite a few instructions, but this will get you well on your way to helping us test this stuff out, so we can get wxRuby to it's true 2.0 release mark. L8ers, Mario Steele On 2/19/08, Jacek Nowak wrote: > > Then, when it crashes, type 'whe' to get a backtrace, which can be > > copied and pasted to the list > > Here you are: > > Program received signal SIGSEGV, Segmentation fault. > [Switching to Thread -1211454640 (LWP 6540)] > 0xb724e51c in GC_mark_wxWindow () from > /var/lib/gems/1.8/gems/wxruby-1.9.4-x86-linux/lib/wxruby2.so > (gdb) whe > #0 0xb724e51c in GC_mark_wxWindow () from > /var/lib/gems/1.8/gems/wxruby-1.9.4-x86-linux/lib/wxruby2.so > #1 0xb7ea0070 in ?? () from /usr/lib/libruby1.8.so.1.8 > #2 0x084a9cf0 in ?? () > #3 0x00016112 in ?? () > #4 0x085b90e8 in ?? () > #5 0xb7e82a25 in ?? () from /usr/lib/libruby1.8.so.1.8 > #6 0x00016112 in ?? () > #7 0x00000001 in ?? () > #8 0xbfdb0938 in ?? () > #9 0xbfdb0918 in ?? () > #10 0xb7e9fad4 in ruby_stack_check () from /usr/lib/libruby1.8.so.1.8 > #11 0xb6f1efda in wxRubyApp::mark_iterate () from > /var/lib/gems/1.8/gems/wxruby-1.9.4-x86-linux/lib/wxruby2.so > #12 0xb7e95bb8 in ?? () from /usr/lib/libruby1.8.so.1.8 > #13 0xb418b8e8 in ?? () > #14 0x00000004 in ?? () > #15 0xb7ca79f4 in ?? () > #16 0xb7e8ae18 in ?? () from /usr/lib/libruby1.8.so.1.8 > #17 0x00000040 in ?? () > #18 0x00000001 in ?? () > #19 0x00000030 in ?? () > #20 0xb7ca79f4 in ?? () > #21 0xb418b8e8 in ?? () > #22 0xb418b94c in ?? () > #23 0x00000000 in ?? () > (gdb) > > -- > Jacek Nowak > jacekwiktor at gmail.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/ http://rubyforge.org/projects/vwmc/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080219/b97ccd7c/attachment-0001.html From zpeng1 at yahoo.com Tue Feb 19 18:25:01 2008 From: zpeng1 at yahoo.com (Zhang Peng) Date: Tue, 19 Feb 2008 15:25:01 -0800 (PST) Subject: [wxruby-users] hang on leopard Message-ID: <835302.91857.qm@web59316.mail.re1.yahoo.com> Yes. I already use frame as the parent. Can I send you the zip file? I isolate it to about 350 lines ... the part that is in question is less than 50 lines. Most of the lines are from the xrc file and setup window/frame/dialog. ========================================== ----- Original Message ---- From: Alex Fenton To: General discussion of wxRuby Sent: Tuesday, February 19, 2008 2:46:12 AM Subject: Re: [wxruby-users] hang on leopard Zhang Peng wrote: > The error messages do not happen if I do not do show/hide the 2 dialog > boxes. > > Is there anything that I should do before calling show(false) and > show(true)? Not that I can think of. It might be worth checking the first argument to Dialog.new - I would recommend that the Dialogs are given the frame as the parent, not nil. You may be doing this already. > 2008-02-18 16:00:06.129 ruby[686:10b] *** Exception handlers were not > properly removed. Some code has jumped or returned out of an > NS_DURING...NS_HANDLER region without using the NS_VOIDRETURN or > NS_VALUERETURN macros. I haven't seen this error message before. If you're able to isolate the error, please post the code as I use Leopard as my main OS and could give try it out. thanks alex _______________________________________________ wxruby-users mailing list wxruby-users at rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080219/2e9c1dba/attachment.html From zpeng1 at yahoo.com Wed Feb 20 00:35:10 2008 From: zpeng1 at yahoo.com (Zhang Peng) Date: Wed, 20 Feb 2008 13:35:10 +0800 (CST) Subject: [wxruby-users] hang on leopard Message-ID: <98941.1275.qm@web59302.mail.re1.yahoo.com> Hi Alex, Finally, I got my code to work properly by not using the show(true) and show(false) pair within a thread in the classes that subclass from Dialog. The symptoms I experienced if you put the show(true/false) pair within a Thread, you get the following problems: 1. The entire application hangs .. beach ball spinning in leopard. 2. I have seen several segmentation fault during my test the past few days. 3. The application kept printing the following errors once every few tests. 2008-02-18 16:00:06.129 ruby[686:10b] *** Exception handlers were not properly removed. Some code has jumped or returned out of an NS_DURING...NS_HANDLER region without using the NS_VOIDRETURN or NS_VALUERETURN macros. and Mon Feb 18 16:00:06 ruby[686] : CGContextRestoreGState: invalid context Now, here are the high level code that causes the problem on 10.5.2 with ruby version 1.86 and wxruby 1.9.4 (The same source code does not cause any problem on Windows XP running under Parallels on OS X): ============================================ PROBLEMATIC CODE THAT CAUSES HANG ON LEOPARD Within 15 times the button is hit (as soon as 1 or 2 hits sometimes) ============================================ def on_button(event) $dialog1.start end class dlg1: def start if (@dialog1Thread == nil) @dialog1Thread = Thread.new { loop do $dialog1.show(true) $dialog2.start ... $dialog1.show(false) Thread.stop end # loop do } # @flashModeThread = Thread.new else # if (@ dialog1Thread == nil) @dialog1Thread.run end # if (@ dialog1Thread == nil) end # def start class dlg2: def start if (@dialog2Thread == nil) @dialog2Thread = Thread.new { loop do $dialog2.show(true) ... $dialog2.show(false) Thread.stop end # loop do } else @ dialog2Thread.run end end # dialog2Thread ================================================= MOVING show(true/false) pair out from the dialog thread to the on_button solves the issue ================================================= def on_button(event) $dialog1.show(true) $dialog2.show(true) $dialog1.start if $WaitTimer == nil $WaitTimer = Wx::Timer.every(1) do if $dialog2.done == true $dialog1.show(false) if $dialog1 != nil $dialog2.show(false) if $dialog2 != nil $WaitTimer.stop end end else $WaitTimer.start end end >From my testing, it surely looks like there is a problem with using Wx's show(true/false) within ruby's Thread. But hopefully you can see something else that I might had done wrong, because it is much easier for me to fix my code :-) :-) :-) ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080220/8fb5d587/attachment.html From alex at pressure.to Wed Feb 20 02:45:15 2008 From: alex at pressure.to (Alex Fenton) Date: Wed, 20 Feb 2008 07:45:15 +0000 Subject: [wxruby-users] A bug in wxRuby. Segmentation fault in random situations. In-Reply-To: <570d9b010802190717x78573832j58331e50fb953a8e@mail.gmail.com> References: <570d9b010802170815p2750966br89e5d65ce70584f3@mail.gmail.com> <47BA27CA.4000108@pressure.to> <570d9b010802190319r3cb8cfc7gc9bfdf4b51e5bef2@mail.gmail.com> <47BAC628.7060409@pressure.to> <570d9b010802190717x78573832j58331e50fb953a8e@mail.gmail.com> Message-ID: <47BBDA8B.7080906@pressure.to> Jacek Nowak wrote: >> Then, when it crashes, type 'whe' to get a backtrace, which can be >> copied and pasted to the list >> > > Here you are: > > Program received signal SIGSEGV, Segmentation fault. > [Switching to Thread -1211454640 (LWP 6540)] > 0xb724e51c in GC_mark_wxWindow () from > Thanks for this. As Mario says, this confirms that it's a GC collection issue. But I would suggest that instead of putting time into installing a build from source, that you first pursue trying to isolate using gc_stress. It just happens that in this case, a full debugging backtrace wouldn't help identify exactly which Window is causing the problem. cheers alex From alex at pressure.to Wed Feb 20 04:49:15 2008 From: alex at pressure.to (Alex Fenton) Date: Wed, 20 Feb 2008 09:49:15 +0000 Subject: [wxruby-users] make frame dynamically size to contents? In-Reply-To: <01da593ba3e8801bb013c2ce47e80304@ruby-forum.com> References: <01da593ba3e8801bb013c2ce47e80304@ruby-forum.com> Message-ID: <47BBF79B.5040808@pressure.to> Tim Ferrell wrote: > What magic and/or code should I use to cause a frame to adjust to fit > the contents? When I change label text, for example... The docs led me > to believe this is done automatically but that doesn't seem to be the > case... Surely I've missed something. :-) Try Window#set_sizer_and_fit(a_sizer) or Sizer#fit(a_window) http://wxruby.rubyforge.org/doc/window.html#Window_setsizerandfit http://wxruby.rubyforge.org/doc/sizer.html#Sizer_fit hth alex From lists at ruby-forum.com Wed Feb 20 11:52:25 2008 From: lists at ruby-forum.com (Tim Ferrell) Date: Wed, 20 Feb 2008 17:52:25 +0100 Subject: [wxruby-users] make frame dynamically size to contents? In-Reply-To: <47BBF79B.5040808@pressure.to> References: <01da593ba3e8801bb013c2ce47e80304@ruby-forum.com> <47BBF79B.5040808@pressure.to> Message-ID: Alex Fenton wrote: > Tim Ferrell wrote: >> What magic and/or code should I use to cause a frame to adjust to fit >> the contents? When I change label text, for example... The docs led me >> to believe this is done automatically but that doesn't seem to be the >> case... Surely I've missed something. :-) > Try Window#set_sizer_and_fit(a_sizer) or Sizer#fit(a_window) > > http://wxruby.rubyforge.org/doc/window.html#Window_setsizerandfit > http://wxruby.rubyforge.org/doc/sizer.html#Sizer_fit > > hth > alex Thanks Alex ... One odd thing I notice is that the sizer seems to squash everything really close together. I added small spacers (2-4 pixels) between controls to try and pad things out a bit but they seem to be ignored... I also tried increasing the border sizes on the controls themselves without success. Any idea what I'm not doing correctly? Cheers, Tim -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Wed Feb 20 14:47:50 2008 From: alex at pressure.to (Alex Fenton) Date: Wed, 20 Feb 2008 19:47:50 +0000 Subject: [wxruby-users] make frame dynamically size to contents? In-Reply-To: References: <01da593ba3e8801bb013c2ce47e80304@ruby-forum.com> <47BBF79B.5040808@pressure.to> Message-ID: <47BC83E6.4010006@pressure.to> Tim Ferrell wrote: > One odd thing I notice is that the sizer seems to squash everything > really close together. I added small spacers (2-4 pixels) between > controls to try and pad things out a bit but they seem to be ignored... > Borders are definitely the way to go in most cases, not spacers. Are you using XRC or pure ruby? If using pure ruby, check that you have included Wx::ALL or Wx::LEFT or Wx::TOP in the third argument to Sizer#add, to indicate which side of the control you wish to add a border to. See bigdemo/wxSizer.rbw for a demonstration of some of the options. If using XRC, check that you have ticked the box to specify which side you want to add a border to. In DialogBlocks, it usually sets a default border of 5 on each side. alex From lists at ruby-forum.com Wed Feb 20 15:51:57 2008 From: lists at ruby-forum.com (Tim Ferrell) Date: Wed, 20 Feb 2008 21:51:57 +0100 Subject: [wxruby-users] make frame dynamically size to contents? In-Reply-To: <47BC83E6.4010006@pressure.to> References: <01da593ba3e8801bb013c2ce47e80304@ruby-forum.com> <47BBF79B.5040808@pressure.to> <47BC83E6.4010006@pressure.to> Message-ID: <34b3dcb746aceb90569843c9be1c40df@ruby-forum.com> Alex Fenton wrote: > Borders are definitely the way to go in most cases, not spacers. Are you > using XRC or pure ruby? If using pure ruby, check that you have included > Wx::ALL or Wx::LEFT or Wx::TOP in the third argument to Sizer#add, to > indicate which side of the control you wish to add a border to. > > See bigdemo/wxSizer.rbw for a demonstration of some of the options. > > If using XRC, check that you have ticked the box to specify which side > you want to add a border to. In DialogBlocks, it usually sets a default > border of 5 on each side. > > alex Turns out I was fine ... I was just requiring the old version of the frame I did in code rather than the code that loaded XRC I was editing :-p Thanks for the help in any case... Cheers, Tim -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Wed Feb 20 16:13:54 2008 From: alex at pressure.to (Alex Fenton) Date: Wed, 20 Feb 2008 21:13:54 +0000 Subject: [wxruby-users] hang on leopard In-Reply-To: <98941.1275.qm@web59302.mail.re1.yahoo.com> References: <98941.1275.qm@web59302.mail.re1.yahoo.com> Message-ID: <47BC9812.4040001@pressure.to> Zhang Peng wrote: > Finally, I got my code to work properly by not using the show(true) > and show(false) pair within a thread in the classes that subclass from > Dialog. The symptoms I experienced if you put the show(true/false) > pair within a Thread, you get the following problems: ... > From my testing, it surely looks like there is a problem with using > Wx's show(true/false) within ruby's Thread. Thanks for posting your code. I agree with your analysis ... but ... The wxWidgets documentation and mailing list are clear that GUI calls in wxWidgets (C++), like show(), should be restricted to a single thread only. Now, ruby 1.8 threads are not the same as OS threads in wxWidgets, but some of the issues may be the same. In particular, the error message that you are getting sounds like OS X is complaining that execution is being prematurely switched out of some core operation. That sounds to me like a possible thread problem. > But hopefully you can see something else that I might had done wrong, > because it is much easier for me to fix my code I think it is a primarily a design problem. You have a lot of globals, and a lot of Threads. In general, if you have a background task running in a ruby thread, notifications about the status of that thread's work should be handled either by a properly shared variable (using Mutex if needed), or by posting a Wx::Event from the slave thread to the master GUI thread. If you were able to say a bit more about why you are using these Threads, we'd be happy to be more specific about a safer alternative. alex From zpeng1 at yahoo.com Wed Feb 20 18:01:52 2008 From: zpeng1 at yahoo.com (Zhang Peng) Date: Wed, 20 Feb 2008 15:01:52 -0800 (PST) Subject: [wxruby-users] hang on leopard Message-ID: <302295.50288.qm@web59309.mail.re1.yahoo.com> Thanks for the explanation, Alex. If it is a thread issue, I wonder why I couldn't duplicate it on XP? Since I can't duplicate it on XP, I was thinking that it is not just a pure thread issue, but Wx for OSX + ruby thread combination is the culprit. If it is a pure thread issue, I would think that I should had hit it on XP too since I did an extensive testing on XP without seeing any problem, unless I was really lucky to not hit the thread bug on XP. I'm already using Mutex for shared variables. Thanks for offering help on design choice. I appreciate it ! I don't actually have a lot of globals and threads ... only 2 globals and 3 threads. Let me try to explain: I have one dialog box that shows a number flashing on the screen one after another, and another dialog box that shows the time and a input text field to collect the answer the user types in for adding up all those numbers from the other dialog. So, I have 2 global variables: one for each instance of the dialog box. I use global because I do not want to destroy and create a new instance of the dialog box every time a user want to do the exercise. I have 3 threads: one to show the flashing number, one to collect answer, and one for showing the time. I use WxTimer.every() for the timer per your suggestion. I use ruby thread for the other 2 as you see in the code I posted yesterday. So, when user hit the button, both ruby threads will start/resume their tasks: one to show the number and one to collect the answer, and WxTimer shows the time. If I can put the show(true/false) pair within the ruby threads, I do not need to create another WxTimer threads on my main thread to check when to "hide" the dialog box. Thanks! ----- Original Message ---- From: Alex Fenton To: General discussion of wxRuby Sent: Wednesday, February 20, 2008 3:13:54 PM Subject: Re: [wxruby-users] hang on leopard Zhang Peng wrote: > Finally, I got my code to work properly by not using the show(true) > and show(false) pair within a thread in the classes that subclass from > Dialog. The symptoms I experienced if you put the show(true/false) > pair within a Thread, you get the following problems: .... > >From my testing, it surely looks like there is a problem with using > Wx's show(true/false) within ruby's Thread. Thanks for posting your code. I agree with your analysis .... but .... The wxWidgets documentation and mailing list are clear that GUI calls in wxWidgets (C++), like show(), should be restricted to a single thread only. Now, ruby 1.8 threads are not the same as OS threads in wxWidgets, but some of the issues may be the same. In particular, the error message that you are getting sounds like OS X is complaining that execution is being prematurely switched out of some core operation. That sounds to me like a possible thread problem. > But hopefully you can see something else that I might had done wrong, > because it is much easier for me to fix my code I think it is a primarily a design problem. You have a lot of globals, and a lot of Threads. In general, if you have a background task running in a ruby thread, notifications about the status of that thread's work should be handled either by a properly shared variable (using Mutex if needed), or by posting a Wx::Event from the slave thread to the master GUI thread. If you were able to say a bit more about why you are using these Threads, we'd be happy to be more specific about a safer alternative. alex _______________________________________________ wxruby-users mailing list wxruby-users at rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080220/a90a29cc/attachment.html From alex at pressure.to Wed Feb 20 18:35:41 2008 From: alex at pressure.to (Alex Fenton) Date: Wed, 20 Feb 2008 23:35:41 +0000 Subject: [wxruby-users] hang on leopard In-Reply-To: <302295.50288.qm@web59309.mail.re1.yahoo.com> References: <302295.50288.qm@web59309.mail.re1.yahoo.com> Message-ID: <47BCB94D.4000704@pressure.to> Zhang Peng wrote: > If it is a thread issue, I wonder why I couldn't duplicate it on XP? > Since I can't duplicate it on XP, I was thinking that it is not just a > pure thread issue, but Wx for OSX + ruby thread combination is the > culprit. Because wxRuby / wxWidgets uses different native platform functions internally, there's no guarantee that if you're doing something wrong, it will fail in the same way, or at all, on different platforms. But it should always work if done right ... > Thanks for offering help on design choice. I appreciate it ! > > I don't actually have a lot of globals and threads ... only 2 globals > and 3 threads. Let me try to explain: > > I have one dialog box that shows a number flashing on the screen one > after another, and another dialog box that shows the time and a input > text field to collect the answer the user types in for adding up all > those numbers from the other dialog. OK. First of all, I really don't think you need to use threads or globals at all to achieve this. wxRuby like other GUI packages is essentially event driven: updates to the GUI should be driven by events. This includes user interaction (clicking a button) or timed events (a timer ticks). > So, I have 2 global variables: one for each instance of the dialog > box. I use global because I do not want to destroy and create a new > instance of the dialog box every time a user want to do the exercise. Fair enough. You could make them instance variables of your Wx::App class, create them when the app starts, and provide an accessor to them. Then you could access them anywhere in your code with Wx::THE_APP.number_dialog etc. > I have 3 threads: one to show the flashing number, one to collect > answer, and one for showing the time. I use WxTimer.every() for the > timer per your suggestion. I use ruby thread for the other 2 as you > see in the code I posted yesterday. I was suggesting you use Wx::Timer in place of threads. A timer to update the status bar with the current time doesn't need to be much more complicated than: Wx::Timer.every(1000) { self.status_text = Time.now.to_s } No threads needed... > So, when user hit the button, both ruby threads will start/resume > their tasks: one to show the number and one to collect the answer, and > WxTimer shows the time. You can catch when the button is clicked with evt_button, and then just call a method on the other dialog to tell it to stop displaying numbers. Again, I'm sure you don't need threads here. Finally, you can catch when characters are entered in a TextCtrl using evt_text. Or, if you want to monitor the TextCtrl's contents continually, again, just use a Timer and call text_ctrl.value. If you need to stop and start Timed actions, you can capture the return value of Wx::Timer.every and call stop on it: @number_timer = Wx::Timer.every(2500) do display_number # call code to display a new number on the screen end @number_timer.stop # Stop the timer ticking @number_timer.start # Restart it later hth alex From mario at ruby-im.net Wed Feb 20 20:52:48 2008 From: mario at ruby-im.net (Mario Steele) Date: Wed, 20 Feb 2008 19:52:48 -0600 Subject: [wxruby-users] hang on leopard In-Reply-To: <302295.50288.qm@web59309.mail.re1.yahoo.com> References: <302295.50288.qm@web59309.mail.re1.yahoo.com> Message-ID: Hello Zhang, As much as we even would like that to be true, the problem is, there is a difference between all three platforms. On Windows, we use Microsoft Visual C++ Compiler to compile wxRuby, as that is the most common compiler used for Ruby. On Linux, we use GCC, as that is the general one. And on Mac OS X, we use Cocoa for the most part, and some GCC. Now with these three different compilers, each is oviously creating a different executable, where certian features are not going to be available. So while, say on Linux and Windows, we could possibly use Threads to work with the GUI Components of wxRuby, on Mac, that may not be the case. On Mac and on Linux, there are certian classes not available, just like on Windows. Cause of all of this, there are bound to be problems on certian platforms, where they wouldn't arise on others. I've ran into this kind of deal, working with various projects between just Windows and Linux, but it can be worse if adding in Mac OS X. Just cause your doing the same thing as far as code goes between different platforms, the actual backends are doing completely different things, to get things to work the way you want them to. L8ers, Mario Steele On 2/20/08, Zhang Peng wrote: > > Thanks for the explanation, Alex. > > If it is a thread issue, I wonder why I couldn't duplicate it on XP? Since > I can't duplicate it on XP, I was thinking that it is not just a pure thread > issue, but Wx for OSX + ruby thread combination is the culprit. If it is a > pure thread issue, I would think that I should had hit it on XP too since I > did an extensive testing on XP without seeing any problem, unless I was > really lucky to not hit the thread bug on XP. > > I'm already using Mutex for shared variables. > > Thanks for offering help on design choice. I appreciate it ! > > I don't actually have a lot of globals and threads ... only 2 globals and > 3 threads. Let me try to explain: > > I have one dialog box that shows a number flashing on the screen one after > another, and another dialog box that shows the time and a input text field > to collect the answer the user types in for adding up all those numbers from > the other dialog. > > So, I have 2 global variables: one for each instance of the dialog box. I > use global because I do not want to destroy and create a new instance of the > dialog box every time a user want to do the exercise. > > I have 3 threads: one to show the flashing number, one to collect answer, > and one for showing the time. I use WxTimer.every() for the timer per > your suggestion. I use ruby thread for the other 2 as you see in the code I > posted yesterday. > > So, when user hit the button, both ruby threads will start/resume their > tasks: one to show the number and one to collect the answer, and WxTimer > shows the time. > > If I can put the show(true/false) pair within the ruby threads, I do not > need to create another WxTimer threads on my main thread to check when to > "hide" the dialog box. > > Thanks! > > ----- Original Message ---- > From: Alex Fenton > To: General discussion of wxRuby > Sent: Wednesday, February 20, 2008 3:13:54 PM > Subject: Re: [wxruby-users] hang on leopard > > Zhang Peng wrote: > > Finally, I got my code to work properly by not using the show(true) > > and show(false) pair within a thread in the classes that subclass from > > Dialog. The symptoms I experienced if you put the show(true/false) > > pair within a Thread, you get the following problems: > ... > > >From my testing, it surely looks like there is a problem with using > > Wx's show(true/false) within ruby's Thread. > Thanks for posting your code. I agree with your analysis .... but .... > > The wxWidgets documentation and mailing list are clear that GUI calls in > wxWidgets (C++), like show(), should be restricted to a single thread > only. Now, ruby 1.8 threads are not the same as OS threads in wxWidgets, > but some of the issues may be the same. In particular, the error message > that you are getting sounds like OS X is complaining that execution is > being prematurely switched out of some core operation. That sounds to me > like a possible thread problem. > > But hopefully you can see something else that I might had done wrong, > > because it is much easier for me to fix my code > I think it is a primarily a design problem. You have a lot of globals, > and a lot of Threads. In general, if you have a background task running > in a ruby thread, notifications about the status of that thread's work > should be handled either by a properly shared variable (using Mutex if > needed), or by posting a Wx::Event from the slave thread to the master > GUI thread. > > If you were able to say a bit more about why you are using these > Threads, we'd be happy to be more specific about a safer alternative. > > alex > > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > > > > ------------------------------ > Never miss a thing. Make Yahoo your homepage. > > _______________________________________________ > 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/ http://rubyforge.org/projects/vwmc/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080220/af24765f/attachment-0001.html From zpeng1 at yahoo.com Thu Feb 21 10:02:34 2008 From: zpeng1 at yahoo.com (Zhang Peng) Date: Thu, 21 Feb 2008 07:02:34 -0800 (PST) Subject: [wxruby-users] hang on leopard Message-ID: <264736.38315.qm@web59305.mail.re1.yahoo.com> Hi Alex, Thank you so much for taking time to give me the guidance! I'll try your suggestion and remove the threads and see what happens ... Thanks again! ----- Original Message ---- From: Alex Fenton To: General discussion of wxRuby Sent: Wednesday, February 20, 2008 5:35:41 PM Subject: Re: [wxruby-users] hang on leopard Zhang Peng wrote: > If it is a thread issue, I wonder why I couldn't duplicate it on XP? > Since I can't duplicate it on XP, I was thinking that it is not just a > pure thread issue, but Wx for OSX + ruby thread combination is the > culprit. Because wxRuby / wxWidgets uses different native platform functions internally, there's no guarantee that if you're doing something wrong, it will fail in the same way, or at all, on different platforms. But it should always work if done right .... > Thanks for offering help on design choice. I appreciate it ! > > I don't actually have a lot of globals and threads .... only 2 globals > and 3 threads. Let me try to explain: > > I have one dialog box that shows a number flashing on the screen one > after another, and another dialog box that shows the time and a input > text field to collect the answer the user types in for adding up all > those numbers from the other dialog. OK. First of all, I really don't think you need to use threads or globals at all to achieve this. wxRuby like other GUI packages is essentially event driven: updates to the GUI should be driven by events. This includes user interaction (clicking a button) or timed events (a timer ticks). > So, I have 2 global variables: one for each instance of the dialog > box. I use global because I do not want to destroy and create a new > instance of the dialog box every time a user want to do the exercise. Fair enough. You could make them instance variables of your Wx::App class, create them when the app starts, and provide an accessor to them. Then you could access them anywhere in your code with Wx::THE_APP.number_dialog etc. > I have 3 threads: one to show the flashing number, one to collect > answer, and one for showing the time. I use WxTimer.every() for the > timer per your suggestion. I use ruby thread for the other 2 as you > see in the code I posted yesterday. I was suggesting you use Wx::Timer in place of threads. A timer to update the status bar with the current time doesn't need to be much more complicated than: Wx::Timer.every(1000) { self.status_text = Time.now.to_s } No threads needed... > So, when user hit the button, both ruby threads will start/resume > their tasks: one to show the number and one to collect the answer, and > WxTimer shows the time. You can catch when the button is clicked with evt_button, and then just call a method on the other dialog to tell it to stop displaying numbers. Again, I'm sure you don't need threads here. Finally, you can catch when characters are entered in a TextCtrl using evt_text. Or, if you want to monitor the TextCtrl's contents continually, again, just use a Timer and call text_ctrl.value. If you need to stop and start Timed actions, you can capture the return value of Wx::Timer.every and call stop on it: @number_timer = Wx::Timer.every(2500) do display_number # call code to display a new number on the screen end @number_timer.stop # Stop the timer ticking @number_timer.start # Restart it later hth alex _______________________________________________ wxruby-users mailing list wxruby-users at rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080221/5b81cd75/attachment.html From zpeng1 at yahoo.com Thu Feb 21 12:24:28 2008 From: zpeng1 at yahoo.com (Zhang Peng) Date: Thu, 21 Feb 2008 09:24:28 -0800 (PST) Subject: [wxruby-users] hang on leopard Message-ID: <660903.95478.qm@web59311.mail.re1.yahoo.com> Hi Mario, Thanks for the explanation. I appreciate it. The _only_ reason I was trying out scripting language is because of the "cross platform" (write once and use everywhere). I'm going to give another try of _not_ using thread and use WxEvent per Alex's suggestion and see what happens. If it still give the same issues, then I guess I have to rethink my strategy .... Thanks again for the feedback. ----- Original Message ---- From: Mario Steele To: General discussion of wxRuby Sent: Wednesday, February 20, 2008 7:52:48 PM Subject: Re: [wxruby-users] hang on leopard Hello Zhang, As much as we even would like that to be true, the problem is, there is a difference between all three platforms. On Windows, we use Microsoft Visual C++ Compiler to compile wxRuby, as that is the most common compiler used for Ruby. On Linux, we use GCC, as that is the general one. And on Mac OS X, we use Cocoa for the most part, and some GCC. Now with these three different compilers, each is oviously creating a different executable, where certian features are not going to be available. So while, say on Linux and Windows, we could possibly use Threads to work with the GUI Components of wxRuby, on Mac, that may not be the case. On Mac and on Linux, there are certian classes not available, just like on Windows. Cause of all of this, there are bound to be problems on certian platforms, where they wouldn't arise on others. I've ran into this kind of deal, working with various projects between just Windows and Linux, but it can be worse if adding in Mac OS X. Just cause your doing the same thing as far as code goes between different platforms, the actual backends are doing completely different things, to get things to work the way you want them to. L8ers, Mario Steele On 2/20/08, Zhang Peng wrote: Thanks for the explanation, Alex. If it is a thread issue, I wonder why I couldn't duplicate it on XP? Since I can't duplicate it on XP, I was thinking that it is not just a pure thread issue, but Wx for OSX + ruby thread combination is the culprit. If it is a pure thread issue, I would think that I should had hit it on XP too since I did an extensive testing on XP without seeing any problem, unless I was really lucky to not hit the thread bug on XP. I'm already using Mutex for shared variables. Thanks for offering help on design choice. I appreciate it ! I don't actually have a lot of globals and threads ... only 2 globals and 3 threads. Let me try to explain: I have one dialog box that shows a number flashing on the screen one after another, and another dialog box that shows the time and a input text field to collect the answer the user types in for adding up all those numbers from the other dialog. So, I have 2 global variables: one for each instance of the dialog box. I use global because I do not want to destroy and create a new instance of the dialog box every time a user want to do the exercise. I have 3 threads: one to show the flashing number, one to collect answer, and one for showing the time. I use WxTimer.every() for the timer per your suggestion. I use ruby thread for the other 2 as you see in the code I posted yesterday. So, when user hit the button, both ruby threads will start/resume their tasks: one to show the number and one to collect the answer, and WxTimer shows the time. If I can put the show(true/false) pair within the ruby threads, I do not need to create another WxTimer threads on my main thread to check when to "hide" the dialog box. Thanks! ----- Original Message ---- From: Alex Fenton To: General discussion of wxRuby Sent: Wednesday, February 20, 2008 3:13:54 PM Subject: Re: [wxruby-users] hang on leopard Zhang Peng wrote: > Finally, I got my code to work properly by not using the show(true) > and show(false) pair within a thread in the classes that subclass from > Dialog. The symptoms I experienced if you put the show(true/false) > pair within a Thread, you get the following problems: .... > >From my testing, it surely looks like there is a problem with using > Wx's show(true/false) within ruby's Thread. Thanks for posting your code. I agree with your analysis .... but .... The wxWidgets documentation and mailing list are clear that GUI calls in wxWidgets (C++), like show(), should be restricted to a single thread only. Now, ruby 1.8 threads are not the same as OS threads in wxWidgets, but some of the issues may be the same. In particular, the error message that you are getting sounds like OS X is complaining that execution is being prematurely switched out of some core operation. That sounds to me like a possible thread problem. > But hopefully you can see something else that I might had done wrong, > because it is much easier for me to fix my code I think it is a primarily a design problem. You have a lot of globals, and a lot of Threads. In general, if you have a background task running in a ruby thread, notifications about the status of that thread's work should be handled either by a properly shared variable (using Mutex if needed), or by posting a Wx::Event from the slave thread to the master GUI thread. If you were able to say a bit more about why you are using these Threads, we'd be happy to be more specific about a safer alternative. alex _______________________________________________ wxruby-users mailing list wxruby-users at rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users Never miss a thing. Make Yahoo your homepage. _______________________________________________ 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/ http://rubyforge.org/projects/vwmc/ -----Inline Attachment Follows----- _______________________________________________ wxruby-users mailing list wxruby-users at rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080221/cd533977/attachment.html From echobinary at gmail.com Thu Feb 21 14:04:59 2008 From: echobinary at gmail.com (EchoB) Date: Thu, 21 Feb 2008 14:04:59 -0500 Subject: [wxruby-users] More Adventures with Wx::GridTableBase Message-ID: <47BDCB5B.2020707@gmail.com> The saga continues! I have tried linking a grid to a gridtablebase and gotten mixed results but nothing like what i wanted. results have ranged from, nothing to crashing the ruby interpreter. It seems to me you cannot join a GridTableBase to a Grid w/o having data in the GridTableBase first. Is this true? Then, I get an error when I didnt have GetAttr defined in my GridTableBase. HALP! :-D ===GridTableBase class =========== class TimeTableBase < Wx::GridTableBase def initialize(recordset = nil) super() @record_set = recordset end def set_recordset(recordset) @record_set = recordset end def get_number_rows return_value = nil if @record_set != nil return_value = @record_set.count() end return return_value end def get_number_cols return_value = nil if @record_set != nil return_value = @record_set.columns.length end return return_value end def get_col_label_value(col) return col.to_s end def is_empty_cell(row, col) return_value = true cell_value = get_value(row, col) if (cell_value != nil) if cell_value != "" return_value = false end end return return_value end def get_value(row, col) return_value = nil if @record_set != nil begin return_value = @record_set[@record_set.size][row].values[col] rescue end end return return_value end def get_attr(row, col, kind) # "" # Not having this in gave this error: end #main.rb:26:in `get_attr': in method # GetAttr', argument 4 of type # wxGridCellAttr::wxAttrKind' (TypeError) # end =====Frame class ================================== class TimeFrame < Wx::Frame def initialize(timefly, title, pos, size, style= #Wx::MINIMIZE_BOX | Wx::MAXIMIZE_BOX | Wx::RESIZE_BORDER | Wx::SYSTEM_MENU | Wx::CAPTION | Wx::CLOSE_BOX | Wx::CLIP_CHILDREN) super(nil,-1,title,pos,size,style) @timefly = timefly @database = @timefly.database() ... .... .... @time_grid = Wx::Grid.new(self, -1) #@time_grid_table = nil #@time_grid_table = TimeTableBase.new(recordset) #@time_grid.set_table(@time_grid_table) # <-- this line causes # runtime failure and # simply crashes - no # error code evt_button(30) {|evt| on_go_button_pressed(evt)} end def on_go_button_pressed(evt) timelog = @database[:timelog] sc_date = @sc_date.get_value()#+"/"+ at sc_month.get_value()+"/"+ at sc_day.get_value() recordset = timelog#.filter(:time_open => sd_date) if recordset != nil @time_grid_table = nil @time_grid_table = TimeTableBase.new(recordset) #@time_grid.set_table(@time_grid_table) # <-- this line causes # runtime failure and # simply crashes - no # error code end end end ============================================================== From alex at pressure.to Thu Feb 21 16:09:53 2008 From: alex at pressure.to (Alex Fenton) Date: Thu, 21 Feb 2008 21:09:53 +0000 Subject: [wxruby-users] More Adventures with Wx::GridTableBase In-Reply-To: <47BDCB5B.2020707@gmail.com> References: <47BDCB5B.2020707@gmail.com> Message-ID: <47BDE8A1.1060505@pressure.to> EchoB wrote: > I have tried linking a grid to a gridtablebase and gotten mixed results > but nothing like what i wanted. results have ranged from, nothing to > crashing the ruby interpreter. > Please do report crashes, ideally using the bug tracker. Whatever the problem, wxRuby should raise an exception rather than segfault. But we need a complete, self-contained, minimal sample that demonstrates the problem. > It seems to me you cannot join a GridTableBase to a Grid w/o having data > in the GridTableBase first. > Is this true? > Well, whatever your GridTableBase class is, it is obliged to return meaningful values for the required methods (eg get_number_cols, get_number_rows) whatever its internal state. From the code you posted, it seems if the "recordset" is not defined in your GridTable class, it returns nil for those methods. Which it shouldn't do - at least return 0. As I've suggested before, I'm not sure why you're trying to use GridTableBase rather than just using a straightforward Wx::Grid and calling set_value to populate the table whenever the recordset is changed. It would only really be sensible if your recordset is so huge that filling the table manually is too slow. alex From lists at ruby-forum.com Thu Feb 21 17:38:13 2008 From: lists at ruby-forum.com (Robert Armstrong) Date: Thu, 21 Feb 2008 23:38:13 +0100 Subject: [wxruby-users] =?utf-8?q?XRCise_says_=22Cannot_create_wrapper_for?= =?utf-8?q?_subclass_of=09wxWiz?= In-Reply-To: <3993c9319a68d05096d69a3d7498a9b8@ruby-forum.com> References: <15339.64.142.64.96.1194834148.squirrel@webmail.sonic.net> <4738AC46.30505@pressure.to> <3993c9319a68d05096d69a3d7498a9b8@ruby-forum.com> Message-ID: Thanks for the helpful hint. I had just run into this with the current RC of wxFormBuilder 3.0. Setting the subclass value to any valid text solves the error message. -- Posted via http://www.ruby-forum.com/. From mario at ruby-im.net Thu Feb 21 21:14:51 2008 From: mario at ruby-im.net (Mario Steele) Date: Thu, 21 Feb 2008 20:14:51 -0600 Subject: [wxruby-users] hang on leopard In-Reply-To: <660903.95478.qm@web59311.mail.re1.yahoo.com> References: <660903.95478.qm@web59311.mail.re1.yahoo.com> Message-ID: Hey Zhang, No problem. If you need help re-structuring the layout of your program, feel free to email me, and I'll be happy to help you out with it. Good Luck, Mario Steele On 2/21/08, Zhang Peng wrote: > > Hi Mario, > > Thanks for the explanation. I appreciate it. > > The _only_ reason I was trying out scripting language is because of the > "cross platform" (write once and use everywhere). > > I'm going to give another try of _not_ using thread and use WxEvent per > Alex's suggestion and see what happens. > > If it still give the same issues, then I guess I have to rethink my > strategy .... > > Thanks again for the feedback. > > ----- Original Message ---- > From: Mario Steele > To: General discussion of wxRuby > Sent: Wednesday, February 20, 2008 7:52:48 PM > Subject: Re: [wxruby-users] hang on leopard > > Hello Zhang, > > As much as we even would like that to be true, the problem is, there is a > difference between all three platforms. On Windows, we use Microsoft Visual > C++ Compiler to compile wxRuby, as that is the most common compiler used for > Ruby. On Linux, we use GCC, as that is the general one. And on Mac OS X, > we use Cocoa for the most part, and some GCC. Now with these three > different compilers, each is oviously creating a different executable, where > certian features are not going to be available. So while, say on Linux and > Windows, we could possibly use Threads to work with the GUI Components of > wxRuby, on Mac, that may not be the case. On Mac and on Linux, there are > certian classes not available, just like on Windows. > > Cause of all of this, there are bound to be problems on certian platforms, > where they wouldn't arise on others. I've ran into this kind of deal, > working with various projects between just Windows and Linux, but it can be > worse if adding in Mac OS X. > > Just cause your doing the same thing as far as code goes between different > platforms, the actual backends are doing completely different things, to get > things to work the way you want them to. > > L8ers, > Mario Steele > > On 2/20/08, Zhang Peng wrote: > > > > Thanks for the explanation, Alex. > > > > If it is a thread issue, I wonder why I couldn't duplicate it on XP? > > Since I can't duplicate it on XP, I was thinking that it is not just a pure > > thread issue, but Wx for OSX + ruby thread combination is the culprit. If > > it is a pure thread issue, I would think that I should had hit it on XP too > > since I did an extensive testing on XP without seeing any problem, unless I > > was really lucky to not hit the thread bug on XP. > > > > I'm already using Mutex for shared variables. > > > > Thanks for offering help on design choice. I appreciate it ! > > > > I don't actually have a lot of globals and threads ... only 2 globals > > and 3 threads. Let me try to explain: > > > > I have one dialog box that shows a number flashing on the screen one > > after another, and another dialog box that shows the time and a input text > > field to collect the answer the user types in for adding up all those > > numbers from the other dialog. > > > > So, I have 2 global variables: one for each instance of the dialog box. > > I use global because I do not want to destroy and create a new instance of > > the dialog box every time a user want to do the exercise. > > > > I have 3 threads: one to show the flashing number, one to collect > > answer, and one for showing the time. I use WxTimer.every() for the > > timer per your suggestion. I use ruby thread for the other 2 as you see in > > the code I posted yesterday. > > > > So, when user hit the button, both ruby threads will start/resume their > > tasks: one to show the number and one to collect the answer, and WxTimer > > shows the time. > > > > If I can put the show(true/false) pair within the ruby threads, I do not > > need to create another WxTimer threads on my main thread to check when to > > "hide" the dialog box. > > > > Thanks! > > > > ----- Original Message ---- > > From: Alex Fenton > > To: General discussion of wxRuby > > Sent: Wednesday, February 20, 2008 3:13:54 PM > > Subject: Re: [wxruby-users] hang on leopard > > > > Zhang Peng wrote: > > > Finally, I got my code to work properly by not using the show(true) > > > and show(false) pair within a thread in the classes that subclass from > > > > > Dialog. The symptoms I experienced if you put the show(true/false) > > > pair within a Thread, you get the following problems: > > ... > > > >From my testing, it surely looks like there is a problem with using > > > Wx's show(true/false) within ruby's Thread. > > Thanks for posting your code. I agree with your analysis .... but .... > > > > The wxWidgets documentation and mailing list are clear that GUI calls in > > > > wxWidgets (C++), like show(), should be restricted to a single thread > > only. Now, ruby 1.8 threads are not the same as OS threads in wxWidgets, > > > > but some of the issues may be the same. In particular, the error message > > > > that you are getting sounds like OS X is complaining that execution is > > being prematurely switched out of some core operation. That sounds to me > > > > like a possible thread problem. > > > But hopefully you can see something else that I might had done wrong, > > > because it is much easier for me to fix my code > > I think it is a primarily a design problem. You have a lot of globals, > > and a lot of Threads. In general, if you have a background task running > > in a ruby thread, notifications about the status of that thread's work > > should be handled either by a properly shared variable (using Mutex if > > needed), or by posting a Wx::Event from the slave thread to the master > > GUI thread. > > > > If you were able to say a bit more about why you are using these > > Threads, we'd be happy to be more specific about a safer alternative. > > > > alex > > > > > > _______________________________________________ > > wxruby-users mailing list > > wxruby-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/wxruby-users > > > > > > > > ------------------------------ > > Never miss a thing. Make Yahoo your homepage. > > > > _______________________________________________ > > 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/ > http://rubyforge.org/projects/vwmc/ > > -----Inline Attachment Follows----- > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > > > > ------------------------------ > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it > now. > > _______________________________________________ > 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/ http://rubyforge.org/projects/vwmc/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080221/6f774203/attachment.html From zpeng1 at yahoo.com Thu Feb 21 23:08:19 2008 From: zpeng1 at yahoo.com (Zhang Peng) Date: Thu, 21 Feb 2008 20:08:19 -0800 (PST) Subject: [wxruby-users] hang on leopard Message-ID: <747566.88378.qm@web59303.mail.re1.yahoo.com> Hi Mario, Alex and you are great ! I'll try not to bother you guys too much :-) :-) :-) I'm going to restructure my program and not use ruby threads in WxDialog based class, and use WxEvent instead per Alex's suggestion. I'm sure you guys will have a chance to help me out again in the near future :-) :-) :-) Sincerely ... Z.P. ----- Original Message ---- From: Mario Steele To: General discussion of wxRuby Sent: Thursday, February 21, 2008 8:14:51 PM Subject: Re: [wxruby-users] hang on leopard Hey Zhang, No problem. If you need help re-structuring the layout of your program, feel free to email me, and I'll be happy to help you out with it. Good Luck, Mario Steele On 2/21/08, Zhang Peng wrote: Hi Mario, Thanks for the explanation. I appreciate it. The _only_ reason I was trying out scripting language is because of the "cross platform" (write once and use everywhere). I'm going to give another try of _not_ using thread and use WxEvent per Alex's suggestion and see what happens. If it still give the same issues, then I guess I have to rethink my strategy .... Thanks again for the feedback. ----- Original Message ---- From: Mario Steele To: General discussion of wxRuby Sent: Wednesday, February 20, 2008 7:52:48 PM Subject: Re: [wxruby-users] hang on leopard Hello Zhang, As much as we even would like that to be true, the problem is, there is a difference between all three platforms. On Windows, we use Microsoft Visual C++ Compiler to compile wxRuby, as that is the most common compiler used for Ruby. On Linux, we use GCC, as that is the general one. And on Mac OS X, we use Cocoa for the most part, and some GCC. Now with these three different compilers, each is oviously creating a different executable, where certian features are not going to be available. So while, say on Linux and Windows, we could possibly use Threads to work with the GUI Components of wxRuby, on Mac, that may not be the case. On Mac and on Linux, there are certian classes not available, just like on Windows. Cause of all of this, there are bound to be problems on certian platforms, where they wouldn't arise on others. I've ran into this kind of deal, working with various projects between just Windows and Linux, but it can be worse if adding in Mac OS X. Just cause your doing the same thing as far as code goes between different platforms, the actual backends are doing completely different things, to get things to work the way you want them to. L8ers, Mario Steele On 2/20/08, Zhang Peng wrote: Thanks for the explanation, Alex. If it is a thread issue, I wonder why I couldn't duplicate it on XP? Since I can't duplicate it on XP, I was thinking that it is not just a pure thread issue, but Wx for OSX + ruby thread combination is the culprit. If it is a pure thread issue, I would think that I should had hit it on XP too since I did an extensive testing on XP without seeing any problem, unless I was really lucky to not hit the thread bug on XP. I'm already using Mutex for shared variables. Thanks for offering help on design choice. I appreciate it ! I don't actually have a lot of globals and threads ... only 2 globals and 3 threads. Let me try to explain: I have one dialog box that shows a number flashing on the screen one after another, and another dialog box that shows the time and a input text field to collect the answer the user types in for adding up all those numbers from the other dialog. So, I have 2 global variables: one for each instance of the dialog box. I use global because I do not want to destroy and create a new instance of the dialog box every time a user want to do the exercise. I have 3 threads: one to show the flashing number, one to collect answer, and one for showing the time. I use WxTimer.every() for the timer per your suggestion. I use ruby thread for the other 2 as you see in the code I posted yesterday. So, when user hit the button, both ruby threads will start/resume their tasks: one to show the number and one to collect the answer, and WxTimer shows the time. If I can put the show(true/false) pair within the ruby threads, I do not need to create another WxTimer threads on my main thread to check when to "hide" the dialog box. Thanks! ----- Original Message ---- From: Alex Fenton To: General discussion of wxRuby Sent: Wednesday, February 20, 2008 3:13:54 PM Subject: Re: [wxruby-users] hang on leopard Zhang Peng wrote: > Finally, I got my code to work properly by not using the show(true) > and show(false) pair within a thread in the classes that subclass from > Dialog. The symptoms I experienced if you put the show(true/false) > pair within a Thread, you get the following problems: .... > >From my testing, it surely looks like there is a problem with using > Wx's show(true/false) within ruby's Thread. Thanks for posting your code. I agree with your analysis .... but .... The wxWidgets documentation and mailing list are clear that GUI calls in wxWidgets (C++), like show(), should be restricted to a single thread only. Now, ruby 1.8 threads are not the same as OS threads in wxWidgets, but some of the issues may be the same. In particular, the error message that you are getting sounds like OS X is complaining that execution is being prematurely switched out of some core operation. That sounds to me like a possible thread problem. > But hopefully you can see something else that I might had done wrong, > because it is much easier for me to fix my code I think it is a primarily a design problem. You have a lot of globals, and a lot of Threads. In general, if you have a background task running in a ruby thread, notifications about the status of that thread's work should be handled either by a properly shared variable (using Mutex if needed), or by posting a Wx::Event from the slave thread to the master GUI thread. If you were able to say a bit more about why you are using these Threads, we'd be happy to be more specific about a safer alternative. alex _______________________________________________ wxruby-users mailing list wxruby-users at rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users Never miss a thing. Make Yahoo your homepage. _______________________________________________ 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/ http://rubyforge.org/projects/vwmc/ -----Inline Attachment Follows----- _______________________________________________ wxruby-users mailing list wxruby-users at rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. _______________________________________________ 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/ http://rubyforge.org/projects/vwmc/ -----Inline Attachment Follows----- _______________________________________________ wxruby-users mailing list wxruby-users at rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080221/3cfb20b5/attachment-0001.html From lists at ruby-forum.com Fri Feb 22 12:02:22 2008 From: lists at ruby-forum.com (Tim Ferrell) Date: Fri, 22 Feb 2008 18:02:22 +0100 Subject: [wxruby-users] problem with Gauge on windows xp... In-Reply-To: References: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com> <71e9fa0e205b3fc18cbd8510e2be02d6@ruby-forum.com> <3c12d9b081e028f0cf6a8eba5c7b72e4@ruby-forum.com> <47BA2A42.2010908@pressure.to> Message-ID: <87f254451e2b19547ca72ddea5b537fd@ruby-forum.com> Tim Ferrell wrote: > Alex Fenton wrote: >> I have never tried using Wx::App#yield so I'm not sure whether it will >> work correctly within a ruby context on all platforms. You might try an >> alternate strategy of using one or more Ruby threads within which to run >> the downloads. > > That does seem to be the issue... #yield doesn't behave the same under > Windows as it does on OS X :-/ I'll work on using a separate thread for > the downloads and see how that fares... > > Thanks for the help with the xrc issue - I really didn't want to have to > code my interfaces by hand :-p > > Cheers, > Tim Well, I am still seeing some strangeness under Windows ... not sure if I've done something wrong, though... As before this all works fine on my Mac... I wrapped the open-uri call with a thread and added the Wx::Timer.every call to the main app on_init as you suggested like so: -- snippet --- t = Thread.new { File.open(File.join(Dir::tmpdir, fname), 'wb') { |ofile| open(url, :content_length_proc => lambda {|total| size = total }, :progress_proc => lambda { |current| Thread.exit if @dialog.cancelled @dialog.progress_item.value = (100 * (current/size.to_f)).to_i if size > 0 @dialog.update }) { |urlreader| urlreader.binmode ofile.write(urlreader.read) } } } t.join t.kill if t.alive? # kill thread raise "user cancelled" if @dialog.cancelled -- end snippet --- @dialog is an instance of the subclass of the base class generated from my xrc by xrcise... that #update method looks like so: def update(center) self.layout self.fit self.center(Wx::BOTH) if center Wx::get_app.yield Thread.pass end My problem can be shown in these grabs: http://www.mcgeecorp.com/downloads/wxwin00.jpg http://www.mcgeecorp.com/downloads/wxwin01.jpg http://www.mcgeecorp.com/downloads/wxwin02.jpg You can see from this that the text label and the cancel button are not being drawn correctly ... the gauges paint and update fine... After the first file gets downloaded, successive runs through the loop seem clean up the label text but the cancel button never paints right *and* the dialog is unresponsive to user input - if I click the close box I get the windows message that the app has stopped responding... clicking where the close button should be does nothing... Am I doing something wrong or could this be something else? Thanks, Tim -- Posted via http://www.ruby-forum.com/. From mario at ruby-im.net Fri Feb 22 17:25:31 2008 From: mario at ruby-im.net (Mario Steele) Date: Fri, 22 Feb 2008 16:25:31 -0600 Subject: [wxruby-users] problem with Gauge on windows xp... In-Reply-To: <87f254451e2b19547ca72ddea5b537fd@ruby-forum.com> References: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com> <71e9fa0e205b3fc18cbd8510e2be02d6@ruby-forum.com> <3c12d9b081e028f0cf6a8eba5c7b72e4@ruby-forum.com> <47BA2A42.2010908@pressure.to> <87f254451e2b19547ca72ddea5b537fd@ruby-forum.com> Message-ID: Hey Tim, Actually, your code is perfectly fine, there's nothing wrong with it. What is the problem though, is that when your running through your code, and utilizing open-uri, it's utilizing blocking sockets, in which whenever a read method is called on the socket, if there is no data available, it will wait till there is data available. Since Ruby uses Green threads instead of Native OS Threads, this thends to block external C/C++ code from executing, as Ruby's main System OS Thread has priority. This caues, as you have seen, repaint issues, and missed answering of Events generated by wxRuby/wxWidgets. The solution to this problem, is to write the actual Socket calls yourself, to do the calls Asynchronously. You can actually look here: http://wxruby.rubyforge.org/wiki/wiki.pl?Sockets on how to create Asynchronous Sockets with wxRuby, and utilize them to write to and read from sockets, without blocking. However, it is key to note, that since you will be writting the socket routines yourself, you will either have to modify the library your using, in this case open-uri, to use the new socket method routines, instead of the standard one, or you will have to do all the reading, writting, connecting, and disconnecting yourself. If you have any further questions about how to go about implementing this, let me know, and I'll be happy to help you out with it. L8ers, Mario Steele On 2/22/08, Tim Ferrell wrote: > > Tim Ferrell wrote: > > Alex Fenton wrote: > >> I have never tried using Wx::App#yield so I'm not sure whether it will > >> work correctly within a ruby context on all platforms. You might try an > >> alternate strategy of using one or more Ruby threads within which to > run > >> the downloads. > > > > That does seem to be the issue... #yield doesn't behave the same under > > Windows as it does on OS X :-/ I'll work on using a separate thread for > > the downloads and see how that fares... > > > > Thanks for the help with the xrc issue - I really didn't want to have to > > code my interfaces by hand :-p > > > > Cheers, > > Tim > > Well, I am still seeing some strangeness under Windows ... not sure if > I've done something wrong, though... As before this all works fine on my > Mac... > > I wrapped the open-uri call with a thread and added the Wx::Timer.every > call to the main app on_init as you suggested like so: > > -- snippet --- > > t = Thread.new { > File.open(File.join(Dir::tmpdir, fname), 'wb') { |ofile| > open(url, > :content_length_proc => lambda {|total| size = total }, > :progress_proc => lambda { |current| > Thread.exit if @dialog.cancelled > @dialog.progress_item.value = > (100 * (current/size.to_f)).to_i if size > 0 > @dialog.update > }) { |urlreader| > urlreader.binmode > ofile.write(urlreader.read) > } > } > } > t.join > t.kill if t.alive? # kill thread > raise "user cancelled" if @dialog.cancelled > > -- end snippet --- > > @dialog is an instance of the subclass of the base class generated from > my xrc by xrcise... that #update method looks like so: > > def update(center) > self.layout > self.fit > self.center(Wx::BOTH) if center > Wx::get_app.yield > Thread.pass > end > > My problem can be shown in these grabs: > > http://www.mcgeecorp.com/downloads/wxwin00.jpg > http://www.mcgeecorp.com/downloads/wxwin01.jpg > http://www.mcgeecorp.com/downloads/wxwin02.jpg > > You can see from this that the text label and the cancel button are not > being drawn correctly ... the gauges paint and update fine... After the > first file gets downloaded, successive runs through the loop seem clean > up the label text but the cancel button never paints right *and* the > dialog is unresponsive to user input - if I click the close box I get > the windows message that the app has stopped responding... clicking > where the close button should be does nothing... > > Am I doing something wrong or could this be something else? > > Thanks, > Tim > -- > 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/ http://rubyforge.org/projects/vwmc/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080222/2f6bf211/attachment.html From lists at ruby-forum.com Sat Feb 23 11:14:49 2008 From: lists at ruby-forum.com (Tim Ferrell) Date: Sat, 23 Feb 2008 17:14:49 +0100 Subject: [wxruby-users] problem with Gauge on windows xp... In-Reply-To: References: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com> <71e9fa0e205b3fc18cbd8510e2be02d6@ruby-forum.com> <3c12d9b081e028f0cf6a8eba5c7b72e4@ruby-forum.com> <47BA2A42.2010908@pressure.to> <87f254451e2b19547ca72ddea5b537fd@ruby-forum.com> Message-ID: <892aa7be8dc4874f76f25e1916d5a9ae@ruby-forum.com> Mario Steele wrote: > Hey Tim, Hey Mario... > Actually, your code is perfectly fine, there's nothing wrong with it. What > is the problem though, is that when your running through your code, and > utilizing open-uri, it's utilizing blocking sockets, in which whenever a > read method is called on the socket, if there is no data available, it will > wait till there is data available. I can see the concern there ... I would think (perhaps incorrectly) that adding Thread.pass as part of the progress_proc callback would alleviate some of that, though... In any case, I actually see the same problems with painting without using open-uri. I created a stripped down sample here: http://www.mcgeecorp.com/downloads/xrc_test.zip It uses the same xrc and base class as my program with open-uri, etc... but in this case I am just using sleep calls and an upto loop to simulate work. Any other ideas? What version of wxWidgets is bundled with the gem? Could that be an issue here? Thanks! Cheers, Tim -- Posted via http://www.ruby-forum.com/. From zpeng1 at yahoo.com Sat Feb 23 18:29:51 2008 From: zpeng1 at yahoo.com (Zhang Peng) Date: Sat, 23 Feb 2008 15:29:51 -0800 (PST) Subject: [wxruby-users] wxruby 1.9.4 crashes with ruby 1.9.0 Message-ID: <315562.84087.qm@web59310.mail.re1.yahoo.com> I downloaded ruby 1.9.0 and do "make" and "make install" ruby to /usr/local ... When I tried to run my wxruby code, I got the following message ... Any idea what I did wrong? [BUG] unknown type 0x22 (0x12 given) ruby 1.9.0 (2007-12-25 revision 14709) [i686-darwin9.2.0] -- control frame ---------- c:0008 p:-604028 s:0023 b:0023 l:000022 d:000022 TOP c:0007 p:---- s:0021 b:0021 l:000020 d:000020 CFUNC :require c:0006 p:0009 s:0017 b:0017 l:000016 d:000016 TOP /usr/local/lib/ruby/gems/1.9.0/gems/wxruby-1.9.4-universal-darwin-9/lib/wx.rb:12 c:0005 p:---- s:0014 b:0014 l:000013 d:000013 FINISH :class_eval c:0004 p:---- s:0012 b:0012 l:000011 d:000011 CFUNC :require c:0003 p:0009 s:0008 b:0008 l:000007 d:000007 TOP abg.rb:9 c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH :inherited c:0001 p:0000 s:0002 b:0002 l:000001 d:000001 TOP :37724 --------------------------- DBG> : "/usr/local/lib/ruby/gems/1.9.0/gems/wxruby-1.9.4-universal-darwin-9/lib/wx.rb:12:in `require'" DBG> : "/usr/local/lib/ruby/gems/1.9.0/gems/wxruby-1.9.4-universal-darwin-9/lib/wx.rb:12:in `'" DBG> : "abg.rb:9:in `require'" DBG> : "abg.rb:9:in `
'" -- backtrace of native function call (Use addr2line) -- 0xdb486 0x1b7ec 0x1b82b 0x1d9c2 0x1001c5b 0x13050a3 0x1305b9e 0x24be 0xd0e04 0x27279 0xd1910 0xd57a4 0xd9b1c 0xd9de9 0x26ce9 0x2724a 0xd1910 0xd57a4 0xd9b1c 0xd9de9 0x1eca4 0x2380a 0x23df 0x2346 ------------------------------------------------------- Abort trap ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080223/3921fdaa/attachment.html From lists at ruby-forum.com Sat Feb 23 21:16:18 2008 From: lists at ruby-forum.com (Carl Youngblood) Date: Sun, 24 Feb 2008 03:16:18 +0100 Subject: [wxruby-users] draw_poly_polygon Message-ID: Hey everyone, I keep getting in `draw_poly_polygon': in method 'DrawPolyPolygon', argument 3 of type 'int []' (TypeError) from the docs I think it wants g.draw_poly_polygon 2, [1, 2, 3, 4, 5, 6], [Wx::Point.new(25, 0), Wx::Point.new(75, 0), Wx::Point.new(100, 50), Wx::Point.new(75, 100), Wx::Point.new(25, 100), Wx::Point.new(0, 50)] but it just won't fly. Can anyone tell me how to use draw_poly_polygon correctly? Thanks! Carl -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sun Feb 24 15:13:16 2008 From: lists at ruby-forum.com (Gerard Rakoczy) Date: Sun, 24 Feb 2008 21:13:16 +0100 Subject: [wxruby-users] wxruby effect like fxshutter Message-ID: <4656ef5f9f162c23848a7012ec463571@ruby-forum.com> hi, i was searching for an efect in wxruby like fxshutter from fxruby. http://www.fxruby.org/doc/examples.html is it possible to build an skeleton like this in wxruby? i am ruby beginner -- Posted via http://www.ruby-forum.com/. From mario at ruby-im.net Sun Feb 24 18:38:39 2008 From: mario at ruby-im.net (Mario Steele) Date: Sun, 24 Feb 2008 17:38:39 -0600 Subject: [wxruby-users] wxruby effect like fxshutter In-Reply-To: <4656ef5f9f162c23848a7012ec463571@ruby-forum.com> References: <4656ef5f9f162c23848a7012ec463571@ruby-forum.com> Message-ID: Hello Gerard, Currently, there is nothing like that implemented in wxRuby. However, it shouldn't be to hard in which to implement it. It would all have to be hand written, with buttons, and custom drawing. Right now, I don't have time to write up an example. Sorry. L8ers, Mario Steele On 2/24/08, Gerard Rakoczy wrote: > > hi, > i was searching for an efect in wxruby like fxshutter from fxruby. > http://www.fxruby.org/doc/examples.html > > is it possible to build an skeleton like this in wxruby? > > i am ruby beginner > > -- > 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/ http://rubyforge.org/projects/vwmc/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080224/8541a989/attachment.html From alex at pressure.to Mon Feb 25 06:26:55 2008 From: alex at pressure.to (Alex Fenton) Date: Mon, 25 Feb 2008 11:26:55 +0000 Subject: [wxruby-users] problem with Gauge on windows xp... In-Reply-To: <87f254451e2b19547ca72ddea5b537fd@ruby-forum.com> References: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com> <71e9fa0e205b3fc18cbd8510e2be02d6@ruby-forum.com> <3c12d9b081e028f0cf6a8eba5c7b72e4@ruby-forum.com> <47BA2A42.2010908@pressure.to> <87f254451e2b19547ca72ddea5b537fd@ruby-forum.com> Message-ID: <47C2A5FF.1010900@pressure.to> Tim Ferrell wrote: > Well, I am still seeing some strangeness under Windows ... not sure if > I've done something wrong, though... As before this all works fine on my > Mac... > > t.join > t.kill if t.alive? # kill thread Have you tried without Thread#join? It's only really necessary in a script to prevent the whole thing exiting, whereas in a GUI app things will keep running anyway until the app exits (which will presumably check pending downloads). alex From alex at pressure.to Mon Feb 25 06:32:39 2008 From: alex at pressure.to (Alex Fenton) Date: Mon, 25 Feb 2008 11:32:39 +0000 Subject: [wxruby-users] wxruby effect like fxshutter In-Reply-To: <4656ef5f9f162c23848a7012ec463571@ruby-forum.com> References: <4656ef5f9f162c23848a7012ec463571@ruby-forum.com> Message-ID: <47C2A757.5000308@pressure.to> Gerard Rakoczy wrote: > i was searching for an efect in wxruby like fxshutter from fxruby. > http://www.fxruby.org/doc/examples.html The nearest thing is wxToolBook, which allows multiple pages to be controlled (like a notebook), but using icon tools rather than tabs to switch between windows. Unfortunately this is one of the few new classes in wxWidgets 2.8 that isn't currently ported in wxRuby. You could probably create a similar effect by using a ToolBar + using a Sizer to contain the main window, and swap and hide/show panels. alex From alex at pressure.to Mon Feb 25 07:14:32 2008 From: alex at pressure.to (Alex Fenton) Date: Mon, 25 Feb 2008 12:14:32 +0000 Subject: [wxruby-users] wxruby 1.9.4 crashes with ruby 1.9.0 In-Reply-To: <315562.84087.qm@web59310.mail.re1.yahoo.com> References: <315562.84087.qm@web59310.mail.re1.yahoo.com> Message-ID: <47C2B128.2010405@pressure.to> Zhang Peng wrote: > I downloaded ruby 1.9.0 and do "make" and "make install" ruby to > /usr/local ... > > When I tried to run my wxruby code, I got the following message ... There is a known bug in ruby 1.9.0 which affects event handlers of the form: evt_foo :on_foo Do you have any of these in your code? If so see if it works if you specify the event handler like this: evt_foo { | event | on_foo(event) } http://rubyforge.org/tracker/?func=detail&aid=16625&group_id=426&atid=1698 alex From zpeng1 at yahoo.com Mon Feb 25 09:15:36 2008 From: zpeng1 at yahoo.com (Zhang Peng) Date: Mon, 25 Feb 2008 06:15:36 -0800 (PST) Subject: [wxruby-users] wxruby 1.9.4 crashes with ruby 1.9.0 Message-ID: <972035.60728.qm@web59316.mail.re1.yahoo.com> No. I don't have any "evt_foo :on_foo" construct in my code. What else might cause the problem? Thanks! ----- Original Message ---- From: Alex Fenton To: General discussion of wxRuby Sent: Monday, February 25, 2008 6:14:32 AM Subject: Re: [wxruby-users] wxruby 1.9.4 crashes with ruby 1.9.0 Zhang Peng wrote: > I downloaded ruby 1.9.0 and do "make" and "make install" ruby to > /usr/local .... > > When I tried to run my wxruby code, I got the following message .... There is a known bug in ruby 1.9.0 which affects event handlers of the form: evt_foo :on_foo Do you have any of these in your code? If so see if it works if you specify the event handler like this: evt_foo { | event | on_foo(event) } http://rubyforge.org/tracker/?func=detail&aid=16625&group_id=426&atid=1698 alex _______________________________________________ wxruby-users mailing list wxruby-users at rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080225/e27b7c09/attachment.html From alex at pressure.to Mon Feb 25 09:19:52 2008 From: alex at pressure.to (Alex Fenton) Date: Mon, 25 Feb 2008 14:19:52 +0000 Subject: [wxruby-users] wxruby 1.9.4 crashes with ruby 1.9.0 In-Reply-To: <972035.60728.qm@web59316.mail.re1.yahoo.com> References: <972035.60728.qm@web59316.mail.re1.yahoo.com> Message-ID: <47C2CE88.1050200@pressure.to> Zhang Peng wrote: > No. I don't have any "evt_foo :on_foo" construct in my code. > > What else might cause the problem? Hard to say without any code to look at. You did compile your own wxruby against 1.9.0? Binary libraries compiled against ruby 1.8.6 are not compatible with 1.9.0. alex From zpeng1 at yahoo.com Mon Feb 25 15:46:07 2008 From: zpeng1 at yahoo.com (Zhang Peng) Date: Mon, 25 Feb 2008 12:46:07 -0800 (PST) Subject: [wxruby-users] wxruby 1.9.4 crashes with ruby 1.9.0 Message-ID: <412682.14253.qm@web59311.mail.re1.yahoo.com> Ok. That could be the problem then since I did not compile wxruby. I'll check out how to do "compile wxruby against 1.9.0" and see if it works better. Thanks! ----- Original Message ---- From: Alex Fenton To: General discussion of wxRuby Sent: Monday, February 25, 2008 8:19:52 AM Subject: Re: [wxruby-users] wxruby 1.9.4 crashes with ruby 1.9.0 Zhang Peng wrote: > No. I don't have any "evt_foo :on_foo" construct in my code. > > What else might cause the problem? Hard to say without any code to look at. You did compile your own wxruby against 1.9.0? Binary libraries compiled against ruby 1.8.6 are not compatible with 1.9.0. alex _______________________________________________ wxruby-users mailing list wxruby-users at rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080225/3fbbd24f/attachment.html From alex at pressure.to Mon Feb 25 16:01:44 2008 From: alex at pressure.to (Alex Fenton) Date: Mon, 25 Feb 2008 21:01:44 +0000 Subject: [wxruby-users] wxruby 1.9.4 crashes with ruby 1.9.0 In-Reply-To: <412682.14253.qm@web59311.mail.re1.yahoo.com> References: <412682.14253.qm@web59311.mail.re1.yahoo.com> Message-ID: <47C32CB8.8020106@pressure.to> Zhang Peng wrote: > Ok. That could be the problem then since I did not compile wxruby. > > I'll check out how to do "compile wxruby against 1.9.0" and see if it > works better. Should be fairly straightforward on OS X, there's a wiki page with a step-by-step. Any particular reason for using 1.9.0? Whilst it's good to get some testing on there, it's got's plenty of bugs. If you're looking to build real-life apps, I'd stick with 1.8.x best alex From alex at pressure.to Wed Feb 27 06:11:27 2008 From: alex at pressure.to (Alex Fenton) Date: Wed, 27 Feb 2008 11:11:27 +0000 Subject: [wxruby-users] draw_poly_polygon In-Reply-To: References: Message-ID: <47C5455F.8090900@pressure.to> Hi Carl Carl Youngblood wrote: > in `draw_poly_polygon': in method 'DrawPolyPolygon', argument 3 of type > 'int []' (TypeError) > > from the docs I think it wants > > g.draw_poly_polygon 2, [1, 2, 3, 4, 5, 6], [Wx::Point.new(25, 0), > Wx::Point.new(75, 0), Wx::Point.new(100, 50), Wx::Point.new(75, 100), > Wx::Point.new(25, 100), Wx::Point.new(0, 50)] > Thanks for the report; seems this method isn't currently set up correctly in wxRuby. Just stick to using draw_polygon for now. I'll have a look at fixing this bug for the next release. I think the method signature in ruby would simply be: draw_poly_polygon([[array of points], [array of points], [array of points]], offset_x, offset_y, rule) alex From chauk.mean at gmail.com Wed Feb 27 08:38:04 2008 From: chauk.mean at gmail.com (Chauk-Mean P) Date: Wed, 27 Feb 2008 14:38:04 +0100 Subject: [wxruby-users] Missing evt_tree_item_menu method for TreeCtrl ? Message-ID: Hi, The documentation mentions the evt_tree_item_menu method for TreeCtrl but it seems that this method is not defined (wxRuby 1.9.4 on Windows). As a workaround, I'm currently using evt_tree_item_right_click. Cheers. Chauk-Mean. From alex at pressure.to Wed Feb 27 09:41:05 2008 From: alex at pressure.to (Alex Fenton) Date: Wed, 27 Feb 2008 14:41:05 +0000 Subject: [wxruby-users] Missing evt_tree_item_menu method for TreeCtrl ? In-Reply-To: References: Message-ID: <47C57681.5050909@pressure.to> Hi Chauk-Mean P wrote: > The documentation mentions the evt_tree_item_menu method for TreeCtrl > but it seems that this method is not defined (wxRuby 1.9.4 on > Windows). Thanks for spotting that. We'll fix in SVN, but in the meantime if you wanted to use the right event handler you could add the following at the top of your script after require 'wx'. Wx::EvtHandler.register_class(Wx::TreeEvent, Wx::EVT_COMMAND_TREE_ITEM_MENU, 'evt_tree_item_menu', 1) alex From chauk.mean at gmail.com Wed Feb 27 11:03:29 2008 From: chauk.mean at gmail.com (Chauk-Mean P) Date: Wed, 27 Feb 2008 17:03:29 +0100 Subject: [wxruby-users] Missing evt_tree_item_menu method for TreeCtrl ? In-Reply-To: <47C57681.5050909@pressure.to> References: <47C57681.5050909@pressure.to> Message-ID: Hi Alex, 2008/2/27, Alex Fenton : > in the meantime if you wanted to use the right event handler > you could add the following at the > top of your script after require 'wx'. > > Wx::EvtHandler.register_class(Wx::TreeEvent, > Wx::EVT_COMMAND_TREE_ITEM_MENU, > 'evt_tree_item_menu', 1) > Thanks. This is much better than my basic workaround. Now the contextual menu key on my keyboard works also. Chauk-Mean. From echobinary at gmail.com Wed Feb 27 11:36:23 2008 From: echobinary at gmail.com (EchoB) Date: Wed, 27 Feb 2008 11:36:23 -0500 Subject: [wxruby-users] More Adventures with Wx::GridTableBase In-Reply-To: References: Message-ID: <47C59187.40906@gmail.com> > Well, whatever your GridTableBase class is, it is obliged to return > meaningful values for the required methods (eg get_number_cols, > get_number_rows) whatever its internal state. From the code you posted, > it seems if the "recordset" is not defined in your GridTable class, it > returns nil for those methods. Which it shouldn't do - at least return 0. > > As I've suggested before, I'm not sure why you're trying to use > GridTableBase rather than just using a straightforward Wx::Grid and > calling set_value to populate the table whenever the recordset is > changed. It would only really be sensible if your recordset is so huge > that filling the table manually is too slow. Ok. What is the order of operations one should use to define a grid, and then a gridtablebase? My dataset is going to change many times at runtime. Here is the larger picture: My application is a time tracking application, working like a punch clock. So projectIDs, TimeIn, TimeOut, and descriptions can get into the hundreds per week and defiantly per month. I have an Sqlite3 database with Sequel as the abstraction layer retrieving the dataset. I have completed the "data entry" portion of my project. In order for that information to be useful, I need to be able to view it, etc. I am passing Sequel datasets to my derived wxGridTableBase class. The nature of my dataset is that I would like to adjust the dataset on an event driven basis. For example button(s) to switch views between: week summary of hours month summary of hours daily summary of hours etc.. All ordered by projectID. I can handle the sql queries. But I have yet to even be able to successfully link the wxGrid to the wxGridTableBase. I have scoured forums and the wxRuby docs, sample code (BigDemo, etc...), and asked in #wxruby. Google returns results in wxPython, but that doesn't help me. I guess I just don't know what I'm doing with it yet. To sum up: 1) What is the best practice or order of operations for defining a wxGrid and then linking it to a wxGridTableBase? 2) Is the linking in #1 possible to do on a runtime event-driven basis? 3) Is there any wxRuby demo code anywhere? Or where can I find more ruby/wxruby 'centric documentation on this class? From lists at ruby-forum.com Wed Feb 27 16:41:46 2008 From: lists at ruby-forum.com (Tim Ferrell) Date: Wed, 27 Feb 2008 22:41:46 +0100 Subject: [wxruby-users] problem with Gauge on windows xp... In-Reply-To: <47C2A5FF.1010900@pressure.to> References: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com> <71e9fa0e205b3fc18cbd8510e2be02d6@ruby-forum.com> <3c12d9b081e028f0cf6a8eba5c7b72e4@ruby-forum.com> <47BA2A42.2010908@pressure.to> <87f254451e2b19547ca72ddea5b537fd@ruby-forum.com> <47C2A5FF.1010900@pressure.to> Message-ID: <800ff042b40806f330a946e2e8becf02@ruby-forum.com> Alex Fenton wrote: > Tim Ferrell wrote: >> Well, I am still seeing some strangeness under Windows ... not sure if >> I've done something wrong, though... As before this all works fine on my >> Mac... >> >> t.join >> t.kill if t.alive? # kill thread > Have you tried without Thread#join? It's only really necessary in a > script to prevent the whole thing exiting, whereas in a GUI app things > will keep running anyway until the app exits (which will presumably > check pending downloads). > > alex The code snippet I provided did not give enough context ... that snippet is called in a loop and I use Thread#join to have the loop wait until that thread finishes before proceeding to the next item to process... I would need to do some kind of polling of thread status otherwise and that just seemed cleaner... I did notice another thing of interest with the xrc_test I did... Bear in mind there is not any blocking IO going on - just a simple counter loop with a short sleep to simulate work... I had the following code in an update method in the subclass of the xrc-derived progress dialog: def update self.layout self.fit self.center(Wx::BOTH) Wx::get_app.yield end and I noticed painting artifacts and the like even though there was little going on. I took out this method call (which I had after I updated the label text as part of the counter loop) and the painting problems went away! Of course the dialog does not resize itself then so that isn't really a fix, but it did hint at the problem being one of the calls made in that method. I commented them out in turn and discovered that it is the Frame#fit method that is causing the painting weirdness. Any ideas what could be causing that? Is my usage of it proper? Thanks! Tim -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Feb 27 17:34:14 2008 From: lists at ruby-forum.com (Gerard Rakoczy) Date: Wed, 27 Feb 2008 23:34:14 +0100 Subject: [wxruby-users] use of sqlite Message-ID: hi, well, i have another problem. i would like to use a sqlite based database in my application. do i need only sqlite gem and binaries or also wxsqlite? and how to use it? maybe some tutorial or some guidelines... thanks a lot -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Wed Feb 27 17:44:34 2008 From: alex at pressure.to (Alex Fenton) Date: Wed, 27 Feb 2008 22:44:34 +0000 Subject: [wxruby-users] use of sqlite In-Reply-To: References: Message-ID: <47C5E7D2.3090400@pressure.to> Gerard Rakoczy wrote: > well, i have another problem. i would like to use a sqlite based > database in my application. do i need only sqlite gem and binaries or > also wxsqlite? > Only wxRuby plus sqlite are required. SQLite is a great choice for an application storage - I've been using it for several years as the backend for a GUI application. > and how to use it? Well, that's up to you. There's no particular tricks here - just load and save the data to the database, and put a cute GUI on top of it. If you run into problems, feel free to ask here. alex From lists at ruby-forum.com Wed Feb 27 22:42:59 2008 From: lists at ruby-forum.com (Tim Ferrell) Date: Thu, 28 Feb 2008 04:42:59 +0100 Subject: [wxruby-users] use of sqlite In-Reply-To: References: Message-ID: <86744925e4166fe18ee82cceeb95160a@ruby-forum.com> Gerard Rakoczy wrote: > maybe some tutorial or some guidelines... maybe this might help? http://sqlite-ruby.rubyforge.org/sqlite3/faq.html Cheers, Tim -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Thu Feb 28 05:35:51 2008 From: alex at pressure.to (Alex Fenton) Date: Thu, 28 Feb 2008 10:35:51 +0000 Subject: [wxruby-users] problem with Gauge on windows xp... In-Reply-To: <800ff042b40806f330a946e2e8becf02@ruby-forum.com> References: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com> <71e9fa0e205b3fc18cbd8510e2be02d6@ruby-forum.com> <3c12d9b081e028f0cf6a8eba5c7b72e4@ruby-forum.com> <47BA2A42.2010908@pressure.to> <87f254451e2b19547ca72ddea5b537fd@ruby-forum.com> <47C2A5FF.1010900@pressure.to> <800ff042b40806f330a946e2e8becf02@ruby-forum.com> Message-ID: <47C68E87.3010507@pressure.to> Tim Ferrell wrote: > The code snippet I provided did not give enough context ... that snippet > is called in a loop and I use Thread#join to have the loop wait until > that thread finishes before proceeding to the next item to process... I > would need to do some kind of polling of thread status otherwise and > that just seemed cleaner... > This is from the pickaxe documentation of Thread.join: "The calling thread will suspend execution and run /thr/. Does not return until /thr/ exits. Any threads not joined will be killed when the main program exits." I don't think this is what you want - i.e. to suspend execution of the GUI thread while the download runs. If you want the GUI to keep updating, polling is the way to go. It needn't be complicated. In your case it could be a simple as something like this, assuming the download is in a thread saved as @download_thread Wx::Timer.every(100) do if not @download_thread.status # false = finished normally, nil = finished with exception @download_thread = start_next_job end end Using Wx::Timer is probably preferable to sleep in your circumstance as it will give more reliable timings. > I commented them out in turn and discovered > that it is the Frame#fit method that is causing the painting weirdness. > Any ideas what could be causing that? Is my usage of it proper? > Looks OK to me. I guess it's just because calling fit causes a repaint, which isn't otherwise visible. Hopefully using the threads right will resolve this hth alex From lists at ruby-forum.com Thu Feb 28 11:18:51 2008 From: lists at ruby-forum.com (Tim Ferrell) Date: Thu, 28 Feb 2008 17:18:51 +0100 Subject: [wxruby-users] problem with Gauge on windows xp... In-Reply-To: <47C68E87.3010507@pressure.to> References: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com> <71e9fa0e205b3fc18cbd8510e2be02d6@ruby-forum.com> <3c12d9b081e028f0cf6a8eba5c7b72e4@ruby-forum.com> <47BA2A42.2010908@pressure.to> <87f254451e2b19547ca72ddea5b537fd@ruby-forum.com> <47C2A5FF.1010900@pressure.to> <800ff042b40806f330a946e2e8becf02@ruby-forum.com> <47C68E87.3010507@pressure.to> Message-ID: <9d45b60f13b52bc7945a09f99c053b03@ruby-forum.com> Alex Fenton wrote: > Looks OK to me. I guess it's just because calling fit causes a repaint, > which isn't otherwise visible. Hopefully using the threads right will > resolve this > Hey Alex - I tried your suggestion, removing Thread#join in favor of a polling loop... and I still see the same odd painting errors on XP and the GUI remains unresponsive to user interaction (no matter how hard I click *grin*)... Maybe I'm just not understanding this clearly... as I see it there are 3 threads involved here: the main program thread, the gui thread spawned by Wx::App.main_loop, and the thread I am spawning to wrap the open-uri call... I think I have a handle on having them all pass off to each other and the app works fine on my mac and on Ubuntu - in both my test app and the full program I only see the painting problems and unresponsiveness under Windows... Could this be the result of some bug in wxWidgets? What version is bundled with the wxRuby gem? If it would help I'd be happy to try and set up a debuggable environment here ... I assume I'd need VC6 to compile since that is what the One-Click installer uses but are there any special steps I'd need to take with wxMSW and wxRuby? Is there, perhaps, a guide to setting up all of this from source? In any case, thanks much to you and Mario both for your help and suggestions thus far :-) Cheers, Tim -- Posted via http://www.ruby-forum.com/. From jacekwiktor at gmail.com Thu Feb 28 13:07:56 2008 From: jacekwiktor at gmail.com (Jacek Nowak) Date: Thu, 28 Feb 2008 19:07:56 +0100 Subject: [wxruby-users] A bug in wxRuby. Segmentation fault in random situations. In-Reply-To: <47BBDA8B.7080906@pressure.to> References: <570d9b010802170815p2750966br89e5d65ce70584f3@mail.gmail.com> <47BA27CA.4000108@pressure.to> <570d9b010802190319r3cb8cfc7gc9bfdf4b51e5bef2@mail.gmail.com> <47BAC628.7060409@pressure.to> <570d9b010802190717x78573832j58331e50fb953a8e@mail.gmail.com> <47BBDA8B.7080906@pressure.to> Message-ID: <570d9b010802281007u18d4d81ap7cbb33299e99ec7c@mail.gmail.com> Hi, I have a lot of trouble trying to find out what exactly causes the bug. Generally it seems that the more code I remove from my application, the more rarely the crash happens. What I did: 1. First I removed all calls of method "destroy" in dialogs. Normally my code for displaying dialogs was everywhere like that: d = SomeDialog.new(self,-1,"title",some_arguments) d.show_modal d.destroy I removed all calls to "destroy" and it _seems_ that now my application crashes less often (at least it doesn't crash in the place where it always crashed before). But still it crashes from time to time. 2. I managed to create a small chunk of code which always crashes just after closing of MDIChildFrame but it crashes only when gc_stress is set to 1ms or something near that. If I set it to 1s or more I'm not able to trigger the crash so I don't know if this is the issue of GC called too often or the problem with the code. I am sending you the code below: # ============== BEGIN OF CODE: #!/usr/bin/env ruby require 'rubygems' require 'wx' include Wx class KatalogTowarowFrame < Wx::MDIChildFrame def initialize(parent,id,title) super(parent,id,title) button1 = Button.new(self,-1,"aaaa") button2 = Button.new(self,-1,"bbbb") sizer1 = BoxSizer.new(HORIZONTAL) sizer1.add(button1,1,GROW,2) sizer1.add(button2,1,GROW,2) set_sizer(sizer1) end end class MainFrame < Wx::MDIParentFrame def initialize super(nil, -1, "Application that crashes", DEFAULT_POSITION, Wx::Size.new(800,600), DEFAULT_FRAME_STYLE | VSCROLL | HSCROLL | FRAME_NO_WINDOW_MENU) menu1 = Menu.new menu1.append(5000, "test test","test test") menubar = MenuBar.new() menubar.append(menu1,"fdlgfdgfdgddffgd") set_menu_bar(menubar) create_status_bar evt_menu(5000) {|event| on_a(event)} end def on_a(event) win = KatalogTowarowFrame.new(self,-1,"Kartoteka towarow") win.show win.set_focus end end class Aplikacja < Wx::App def on_init gc_stress mainframe = MainFrame.new mainframe.set_title("abc") mainframe.show() end end Aplikacja.new.main_loop # ============== END OF CODE -- Jacek Nowak jacekwiktor at gmail.com From alex at pressure.to Thu Feb 28 13:15:26 2008 From: alex at pressure.to (Alex Fenton) Date: Thu, 28 Feb 2008 18:15:26 +0000 Subject: [wxruby-users] problem with Gauge on windows xp... In-Reply-To: <9d45b60f13b52bc7945a09f99c053b03@ruby-forum.com> References: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com> <71e9fa0e205b3fc18cbd8510e2be02d6@ruby-forum.com> <3c12d9b081e028f0cf6a8eba5c7b72e4@ruby-forum.com> <47BA2A42.2010908@pressure.to> <87f254451e2b19547ca72ddea5b537fd@ruby-forum.com> <47C2A5FF.1010900@pressure.to> <800ff042b40806f330a946e2e8becf02@ruby-forum.com> <47C68E87.3010507@pressure.to> <9d45b60f13b52bc7945a09f99c053b03@ruby-forum.com> Message-ID: <47C6FA3E.8040107@pressure.to> Tim Ferrell wrote: > Alex Fenton wrote: > > I tried your suggestion, removing Thread#join in favor of a polling > loop... and I still see the same odd painting errors on XP and the GUI > remains unresponsive to user interaction (no matter how hard I click > *grin*)... > I'm sorry that didn't help. Is this a problem only when downloading in the background, or even with a fake work task like 'sleep'? > Maybe I'm just not understanding this clearly... as I see it there are 3 > threads involved here: the main program thread, the gui thread spawned > by Wx::App.main_loop, and the thread I am spawning to wrap the open-uri > call... > main_loop doesn't spawn a thread itself - the main program thread is the GUI thread. That's why I was thinking that things that temporarily halt execution of that thread - like join - could stall updates. > Could this be the result of some bug in wxWidgets? What version is > bundled with the wxRuby gem? The version is that latest stable 2.8.7. It could be a wx bug, but much more likely is a problem in the way Ruby threads interact with the event and scheduling internals. All of the GUI toolkits face this problem - that they are not designed with ruby's threading model in mind. > If it would help I'd be happy to try and > set up a debuggable environment here ... I assume I'd need VC6 to > compile since that is what the One-Click installer uses but are there > any special steps I'd need to take with wxMSW and wxRuby? Is there, > perhaps, a guide to setting up all of this from source? Thanks for the offer. We use VC 7.1 as 6.0 isn't available. The wiki has several quite detailed pages on compiling wxWidgets and wxRuby. I'm not sure how helpful this will be, though - I think it's more a question of designing the use of threads to avoid the problem. Are you able to reduce it to a simple standalone sample - perhaps by altering the samples/etc/threaded.rb example to demonstrate it? thanks alex From lists at ruby-forum.com Thu Feb 28 13:53:51 2008 From: lists at ruby-forum.com (Tim Ferrell) Date: Thu, 28 Feb 2008 19:53:51 +0100 Subject: [wxruby-users] problem with Gauge on windows xp... In-Reply-To: <47C6FA3E.8040107@pressure.to> References: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com> <71e9fa0e205b3fc18cbd8510e2be02d6@ruby-forum.com> <3c12d9b081e028f0cf6a8eba5c7b72e4@ruby-forum.com> <47BA2A42.2010908@pressure.to> <87f254451e2b19547ca72ddea5b537fd@ruby-forum.com> <47C2A5FF.1010900@pressure.to> <800ff042b40806f330a946e2e8becf02@ruby-forum.com> <47C68E87.3010507@pressure.to> <9d45b60f13b52bc7945a09f99c053b03@ruby-forum.com> <47C6FA3E.8040107@pressure.to> Message-ID: <337de74230338e6d814671364584bbec@ruby-forum.com> Alex Fenton wrote: > I'm sorry that didn't help. Is this a problem only when downloading in > the background, or even with a fake work task like 'sleep'? This happens even with the test app I posted above that simulates the download thread work with a short sleep call... and, again, only under Windows :-) Here is the link: http://www.mcgeecorp.com/downloads/xrc_test.zip > main_loop doesn't spawn a thread itself - the main program thread is the > GUI thread. That's why I was thinking that things that temporarily halt > execution of that thread - like join - could stall updates. Ah... thanks for the clarification :-) Although I am new to wxRuby (and, as such, still getting my bearings), it looks to have a great blend of features and I'd like to get to a point where I can contribute in some way or another. Cheers, Tim -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Thu Feb 28 16:15:19 2008 From: alex at pressure.to (Alex Fenton) Date: Thu, 28 Feb 2008 21:15:19 +0000 Subject: [wxruby-users] problem with Gauge on windows xp... In-Reply-To: <337de74230338e6d814671364584bbec@ruby-forum.com> References: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com> <71e9fa0e205b3fc18cbd8510e2be02d6@ruby-forum.com> <3c12d9b081e028f0cf6a8eba5c7b72e4@ruby-forum.com> <47BA2A42.2010908@pressure.to> <87f254451e2b19547ca72ddea5b537fd@ruby-forum.com> <47C2A5FF.1010900@pressure.to> <800ff042b40806f330a946e2e8becf02@ruby-forum.com> <47C68E87.3010507@pressure.to> <9d45b60f13b52bc7945a09f99c053b03@ruby-forum.com> <47C6FA3E.8040107@pressure.to> <337de74230338e6d814671364584bbec@ruby-forum.com> Message-ID: <47C72467.1070406@pressure.to> Tim Ferrell wrote: > This happens even with the test app I posted above that simulates the > download thread work with a short sleep call... and, again, only under > Windows :-) > > Here is the link: http://www.mcgeecorp.com/downloads/xrc_test.zip > Attached is a version of your main app code restructured along the lines I was suggesting. The jobs run in threads, and a Wx::Timer repeating task (monitor) checks the state of the queue and whether cancelled. This works well for me on OS X and Windows. I think the problem may be using ruby's sleep in the main thread - I guess on Windows this stops wx updating to screen. I don't think you need to call update at all. > Although I am new to wxRuby (and, as such, still getting my bearings), > it looks to have a great blend of features and I'd like to get to a > point where I can contribute in some way or another. Thanks. Just being patient with problems and working through them on the list is much appreciated. Even if no-one remembers the solution, it's archived and searchable. cheers alex -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: xrc_test.rb Url: http://rubyforge.org/pipermail/wxruby-users/attachments/20080228/b7fbed98/attachment.pl From lists at ruby-forum.com Thu Feb 28 17:48:25 2008 From: lists at ruby-forum.com (Tim Ferrell) Date: Thu, 28 Feb 2008 23:48:25 +0100 Subject: [wxruby-users] problem with Gauge on windows xp... In-Reply-To: <47C72467.1070406@pressure.to> References: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com> <71e9fa0e205b3fc18cbd8510e2be02d6@ruby-forum.com> <3c12d9b081e028f0cf6a8eba5c7b72e4@ruby-forum.com> <47BA2A42.2010908@pressure.to> <87f254451e2b19547ca72ddea5b537fd@ruby-forum.com> <47C2A5FF.1010900@pressure.to> <800ff042b40806f330a946e2e8becf02@ruby-forum.com> <47C68E87.3010507@pressure.to> <9d45b60f13b52bc7945a09f99c053b03@ruby-forum.com> <47C6FA3E.8040107@pressure.to> <337de74230338e6d814671364584bbec@ruby-forum.com> <47C72467.1070406@pressure.to> Message-ID: Alex Fenton wrote: > > Attached is a version of your main app code restructured along the lines > I was suggesting. The jobs run in threads, and a Wx::Timer repeating > task (monitor) checks the state of the queue and whether cancelled. > > This works well for me on OS X and Windows. I think the problem may be > using ruby's sleep in the main thread - I guess on Windows this stops wx > updating to screen. > > I don't think you need to call update at all. > It ran fine for me on XP (thanks!) but for some reason when running it on my Mac it just freezes up as soon as it starts... I'm on Leopard (10.5.2) using MacPorts for ruby with the latest wxruby gem... Any ideas what might be happening?? Sorry to be such a bother... Cheers, Tim -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Thu Feb 28 18:31:08 2008 From: alex at pressure.to (Alex Fenton) Date: Thu, 28 Feb 2008 23:31:08 +0000 Subject: [wxruby-users] problem with Gauge on windows xp... In-Reply-To: References: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com> <71e9fa0e205b3fc18cbd8510e2be02d6@ruby-forum.com> <3c12d9b081e028f0cf6a8eba5c7b72e4@ruby-forum.com> <47BA2A42.2010908@pressure.to> <87f254451e2b19547ca72ddea5b537fd@ruby-forum.com> <47C2A5FF.1010900@pressure.to> <800ff042b40806f330a946e2e8becf02@ruby-forum.com> <47C68E87.3010507@pressure.to> <9d45b60f13b52bc7945a09f99c053b03@ruby-forum.com> <47C6FA3E.8040107@pressure.to> <337de74230338e6d814671364584bbec@ruby-forum.com> <47C72467.1070406@pressure.to> Message-ID: <47C7443C.6050309@pressure.to> Tim Ferrell wrote: > It ran fine for me on XP (thanks!) but for some reason when running it > on my Mac it just freezes up as soon as it starts... I'm on Leopard > (10.5.2) using MacPorts for ruby with the latest wxruby gem... Any ideas > what might be happening?? I tried it on 10.5.2 with system ruby + 1.9.4 gem - after a few runs, I see what you mean. I got this error message once. 2008-02-28 23:06:02.105 ruby[64018:10b] *** Exception handlers were not properly removed. Some code has jumped or returned out of an NS_DURING...NS_HANDLER region without using the NS_VOIDRETURN or NS_VALUERETURN macros. Which makes me think that the thread scheduler is jumping out of some critical portion of GUI code. I reworked the example so that all GUI updating is done through the main thread, using monitor to check progress with thread-local variables. This seems to work reliably now on OS X. hth alex __ def start_job(idx) Thread.abort_on_exception = true url = "blah #{idx}" fname = File.basename(url) @dialog.status_label.label = "Faking download #{idx} of #{10}: #{fname}" @dialog.update @dialog.progress_all.value = (100 * (idx/10.0)).to_i @worker = Thread.new do Thread.current[:progress] = 0 1.upto(10) do | count | break if @dialog.cancelled Thread.current[:progress] = (100 * (count/10.0)).to_i sleep(0.1) end if @dialog.cancelled Thread.stop end end end # Test the state of the queue and worker progress def monitor_jobs if not @worker # Get started @dialog.show start_job(@job_n) elsif @worker and @job_n < 10 # Still running if @dialog.cancelled # test for cancellation finish end if @worker.status @dialog.progress_item.value = @worker[:progress] else # start next start_job(@job_n += 1) end else # completed finish end end From dirk.traulsen at lypso.de Fri Feb 29 02:56:00 2008 From: dirk.traulsen at lypso.de (Dirk Traulsen) Date: Fri, 29 Feb 2008 08:56:00 +0100 Subject: [wxruby-users] Thread code questions In-Reply-To: <47C7443C.6050309@pressure.to> References: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com>, , <47C7443C.6050309@pressure.to> Message-ID: <47C7C8A0.120.37C8EBA6@dirk.traulsen.lypso.de> Hi! I followed the 'problem with Gauge on windows xp...' discussion and I'm having difficulties to understand the resulting code from Alex. As my problems are not connected to Tims problem, I start a new one. Please bear in mind that these are questions because I would like to understand the code and are not meant as a critical comment about the code. Am 28 Feb 2008 um 23:31 hat Alex Fenton geschrieben: > >def start_job(idx) > Thread.abort_on_exception = true > url = "blah #{idx}" > fname = File.basename(url) > @dialog.status_label.label = "Faking download #{idx} of #{10}: #{fname}" 1. Is there any advantage of writing "#{10}" instead of "10" here, I don't see? > @dialog.update > @dialog.progress_all.value = (100 * (idx/10.0)).to_i > @worker = Thread.new do > Thread.current[:progress] = 0 2. Is Thread.current not identical with self inside the block? 3. Why do we have to define the thread-local progress here? Without this line it would also be defined as a thread-local variable in the upto-block, wouldn't be a block variable and would so survive the block cycles, wouldn't it? > 1.upto(10) do | count | > break if @dialog.cancelled > Thread.current[:progress] = (100 * (count/10.0)).to_i 4. Why is the former @dialog.update now unnecessary? > sleep(0.1) > end > if @dialog.cancelled > Thread.stop > end 5. Why not directely 'Thread.stop if @dialog.cancelled' in the upto- block? finish exits in this case anyway. What am I overlooking? > end >end Am 28 Feb 2008 um 21:15 hat Alex Fenton geschrieben: > def finish > @monitor.stop > if @dialog.cancelled > @dialog.hide > md = Wx::MessageDialog.new(@dialog, "You cancelled!", > TITLE, > Wx::OK|Wx::ICON_EXCLAMATION) > md.show_modal > code = 1 > else > @dialog.progress_all.value = 100 > @dialog.hide > md = Wx::MessageDialog.new(@dialog, 'Fake download(s) complete!', > TITLE, Wx::OK, Wx::DEFAULT_POSITION) > md.show_modal > @dialog.hide 6. Why do we need '@dialog.hide' two times? > code = 0 > end > @dialog.destroy > exit(code) > end Thanks in advance if someone is willing to help me understand. Dirk From alex at pressure.to Fri Feb 29 03:29:52 2008 From: alex at pressure.to (Alex Fenton) Date: Fri, 29 Feb 2008 08:29:52 +0000 Subject: [wxruby-users] Thread code questions In-Reply-To: <47C7C8A0.120.37C8EBA6@dirk.traulsen.lypso.de> References: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com>, , <47C7443C.6050309@pressure.to> <47C7C8A0.120.37C8EBA6@dirk.traulsen.lypso.de> Message-ID: <47C7C280.7000000@pressure.to> Hi Dirk Dirk Traulsen wrote: > I followed the 'problem with Gauge on windows xp...' discussion and I'm > having difficulties to understand the resulting code from Alex. As my > problems are not connected to Tims problem, I start a new one. > Cool - it's been a useful thread for me too. > Please bear in mind that these are questions because I would like to > understand the code and are not meant as a critical comment about the > code. > I made quick minimal changes to the original code to address the threading only, and Tim's code was extracted from a real app, so some elements may well be redundant. >> @dialog.status_label.label = "Faking download #{idx} of #{10}: #{fname}" >> > > 1. Is there any advantage of writing "#{10}" instead of "10" here, I > don't see? > No, there isn't. I guess in Tim's code it was a place holder where in the real code a variable would go. >> @dialog.update >> @dialog.progress_all.value = (100 * (idx/10.0)).to_i >> @worker = Thread.new do >> Thread.current[:progress] = 0 >> > > 2. Is Thread.current not identical with self inside the block? > No, self remains the same as it was (in this case, the instance of XRCTest). It's a new execution thread, but nothing about the scope changes. Compare - a File.open do ... end block doesn't change "self" to the file within it. > 3. Why do we have to define the thread-local progress here? Without > this line it would also be defined as a thread-local variable in the > upto-block, wouldn't be a block variable and would so survive the block > cycles, wouldn't it? > Because potentially "monitor" could be called again in the main thread, and in that, access the local variable before the execution in the worker thread reaches the point where the local variable is set. Then it'd be passing nil to progress.value= which is an exception. Try putting a "sleep 1" in the line immediately before this, and see what happens. >> 1.upto(10) do | count | >> break if @dialog.cancelled >> Thread.current[:progress] = (100 * (count/10.0)).to_i >> > > 4. Why is the former @dialog.update now unnecessary? > I think Tim was calling update because he wasn't seeing the dialog refreshing. But it happened not to be the root of the problem. All of the in-built GUI widgets in wxRuby redraw themselves automatically as their state changes. Calling fit or layout upon a sizer is only needed when the contents of a container are changed - a widget is removed, or added. >> sleep(0.1) >> end >> if @dialog.cancelled >> Thread.stop >> end >> > > 5. Why not directely 'Thread.stop if @dialog.cancelled' in the upto- > block? finish exits in this case anyway. What am I overlooking? > That should work too and save a few lines, though I haven't tested. >> @dialog.progress_all.value = 100 >> @dialog.hide >> md = Wx::MessageDialog.new(@dialog, 'Fake download(s) complete!', >> TITLE, Wx::OK, Wx::DEFAULT_POSITION) >> md.show_modal >> @dialog.hide >> > > 6. Why do we need '@dialog.hide' two times? > We don't :) hth alex From dirk.traulsen at lypso.de Fri Feb 29 05:54:07 2008 From: dirk.traulsen at lypso.de (Dirk Traulsen) Date: Fri, 29 Feb 2008 11:54:07 +0100 Subject: [wxruby-users] Thread code questions In-Reply-To: <47C7C280.7000000@pressure.to> References: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com>, <47C7C8A0.120.37C8EBA6@dirk.traulsen.lypso.de>, <47C7C280.7000000@pressure.to> Message-ID: <47C7F25F.26231.386BFAFF@dirk.traulsen.lypso.de> Alex, thank you for your clear and helpful explanations. Dirk From lists at ruby-forum.com Fri Feb 29 08:05:51 2008 From: lists at ruby-forum.com (Tim Ferrell) Date: Fri, 29 Feb 2008 14:05:51 +0100 Subject: [wxruby-users] Thread code questions In-Reply-To: <47C7C280.7000000@pressure.to> References: <618d7e63e2c50ced538d0be2c1034b30@ruby-forum.com> <71e9fa0e205b3fc18cbd8510e2be02d6@ruby-forum.com> <3c12d9b081e028f0cf6a8eba5c7b72e4@ruby-forum.com> <47BA2A42.2010908@pressure.to> <87f254451e2b19547ca72ddea5b537fd@ruby-forum.com> <47C2A5FF.1010900@pressure.to> <800ff042b40806f330a946e2e8becf02@ruby-forum.com> <47C68E87.3010507@pressure.to> <9d45b60f13b52bc7945a09f99c053b03@ruby-forum.com> <47C6FA3E.8040107@pressure.to> <337de74230338e6d814671364584bbec@ruby-forum.com> <47C72467.1070406@pressure.to> <47C7443C.6050309@pressure.to> <47C7C8A0.120.37C8EBA6@dirk.traulsen.lypso.de> <47C7C280.7000000@pressure.to> Message-ID: <5b3f85312e7ecfe56b4a9eff0b6b86c1@ruby-forum.com> Alex Fenton wrote: >> 1. Is there any advantage of writing "#{10}" instead of "10" here, I >> don't see? >> > No, there isn't. I guess in Tim's code it was a place holder where in > the real code a variable would go. That is indeed the case... >> 4. Why is the former @dialog.update now unnecessary? >> > I think Tim was calling update because he wasn't seeing the dialog > refreshing. But it happened not to be the root of the problem. All of > the in-built GUI widgets in wxRuby redraw themselves automatically as > their state changes. > > Calling fit or layout upon a sizer is only needed when the contents of a > container are changed - a widget is removed, or added. I was trying anything that seemed relevant to get the dialog to resize as I changed the label text :-) Actually I still find the call to #fit necessary in order to have the dialog resize when the label text grows beyond what the current dialog size can show... >> 5. Why not directely 'Thread.stop if @dialog.cancelled' in the upto- >> block? finish exits in this case anyway. What am I overlooking? >> > That should work too and save a few lines, though I haven't tested. > I condensed to that as I factored this code back into my app with no ill effects... Thanks again to Alex for all the help with this! One good thing that has come out of this - it has definitely reinforced my commitment to cross-platform *testing* as I develop... :-) Cheers, Tim -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Feb 29 09:09:48 2008 From: lists at ruby-forum.com (Tim Ferrell) Date: Fri, 29 Feb 2008 15:09:48 +0100 Subject: [wxruby-users] xrc loading in xrcise-generated base classes Message-ID: <3f2a5fb13399a371ec36156a69d55356@ruby-forum.com> Just a small suggestion... after generating a dialog base class with xrcise, I end up having to modify the line to load the xrc file to the following: xml.load(File.join(File.dirname(__FILE__), "progress_dialog_base.xrc")) in order to make sure the base class can still load the xrc if the working directory is not the app root - and this also enables me to keep all of your xrc files and generated classes in a project subdirectory... Could something like this be added xrcise so this would be the default? It also might be nice to have xml.load search the ruby $LOAD_PATH if that is possible... Cheers, Tim -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Fri Feb 29 16:45:06 2008 From: alex at pressure.to (Alex Fenton) Date: Fri, 29 Feb 2008 21:45:06 +0000 Subject: [wxruby-users] xrc loading in xrcise-generated base classes In-Reply-To: <3f2a5fb13399a371ec36156a69d55356@ruby-forum.com> References: <3f2a5fb13399a371ec36156a69d55356@ruby-forum.com> Message-ID: <47C87CE2.6080306@pressure.to> Hi Tim Tim Ferrell wrote: > Just a small suggestion... after generating a dialog base class with > xrcise, I end up having to modify the line to load the xrc file to the > following: > > xml.load(File.join(File.dirname(__FILE__), > "progress_dialog_base.xrc")) > > in order to make sure the base class can still load the xrc if the > working directory is not the app root - and this also enables me to keep > all of your xrc files and generated classes in a project subdirectory... > It's a good point you raise ... > Could something like this be added xrcise so this would be the default? > It also might be nice to have xml.load search the ruby $LOAD_PATH if > that is possible... > ... but I'm not sure I'm wild about your exact solution, at least as the default. I personally to keep XRC files in share/, along with icons, translations etc, and only .rb files in lib/. It's just a matter of preference. Maybe the solution is a xrcise command-line option - or better, I should get around to finishing the XRC->pure ruby translator which removes the need for the XRC file at all at runtime. There's a heap of code checked in to do this, I just never got around to hooking it up to the command-line tool. alex From lists at ruby-forum.com Fri Feb 29 17:01:22 2008 From: lists at ruby-forum.com (Tim Ferrell) Date: Fri, 29 Feb 2008 23:01:22 +0100 Subject: [wxruby-users] xrc loading in xrcise-generated base classes In-Reply-To: <47C87CE2.6080306@pressure.to> References: <3f2a5fb13399a371ec36156a69d55356@ruby-forum.com> <47C87CE2.6080306@pressure.to> Message-ID: <005f2f6f5a734c2626209160e6443962@ruby-forum.com> Alex Fenton wrote: > > It's a good point you raise ... > > ... but I'm not sure I'm wild about your exact solution, at least as the > default. I personally to keep XRC files in share/, along with icons, > translations etc, and only .rb files in lib/. It's just a matter of > preference. Agreed ... and I like the idea of there being flexibility in whatever way this is approached. To each his own, and all that... :-) > Maybe the solution is a xrcise command-line option - or better, I should > get around to finishing the XRC->pure ruby translator which removes the > need for the XRC file at all at runtime. There's a heap of code checked > in to do this, I just never got around to hooking it up to the > command-line tool. A command line option would be cool ... something like "append (interpolated) path", maybe... The thought occurs to me, though, that I could just just wire up the substitution as part of the rake task that generates the base classes... I just wasn't sure if anyone else had a similar request... As for the translator, do you intend to have it work in both directions or just from XRC to ruby? Sounds interesting in any case... Cheers, Tim -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Fri Feb 29 17:06:37 2008 From: alex at pressure.to (Alex Fenton) Date: Fri, 29 Feb 2008 22:06:37 +0000 Subject: [wxruby-users] xrc loading in xrcise-generated base classes In-Reply-To: <005f2f6f5a734c2626209160e6443962@ruby-forum.com> References: <3f2a5fb13399a371ec36156a69d55356@ruby-forum.com> <47C87CE2.6080306@pressure.to> <005f2f6f5a734c2626209160e6443962@ruby-forum.com> Message-ID: <47C881ED.2020103@pressure.to> Tim Ferrell wrote: >> Maybe the solution is a xrcise command-line option - or better, I should >> get around to finishing the XRC->pure ruby translator which removes the >> need for the XRC file at all at runtime. There's a heap of code checked >> in to do this, I just never got around to hooking it up to the >> command-line tool. >> > > A command line option would be cool ... something like "append > (interpolated) path", maybe... > I'll give it some thought, definitely in favour of this. > The thought occurs to me, though, that I could just just wire up the > substitution as part of the rake task that generates the base classes... > I just wasn't sure if anyone else had a similar request... > Actually, that's probably an easier solution - should only be a few lines in Rake. You don't want to see the extensive mangling that the wxRuby build process does to SWIG's output. > As for the translator, do you intend to have it work in both directions > or just from XRC to ruby? Sounds interesting in any case... > LOL - just XRC to ruby. Ruby to XRC would be ... wild. alex From alex at pressure.to Fri Feb 29 21:09:51 2008 From: alex at pressure.to (Alex Fenton) Date: Sat, 01 Mar 2008 02:09:51 +0000 Subject: [wxruby-users] A bug in wxRuby. Segmentation fault in random situations. In-Reply-To: <570d9b010802281007u18d4d81ap7cbb33299e99ec7c@mail.gmail.com> References: <570d9b010802170815p2750966br89e5d65ce70584f3@mail.gmail.com> <47BA27CA.4000108@pressure.to> <570d9b010802190319r3cb8cfc7gc9bfdf4b51e5bef2@mail.gmail.com> <47BAC628.7060409@pressure.to> <570d9b010802190717x78573832j58331e50fb953a8e@mail.gmail.com> <47BBDA8B.7080906@pressure.to> <570d9b010802281007u18d4d81ap7cbb33299e99ec7c@mail.gmail.com> Message-ID: <47C8BAEF.5010500@pressure.to> Hi Jacek Thanks for posting more details. I've just fixed a bug in SVN which fits with the code and symptom you supplied. I tested your code on OS X and it now doesn't crash after the MDI child is closed with HEAD, though I can reproduce the crash with the 1.9.4 rubygem. So I am hopeful that this will be resolved by the next release which should be soon, but if you are able please test with the latest source from SVN. Jacek Nowak wrote: > I have a lot of trouble trying to find out what exactly causes the bug. > > So did I ... this bug has been vexing me for more than a month and was a git to track down. > 1. First I removed all calls of method "destroy" in dialogs. Definitely stick with this. > But still it crashes from time to time. > The trigger was the destruction of a Frame or Dialog containing a Sizer; after this it would crash on the next GC run. So it would seem sporadic, in the pattern you gave. cheers alex