From lists at ruby-forum.com Wed May 2 19:48:12 2012 From: lists at ruby-forum.com (Kevin McCaughey) Date: Wed, 02 May 2012 21:48:12 +0200 Subject: [wxruby-users] invalid gem format on ruby 1.9 In-Reply-To: References: Message-ID: <710ddf12f9c77f4eea9c794c1cdcd760@ruby-forum.com> Although not directly helpful, I just thought I would post that I got wxruby installed ok on Windows - so it does work (once you remember the 1.9 version is the one you need). -- Posted via http://www.ruby-forum.com/. From ivan_vilches at hotmail.com Fri May 11 07:16:10 2012 From: ivan_vilches at hotmail.com (Ivan Vilches Basaul) Date: Fri, 11 May 2012 07:16:10 +0000 Subject: [wxruby-users] key event down Message-ID: i cannot do work key down event pls give me a hand thanks this is my code: require "rubygems" require "wx" include Wx class MyFrame < Frame def initialize super(nil, #Parent :title => "RadioBox Example", #Displays on top of window :pos => [1030, 25], #or Wx::DEFAULT_POSITION :size => [250, 500] #or Wx::DEFAULT_SIZE #For the position and size arguments, you don't need to specify Point and Size #objects anymore. See: wxRuby Overview on the doc page wxruby_intro.html ) evt_key_down() { | ev | @text_position.label = "working key down" } panel = Wx::Panel.new(self) #Parent = self = this Frame drink_choices = ["coffee", "tea", "juice", "milk"] #labels for radio buttons radios = Wx::RadioBox.new( panel, #Parent :label => "Drinks", #Label for box surrounding radio buttons :pos => [20, 5], :size => Wx::DEFAULT_SIZE, :choices => drink_choices, #The labels for the radio buttons :major_dimension => 1, #Max number of columns(see next line)--try changing it to 2 :style => Wx::RA_SPECIFY_COLS #:major_dimension value applies to columns #The :major_dimension and :style in combination determine the layout of the #RadioBox. In this case, the maximum number of columns is 1, which means #there can only be one radio button per line. Because there are 4 radio buttons, #that means there will be 4 lines, with one radio button per line. ) evt_radiobox(radios.get_id()) {|cmd_event| on_change_radio(cmd_event)} @text_widget = Wx::StaticText.new( panel, #Parent :label => "coffee", :pos => [150, 25], :size => Wx::DEFAULT_SIZE #Store a widget in an instance variable when other #methods, like the one below, need access to it. ) boton = Wx::Button.new( panel, :label => "Posicion", :pos => [20,120], :size => Wx::DEFAULT_SIZE, :style => 0, :validator => Wx::DEFAULT_VALIDATOR, :name => "button" ) evt_button(boton) {|cmd_event| on_click(cmd_event)} @text_position = Wx::StaticText.new( panel, #Parent :label => "Position", :pos => [150, 120], :size => Wx::DEFAULT_SIZE #Store a widget in an instance variable when other #methods, like the one below, need access to it. ) #When there is an event of type evt_radiobox on the widget with the id radios.get_id(), #the block is called and an "event object" is passed to the block. The block calls #the method on_change_radio(), defined below, relaying the event object to the #method. The event object contains useful information about the radio button #that was selected. show #equivalent to self.show, makes the frame visible end def on_change_radio(cmd_event) selected_drink = cmd_event.string #Selected radio's label #Instead of calling cmd_event.get_string() or cmd_event.set_string(), you can #now call an accessor method with the same name as the property you are trying #to get or set. See: wxRuby Overview on the doc page wxruby_intro.html @text_widget.label = selected_drink end def on_click(cmd_event) @text_position.label = "testeando" end end class MinimalApp < Wx::App def on_init MyFrame.new end end MinimalApp.new.main_loop #main_loop() tells wxruby to start reacting #to radio button selections, button clicks, etc. #on your App. -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Wed May 16 20:18:23 2012 From: lists at ruby-forum.com (Norbert Lange) Date: Wed, 16 May 2012 22:18:23 +0200 Subject: [wxruby-users] Notebook Change Page Event Handling Message-ID: <2071a5792c06c7368cc690c1b37018f1@ruby-forum.com> I'm still a bit new to Ruby, but have been using WxRuby for a couple of months now. I've created a notebook with a few pages, and am having a tough time understanding how to implement an event handler that would get called whenever the page gets changed. Would someone be kind enough to post a simple example? -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Thu May 17 09:22:42 2012 From: alex at pressure.to (Alex Fenton) Date: Thu, 17 May 2012 10:22:42 +0100 Subject: [wxruby-users] Notebook Change Page Event Handling In-Reply-To: <2071a5792c06c7368cc690c1b37018f1@ruby-forum.com> References: <2071a5792c06c7368cc690c1b37018f1@ruby-forum.com> Message-ID: <4FB4C362.2000007@pressure.to> hi On 16/05/12 21:18, Norbert Lange wrote: > I'm still a bit new to Ruby, but have been using WxRuby for a couple of > months now. I've created a notebook with a few pages, and am having a > tough time understanding how to implement an event handler that would > get called whenever the page gets changed. Welcome to wxRuby. There are two events : evt_notebook_changing and evt_notebook_changed. They receive a Wx::NotebookEvent, and the former can be veto-ed if you want to prevent the change. There's an example within the bigdemo sample: http://wxruby.rubyforge.org/svn/trunk/wxruby/samples/bigdemo/wxNotebook.rbw alex From lists at ruby-forum.com Thu May 17 15:28:36 2012 From: lists at ruby-forum.com (Norbert Lange) Date: Thu, 17 May 2012 17:28:36 +0200 Subject: [wxruby-users] Notebook Change Page Event Handling In-Reply-To: <4FB4C362.2000007@pressure.to> References: <2071a5792c06c7368cc690c1b37018f1@ruby-forum.com> <4FB4C362.2000007@pressure.to> Message-ID: Alex Fenton wrote in post #1061104: > hi > > On 16/05/12 21:18, Norbert Lange wrote: >> I'm still a bit new to Ruby, but have been using WxRuby for a couple of >> months now. I've created a notebook with a few pages, and am having a >> tough time understanding how to implement an event handler that would >> get called whenever the page gets changed. > > Welcome to wxRuby. There are two events : evt_notebook_changing and > evt_notebook_changed. They receive a Wx::NotebookEvent, and the former > can be veto-ed if you want to prevent the change. > > There's an example within the bigdemo sample: > http://wxruby.rubyforge.org/svn/trunk/wxruby/samples/bigdemo/wxNotebook.rbw > > alex Thanks Alex. That's exactly what I was looking for. Norbert -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu May 17 22:02:10 2012 From: lists at ruby-forum.com (Norbert Lange) Date: Fri, 18 May 2012 00:02:10 +0200 Subject: [wxruby-users] Grid Cell Background Colour Message-ID: <478be0c7b773616f3686547908a75cd4@ruby-forum.com> On to my next question. :-) I've been trying to get the cell background colour to work for a Wx::Grid control. Setting a default background colour works, but using the set_cell_background_colour method for an individual cell doesn't. Following is a short snippet of what I'm trying to do (essentially highlight cells that don't match): columnNames = Array.[]("Col1", "Col2", "Col3") row1 = Array.[]("A", "B", "C") row2 = Array.[]("X", "Y", "Z") resultSet = Array.[](row1, row2) table = Table.new(columnNames, resultSet) grid = Wx::Grid.new(panel, -1) grid.set_table(table) @grid.set_cell_background_colour(1, 1, Wx::RED) Any help is greatly appreciated. Norbert -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu May 17 22:21:36 2012 From: lists at ruby-forum.com (Norbert Lange) Date: Fri, 18 May 2012 00:21:36 +0200 Subject: [wxruby-users] Grid Cell Background Colour In-Reply-To: <478be0c7b773616f3686547908a75cd4@ruby-forum.com> References: <478be0c7b773616f3686547908a75cd4@ruby-forum.com> Message-ID: <02ba26f353fc7cf9b86b4c1437cc21e5@ruby-forum.com> I should probably also have mentioned, the Table object is derived from Wx::GridTableBase. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri May 18 17:15:49 2012 From: lists at ruby-forum.com (Norbert Lange) Date: Fri, 18 May 2012 19:15:49 +0200 Subject: [wxruby-users] Grid Cell Background Colour In-Reply-To: <478be0c7b773616f3686547908a75cd4@ruby-forum.com> References: <478be0c7b773616f3686547908a75cd4@ruby-forum.com> Message-ID: <3284e5bea866e75cad1a46a1980419a3@ruby-forum.com> Update: I finally got this working. In case anyone else runs into the same thing, I finally realized I needed to override the set_attr and get_attr methods in my Table subclass. Norbert -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue May 22 21:29:03 2012 From: lists at ruby-forum.com (Norbert Lange) Date: Tue, 22 May 2012 23:29:03 +0200 Subject: [wxruby-users] Wx:Grid Setting Cursor Position Message-ID: I'm using the grid widget with an underlying GridTableBase and trying to implement a "Find" button which would cause the current cursor position to go to the next matching cell. I'm wondering if there's an easy way to do it? I'm playing with the Grid.select_block_row(), Grid.set_grid_cursor() and Grid.scroll() methods, but the results are a bit erratic. Is there a better way to do this than using Grid.move_cursor_down/right? Thanks, Norbert -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu May 24 15:27:47 2012 From: lists at ruby-forum.com (Norbert Lange) Date: Thu, 24 May 2012 17:27:47 +0200 Subject: [wxruby-users] Wx:Grid Setting Cursor Position In-Reply-To: References: Message-ID: It took a bit of time and experimenting, but this seems to work, for anyone else who's maybe run into the same issues. Here's the code I came up with for scrolling to a grid position given a cell row and column. I hope someone finds it useful. Norbert Attachments: http://www.ruby-forum.com/attachment/7431/Setting_Grid_Cursor_Example.rb -- Posted via http://www.ruby-forum.com/.