From lists at ruby-forum.com Sat Sep 4 06:58:12 2010 From: lists at ruby-forum.com (Tony Meier) Date: Sat, 4 Sep 2010 12:58:12 +0200 Subject: [wxruby-users] GridCellNumberEditor peculiarities In-Reply-To: <4B950548.80105@pressure.to> References: <84bfac65f005dcd32539881a0b53f244@ruby-forum.com> <60725e8f245f906a106951710389d16e@ruby-forum.com> <4B950548.80105@pressure.to> Message-ID: Hi Alex, any news on this issue? I'm still struggling to completely wrap my head around the CellEditors. Right now I've managed to get everything working half-way but one issue remains: Leaving the Cell-Editor with Enter. On Windows, this works with normal editors but not with numeric editors. On OSX this doesn't work at all. Looking up the wxwidgets documentation, I found that there should be a virtual editor method called "handleReturn" (see [1]). Attempts to implement a ruby method handle_return doesn't yield any result. Can you please advise what would be the best (or any) way to process an enter key and to finalize cell editing? Thanks, Tony [1] http://docs.wxwidgets.org/trunk/classwx_grid_cell_editor.html#265a3c935b3d5c204c8c75149fa0cb74 Alex Fenton wrote: > Tony Meier wrote: >> me again - I'm still struggling with the Grid code. Maybe this is a >> problem with my runtime environment? >> >> I'm using wxruby 2.0.1 on Snow Leopard 10.6.2 using Ruby 1.8.7 and >> wxWidgets 2.8.10. Is this supposed to be a valid combination? >> > > 2.0.1 came out just before Snow Leopard was released, and I think we > need to update and rebuild for 10.6 - just haven't got around to it > though I've been using 10.6 for a few months. > > However, this sort of problem would almost certainly show up as big-fail > crash on startup, rather than minor behavioural differences. > >> It seems that, with this combination the GridCellNumberEditor cannot be >> properly derived from. > > I have a feeling that the concrete XXXEditor classes are not fully > inheritable from - they are designed as concrete final classes in C++. > But I'm not sure about this - will have a go with your sample later > today (also looking at your wheel question) and let you know > > alex -- Posted via http://www.ruby-forum.com/. From walter_barnes05 at yahoo.com Tue Sep 7 20:35:16 2010 From: walter_barnes05 at yahoo.com (Walter Barnes) Date: Tue, 7 Sep 2010 17:35:16 -0700 (PDT) Subject: [wxruby-users] Validator data transfer Message-ID: <782970.69482.qm@web113215.mail.gq1.yahoo.com> Hi all, I'm working on a dialog box for a SketchUp plug-in using wxSU with several text controls that accept numerical input only and need a little help with the validators. After going through the docs for wxRuby and wxWidgets I tried the following: class SpurGearDialog < Wx::Dialog attr_accessor :gear_teeth def create_gear_parameter_controls ... #set validators val = Wx::TextValidator.new(Wx::FILTER_INCLUDE_CHAR_LIST, @gear_teeth) val.set_includes(@arr_int) @tc_gTeeth.set_validator(val) ... end end With @tc_gTeeth being the text control, @gear_teeth the instance variable that I want the validator to save data to and @arr_int is my list of acceptable characters. When I attempt to open the dialog box, SketchUp crashes at the third line. I found I can only get the validator to work by removing @gear_teeth when creating the validator. However, if I do this I do not see how the validator can transfer data between the control and my dialog class. I'm a Ruby newbie so the problem might be my code but if not, is there a way to get data from the control using validators in wxRuby or is data transfer just not supported at this time? TIA! Walter -------------- next part -------------- An HTML attachment was scrubbed... URL: From mario at ruby-im.net Tue Sep 7 23:18:29 2010 From: mario at ruby-im.net (Mario Steele) Date: Tue, 7 Sep 2010 23:18:29 -0400 Subject: [wxruby-users] Validator data transfer In-Reply-To: <782970.69482.qm@web113215.mail.gq1.yahoo.com> References: <782970.69482.qm@web113215.mail.gq1.yahoo.com> Message-ID: Hello Walter, On Tue, Sep 7, 2010 at 8:35 PM, Walter Barnes wrote: > Hi all, > > I'm working on a dialog box for a SketchUp plug-in using wxSU with several > text controls that accept numerical input only and need a little help with > the validators. > > After going through the docs for wxRuby and wxWidgets I tried the > following: > > class SpurGearDialog < Wx::Dialog > > attr_accessor :gear_teeth > > def create_gear_parameter_controls > > ... > > #set validators > val = Wx::TextValidator.new(Wx::FILTER_INCLUDE_CHAR_LIST, > @gear_teeth) > val.set_includes(@arr_int) > @tc_gTeeth.set_validator(val) > > ... > > end > end > > With @tc_gTeeth being the text control, @gear_teeth the instance variable > that I want the validator to save data to and @arr_int is my list of > acceptable characters. > > When I attempt to open the dialog box, SketchUp crashes at the third line. > I found I can only get the validator to work by removing @gear_teeth when > creating the validator. However, if I do this I do not see how the validator > can transfer data between the control and my dialog class. > > I'm a Ruby newbie so the problem might be my code but if not, is there a > way to get data from the control using validators in wxRuby or is data > transfer just not supported at this time? > > TIA! > > Walter > When your dialog is accepted by the user, (Eg: Wx::ID_OK is returned from show_modal), you use text_ctrl.value to retrieve the data that is stored in the field. You need to put an attr_reader on your dialog class, for your tc_gTeeth. Afterwhich, once your dialog is accepted, you use myDialog.tc_gTeeth.value to retrieve the value that the user has inputed. Hope this helps and makes sense. hth, Mario > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -- Mario Steele Lieutenant Commander 3 XO - Geo 99 XO - STO IFT Fleet http://www.trekfederation.com http://geo99.ruby-im.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From walter_barnes05 at yahoo.com Wed Sep 8 00:43:37 2010 From: walter_barnes05 at yahoo.com (Walter Barnes) Date: Tue, 7 Sep 2010 21:43:37 -0700 (PDT) Subject: [wxruby-users] Validator data transfer In-Reply-To: References: <782970.69482.qm@web113215.mail.gq1.yahoo.com> Message-ID: <477826.38688.qm@web113204.mail.gq1.yahoo.com> It would appear then that validators are not fully implemented in wxRuby. From the wxWidgets docs, I think it's possible to have a public String variable in the dialog class that the validator sends the value of the text control to. Basically then you can do MyDialog.my_variable without dealing directly with the dialog controls. If that's not possible in wxRuby I'll go ahead and do as you suggest and set up accessors for the text controls. Thanks Mario! ________________________________ From: Mario Steele To: General discussion of wxRuby Sent: Tue, September 7, 2010 8:18:29 PM Subject: Re: [wxruby-users] Validator data transfer Hello Walter, On Tue, Sep 7, 2010 at 8:35 PM, Walter Barnes wrote: Hi all, > >I'm working on a dialog box for a SketchUp plug-in using wxSU with several text >controls that accept numerical input only and need a little help with the >validators. > >After going through the docs for wxRuby and wxWidgets I tried the following: > >class SpurGearDialog < Wx::Dialog > > attr_accessor :gear_teeth > > def create_gear_parameter_controls > >... > > #set validators > val = Wx::TextValidator.new(Wx::FILTER_INCLUDE_CHAR_LIST, @gear_teeth) > val.set_includes(@arr_int) > @tc_gTeeth.set_validator(val) > >... > > end >end > >With @tc_gTeeth being the text control, @gear_teeth the instance variable that >I want the validator to save data to and @arr_int is my list of acceptable >characters. > >When I attempt to open the dialog box, SketchUp crashes at the third line. I >found I can only get the validator to work by removing @gear_teeth when creating >the validator. However, if I do this I do not see how the validator can transfer >data between the control and my dialog class. > >I'm a Ruby newbie so the problem might be my code but if not, is there a way to >get data from the control using validators in wxRuby or is data transfer just >not supported at this time? > >TIA! > >Walter When your dialog is accepted by the user, (Eg: Wx::ID_OK is returned from show_modal), you use text_ctrl.value to retrieve the data that is stored in the field. You need to put an attr_reader on your dialog class, for your tc_gTeeth. Afterwhich, once your dialog is accepted, you use myDialog.tc_gTeeth.value to retrieve the value that the user has inputed. Hope this helps and makes sense. hth, Mario >_______________________________________________ >wxruby-users mailing list >wxruby-users at rubyforge.org >http://rubyforge.org/mailman/listinfo/wxruby-users > -- Mario Steele Lieutenant Commander 3 XO - Geo 99 XO - STO IFT Fleet http://www.trekfederation.com http://geo99.ruby-im.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From sutniuq at gmx.net Thu Sep 9 03:58:57 2010 From: sutniuq at gmx.net (Quintus) Date: Thu, 09 Sep 2010 09:58:57 +0200 Subject: [wxruby-users] Wx::Grid and motion events, bug? Message-ID: <4C8893C1.6030202@gmx.net> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi there, Doesn't a Wx::Grid get motion events sent? This code demonstrates the problem: - -------------------------------------------------------------- #!/usr/bin/env ruby #Encoding: UTF-8 require "wx" class MyFrame < Wx::Frame include Wx def initialize(parent = nil) super(parent, title: "Test", size: Size.new(400, 400)) self.background_colour = NULL_COLOUR StaticText.new(self, label: "") #Dummy @grid = Grid.new(self, size: Size.new(300, 200)) @grid.create_grid(10, 10) @grid.evt_motion{|e| p "!"; $stdout.flush} end end class MyApp < Wx::App include Wx def on_init @mainwindow = MyFrame.new @mainwindow.show end end x = MyApp.new x.main_loop - -------------------------------------------------------------- If I hover the mouse above the grid, nothing happens, but if I put in a panel control instead of a grid, it works. Surprisingly, if I changed the line @grid.evt_motion{|e| p "!"; $stdout.flush} to THE_APP.evt_motion{|e| p "!"; $stdout.flush} I get motion events for everything but the grid. As soon as the cursor enters the grid control, no output arrives anymore. What's going on here? Is that a bug? I'm working on Ubuntu Lucid. Here's the uname -a: Linux ikarus 2.6.32-24-generic #42-Ubuntu SMP Fri Aug 20 14:21:58 UTC 2010 x86_64 GNU/Linux and here's my ruby -v: ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux] I compiled both Ruby and wxRuby from source. Marvin -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkyIk7MACgkQDYShvwAbcNntNQCfcw+zR78b6ZxoTImx+rCRzCeN khQAnjo4Zcix/0VkZqrwkz3f6x6XpCSM =tLGS -----END PGP SIGNATURE----- From chauk.mean at gmail.com Thu Sep 9 16:08:05 2010 From: chauk.mean at gmail.com (Chauk-Mean Proum) Date: Thu, 9 Sep 2010 22:08:05 +0200 Subject: [wxruby-users] Suggestions to reduce binary size, make loading faster In-Reply-To: References: Message-ID: Hi Lui, 2010/2/4 Lui Kore : > The loading of wxruby is not very fast too(~ 1.3s on my machine). After > a small profile, I found the following code in wx.rb the bottle-neck: > > ? ?require 'wx/classes/evthandler.rb' > ? ?class_files = File.join( File.dirname(__FILE__), 'wx', 'classes', > '*.rb') > ? ?Dir.glob(class_files) do | class_file | > ? ? ?require 'wx/classes/' + class_file[/\w+\.rb$/] > ? ?end > > A simple improvement is to make wx/classes/*.rb into one. > I wrote the following script, placed it under wx/, then run it to > generate a new classes.rb containing most classes under wx/classes/ > Sorry for such a long delay ... I've tested your suggestion and indeed the loading is a bit faster. But the improvement is only about 10-11% on my system according to a Benchmark.measure of a require 'wx'. I don't know yet if it is worth adding a rake task for generating the classes.rb automatically even if I've already written it. Does anybody has an opinion on the subject ? Cheers. Chauk-Mean. From sutniuq at gmx.net Fri Sep 10 10:04:48 2010 From: sutniuq at gmx.net (Quintus) Date: Fri, 10 Sep 2010 16:04:48 +0200 Subject: [wxruby-users] Wx::Grid and motion events, bug? In-Reply-To: <4C8893C1.6030202@gmx.net> References: <4C8893C1.6030202@gmx.net> Message-ID: <4C8A3B00.2000002@gmx.net> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am 09.09.2010 09:58, schrieb Quintus: > Hi there, > > Doesn't a Wx::Grid get motion events sent? This code demonstrates the > problem: > This problem seems to be quite serious. I just noticed that a Wx::Grid doesn't get ANY mouse events sent: =========================================================== #!/usr/bin/env ruby #Encoding: UTF-8 require "wx" class MyFrame < Wx::Frame include Wx def initialize(parent = nil) super(parent, title: "Test", size: Size.new(400, 400)) self.background_colour = NULL_COLOUR StaticText.new(self, label: "") #Dummy @grid = Grid.new(self, size: Size.new(300, 200)) @grid.create_grid(10, 10) @grid.evt_left_down{|e| p "!"; $stdout.flush} @grid.evt_left_up{|e| p "!"; $stdout.flush} @grid.evt_motion{|e| p "!"; $stdout.flush} @grid.evt_left_dclick{|e| p "!"; $stdout.flush} @grid.evt_right_down{|e| p "!"; $stdout.flush} end end class MyApp < Wx::App include Wx def on_init @mainwindow = MyFrame.new @mainwindow.show end end x = MyApp.new x.main_loop =========================================================== No way to get a single "!" out of the above program. Shall I file a bug on the tracker? Marvin -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkyKOvUACgkQDYShvwAbcNmM+ACeLxUBLq0mFUa62uUHiT1jxHoa 9NMAnAslCNhfTb5OFgsPKXyNf0u9gSjN =Ikpy -----END PGP SIGNATURE----- From lists at ruby-forum.com Mon Sep 13 08:13:59 2010 From: lists at ruby-forum.com (Tony Meier) Date: Mon, 13 Sep 2010 14:13:59 +0200 Subject: [wxruby-users] OS X Snow Leopard + wxRuby 2.0.1 gem - WORKING In-Reply-To: <9f6a282c80332f75a588faab2c901c81@ruby-forum.com> References: <4C344B85.6000808@pressure.to> <9f6a282c80332f75a588faab2c901c81@ruby-forum.com> Message-ID: Sweet. Runs perfectly on my 10.6.4 machine. Did anyone manage to launch the 32bit ruby environment from Netbeans? Thanks, Tony -- Posted via http://www.ruby-forum.com/. From penguinroad at gmail.com Fri Sep 17 03:55:32 2010 From: penguinroad at gmail.com (hendra kusuma) Date: Fri, 17 Sep 2010 15:55:32 +0800 Subject: [wxruby-users] change widget focus with enter instead of tab Message-ID: Dear all, is there a way to change widget focus with enter key instead of tab Regards Hendra -- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com From fabio.petrucci at gmail.com Fri Sep 17 05:31:56 2010 From: fabio.petrucci at gmail.com (Fabio Petrucci) Date: Fri, 17 Sep 2010 11:31:56 +0200 Subject: [wxruby-users] change widget focus with enter instead of tab In-Reply-To: References: Message-ID: Set style to text filed that should receive enter event: text_fied_1.toggle_window_style(Wx::TE_PROCESS_ENTER) into the panel that contain text_field_1 evt_text_enter(text_field_a) { |evt| text_field_2.set_focus()} hope this help. regards, bio. On Fri, Sep 17, 2010 at 9:55 AM, hendra kusuma wrote: > Dear all, > > is there a way to change widget focus with enter key instead of tab > > Regards > Hendra > > -- > Suka linux? > Kunjungi blog saya http://penguinroad.blogspot.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: From walter_barnes05 at yahoo.com Fri Sep 17 17:46:35 2010 From: walter_barnes05 at yahoo.com (Walter Barnes) Date: Fri, 17 Sep 2010 14:46:35 -0700 (PDT) Subject: [wxruby-users] need help with navigation key events Message-ID: <986846.70202.qm@web113204.mail.gq1.yahoo.com> Hello, I'm having some trouble figuring out how to process navigation key events. I added the following test code to my dialog box: def initialize( .... ) evt_navigation_key(:on_navigation_key) end def on_navigation_key(event) puts "--tab pressed--" puts " event object: " + event.get_event_object.inspect obj = event.get_current_focus if obj puts " current focus: " + obj.inspect else puts " event.get_current_focus returned nil" puts " current focus: " + Wx::Window.find_focus.inspect end event.skip end When testing the dialog box (which subclasses Wx::Dialog) there are no messages when tabbing from a text control. All other controls generate the expected messages. I am able however to tab through all controls in the correct order both forward and back. All my controls except for a checkbox are grouped in static boxes. I have tried doing "xxxx.evt_navigation_key { |event| on_navigation_key(event) }" for the text boxes as well as the static boxes that contain them to no effect. I've also noticed unusual behavior too. When tabbing into a radio box, there is no visual indication that it has the focus if the text control that precedes it is enabled. If the text control is disabled then it works fine. Also, when doing a shift+tab to navigate backwards, it will first go forward one control then start going backwards. Lastly, two navigation events with the same output are generated when cycling from the last control back to the first. How do I get the navigation events to work properly and how can I capture navigation events when a text control has the focus? Some additional info: I'm using Windows XP SP3, all controls and static boxes are children of the dialog box, all text controls are single line with the TE_RICH window style. TIA, Walter -------------- next part -------------- An HTML attachment was scrubbed... URL: From penguinroad at gmail.com Fri Sep 17 21:34:49 2010 From: penguinroad at gmail.com (hendra kusuma) Date: Sat, 18 Sep 2010 09:34:49 +0800 Subject: [wxruby-users] change widget focus with enter instead of tab In-Reply-To: References: Message-ID: very helpful thank you On Fri, Sep 17, 2010 at 5:31 PM, Fabio Petrucci wrote: > Set style to text filed that should receive enter event: > > text_fied_1.toggle_window_style(Wx::TE_PROCESS_ENTER) > > into the panel that contain text_field_1 > > evt_text_enter(text_field_a) { |evt| text_field_2.set_focus()} > > hope this help. > > regards, > > bio. > > On Fri, Sep 17, 2010 at 9:55 AM, hendra kusuma wrote: > >> Dear all, >> >> is there a way to change widget focus with enter key instead of tab >> >> Regards >> Hendra >> >> -- >> Suka linux? >> Kunjungi blog saya http://penguinroad.blogspot.com >> _______________________________________________ >> 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 > -- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From penguinroad at gmail.com Fri Sep 17 22:09:14 2010 From: penguinroad at gmail.com (hendra kusuma) Date: Sat, 18 Sep 2010 10:09:14 +0800 Subject: [wxruby-users] some question Message-ID: I am making a program and get some trouble here 1. how do I close all opened child window in mdi form? 2. I cannot disable menu_item, perhaps I use .enable false the wrong way? -- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From walter_barnes05 at yahoo.com Sat Sep 18 00:21:01 2010 From: walter_barnes05 at yahoo.com (Walter Barnes) Date: Fri, 17 Sep 2010 21:21:01 -0700 (PDT) Subject: [wxruby-users] need help with navigation key events In-Reply-To: <986846.70202.qm@web113204.mail.gq1.yahoo.com> References: <986846.70202.qm@web113204.mail.gq1.yahoo.com> Message-ID: <499245.15536.qm@web113213.mail.gq1.yahoo.com> never mind, looks like I fixed it :-) Problem was that I needed to place all my controls in a panel. For some reason, panel.evt_navigation_key works but dialog.evt_navigation_key does not. This also fixed all the weird behavior I mentioned below too. I am curious though... what is the difference between handling navigation events coming from a panel and handling the same type of events coming from a dialog? Thanks, Walter ________________________________ From: Walter Barnes To: wxRuby Users Sent: Fri, September 17, 2010 2:46:35 PM Subject: [wxruby-users] need help with navigation key events Hello, I'm having some trouble figuring out how to process navigation key events. I added the following test code to my dialog box: def initialize( .... ) evt_navigation_key(:on_navigation_key) end def on_navigation_key(event) puts "--tab pressed--" puts " event object: " + event.get_event_object.inspect obj = event.get_current_focus if obj puts " current focus: " + obj.inspect else puts " event.get_current_focus returned nil" puts " current focus: " + Wx::Window.find_focus.inspect end event.skip end When testing the dialog box (which subclasses Wx::Dialog) there are no messages when tabbing from a text control. All other controls generate the expected messages. I am able however to tab through all controls in the correct order both forward and back. All my controls except for a checkbox are grouped in static boxes. I have tried doing "xxxx.evt_navigation_key { |event| on_navigation_key(event) }" for the text boxes as well as the static boxes that contain them to no effect. I've also noticed unusual behavior too. When tabbing into a radio box, there is no visual indication that it has the focus if the text control that precedes it is enabled. If the text control is disabled then it works fine. Also, when doing a shift+tab to navigate backwards, it will first go forward one control then start going backwards. Lastly, two navigation events with the same output are generated when cycling from the last control back to the first. How do I get the navigation events to work properly and how can I capture navigation events when a text control has the focus? Some additional info: I'm using Windows XP SP3, all controls and static boxes are children of the dialog box, all text controls are single line with the TE_RICH window style. TIA, Walter -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Sun Sep 19 13:21:26 2010 From: lists at ruby-forum.com (Tony Meier) Date: Sun, 19 Sep 2010 19:21:26 +0200 Subject: [wxruby-users] change widget focus with enter instead of tab In-Reply-To: References: Message-ID: <2452cd47d89d7c30b15b1a17813e6688@ruby-forum.com> Fabio Petrucci wrote: > Set style to text filed that should receive enter event: > > text_fied_1.toggle_window_style(Wx::TE_PROCESS_ENTER) > into the panel that contain text_field_1 > evt_text_enter(text_field_a) { |evt| text_field_2.set_focus()} > > hope this help. > > regards, > > bio. is this possible for grid cell editors, too? Thanks, Tony -- Posted via http://www.ruby-forum.com/. From fabio.petrucci at gmail.com Mon Sep 20 03:29:23 2010 From: fabio.petrucci at gmail.com (Fabio Petrucci) Date: Mon, 20 Sep 2010 09:29:23 +0200 Subject: [wxruby-users] change widget focus with enter instead of tab In-Reply-To: <2452cd47d89d7c30b15b1a17813e6688@ruby-forum.com> References: <2452cd47d89d7c30b15b1a17813e6688@ruby-forum.com> Message-ID: On Sun, Sep 19, 2010 at 7:21 PM, Tony Meier wrote: > Fabio Petrucci wrote: > > Set style to text filed that should receive enter event: > > > > text_fied_1.toggle_window_style(Wx::TE_PROCESS_ENTER) > > into the panel that contain text_field_1 > > evt_text_enter(text_field_a) { |evt| text_field_2.set_focus()} > > > > hope this help. > > > > regards, > > > > bio. > > is this possible for grid cell editors, too? > > Thanks, > Tony > -- > I don't really know... You think should check for something like 'activate' event and then, if you can localize cell grid objects and they respond to 'set_focus', it should work. Let us know. Good luck. bio. -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Wed Sep 22 10:06:12 2010 From: lists at ruby-forum.com (Tony Meier) Date: Wed, 22 Sep 2010 16:06:12 +0200 Subject: [wxruby-users] Using Wx::RichTextCtrl to generate PDF Message-ID: <62be5705a3f3a8daaac51864560d3e7f@ruby-forum.com> Hi, I intend to use a RichTextCtrl so the user can edit parts of a PDF that will be generated using Prawn. Any ideas on how to best render the user-editable content into the PDF? I was thinking of parsing the XML output since I'm not sure if it's possible to easily extend the RichTextFileHandler class from within Ruby. Or is RichTextPrinting the proper way to start here? Thanks, Tony -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Wed Sep 22 10:40:29 2010 From: alex at pressure.to (Alex Fenton) Date: Wed, 22 Sep 2010 15:40:29 +0100 Subject: [wxruby-users] Using Wx::RichTextCtrl to generate PDF In-Reply-To: <62be5705a3f3a8daaac51864560d3e7f@ruby-forum.com> References: <62be5705a3f3a8daaac51864560d3e7f@ruby-forum.com> Message-ID: <4C9A155D.1080008@pressure.to> Hi On 22/09/2010 15:06, Tony Meier wrote: > I intend to use a RichTextCtrl so the user can edit parts of a PDF that > will be generated using Prawn. Any ideas on how to best render the > user-editable content into the PDF? > > I was thinking of parsing the XML output since I'm not sure if it's > possible to easily extend the RichTextFileHandler class from within > Ruby. Or is RichTextPrinting the proper way to start here? I think probably the XML route. There is a wxWidgets class to print to a postscript file on any platform, but I have never managed to port it to Ruby. I remember writing some code some time ago to parse wxRTC's XML in Ruby, but I don't have it to hand. I know a guy who uses wxPython who wrote a library for doing just that which might be a reference, since the XML language used by RTC isn't that well documented. http://osdir.com/ml/wxpython-users/2010-02/msg00042.html alex From alex at pressure.to Wed Sep 22 10:44:40 2010 From: alex at pressure.to (Alex Fenton) Date: Wed, 22 Sep 2010 15:44:40 +0100 Subject: [wxruby-users] some question In-Reply-To: References: Message-ID: <4C9A1658.5020208@pressure.to> hi hendra On 18/09/2010 03:09, hendra kusuma wrote: > 1. how do I close all opened child window in mdi form? Untested, but maybe something like while child = mdi_parent.active_child child.close end > 2. I cannot disable menu_item, perhaps I use .enable false the wrong way? MenuBar#enable(menu_item_id, false) hth alex From lists at ruby-forum.com Wed Sep 22 11:19:27 2010 From: lists at ruby-forum.com (Tony Meier) Date: Wed, 22 Sep 2010 17:19:27 +0200 Subject: [wxruby-users] Using Wx::RichTextCtrl to generate PDF In-Reply-To: <4C9A155D.1080008@pressure.to> References: <62be5705a3f3a8daaac51864560d3e7f@ruby-forum.com> <4C9A155D.1080008@pressure.to> Message-ID: <365ca02dd5bc7345730117cac90869a3@ruby-forum.com> Hi, > I think probably the XML route. > Thanks for the hint and the link to the wxpython project. Looks doable to me. So I'll go the XML way then. With my first spike attempts I'm getting strange results though. Here's my test class. Two things (a) I would expect it to write an XML file to my home dir, which it doesn't. Actually I would much rather like it to a string but my first attempt (file) fails already (b) I would expect it to copy the contents of the editor to the clipboard, which it doesn't => crashes with NoMethodError: undefined method ?begin? for # Any ideas what might be going wrong? Or maybe an idea of what's the best way to actually get the XML out of the control in order to parse it? I'm using wxruby 2.0.1, ruby 1.8.7p174 on OSX 10.6.4 Thanks so much, Tony --- #!/usr/bin/env arch -i386 ruby require 'rubygems' require "wx" include Wx class MyFrame < Wx::Frame def initialize super(nil, :title => "RichText Example", :pos => [150, 25], :size => [800, 500]) panel = Wx::Panel.new(self) #Parent = self = this Frame @editor = Wx::RichTextCtrl.new( panel, # parent ID_ANY, # ID "Initial text", # value [0, 20], # position [400, 400] #size ) boldbtn = Wx::Button.new(panel, ID_ANY, "bold", [0,0], [100,50]) dumpbtn = Wx::Button.new(panel, ID_ANY, "dump",[100,0], [100,50]) evt_button(boldbtn) { |evt| @editor.apply_bold_to_selection() } evt_button(dumpbtn) { |evt| buffer.save_file("/Users/tm/test.xml", Wx::RICHTEXT_TYPE_XML) @editor.select_all() range = @editor.get_selection_range() buffer = @editor.get_buffer() buffer.copy_to_clipboard(range) } show() end end class MinimalApp < Wx::App def on_init MyFrame.new end end MinimalApp.new.main_loop -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Wed Sep 22 11:33:37 2010 From: alex at pressure.to (Alex Fenton) Date: Wed, 22 Sep 2010 16:33:37 +0100 Subject: [wxruby-users] Using Wx::RichTextCtrl to generate PDF In-Reply-To: <365ca02dd5bc7345730117cac90869a3@ruby-forum.com> References: <62be5705a3f3a8daaac51864560d3e7f@ruby-forum.com> <4C9A155D.1080008@pressure.to> <365ca02dd5bc7345730117cac90869a3@ruby-forum.com> Message-ID: <4C9A21D1.5040702@pressure.to> On 22/09/2010 16:19, Tony Meier wrote: > So I'll go the XML way then. With my first spike attempts I'm getting > strange results though. Here's my test class. > > Two things > > (a) I would expect it to write an XML file to my home dir, which it > doesn't. Actually I would much rather like it to a string but my first > attempt (file) fails already > > (b) I would expect it to copy the contents of the editor to the > clipboard, which it doesn't => crashes with NoMethodError: undefined > method ?begin? for # > > Any ideas what might be going wrong? Or maybe an idea of what's the best > way to actually get the XML out of the control in order to parse it? This is from memory - I probably should have written it up when I was working with this a year or two ago - but I think you have to create an instance of Wx::RichTextXMLHandler http://wxruby.rubyforge.org/doc/richtextxmlhandler.html Then you can use handler.save_file(rich_text_ctrl.buffer, file_or_io) If you want as a string, use a StringIO as the second argument. hth alex From lists at ruby-forum.com Wed Sep 22 12:00:07 2010 From: lists at ruby-forum.com (Tony Meier) Date: Wed, 22 Sep 2010 18:00:07 +0200 Subject: [wxruby-users] Using Wx::RichTextCtrl to generate PDF In-Reply-To: <4C9A21D1.5040702@pressure.to> References: <62be5705a3f3a8daaac51864560d3e7f@ruby-forum.com> <4C9A155D.1080008@pressure.to> <365ca02dd5bc7345730117cac90869a3@ruby-forum.com> <4C9A21D1.5040702@pressure.to> Message-ID: <4e00ab3f7bbe00e1bfdd174a7873136d@ruby-forum.com> > hth it did. Thanks again! -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Sep 23 00:11:50 2010 From: lists at ruby-forum.com (Chase Wilson) Date: Thu, 23 Sep 2010 06:11:50 +0200 Subject: [wxruby-users] evt_media_loaded not working on vista/windows 7 Message-ID: For some reason the evt_media_loaded is not being triggered on my windows vista and windows 7 machines. I use this so that I can auto play audio, and as soon as it's loaded I can play. I also have a windows XP machine where it works just fine using the exact same code. Is there anything I can do to fix this, or is there any way around this? Right now I have it wait .5 seconds before trying to play the audio file. But it may take longer to load different files based on size, and also sometimes users play remote files on servers, so there may be a slow connection. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Sep 23 09:43:38 2010 From: lists at ruby-forum.com (Tony Meier) Date: Thu, 23 Sep 2010 15:43:38 +0200 Subject: [wxruby-users] wxRichTextCtrl not Working through wxFormBuilder In-Reply-To: <4C639F89.9040208@pressure.to> References: <4C639F89.9040208@pressure.to> Message-ID: <6df4ebfd69d17d2901c3c3e6c8bb6ffe@ruby-forum.com> > I wrote a convenience method to handle it properly. It's called like > this (assuming a TextCtrl mapped to the instance var @text_box) thanks, that worked fine for me, too. One thing to note is that, strangely, it doesn't work if the RTC is the only control in the sizer. So make sure that there is at least one more control in the same sizer with your edit control. Cheers, Tony -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Mon Sep 27 06:34:34 2010 From: lists at ruby-forum.com (Tony Meier) Date: Mon, 27 Sep 2010 12:34:34 +0200 Subject: [wxruby-users] Using Wx::RichTextCtrl to generate PDF In-Reply-To: <4e00ab3f7bbe00e1bfdd174a7873136d@ruby-forum.com> References: <62be5705a3f3a8daaac51864560d3e7f@ruby-forum.com> <4C9A155D.1080008@pressure.to> <365ca02dd5bc7345730117cac90869a3@ruby-forum.com> <4C9A21D1.5040702@pressure.to> <4e00ab3f7bbe00e1bfdd174a7873136d@ruby-forum.com> Message-ID: <34975fb428d9b564de6810be5f13df66@ruby-forum.com> Ah, one more thing. Sorry to bother with that. Exporting to XML works fine now, however, I'd like to depersist the content of the editor when it re-opens. The problem with that is, that the XML handler doesn't seem to import what it just exported. Here's my test case: def store_and_load buffer = @editor.get_buffer() handler = Wx::RichTextXMLHandler.new io = StringIO.new() handler.save_file(buffer, io) io.rewind() handler.load_file(buffer, io) end This gives me a dialog box with an XML parsing error 'no element found at line 1'. Dumping the XML, however, yields valid content. The error also persists if a) I remove the first line from the string 'io' or b) create a new handler (instead of rewinding the existing one) c) create a new StringIO class Any hint would be very much appreciated! Thanks so much, Tony --- dumped XML string: foobar -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Tue Sep 28 04:19:15 2010 From: alex at pressure.to (Alex Fenton) Date: Tue, 28 Sep 2010 09:19:15 +0100 Subject: [wxruby-users] Using Wx::RichTextCtrl to generate PDF In-Reply-To: <34975fb428d9b564de6810be5f13df66@ruby-forum.com> References: <62be5705a3f3a8daaac51864560d3e7f@ruby-forum.com> <4C9A155D.1080008@pressure.to> <365ca02dd5bc7345730117cac90869a3@ruby-forum.com> <4C9A21D1.5040702@pressure.to> <4e00ab3f7bbe00e1bfdd174a7873136d@ruby-forum.com> <34975fb428d9b564de6810be5f13df66@ruby-forum.com> Message-ID: <4CA1A503.2060604@pressure.to> Hi Tony On 27/09/10 11:34, Tony Meier wrote: > The problem with that is, that the XML handler doesn't seem to import > what it just exported. Here's my test case: > > def store_and_load > buffer = @editor.get_buffer() > handler = Wx::RichTextXMLHandler.new > io = StringIO.new() > handler.save_file(buffer, io) > io.rewind() > handler.load_file(buffer, io) > end > > This gives me a dialog box with an XML parsing error 'no element found > at line 1'. > Haven't run your code, but you might look into whether there's an XML Byte-Order Mark (BOM) either coming out or going in. Inspect the XML string byte-wise (it won't show up when dumped) and try either adding a BOM, if missing, or deleting it, if present. http://www.opentag.com/xfaq_enc.htm cheers alex From penguinroad at gmail.com Tue Sep 28 08:58:53 2010 From: penguinroad at gmail.com (hendra kusuma) Date: Tue, 28 Sep 2010 20:58:53 +0800 Subject: [wxruby-users] ask gridtablebase Message-ID: Dear all, I need help I intent to make a gridtablebase class to save my data temporary and display it on a grid Due to my assumption, if I create a gridtablebase object and connect it to a grid object, the grid should display what's in gridtablebase object here is part of the code, class Gridtablebase_ds < Wx::GridTableBase def initialize() super @data = [] @col_names = ['Col1', 'Col2'] @data << ['1', 'John'] @data << ['1', 'Doe'] end def get_value(row, col) (@data[row])[col] end def append_data(data=[]) @data << data end #some other code here end in my other class, I use Gridtablebase_ds as follow @ds = Detil_Gridtablebase_ds.new @grid.set_table @ds @grid.refresh until now it works fine, but then I tried to add data to Gridtablebase_ds object @ds.append_data ['3', 'McGyver'] but the grid doesn't change, and I can't find any clue to where the mistakes is What is wrong here, perhaps I miss something Thank you Regards Hendra -- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com From alex at pressure.to Tue Sep 28 09:09:11 2010 From: alex at pressure.to (Alex Fenton) Date: Tue, 28 Sep 2010 14:09:11 +0100 Subject: [wxruby-users] ask gridtablebase In-Reply-To: References: Message-ID: <4CA1E8F7.1050909@pressure.to> hi hendra On 28/09/2010 13:58, hendra kusuma wrote: > Due to my assumption, if I create a gridtablebase object and connect > it to a grid object, the grid should display what's in gridtablebase > object yes, but ... > until now it works fine, but then I tried to add data to Gridtablebase_ds object > > @ds.append_data ['3', 'McGyver'] > > but the grid doesn't change ... there is no automatic trigger to update the visual display when the underlying table changes. call @grid.refresh if you need to. best alex From lists at ruby-forum.com Wed Sep 29 09:06:59 2010 From: lists at ruby-forum.com (Tony Meier) Date: Wed, 29 Sep 2010 15:06:59 +0200 Subject: [wxruby-users] Using Wx::RichTextCtrl to generate PDF In-Reply-To: <4CA1A503.2060604@pressure.to> References: <62be5705a3f3a8daaac51864560d3e7f@ruby-forum.com> <4C9A155D.1080008@pressure.to> <365ca02dd5bc7345730117cac90869a3@ruby-forum.com> <4C9A21D1.5040702@pressure.to> <4e00ab3f7bbe00e1bfdd174a7873136d@ruby-forum.com> <34975fb428d9b564de6810be5f13df66@ruby-forum.com> <4CA1A503.2060604@pressure.to> Message-ID: Hi Alex, thanks for your reply. Looking at the output string with String#bytes.each {|b| p b.chr } it seems there is no BOM coming out of the RTC, the first byte is the opening angle bracket. Prepending a BOM doesn't change the observed behavior though. Here's my changed code: UTF8BOM = "\xef\xbb\xbf" def store_and_load buffer = @editor.get_buffer() handler = Wx::RichTextXMLHandler.new io = StringIO.new() handler.save_file(buffer, io) s = UTF8BOM + io.string io.string = s io.rewind() handler.load_file(buffer, io) # gives a warning dialog: "No element found on line 1" end FWIW, I can repro this on Win7 and OSX. Thanks again for your time, Tony Alex Fenton wrote: > Hi Tony > > On 27/09/10 11:34, Tony Meier wrote: >> end >> >> This gives me a dialog box with an XML parsing error 'no element found >> at line 1'. >> > > Haven't run your code, but you might look into whether there's an XML > Byte-Order Mark (BOM) either coming out or going in. Inspect the XML > string byte-wise (it won't show up when dumped) and try either adding a > BOM, if missing, or deleting it, if present. > > http://www.opentag.com/xfaq_enc.htm > > cheers > alex -- Posted via http://www.ruby-forum.com/. From penguinroad at gmail.com Wed Sep 29 11:48:13 2010 From: penguinroad at gmail.com (hendra kusuma) Date: Wed, 29 Sep 2010 23:48:13 +0800 Subject: [wxruby-users] framework, plan to release Message-ID: This past year I have been making a framework to speed up the creating process of gui application, especially database back end I am using wxruby and sequel the main thing that is my creation is a code generator to make something like frame :expand => true do flexgridsizer :cols => 2 do label :text => "Insert your name here" text :name => "txt_name" end end became a ruby code, complete with basic function such as txt_name_update() and txt_name_enter() I must say that I am already half way there I already cover most basic widget, frame and mdi window I even make scaffolding script to create a full functioning window from command line I'm stuck the code is ugly... very ugly, it consist of many unhealthy way to solve problem and It's almost beyond my ability to expand the functionality but I really wish this framework can go further, to be a much better one then it is now So I am planning to put it online, after a little cleaning on the code and hope that there will be people willing to help so we can improve this project and perhaps one day we will be able to see rails for desktop in action PS. moderator if this is not the right place to post this, I apologize -- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From penguinroad at gmail.com Wed Sep 29 11:41:15 2010 From: penguinroad at gmail.com (hendra kusuma) Date: Wed, 29 Sep 2010 23:41:15 +0800 Subject: [wxruby-users] ask gridtablebase In-Reply-To: <4CA1E8F7.1050909@pressure.to> References: <4CA1E8F7.1050909@pressure.to> Message-ID: On Tue, Sep 28, 2010 at 9:09 PM, Alex Fenton wrote: > hi hendra > > > On 28/09/2010 13:58, hendra kusuma wrote: > >> Due to my assumption, if I create a gridtablebase object and connect >> it to a grid object, the grid should display what's in gridtablebase >> object >> > > yes, but ... > > > until now it works fine, but then I tried to add data to Gridtablebase_ds >> object >> >> @ds.append_data ['3', 'McGyver'] >> >> but the grid doesn't change >> > > ... there is no automatic trigger to update the visual display when the > underlying table changes. call @grid.refresh if you need to. > Thanks Alex I already done that and it is not working well, I found the answer from archive email anyway back then somebody asked the same thing and the conclusion was wxgrid seems to copy the gridtablebase object. I guess there is no direct connection between gridtablebase object and the one wxgrid copy and due to my experiment, I can't even modify the object with get_table method something like wxgrid.get_table.add_data(['3', 'McGyver']) also does not work I think it was you who said that it is the behaviour of wxwidget, so it will stay like that. But perhaps I am wrong I end up making a datasource object to handle the situation and refresh the grid my remaking the gridtablebase object and re-set the grid table Thanks -- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: