From lists at ruby-forum.com Mon Jun 1 12:09:45 2009 From: lists at ruby-forum.com (Jason Lillywhite) Date: Mon, 1 Jun 2009 18:09:45 +0200 Subject: [wxruby-users] multiple forms or panels Message-ID: <17907f3cb568782fba164c4a5fa32f80@ruby-forum.com> How do I organize widgets in a form when I need them placed in more than a single column or row? I leaned how to use BoxSizer and successfully displayed my widgets in a single column but can't get the next column. Here is my code, which puts a text, radio, button all in one column, but what if I wanted my radios over to the right?: require "rubygems" require "wx" include Wx class MyFrame < Frame def initialize super(nil, :title => "My Test Frame") @panel = Panel.new(self) @result = StaticText.new(@panel, :label=>'Result') @y = TextCtrl.new(@panel, -1, '10') shape_choice = %w(Circular Rectangular Trapezoidal ) submit_button = Button.new(@panel, :label => 'Calculate') my_radio = RadioBox.new( @panel, :label => "Select Conduit Shape", :choices => shape_choice, :major_dimension => 1 ) @panel_sizer = BoxSizer.new(VERTICAL) @panel.set_sizer(@panel_sizer) @panel_sizer.add(@y, 0, GROW|ALL, 2) @panel_sizer.add(my_radio, 0, GROW|ALL, 2) @panel_sizer.add(submit_button, 0, GROW|ALL, 2) @panel_sizer.add(@result, 0, GROW|ALL, 2) evt_button(submit_button.get_id()) {|cmd_event| on_submit(cmd_event)} evt_radiobox(my_radio.get_id()) {|cmd_event| on_change_radio(cmd_event)} show() end def on_change_radio(cmd_event) @selected_shape = cmd_event.string end def on_submit(cmd_event) y = @y.get_value().to_f area = case when @selected_shape == 'Circular' then Math::PI * y**2 / 4.0 when @selected_shape == 'Rectangular' then y * 5.0 else (5.0 + 2.0 * y) * y end @result.label = "#{area} square feet" end end class MinimalApp < App def on_init MyFrame.new end end MinimalApp.new.main_loop -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Mon Jun 1 12:33:11 2009 From: alex at pressure.to (Alex Fenton) Date: Mon, 01 Jun 2009 17:33:11 +0100 Subject: [wxruby-users] multiple forms or panels In-Reply-To: <17907f3cb568782fba164c4a5fa32f80@ruby-forum.com> References: <17907f3cb568782fba164c4a5fa32f80@ruby-forum.com> Message-ID: <4A2402C7.7040808@pressure.to> Jason Lillywhite wrote: > How do I organize widgets in a form when I need them placed in more than > a single column or row? I leaned how to use BoxSizer and successfully > displayed my widgets in a single column but can't get the next column. > It sounds like you want either Wx::GridSizer or Wx::FlexGridSizer. The latter allows for variable width columns or rows, so I generally find it more useful. There is also Wx::GridBagSizer, which allows cells to span rows or columns, but I find nesting other simpler sizers easier to use than the API for it. alex From lists at ruby-forum.com Mon Jun 1 14:07:04 2009 From: lists at ruby-forum.com (Pito Salas) Date: Mon, 1 Jun 2009 20:07:04 +0200 Subject: [wxruby-users] ImageMagick Message-ID: I'd like to combine Wx (Wx::Image) with Rmagick/ImageMagick processing. Other than saving to disk constantly, how would I pass an Rmagick/ImageMagick image (e.g. RMagick:Image) to and from a Wx Image (e.g. Wx:Image)? -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Mon Jun 1 15:17:13 2009 From: alex at pressure.to (Alex Fenton) Date: Mon, 01 Jun 2009 20:17:13 +0100 Subject: [wxruby-users] ImageMagick In-Reply-To: References: Message-ID: <4A242939.90709@pressure.to> Pito Salas wrote: > I'd like to combine Wx (Wx::Image) with Rmagick/ImageMagick processing. > Other than saving to disk constantly, how would I pass an > Rmagick/ImageMagick image (e.g. RMagick:Image) to and from a Wx Image > (e.g. Wx:Image)? > If the image data from RMagick can be put into a string, you can use StringIO + Wx::Image.read and Wx::Image#write to exchange image data in a recognised format (PNG, TIF etc) in memory. See also Wx::Image#set_data for low-level access to raw image data (see the images/maths_drawing.rb for an example of using this). a From alex at pressure.to Mon Jun 1 15:18:40 2009 From: alex at pressure.to (Alex Fenton) Date: Mon, 01 Jun 2009 20:18:40 +0100 Subject: [wxruby-users] Drag and Drop help In-Reply-To: <88f50c5debefaeb7332cd63fc7b1f4de@ruby-forum.com> References: <2c158f4df31caf4cee10ffe3c2904fc0@ruby-forum.com> <49F1A462.6020907@pressure.to> <4A0008D1.8030901@pressure.to> <2a052ccba1a8ba58e280da4b9ae3ac6e@ruby-forum.com> <88f50c5debefaeb7332cd63fc7b1f4de@ruby-forum.com> Message-ID: <4A242990.9060806@pressure.to> Daniel Daniel Zepeda wrote: > Just wanted to make sure this was the final word. I guess the workaround > is to only use drag images in OSX. Kind of disappointing, but oh well, > everything seems harder in Windows, and it's not the fault of Wx. I > wonder what GTK is like. > I haven't had a chance to look at the sample you posted yet - have been moving house again etc. Can't promise to have any useful comments but will have a look when have some time to work through it. a From lists at ruby-forum.com Mon Jun 1 15:24:14 2009 From: lists at ruby-forum.com (Jason Lillywhite) Date: Mon, 1 Jun 2009 21:24:14 +0200 Subject: [wxruby-users] multiple forms or panels In-Reply-To: <4A2402C7.7040808@pressure.to> References: <17907f3cb568782fba164c4a5fa32f80@ruby-forum.com> <4A2402C7.7040808@pressure.to> Message-ID: Thank you for the pointer. I tried a simple example, doing my best to read through wxWidgets examples and wxruby docs and - no success. I created 4 buttons and they all show on top of each other. Can you see anything I'm doing wrong? Thank you. I'm doing this: class MyFrame < Frame def initialize super(nil) panel = Panel.new(self) gs = FlexGridSizer.new(2,2,20,20) b1 = Button.new(panel, :label=>"one") b2 = Button.new(panel, :label=>"two") b3 = Button.new(panel, :label=>"three") b4 = Button.new(panel, :label=>"four") gs.add(b1) gs.add(b2) gs.add(b3) gs.add(b4) gs.add_growable_row(1,1) gs.add_growable_col(1,1) show() end end class MinimalApp < App def on_init MyFrame.new end end MinimalApp.new.main_loop -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Mon Jun 1 15:45:27 2009 From: lists at ruby-forum.com (Daniel Zepeda) Date: Mon, 1 Jun 2009 21:45:27 +0200 Subject: [wxruby-users] Drag and Drop help In-Reply-To: <4A242990.9060806@pressure.to> References: <2c158f4df31caf4cee10ffe3c2904fc0@ruby-forum.com> <49F1A462.6020907@pressure.to> <4A0008D1.8030901@pressure.to> <2a052ccba1a8ba58e280da4b9ae3ac6e@ruby-forum.com> <88f50c5debefaeb7332cd63fc7b1f4de@ruby-forum.com> <4A242990.9060806@pressure.to> Message-ID: <94cb38e2bdf57315dfb3f56dee440b05@ruby-forum.com> Alex Fenton wrote: > Daniel > I haven't had a chance to look at the sample you posted yet - have been > moving house again etc. Can't promise to have any useful comments but > will have a look when have some time to work through it. > > a Hey that's great Alex, thanks for giving me a heads up on your situation. I know what you are going through, so best of luck, hope things work out on the home front for you. I'm a patient man, whatever time you can give me when you can give it to me is appreciated. DZ -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Mon Jun 1 17:07:24 2009 From: lists at ruby-forum.com (Peter Lane) Date: Mon, 1 Jun 2009 23:07:24 +0200 Subject: [wxruby-users] multiple forms or panels In-Reply-To: References: <17907f3cb568782fba164c4a5fa32f80@ruby-forum.com> <4A2402C7.7040808@pressure.to> Message-ID: <9ae19b9f941c43ed91a37b7dcc25ee92@ruby-forum.com> Jason Lillywhite wrote: > Thank you for the pointer. I tried a simple example, doing my best to > read through wxWidgets examples and wxruby docs and - no success. I > created 4 buttons and they all show on top of each other. Can you see > anything I'm doing wrong? Thank you. > > I'm doing this: > > class MyFrame < Frame > def initialize > super(nil) > panel = Panel.new(self) > gs = FlexGridSizer.new(2,2,20,20) > > b1 = Button.new(panel, :label=>"one") > b2 = Button.new(panel, :label=>"two") > b3 = Button.new(panel, :label=>"three") > b4 = Button.new(panel, :label=>"four") > > gs.add(b1) > gs.add(b2) > gs.add(b3) > gs.add(b4) > > gs.add_growable_row(1,1) > gs.add_growable_col(1,1) > > show() > end > end > > class MinimalApp < App > def on_init > MyFrame.new > end > end > > MinimalApp.new.main_loop Two things are not quite right. First, you don't need the 'add_growable_row' etc as you have declared your grid to be 2x2. Also, you have not told the panel about your sizer, so it does not know how to layout your widgets. Change the middle part to: ---------------------------------------- gs.add(b1) gs.add(b2) gs.add(b3) gs.add(b4) # gs.add_growable_row(1,1) # delete this # gs.add_growable_col(1,1) # delete this panel.sizer = gs # set the sizer show() ---------------------------------------- You don't need to create a separate panel to hold your widgets in, and can instead add the widgets to 'self'. Personally, I prefer to use nested combinations of BoxSizers in most cases. The following example may be helpful. ---------------------------------------- require 'wx' class BoxFrame < Wx::Frame def initialize super(nil, :title => "BoxSizers") # create two sub-sizers left_sizer = Wx::BoxSizer.new Wx::VERTICAL left_sizer.add(Wx::StaticText.new(self, Wx::ID_ANY, "Left side")) left_sizer.add(Wx::Button.new(self, Wx::ID_ANY, "Button")) right_sizer = Wx::BoxSizer.new Wx::VERTICAL right_sizer.add(Wx::StaticText.new(self, Wx::ID_ANY, "Right side")) right_sizer.add(Wx::Button.new(self, Wx::ID_ANY, "Button")) # add left/right to main sizer with some padding main_sizer = Wx::BoxSizer.new Wx::HORIZONTAL main_sizer.add(left_sizer, 1, Wx::ALL, 10) main_sizer.add(right_sizer, 1, Wx::ALL, 10) set_sizer main_sizer end end class GridFrame < Wx::Frame def initialize super(nil, :title => "FlexGridSizer") main_sizer = Wx::FlexGridSizer.new(2, 2, 10, 20) main_sizer.add(Wx::StaticText.new(self, Wx::ID_ANY, "Left side")) main_sizer.add(Wx::StaticText.new(self, Wx::ID_ANY, "Right side")) main_sizer.add(Wx::Button.new(self, Wx::ID_ANY, "Left Button")) main_sizer.add(Wx::Button.new(self, Wx::ID_ANY, "Right Button")) set_sizer main_sizer end end Wx::App.run do BoxFrame.new.show GridFrame.new.show end ---------------------------------------- Hope that helps, Peter. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Mon Jun 1 18:01:23 2009 From: lists at ruby-forum.com (Jason Lillywhite) Date: Tue, 2 Jun 2009 00:01:23 +0200 Subject: [wxruby-users] multiple forms or panels In-Reply-To: <9ae19b9f941c43ed91a37b7dcc25ee92@ruby-forum.com> References: <17907f3cb568782fba164c4a5fa32f80@ruby-forum.com> <4A2402C7.7040808@pressure.to> <9ae19b9f941c43ed91a37b7dcc25ee92@ruby-forum.com> Message-ID: <638720051088c57670177bc7d423caf2@ruby-forum.com> ah, I see. Thank you for that clarification. Just what I needed! -- Posted via http://www.ruby-forum.com/. From chauk.mean at gmail.com Tue Jun 2 15:25:09 2009 From: chauk.mean at gmail.com (Chauk-Mean Proum) Date: Tue, 2 Jun 2009 21:25:09 +0200 Subject: [wxruby-users] ImageMagick In-Reply-To: <4A242939.90709@pressure.to> References: <4A242939.90709@pressure.to> Message-ID: Hi, On Mon, Jun 1, 2009 at 9:17 PM, Alex Fenton wrote: > Pito Salas wrote: >> >> I'd like to combine Wx (Wx::Image) with Rmagick/ImageMagick processing. >> Other than saving to disk constantly, how would I pass an >> Rmagick/ImageMagick image (e.g. RMagick:Image) to and from a Wx Image >> (e.g. Wx:Image)? >> > > If the image data from RMagick can be put into a string, you can use > StringIO + Wx::Image.read and Wx::Image#write to exchange image data in a > recognised format (PNG, TIF etc) in memory. See also Wx::Image#set_data for > low-level access to raw image data (see the images/maths_drawing.rb for an > example of using this). I'm just about to add an RMagick sample to wxRuby. The following code snippet allows direct exchange between RMagick and wxRuby : magick_image = Magick::ImageList.new(img_file) # some magick conversion wx_image = Wx::Image.new(magick_image.columns, magick_image.rows) wx_image.set_data(magick_image.to_blob { self.format = "RGB" } The only problem is transparency. If img_file is a PNG file with transparent areas, those transparent areas are lost (i.e. displaying a Wx::Bitmap corresponding to the Wx::Image shows black areas instead of transparent areas). At the moment, the only way I found to keep the transparency is to save the magick_image into a PNG file and read it into a Wx::Image, but this is not what you're looking for. Cheers. Chauk-Mean. From alex at pressure.to Wed Jun 3 07:07:37 2009 From: alex at pressure.to (Alex Fenton) Date: Wed, 03 Jun 2009 12:07:37 +0100 Subject: [wxruby-users] ImageMagick In-Reply-To: References: <4A242939.90709@pressure.to> Message-ID: <4A265979.7070806@pressure.to> Chauk-Mean Proum wrote: > The only problem is transparency. > If img_file is a PNG file with transparent areas, those transparent > areas are lost (i.e. displaying a Wx::Bitmap corresponding to the > Wx::Image shows black areas instead of transparent areas). > > At the moment, the only way I found to keep the transparency is to > save the magick_image into a PNG file and read it into a Wx::Image, > but this is not what you're looking for. Does Wx::Image#set_alpha help here? it works like set_data but for the alpha channel. a From chauk.mean at gmail.com Wed Jun 3 18:39:16 2009 From: chauk.mean at gmail.com (Chauk-Mean Proum) Date: Thu, 4 Jun 2009 00:39:16 +0200 Subject: [wxruby-users] ImageMagick In-Reply-To: <4A265979.7070806@pressure.to> References: <4A242939.90709@pressure.to> <4A265979.7070806@pressure.to> Message-ID: On Wed, Jun 3, 2009 at 1:07 PM, Alex Fenton wrote: > Chauk-Mean Proum wrote: >> >> The only problem is transparency. >> If img_file is a PNG file with transparent areas, those transparent >> areas are lost (i.e. displaying a Wx::Bitmap corresponding to the >> Wx::Image shows black areas instead of transparent areas). >> >> At the moment, the only way I found to keep the transparency is to >> save the magick_image into a PNG file and read it into a Wx::Image, >> but this is not what you're looking for. > > Does Wx::Image#set_alpha help here? it works like set_data but for the alpha > channel. Following Mario's suggestion, I tried "RGBA" format which is available in RMagick. I extracted the image and the alpha raw data. But when I tried to use set_alpha with the alpha raw data, an exception is raised : alpha_raw_string = apha_raw_data.pack("C*") image.set_alpha(alpha_raw_string) It seems that there is a SWIG problem. Cheers. Chauk-Mean. From lists at ruby-forum.com Wed Jun 3 21:34:22 2009 From: lists at ruby-forum.com (Zhimin Zhan) Date: Thu, 4 Jun 2009 03:34:22 +0200 Subject: [wxruby-users] Wx::AuiNotebook.delete_page Segmentation fault Message-ID: <52eff39ecf38487f14bb239fd52e099b@ruby-forum.com> Hi, I got the following error several times (while working most of time), I couldn't create repeatable test case. main_frame.rb:1765: [BUG] Segmentation fault ruby 1.8.6 (2008-03-03) [i386-mswin32] line 1765: @notebook_content.delete_page(0) if @notebook_content Env: Ruby 1.8.6 p114, wxRuby 2.0 msin32 on Windows XP Zhimin -- Posted via http://www.ruby-forum.com/. From chauk.mean at gmail.com Thu Jun 4 07:45:19 2009 From: chauk.mean at gmail.com (Chauk-Mean Proum) Date: Thu, 4 Jun 2009 13:45:19 +0200 Subject: [wxruby-users] ImageMagick In-Reply-To: References: <4A242939.90709@pressure.to> <4A265979.7070806@pressure.to> Message-ID: On Thu, Jun 4, 2009 at 2:54 AM, Mario Steele wrote: > On Wed, Jun 3, 2009 at 5:39 PM, Chauk-Mean Proum > wrote: >> >> On Wed, Jun 3, 2009 at 1:07 PM, Alex Fenton wrote: >> > Chauk-Mean Proum wrote: >> > >> > Does Wx::Image#set_alpha help here? it works like set_data but for the >> > alpha >> > channel. >> >> Following Mario's suggestion, I tried "RGBA" format which is available >> in RMagick. >> I extracted the image and the alpha raw data. > > I just want to clarify, that you separated the RGB and the A values from > each pixel byte section (As I call it) in the blob that is returned from > RMagick, and tried applying it via image.set_data, and image.set_alpha, Yes. Here is the detailed code I'm using : wx_image = Wx::Image.new(magick_image.columns, magick_image.rows) rgba_data = magick_image.to_blob { self.format = "RGBA" } rgba_array = rgba_data.unpack("C*") # separate the RGB image and the alpha data i = 0 image_array, alpha_array = rgba_array.partition do |val| i += 1 if i % 4 != 0 true else false end end image_data = image_array.pack("C*") alpha_data = alpha_array.pack("C*") wx_image.data = image_data wx_image.set_alpha(alpha_data) The set_alpha method raises the following exception : rmagic_bitmap_image.rb:109:in `set_alpha': Wrong arguments for overloaded method 'wxImage.SetAlpha'. (ArgumentError) Possible C/C++ prototypes are: void wxImage.SetAlpha(unsigned char *alpha, bool static_data) void wxImage.SetAlpha(int x, int y, unsigned char alpha) Chauk-Mean. From chauk.mean at gmail.com Thu Jun 4 17:57:44 2009 From: chauk.mean at gmail.com (Chauk-Mean Proum) Date: Thu, 4 Jun 2009 23:57:44 +0200 Subject: [wxruby-users] ImageMagick In-Reply-To: References: <4A242939.90709@pressure.to> <4A265979.7070806@pressure.to> Message-ID: Hi Mario, On Thu, Jun 4, 2009 at 9:37 PM, Mario Steele wrote: > > Alright, this may be a mistake in the Documentation, but try doing: > wx_image.set_alpha(alpha_data, false) I've already tried that with the true value :-) and it didn't work. > Something tells me that SWIG isn't taking into consideration the default > param for static_data. Yes, there is a SWIG problem here. I don't know what but this can be revealed simply with the following code (there is no need to have RMagick) : require 'wx' wx_image = Wx::Image.new(2,2) image_data = [0,0,0,64,64,64,128,128,128,255,255,255].pack("C*") alpha_data = [0,255,0,255].pack("C*") unique_alpha_data = [255].pack("C") wx_image.set_data(image_data) #Following call works : wx_image.set_alpha() #Following calls do not work : #wx_image.set_alpha(alpha_data) #wx_image.set_alpha(alpha_data, false) #wx_image.set_alpha(0,0,unique_alpha_data) I'm not sufficiently comfortable with SWIG to fix such kind of issue. Cheers. Chauk-Mean. From lists at ruby-forum.com Fri Jun 5 17:10:56 2009 From: lists at ruby-forum.com (Jonah Dahlquist) Date: Fri, 5 Jun 2009 23:10:56 +0200 Subject: [wxruby-users] How to dynamically change style (Button) Message-ID: <7465574a2ce214f3180ff9d1ac153da4@ruby-forum.com> Hello, world! How does one go about changing the style of a button after it has already been made? Or if there is none, is there some way to highlight a button? The button can't be a ToggleButton, it must be a BitmapButton. Thanks! -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sat Jun 6 15:10:18 2009 From: lists at ruby-forum.com (Michael Satterwhite) Date: Sat, 6 Jun 2009 21:10:18 +0200 Subject: [wxruby-users] Refreshing Window Message-ID: If a long (relatively) operation takes place after dismissing a dialog, the underlying window is in an indeterminate state until the operation is complete. It would be good to be able to periodically display a status update - or let the user know what's happening. To do this, I need some way to force the system to go back through the event loop so that the screen gets properly updated. I'm probably a bit dense here, but I don't see how this could be done. I'm sure some of you have already encountered this and figured out how to do it. How can this be done? Enquiring minds would love to know. ---Michael -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sat Jun 6 17:45:38 2009 From: lists at ruby-forum.com (Jonah Dahlquist) Date: Sat, 6 Jun 2009 23:45:38 +0200 Subject: [wxruby-users] Refreshing Window In-Reply-To: References: Message-ID: <96db5804325aa3422347a7c9428477b2@ruby-forum.com> I posted with a similar problem. The solution was to use evt_idle. Just set it like this: # run dialog box # user replies evt_idle do # do whatever it is you want to do, including # changing a progress bar, label, or whatever. end Instead of # run dialog box # user replies # do whatever... The evt_idle just doesn't allow the process to run until nothing is happening. However, please note that the window will still be frozen, but whatever changes you make will be applied. I'll follow this to find out if it's possible to keep it from being frozen altogether :) Cheers -- Posted via http://www.ruby-forum.com/. From shs at demosophia.net Sun Jun 7 00:30:24 2009 From: shs at demosophia.net (Svend Haugaard =?UTF-8?B?U8O4cmVuc2Vu?=) Date: Sun, 7 Jun 2009 06:30:24 +0200 Subject: [wxruby-users] Refreshing Window In-Reply-To: <96db5804325aa3422347a7c9428477b2@ruby-forum.com> References: <96db5804325aa3422347a7c9428477b2@ruby-forum.com> Message-ID: <20090607063024.3745c7c0@cybert.demosophia.net> On Sat, 6 Jun 2009 23:45:38 +0200 Jonah Dahlquist wrote: > I posted with a similar problem. The solution was to use evt_idle. > Just set it like this: > > # run dialog box > # user replies > evt_idle do > # do whatever it is you want to do, including > # changing a progress bar, label, or whatever. > end > > Instead of > > # run dialog box > # user replies > # do whatever... > > The evt_idle just doesn't allow the process to run until nothing is > happening. > > However, please note that the window will still be frozen, but > whatever changes you make will be applied. > > I'll follow this to find out if it's possible to keep it from being > frozen altogether :) > > Cheers yes I have solved it the same way. But I was wondering if it were possible to make a 'evt_idle_once' function. That only run once and the gets removed from the event que. It seems a little inefficient, that the block is call every time there is some idle time, even if it is only needed to run it once. From transfire at gmail.com Sun Jun 7 22:14:36 2009 From: transfire at gmail.com (trans) Date: Sun, 7 Jun 2009 19:14:36 -0700 (PDT) Subject: [wxruby-users] Lazy WxRuby Message-ID: <65ad6c28-df1e-4b1b-bd89-b0e7abaa2a94@r34g2000vba.googlegroups.com> If interested I posted an example of how I lazily build a WxRuby interface for an app. Here's the link via DZone: http://www.dzone.com/links/wxruby_for_the_lazy.html T. From chauk.mean at gmail.com Mon Jun 8 15:20:55 2009 From: chauk.mean at gmail.com (Chauk-Mean Proum) Date: Mon, 8 Jun 2009 21:20:55 +0200 Subject: [wxruby-users] Lazy WxRuby In-Reply-To: <65ad6c28-df1e-4b1b-bd89-b0e7abaa2a94@r34g2000vba.googlegroups.com> References: <65ad6c28-df1e-4b1b-bd89-b0e7abaa2a94@r34g2000vba.googlegroups.com> Message-ID: Hi Trans, On Mon, Jun 8, 2009 at 4:14 AM, trans wrote: > If interested I posted an example of how I lazily build a WxRuby > interface for an app. Here's the link via DZone: > > ?http://www.dzone.com/links/wxruby_for_the_lazy.html > Interesting approach. Just some comments on wxRuby usage or style : 1/ You don't need to supply -1 as the ID parameter for a Window (-1 or Wx::ID_ANY is already the default value). For a window, the only mandatory parameter is the parent window (the first parameter). => def notebook @notebook ||= ( notebook = Wx::Notebook.new(frame_panel) frame_sizer.add(notebook, 1, Wx::GROW) notebook ) end 2/ Wx::Bitmap is smart enough to guess the bitmap type based on the file extension (OK, it's not well documented but I'll fix that). Wx::Toolbar has also the add_item method which support keyword arguments (and it's well documented) : @search_start_tool = toolbar.add_tool(-1, 'Start' , Wx::Bitmap.new(DIR + '/images/search.gif', Wx::BITMAP_TYPE_GIF), 'Start') => @search_start_tool = toolbar.add_item(Wx::Bitmap.new(DIR + '/images/search.gif'), :label => 'Start', :short_help => 'Start') Cheers. Chauk-Mean. From transfire at gmail.com Mon Jun 8 16:27:57 2009 From: transfire at gmail.com (trans) Date: Mon, 8 Jun 2009 13:27:57 -0700 (PDT) Subject: [wxruby-users] Lazy WxRuby In-Reply-To: References: <65ad6c28-df1e-4b1b-bd89-b0e7abaa2a94@r34g2000vba.googlegroups.com> Message-ID: <1b64e9a9-e8bb-4171-bc45-00c23ebf3c5e@q14g2000vbn.googlegroups.com> On Jun 8, 3:20?pm, Chauk-Mean Proum wrote: > > Interesting approach. Thanks. The approach really helped me wrap my head around WxRuby better. > Just some comments on wxRuby usage or style : > 1/ You don't need to supply -1 as the ID parameter for a Window (-1 or > Wx::ID_ANY is already the default value). > For a window, the only mandatory parameter is the parent window (the > first parameter). > > => > def notebook > ? ? ? @notebook ||= ( > ? ? ? ? notebook = Wx::Notebook.new(frame_panel) > ? ? ? ? frame_sizer.add(notebook, 1, Wx::GROW) > ? ? ? ? notebook > ? ? ? ) > ? ? end > > 2/ Wx::Bitmap is smart enough to guess the bitmap type based on the > file extension (OK, it's not well documented but I'll fix that). > Wx::Toolbar has also the add_item method which support keyword > arguments (and it's well documented) : > > ?@search_start_tool ? = toolbar.add_tool(-1, 'Start' ? , > ? ? ? ? ? ? Wx::Bitmap.new(DIR + '/images/search.gif', > Wx::BITMAP_TYPE_GIF), 'Start') > > => > > @search_start_tool ? = toolbar.add_item(Wx::Bitmap.new(DIR + > '/images/search.gif'), :label => 'Start', :short_help => 'Start') Nice tips. I'll apply those. Thanks for taking at look at this. T. From lists at ruby-forum.com Tue Jun 9 15:19:38 2009 From: lists at ruby-forum.com (Jonah Dahlquist) Date: Tue, 9 Jun 2009 21:19:38 +0200 Subject: [wxruby-users] Refreshing Window In-Reply-To: References: <96db5804325aa3422347a7c9428477b2@ruby-forum.com> <20090607063024.3745c7c0@cybert.demosophia.net> Message-ID: <56c89bb5e606eab9d6000da6291a1549@ruby-forum.com> Great reply, thanks! As to the evt_idle_once, all you have to do is this: evt_idle do evt_idle do end # your code end That empties the evt_idle function as soon as it is called. -- Posted via http://www.ruby-forum.com/. From chauk.mean at gmail.com Sat Jun 13 07:57:40 2009 From: chauk.mean at gmail.com (Chauk-Mean Proum) Date: Sat, 13 Jun 2009 13:57:40 +0200 Subject: [wxruby-users] ImageMagick In-Reply-To: References: <4A242939.90709@pressure.to> <4A265979.7070806@pressure.to> Message-ID: Hi all, On Thu, Jun 4, 2009 at 11:57 PM, Chauk-Mean Proum wrote: > Yes, there is a SWIG problem here. I don't know what but this can be > revealed simply with the following code (there is no need to have > RMagick) : > ... > > #Following call works : > wx_image.set_alpha() > > #Following calls do not work : > #wx_image.set_alpha(alpha_data) > #wx_image.set_alpha(alpha_data, false) > #wx_image.set_alpha(0,0,unique_alpha_data) > > I'm not sufficiently comfortable with SWIG to fix such kind of issue. I've finally been able to fix this SWIG issue which seems to be caused by : - the use of a typemap for the first form of the SetAlpha C++ method - and by the fact that this SetAlpha C++ method has an overloaded method I've just hidden the overloaded method in the SWIG header for the Image class and now everything works. Maybe Alex will be able to provide a complete fix to this issue without having to hide the overloaded method. I've also found a way to get directly the alpha raw data from a RMagick image. So here is the code to convert seamlessly a RMagick image to a wxRuby image : wx_img = Wx::Image.new(magick_img.columns, magick_img.rows) # Set the image data wx_img.data = magick_img.to_blob { self.format = "RGB" } # Set the alpha (transparency) if any if magick_img.alpha? wx_img.alpha = magick_img.to_blob { self.format = "A" } end I've just committed the fix and a complete sample (samples/drawing/rmagic_bitmap_image.rb) in subversion. Cheers. Chauk-Mean. From lists at ruby-forum.com Mon Jun 15 08:45:23 2009 From: lists at ruby-forum.com (Nicholas Gunther) Date: Mon, 15 Jun 2009 14:45:23 +0200 Subject: [wxruby-users] TextCtrl text alignment Message-ID: As shown in the attached program, the text "My Long Textbox Value "in the TextCtrl object, @my_textbox, aligns off the screen in Windos XP (32 bit, SP3) Any help with this would be appreciated. Thanks, Nick G. Attachments: http://www.ruby-forum.com/attachment/3824/testWx.rb -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Mon Jun 15 12:40:56 2009 From: alex at pressure.to (Alex Fenton) Date: Mon, 15 Jun 2009 17:40:56 +0100 Subject: [wxruby-users] TextCtrl text alignment In-Reply-To: References: Message-ID: <4A367998.7090003@pressure.to> Hi Nick Nicholas Gunther wrote: > As shown in the attached program, the text "My Long Textbox Value "in > the TextCtrl object, @my_textbox, aligns off the screen in Windos XP (32 > bit, SP3) I see what you mean - even if only the TextCtrl is present (it always helps to reduce your example to as simple as possible to isolate the problem). I think this is just a 'feature' of the underlying Windows toolkit - it always selects the first widget in a new frame when it's shown, and when selecting a TextCtrl, selects all the text in there. Why it scrolls a bit horizontally I don't know. But you could mitigate this by calling text_ctrl.set_selection_point(0) text_ctrl.set_selection_point_end after the call to show() btw, a couple of things you can write more tersely in wxRuby code: @my_label = StaticText.new(@my_panel, -1, 'My Label Text', DEFAULT_POSITION, DEFAULT_SIZE, ALIGN_CENTER) # better as: @my_label = StaticText.new(@my_panel, :label => 'My Label Text', :style => ALIGN_CENTRE) evt_button(@my_button.get_id()) { |event| my_button_click(event)} # better as: evt_button @my_button, :my_button_click hth alex From lists at ruby-forum.com Mon Jun 15 13:15:49 2009 From: lists at ruby-forum.com (Nick Gohn) Date: Mon, 15 Jun 2009 19:15:49 +0200 Subject: [wxruby-users] TextCtrl text alignment In-Reply-To: <4A367998.7090003@pressure.to> References: <4A367998.7090003@pressure.to> Message-ID: Well, that is helpful, although I think perhaps you meant: set_INSERTION_point(0), not "set_selection_point". :) BUT point(0), point(1), point(2), point(3), point(4) all produce the same good outcome - the text aligned exactly flush with the left margin, while "set_insertion_point(5)" reproduces the original problem in which the text is scrolled to the left and the first characters that appear are "ong" from "Long..." I note that the comboBox is text is perfectly aligned, exactly one space from the far left margin. You did solve the problem, for which I am grateful, but do you know why set_insertion_point is behaving like this? Is it because in the underlying Windows toolkit the earlier insertion points ((i) with i<5) prevent the horizontal scrolling, but a later insertion point permits it? I suppose so. How odd! Thanks again, Nick Alex Fenton wrote: > Hi Nick > > Nicholas Gunther wrote: >> As shown in the attached program, the text "My Long Textbox Value "in >> the TextCtrl object, @my_textbox, aligns off the screen in Windos XP (32 >> bit, SP3) > > I see what you mean - even if only the TextCtrl is present (it always > helps to reduce your example to as simple as possible to isolate the > problem). > > I think this is just a 'feature' of the underlying Windows toolkit - it > always selects the first widget in a new frame when it's shown, and when > selecting a TextCtrl, selects all the text in there. Why it scrolls a > bit horizontally I don't know. But you could mitigate this by calling > > text_ctrl.set_selection_point(0) > text_ctrl.set_selection_point_end > > after the call to show() > > btw, a couple of things you can write more tersely in wxRuby code: > > @my_label = StaticText.new(@my_panel, -1, 'My Label Text', > DEFAULT_POSITION, DEFAULT_SIZE, ALIGN_CENTER) > # better as: > @my_label = StaticText.new(@my_panel, :label => 'My Label Text', :style > => ALIGN_CENTRE) > > evt_button(@my_button.get_id()) { |event| my_button_click(event)} > # better as: > evt_button @my_button, :my_button_click > > hth > alex -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Mon Jun 15 13:31:49 2009 From: lists at ruby-forum.com (Brad Montgomery) Date: Mon, 15 Jun 2009 19:31:49 +0200 Subject: [wxruby-users] key press event Message-ID: <02454786bde04f87b045dd299a7f0965@ruby-forum.com> Hello all I am new to fxruby and coming from php-gtk and rubygnome I can not seem to capture key press events with this code the code was modified from an online example ruby 1.8.7, ubuntu 9.04, wxruby2.0.0 nothing is echoed to the command line i also tried exit in the block and nothing thanks in advance include Wx class MyFrame < Frame def initialize super(nil, -1, "Test Key Press Event") evt_key_down { |ev| puts 'a key was pressed' } end end class MinimalApp < App def on_init MyFrame.new.show end end MinimalApp.new.main_loop happy coding brad -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Jun 16 01:36:08 2009 From: lists at ruby-forum.com (Dimas Cyriaco) Date: Tue, 16 Jun 2009 07:36:08 +0200 Subject: [wxruby-users] key press event In-Reply-To: <02454786bde04f87b045dd299a7f0965@ruby-forum.com> References: <02454786bde04f87b045dd299a7f0965@ruby-forum.com> Message-ID: <785c30905e4ec707198955b25cc7d702@ruby-forum.com> Brad, your code worked fine for me. Just added: require 'rubygems' require 'wx' before include Wx and changed { |ev| puts 'a key was pressed' } to { |ev| message_box('a key was pressed') } just to make it easier to see the results -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Jun 16 06:29:19 2009 From: lists at ruby-forum.com (Brad Montgomery) Date: Tue, 16 Jun 2009 12:29:19 +0200 Subject: [wxruby-users] key press event In-Reply-To: <785c30905e4ec707198955b25cc7d702@ruby-forum.com> References: <02454786bde04f87b045dd299a7f0965@ruby-forum.com> <785c30905e4ec707198955b25cc7d702@ruby-forum.com> Message-ID: <603fe0c42a32225f817701710667481a@ruby-forum.com> Dimas Cyriaco wrote: > Brad, your code worked fine for me. > > Just added: > require 'rubygems' > require 'wx' > before include Wx > > and changed { |ev| puts 'a key was pressed' } > to { |ev| message_box('a key was pressed') } > just to make it easier to see the results Dimas thanks for the reply I neglected to put those lines in my post but they are in the code what OS are you using, ruby version, & wxruby version ? I got the code to work if I connected the event handler to a Wx::Panel, but that will not solve the problem. When the event handler is connected to the panel and the user touches another widget on the screen that widget will now have focus and the panel will no longer receive the key press events. I need the event handler connected to the Frame/Window and listen for event even if it does not have focus. I am reading from a bar code scanner that sends the data as keyboard input. thanks & happy coding brad -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Tue Jun 16 07:55:12 2009 From: alex at pressure.to (Alex Fenton) Date: Tue, 16 Jun 2009 12:55:12 +0100 Subject: [wxruby-users] key press event In-Reply-To: <603fe0c42a32225f817701710667481a@ruby-forum.com> References: <02454786bde04f87b045dd299a7f0965@ruby-forum.com> <785c30905e4ec707198955b25cc7d702@ruby-forum.com> <603fe0c42a32225f817701710667481a@ruby-forum.com> Message-ID: <4A378820.10404@pressure.to> Hi Brad Brad Montgomery wrote: > I got the code to work if I connected the event handler to a Wx::Panel, > but that will not solve the problem. > When the event handler is connected to the panel and the user touches > another > widget on the screen that widget will now have focus and the panel will > no > longer receive the key press events. > By default, only events that are CommandEvents (those associated with defined actions on controls, like clicking a button, typing text in a TextCtrl) propagate up the window hierarchy to the parent. Other types of events, such as MouseEvents and KeyEvents are only received by the window/widget that currently has focus. So if you have a Panel on top of a Frame, once the Panel child has had the event, it won't propagate further. http://wxruby.rubyforge.org/doc/eventhandlingoverview.html > I need the event handler connected to the Frame/Window and listen for > event > even if it does not have focus. > I am reading from a bar code scanner that sends the data as keyboard > input. > The above normally makes sense for interaction, but I can see it's a bit inconvenient for this less usual situation. There are various ways you could work round this. If you have only a single frame receiving data, and a small number of windows within it, you could capture the key press event on all of them, and then manipulate the received event's propagation level with methods like resume_propagation. See this python example: http://wiki.wxpython.org/index.cgi/EventPropagation If the bar code data is such that it is represented by only a small number of different possible keys you could try using an acceleratortable, which directs all key presses within a frame to menu items http://wxruby.rubyforge.org/doc/acceleratortable.html http://osdir.com/ml/lang.ruby.wxruby.user/2008-06/msg00036.html hth alex From alex at pressure.to Wed Jun 17 06:42:46 2009 From: alex at pressure.to (Alex Fenton) Date: Wed, 17 Jun 2009 11:42:46 +0100 Subject: [wxruby-users] How to dynamically change style (Button) In-Reply-To: <7465574a2ce214f3180ff9d1ac153da4@ruby-forum.com> References: <7465574a2ce214f3180ff9d1ac153da4@ruby-forum.com> Message-ID: <4A38C8A6.8020607@pressure.to> Hi Jonah Jonah Dahlquist wrote: > How does one go about changing the style of a button after it has > already been made? Or if there is none, is there some way to highlight > a button? The button can't be a ToggleButton, it must be a > BitmapButton. I'm not sure exactly what you mean by style - if you just mean the bitmap that is shown, you can use set_bitmap_label (and also other set_bitmap_xxx methods for other states like hover, focus) to change the image that's displayed. Using set_bitmap_focus and set_bitmap_selected will automatically deal with highlighted images for those states - you don't need to managed this yourself. If you need to change the formal "style" argument (eg Wx::BU_AUTODRAW) then you have to swap two different widgets in and out, and show and hide them. alex From alex at pressure.to Wed Jun 17 07:56:17 2009 From: alex at pressure.to (Alex Fenton) Date: Wed, 17 Jun 2009 12:56:17 +0100 Subject: [wxruby-users] Lazy WxRuby In-Reply-To: <65ad6c28-df1e-4b1b-bd89-b0e7abaa2a94@r34g2000vba.googlegroups.com> References: <65ad6c28-df1e-4b1b-bd89-b0e7abaa2a94@r34g2000vba.googlegroups.com> Message-ID: <4A38D9E1.3020903@pressure.to> trans wrote: > If interested I posted an example of how I lazily build a WxRuby > interface for an app. Here's the link via DZone: > > http://www.dzone.com/links/wxruby_for_the_lazy.html Late to the link, but thanks for posting this. I think the approach is interesting and instructive so I added it to the tutorials page on the wiki. Another shortcut you can use: Wx::VBoxSizer.new instead of Wx::BoxSizer.new(Wx::VERTICAL) alex From transfire at gmail.com Wed Jun 17 10:04:40 2009 From: transfire at gmail.com (trans) Date: Wed, 17 Jun 2009 07:04:40 -0700 (PDT) Subject: [wxruby-users] Lazy WxRuby In-Reply-To: <4A38D9E1.3020903@pressure.to> References: <65ad6c28-df1e-4b1b-bd89-b0e7abaa2a94@r34g2000vba.googlegroups.com> <4A38D9E1.3020903@pressure.to> Message-ID: On Jun 17, 7:56?am, Alex Fenton wrote: > trans wrote: > > If interested I posted an example of how I lazily build a WxRuby > > interface for an app. Here's the link via DZone: > > > ?http://www.dzone.com/links/wxruby_for_the_lazy.html > > Late to the link, but thanks for posting this. I think the approach is > interesting and instructive so I added it to the tutorials page on the wiki. Nice :-) > Another shortcut you can use: > > Wx::VBoxSizer.new > > instead of > > Wx::BoxSizer.new(Wx::VERTICAL) Thanks, I updated the post to use this. Btw, just for completeness sake, the Controller class should also have this method: def sites ; service.sites ; end trans From alex at pressure.to Sat Jun 20 07:54:02 2009 From: alex at pressure.to (Alex Fenton) Date: Sat, 20 Jun 2009 12:54:02 +0100 Subject: [wxruby-users] Ask : Single window & catch OnClose event In-Reply-To: <26dadb3d0906192057u74c555dap61cf52e9b470e661@mail.gmail.com> References: <26dadb3d0906192057u74c555dap61cf52e9b470e661@mail.gmail.com> Message-ID: <4A3CCDDA.5070504@pressure.to> Hi hendra kusuma wrote: > I'm creating desktop application using wxruby and encounter some problem > I need my application to be able to open only one for each frame > is there any way to do this? > I tried to include singleton but then my frame lost its contact with > its parent > (my frame class is inherited from WxFrame and I use initialize method > to assign parent) I'm not sure what you mean here - do you mean that only a single instance of the application should be running at one time? If so, the way would probably be to create some kind of lockfile on application start: if the lockfile already exists, then the application is already running. If you want to have only one frame per file document, just keep a hash as an instance variable of the Wx::App object, with the keys being the file paths, and the values being the Wx::Frame objects. Then you can check this hash to see if a Frame is already opened for a given file. > also, I need to catch OnClose event > how can I do that? I need to do something (delete temporary file) > before the frame closed > code example will be appreciated :) Use evt_close, something like: class MyFrame < Wx::Frame def initialize super evt_close do | e | delete_temp_file ... e.skip end note that calling 'skip' is important here, to allow normal processing to continue and the window to actually close hth alex From luciano.zanotto at polimi.it Tue Jun 23 12:30:25 2009 From: luciano.zanotto at polimi.it (Luciano Zanotto) Date: Tue, 23 Jun 2009 18:30:25 +0200 Subject: [wxruby-users] TextValidator problem Message-ID: <4A410321.9010102@polimi.it> I'm really sorry, but sometimes I feel just I'm a little bit dumb... and this is the case. I'm stiil using the TextValidator class. If I use the standard filtering options much of the characters normally used are filtered out. The Wx::FILTER_ALPHANUMERIC option filters out anything which is not [a-z], [A-Z] or [0-9]. It would be nice to use dots, bars and underscores too, so I thought to call the set_includes method, but with no result. Can anyone tell me which kind of parameter should I pass to set_includes? Can anyone give me few lines of working code? Thanks in advance to anyone Luciano From lists at ruby-forum.com Fri Jun 26 07:36:05 2009 From: lists at ruby-forum.com (=?utf-8?Q?Marvin_G=c3=bclker?=) Date: Fri, 26 Jun 2009 13:36:05 +0200 Subject: [wxruby-users] Visual styles in Windows Vista? Message-ID: <564d50427f0cdacd62b9fc5223995bcb@ruby-forum.com> Hi, I've been using wxRuby with Visual Styles on Windows XP very well (as described here: http://rubyonwindows.blogspot.com/2007/10/windows-xp-visual-style-controls-with.html, I only altered version="1.8.6.0" to version="1.9.1.0"), but this seems not to work under Windows Vista, I only get the boring old styles. Is there a solution for that? Windows Vista Home Premium ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-mingw32] Marvin -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Jun 26 07:37:29 2009 From: lists at ruby-forum.com (=?utf-8?Q?Marvin_G=c3=bclker?=) Date: Fri, 26 Jun 2009 13:37:29 +0200 Subject: [wxruby-users] Visual styles in Windows Vista? In-Reply-To: <564d50427f0cdacd62b9fc5223995bcb@ruby-forum.com> References: <564d50427f0cdacd62b9fc5223995bcb@ruby-forum.com> Message-ID: Marvin G?lker wrote: > http://rubyonwindows.blogspot.com/2007/10/windows-xp-visual-style-controls-with.html, Oh sorry, without the comma: http://rubyonwindows.blogspot.com/2007/10/windows-xp-visual-style-controls-with.html Marvin -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sun Jun 28 12:57:35 2009 From: lists at ruby-forum.com (David Mullet) Date: Sun, 28 Jun 2009 18:57:35 +0200 Subject: [wxruby-users] Visual styles in Windows Vista? In-Reply-To: <564d50427f0cdacd62b9fc5223995bcb@ruby-forum.com> References: <564d50427f0cdacd62b9fc5223995bcb@ruby-forum.com> Message-ID: <282007fb25e4ce32b9e21d312935c3ae@ruby-forum.com> Marvin G?lker wrote: > Hi, > > I've been using wxRuby with Visual Styles on Windows XP very well (as > described here: > http://rubyonwindows.blogspot.com/2007/10/windows-xp-visual-style-controls-with.html, > I only altered version="1.8.6.0" to version="1.9.1.0"), but this seems > not to work under Windows Vista, I only get the boring old styles. Is > there a solution for that? > > Windows Vista Home Premium > ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-mingw32] > > Marvin I encountered the same problem. I selected "Run this program in Compatibility Mode for: Windows XP Service Pack 2" in the File Properties for ruby.exe and rubyw.exe. That seems to have resolved the problem, as I now get the "XP/Vista" visual styles. Furthermore, I then deselected this option in the File Properties, rebooted, and still get the "XP/Vista" visual styles. Windows Vista Home Premium Ruby 1.8.6 wxRuby 2.0.0 Hope that helps. I'd be curious to know if you see the same results. David http://rubyonwindows.blogspot.com/ -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sun Jun 28 13:42:28 2009 From: lists at ruby-forum.com (Michael Satterwhite) Date: Sun, 28 Jun 2009 19:42:28 +0200 Subject: [wxruby-users] LoadError: No such file to load -- wx Message-ID: <22bcbef23a9f10732ad74b769c812f4c@ruby-forum.com> I have a program written with wxruby. If I try to execute it with timeclock.rb I get the error "`gem_original_require': no such file to load -- wx (LoadError)" If I run it with ruby timeclock.rb it runs correctly. I *AM* aware of the need to load rubygems. Therefore in my program, I have the explicit statements: require 'rubygems' require 'wx' As a result, I'm not sure what could be the problem. Can anyone offer any help? Thanks in advance ---Michael -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sun Jun 28 13:47:02 2009 From: lists at ruby-forum.com (=?utf-8?Q?Marvin_G=c3=bclker?=) Date: Sun, 28 Jun 2009 19:47:02 +0200 Subject: [wxruby-users] Visual styles in Windows Vista? In-Reply-To: <282007fb25e4ce32b9e21d312935c3ae@ruby-forum.com> References: <564d50427f0cdacd62b9fc5223995bcb@ruby-forum.com> <282007fb25e4ce32b9e21d312935c3ae@ruby-forum.com> Message-ID: David Mullet wrote: > Marvin G?lker wrote: >> Hi, >> >> I've been using wxRuby with Visual Styles on Windows XP very well (as >> described here: >> http://rubyonwindows.blogspot.com/2007/10/windows-xp-visual-style-controls-with.html, >> I only altered version="1.8.6.0" to version="1.9.1.0"), but this seems >> not to work under Windows Vista, I only get the boring old styles. Is >> there a solution for that? >> >> Windows Vista Home Premium >> ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-mingw32] >> >> Marvin > > I encountered the same problem. I selected "Run this program in > Compatibility Mode for: Windows XP Service Pack 2" in the File > Properties for ruby.exe and rubyw.exe. That seems to have resolved the > problem, as I now get the "XP/Vista" visual styles. > > Furthermore, I then deselected this option in the File Properties, > rebooted, and still get the "XP/Vista" visual styles. > > Windows Vista Home Premium > Ruby 1.8.6 > wxRuby 2.0.0 > > Hope that helps. I'd be curious to know if you see the same results. > > David > > http://rubyonwindows.blogspot.com/ Thanks David! I got the effect you described: I first selected compatibility mode for XP SP2 and tried a simple test application with two buttons. They appeared in the new design. Then I deselected the option, just as you said - and the visual styles didn't disappear. Is there an explanation for that? Maybe Windows manipulates the ruby(w).exe file by including a manifest if there's one in the same directory when setting the compatibility mode? Marvin -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Mon Jun 29 05:58:17 2009 From: lists at ruby-forum.com (=?utf-8?Q?Marvin_G=c3=bclker?=) Date: Mon, 29 Jun 2009 11:58:17 +0200 Subject: [wxruby-users] catch enter key pressed in textbox In-Reply-To: <26dadb3d0906290024x11e47eb6je9bd2a9e16a3d1ca@mail.gmail.com> References: <26dadb3d0906290024x11e47eb6je9bd2a9e16a3d1ca@mail.gmail.com> Message-ID: <1d56913a437708facc434458934d2b4b@ruby-forum.com> hendra kusuma wrote: > Dear all, > > how can I catch enter key pressed event in a textbox? > > Regards > Hendra http://wxruby.rubyforge.org/doc/textctrl.html section "Event handling". evt_text_enter(your_textbox_id){|event| do_whatever_you_want} Your textbox has to specify the TE_PROCESS_ENTER style. Marvin -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Jun 30 17:27:04 2009 From: lists at ruby-forum.com (=?utf-8?Q?Marvin_G=c3=bclker?=) Date: Tue, 30 Jun 2009 23:27:04 +0200 Subject: [wxruby-users] Transparent widgets? Message-ID: Hi, I'm trying to create a transparent window with a StaticText on it, but I didn't found out how this is possible. My Code looks like this: #Encoding: UTF-8 require "wx" require "wx_sugar" include Wx class TransparentFrame < Frame def initialize super(nil, -1, "Test", DEFAULT_POSITION, Size.new(400, 400), DEFAULT_FRAME_STYLE | TRANSPARENT_WINDOW) #defining transparency style set_background_colour(Colour.new(0, 0, 0, 0)) #Setting transparent back end #Overriding has_transparent_background def has_transparent_background true end end class Sample < App def on_init @mainwindow = TransparentFrame.new #Creating transparent Frame @text = StaticText.new(@mainwindow, -1, "Test") @text.set_foreground_colour(Colour.from_hex("#FFFFFF")) @text.set_font(Font.new(60, FONTFAMILY_ROMAN, FONTSTYLE_NORMAL, FONTWEIGHT_BOLD)) @text.centre_on_parent @mainwindow.show end end x = Sample.new x.main_loop That only displays a white text on a black background - no transparency. I'm working with Windows Vista Home Premium ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-mingw32] Marvin -- Posted via http://www.ruby-forum.com/.