Hi, I''m using GridCellChoiceEditor for some cells in Grid object. At the beginning values inside choice are initialized like in grid.rb example @editor_c = Wx::GridCellChoiceEditor.new([''foo'', ''bar'', ''baz'']) @grid.set_cell_editor(4, 3, @editor_c) After that when script is started this cell is empty and user can select one of values. So this behavior is ok. # While program is running I want to add new values into this choice editor, so I do next in the code: @editor.set_parameters("foo, bar, baz, new") After that nothing happens and choices still have the same old list of values. # I also tried to use local variable for editor instead on instance variable: edit = @grid.get_cell_editor(4,3) edit.set_parameters("foo, bar, baz,new") @grid.set_cell_editor(4,3,edit) Again list is not updated, and ''new'' string is not added. # Only way I''ve found for now to be able to update editor, is to have empty grid (so nothing is selected in choice cells), and then update editor. This is no acceptable for my application, because list of values in choice cells should be updated during the program running few times (depending on some other user actions). # What am I doing wrong? Is it possible to update list of values in choice editor while program is running? Thanks in advance, Marija -- Posted via http://www.ruby-forum.com/.
Hi again, I''ve found possible solution for this problem in WxPython Wiki pages http://wiki.wxpython.org/GridCellChoiceEditor from this page: "A common question is how to dynamically update the list in a GridCellChoiceEditor. The problem comes from not having direct access to the underlying ComboBox widget in the grid editor. Fortunately the grid editor throws an event that allows us to get to the underlying ComboBox." I convert Python code for Ruby but I have a problem how to get underlying ComboBox from GridCellChoiceEditor If I use Wx::GridEditorCreatedEvent.get_control function (like in Python code - line 249 on wiki page), I get Wx::Control object instead of Wx::ComboBox or Wx::Choice. So question is how to convert Wx::Control object to Wx::ComboBox to be able to dynamically change list of its values. Hope somebody has an answer, Marija -- Posted via http://www.ruby-forum.com/.
Hi Marija, that''s strange because Ruby doesn''t really have a way to cast between types. Maybe it''s a SWIG problem. Could you post a small code sample that shows the issue? On Tue, Apr 12, 2011 at 7:01 PM, Marija Velickovic <lists at ruby-forum.com>wrote:> Hi again, > > I''ve found possible solution for this problem in WxPython Wiki pages > http://wiki.wxpython.org/GridCellChoiceEditor > > from this page: > "A common question is how to dynamically update the list in a > GridCellChoiceEditor. The problem comes from not having direct access to > the underlying ComboBox widget in the grid editor. Fortunately the grid > editor throws an event that allows us to get to the underlying > ComboBox." > > I convert Python code for Ruby but I have a problem how to get > underlying ComboBox from GridCellChoiceEditor > > If I use Wx::GridEditorCreatedEvent.get_control function (like in Python > code - line 249 on wiki page), I get Wx::Control object instead of > Wx::ComboBox or Wx::Choice. > > So question is how to convert Wx::Control object to Wx::ComboBox to be > able to dynamically change list of its values. > > Hope somebody has an answer, > Marija > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20110412/52a9b197/attachment.html>