trying to create a list control, filling with data, but it wont scroll vertically or respond to mouse click. ------------------------------------------- require ''rubygems'' require ''wx'' include Wx class MyFrame < Wx::Frame def initialize() super(nil,-1,''Wristband Manager'',:size => [300,400]) @my_panel = Panel.new(self) show() end end class MasterList < Wx::ListCtrl def initialize(parent) super(parent,:size => [250,200],:style => Wx::LC_REPORT) create_layout add_entries end def create_layout self.insert_column(0, "Name") self.insert_column(1, "Courses") self.insert_column(2, "Band") self.set_column_width(0,100) self.set_column_width(1,25) self.set_column_width(2,50) end def add_entries name = ''Test01'' 50.times do |idx| item0 = Wx::ListItem.new item0.set_text(name) item0.set_column(0) item0.set_id(idx) self.insert_item(item0) item1 = Wx::ListItem.new item1.set_text("15") item1.set_column(1) item1.set_id(idx) self.set_item(item1) item1 = Wx::ListItem.new item1.set_text("Green") item1.set_column(2) item1.set_id(idx) self.set_item(item1) name.succ! end end end class MyApp < App def on_init frame1 = MyFrame.new MasterList.new frame1 end end MyApp.new.main_loop() _______________________________________________ wxruby-users mailing list wxruby-users@rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users
Okay, I''m noticing a few things here: 1. include Wx # if you have this, you don''t have to have Wx:: in front of Wx classes or modules 2. # in MasterList#add_entries item1 = Wx::ListItem.new item1.set_text("Green") # ... name.succ! end # you might want to find a different local name for this ListItem, since it might be interfering with the one above it, unless that''s what you intend. 3. # in My_App#on_init MasterList.new frame1 # you might want to create the master list within frame1, and set parent to self If those don''t do anything, let someone else tell you what to do. - Hameed On Sun, 2010-07-25 at 07:52 -0400, Bruce Loving wrote:> trying to create a list control, filling with data, but it wont scroll > vertically or respond to mouse click. > ------------------------------------------- > require ''rubygems'' > require ''wx'' > include Wx > > class MyFrame < Wx::Frame > def initialize() > super(nil,-1,''Wristband Manager'',:size => [300,400]) > @my_panel = Panel.new(self) > show() > end > end > > class MasterList < Wx::ListCtrl > def initialize(parent) > super(parent,:size => [250,200],:style => Wx::LC_REPORT) > create_layout > add_entries > end > > def create_layout > self.insert_column(0, "Name") > self.insert_column(1, "Courses") > self.insert_column(2, "Band") > self.set_column_width(0,100) > self.set_column_width(1,25) > self.set_column_width(2,50) > end > > def add_entries > name = ''Test01'' > 50.times do |idx| > item0 = Wx::ListItem.new > item0.set_text(name) > item0.set_column(0) > item0.set_id(idx) > self.insert_item(item0) > > item1 = Wx::ListItem.new > item1.set_text("15") > item1.set_column(1) > item1.set_id(idx) > self.set_item(item1) > > item1 = Wx::ListItem.new > item1.set_text("Green") > item1.set_column(2) > item1.set_id(idx) > self.set_item(item1) > name.succ! > end > end > > > end > > class MyApp < App > def on_init > frame1 = MyFrame.new > MasterList.new frame1 > end > end > > MyApp.new.main_loop() > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users
Thanks, #3 did the trick! On Sun, Jul 25, 2010 at 12:36 PM, Hameed Gifford <giff.h92 at gmail.com> wrote:> Okay, I''m noticing a few things here: > > 1. > include Wx # if you have this, you don''t have to have Wx:: in front of > Wx classes or modules > > 2. > # in MasterList#add_entries > item1 = Wx::ListItem.new > item1.set_text("Green") > # ... > name.succ! > end > # you might want to find a different local name for this ListItem, since > it might be interfering with the one above it, unless that''s what you > intend. > > 3. > # in My_App#on_init > MasterList.new frame1 # you might want to create the master list within > frame1, and set parent to self > > > If those don''t do anything, let someone else tell you what to do. > > - Hameed > > > On Sun, 2010-07-25 at 07:52 -0400, Bruce Loving wrote: > > trying to create a list control, filling with data, but it wont scroll > > vertically or respond to mouse click. > > ------------------------------------------- > > require ''rubygems'' > > require ''wx'' > > include Wx > > > > class MyFrame < Wx::Frame > > def initialize() > > super(nil,-1,''Wristband Manager'',:size => [300,400]) > > @my_panel = Panel.new(self) > > show() > > end > > end > > > > class MasterList < Wx::ListCtrl > > def initialize(parent) > > super(parent,:size => [250,200],:style => Wx::LC_REPORT) > > create_layout > > add_entries > > end > > > > def create_layout > > self.insert_column(0, "Name") > > self.insert_column(1, "Courses") > > self.insert_column(2, "Band") > > self.set_column_width(0,100) > > self.set_column_width(1,25) > > self.set_column_width(2,50) > > end > > > > def add_entries > > name = ''Test01'' > > 50.times do |idx| > > item0 = Wx::ListItem.new > > item0.set_text(name) > > item0.set_column(0) > > item0.set_id(idx) > > self.insert_item(item0) > > > > item1 = Wx::ListItem.new > > item1.set_text("15") > > item1.set_column(1) > > item1.set_id(idx) > > self.set_item(item1) > > > > item1 = Wx::ListItem.new > > item1.set_text("Green") > > item1.set_column(2) > > item1.set_id(idx) > > self.set_item(item1) > > name.succ! > > end > > end > > > > > > end > > > > class MyApp < App > > def on_init > > frame1 = MyFrame.new > > MasterList.new frame1 > > end > > end > > > > MyApp.new.main_loop() > > > > _______________________________________________ > > wxruby-users mailing list > > wxruby-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/wxruby-users > > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20100725/aecdcfa0/attachment.html>
No prob. Generally, you want to create window object within the initialize of the parent object. Keeps problems from happening. On Sun, 2010-07-25 at 12:56 -0400, Bruce Loving wrote:> Thanks, #3 did the trick! > > On Sun, Jul 25, 2010 at 12:36 PM, Hameed Gifford <giff.h92 at gmail.com> > wrote: > Okay, I''m noticing a few things here: > > 1. > include Wx # if you have this, you don''t have to have Wx:: in > front of > Wx classes or modules > > 2. > # in MasterList#add_entries > item1 = Wx::ListItem.new > item1.set_text("Green") > > # ... > name.succ! > end > # you might want to find a different local name for this > ListItem, since > it might be interfering with the one above it, unless that''s > what you > intend. > > 3. > # in My_App#on_init > MasterList.new frame1 # you might want to create the master > list within > frame1, and set parent to self > > > If those don''t do anything, let someone else tell you what to > do. > > - Hameed > > > > On Sun, 2010-07-25 at 07:52 -0400, Bruce Loving wrote: > > trying to create a list control, filling with data, but it > wont scroll > > vertically or respond to mouse click. > > ------------------------------------------- > > require ''rubygems'' > > require ''wx'' > > include Wx > > > > class MyFrame < Wx::Frame > > def initialize() > > super(nil,-1,''Wristband Manager'',:size => [300,400]) > > @my_panel = Panel.new(self) > > show() > > end > > end > > > > class MasterList < Wx::ListCtrl > > def initialize(parent) > > super(parent,:size => [250,200],:style => > Wx::LC_REPORT) > > create_layout > > add_entries > > end > > > > def create_layout > > self.insert_column(0, "Name") > > self.insert_column(1, "Courses") > > self.insert_column(2, "Band") > > self.set_column_width(0,100) > > self.set_column_width(1,25) > > self.set_column_width(2,50) > > end > > > > def add_entries > > name = ''Test01'' > > 50.times do |idx| > > item0 = Wx::ListItem.new > > item0.set_text(name) > > item0.set_column(0) > > item0.set_id(idx) > > self.insert_item(item0) > > > > item1 = Wx::ListItem.new > > item1.set_text("15") > > item1.set_column(1) > > item1.set_id(idx) > > self.set_item(item1) > > > > item1 = Wx::ListItem.new > > item1.set_text("Green") > > item1.set_column(2) > > item1.set_id(idx) > > self.set_item(item1) > > name.succ! > > end > > end > > > > > > end > > > > class MyApp < App > > def on_init > > frame1 = MyFrame.new > > MasterList.new frame1 > > end > > end > > > > MyApp.new.main_loop() > > > > > > _______________________________________________ > > 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 > > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users