From lists at ruby-forum.com Wed Dec 2 17:23:48 2009 From: lists at ruby-forum.com (Krzysiek Fe) Date: Wed, 2 Dec 2009 23:23:48 +0100 Subject: [wxruby-users] Logging window Message-ID: <1a663b22eee2874f60d96b948f8d53b8@ruby-forum.com> Hi all. As a part of my first wxRuby app I need to create a window (now I use Notebook tab to do this) where any event can be logged. I've tried with Grid. It has more than I want - columns and rows names. Can anyone how to remove them? I've seen example code at http://wxruby.rubyforge.org/svn/branches/wxruby_2_0_stable/samples/grid/gridtablebase.rb but I didn't noticed where it can be changed (get_col_label_value seems not enough, for me). WxRuby documentation more often fights with me, than cooperates. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Dec 2 17:37:29 2009 From: lists at ruby-forum.com (Gary Hasson) Date: Wed, 2 Dec 2009 23:37:29 +0100 Subject: [wxruby-users] wxRuby GUI textctrl not updating until end In-Reply-To: <1a4fbf3f055f382f01ae4cd4a974ab28@ruby-forum.com> References: <341cbaca604382ccdcb062990c197ead@ruby-forum.com> <1a4fbf3f055f382f01ae4cd4a974ab28@ruby-forum.com> Message-ID: <2a52e6f6360dd4b1455f05eff76ead67@ruby-forum.com> I have found that the recommended solution of placing cpu-intensive code inside a thead only works well for some applications. In particular, in my most recent application, placing the disk I/O intensive code within a thread made a one second operation take 75 seconds. And that was with a timer setting of only 2 ms. Regardless, this all seems backwards to me. My understanding of how this is working is that the thread is getting one pass each time the timer times out. What I really want is for the "intensive code" to get all of the available time, except that I want to "interupt" the intensive code every 100ms to update the GUI and check for GUI clicks, etc. In other words, the entire application, except for the intensive code, would need to be inside the thread that the timer is giving attention to. I'm not sure how to do that, or if that is the best approach. Present code outline: class Myframe < Wx::Frame def initialize normal stuff # Timer interrupt to service thread timer = Wx::Timer.new(self, Wx::ID_ANY) timer.start(2) evt_timer(timer.id) {Thread.pass} end def various other def's ... end def intensive_routine Thread.new do until done do thousands of disk accesses... @msgbox.write_text( "Display status for user..." ) ... end end end def on_init evt_button( @quit_btn ) { on_quit_btn_clicked } ... end end The above code is a greatly simplified representation of working code. When the code is run with the "Thread.new" commented out, the program completes quickly, but it does not update the GUI or pay attention to GUI mouse clicks until the intensive routine has completed. When run with the "Thread.new" uncommented, the GUI is responsive as desired, but the intensive routine is running at a snail's pace. I would appreciate guidance on this. Thanks, Gary -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Dec 2 22:17:12 2009 From: lists at ruby-forum.com (Peter Lane) Date: Thu, 3 Dec 2009 04:17:12 +0100 Subject: [wxruby-users] wxRuby GUI textctrl not updating until end In-Reply-To: <2a52e6f6360dd4b1455f05eff76ead67@ruby-forum.com> References: <341cbaca604382ccdcb062990c197ead@ruby-forum.com> <1a4fbf3f055f382f01ae4cd4a974ab28@ruby-forum.com> <2a52e6f6360dd4b1455f05eff76ead67@ruby-forum.com> Message-ID: <60af4983810853ceee47b21582221aff@ruby-forum.com> Gary Hasson wrote: > I have found that the recommended solution of placing cpu-intensive code > inside a thead only works well for some applications. > > In particular, in my most recent application, placing the disk I/O > intensive code within a thread made a one second operation take 75 > seconds. And that was with a timer setting of only 2 ms. Hi Gary, > Regardless, this all seems backwards to me. My understanding of how this > is working is that the thread is getting one pass each time the timer > times out. What I really want is for the "intensive code" to get all of > the available time, except that I want to "interrupt" the intensive code > every 100ms to update the GUI and check for GUI clicks, etc. I agree. I also don't have a good mental model of what is happening, as there is an interaction between the Ruby threads and the wx library. I wish I could say I understood this. The following is the result only of some experimentation, so please treat with caution! My belief is that things should happen as you describe. When using wxRuby, the code is using the GUI thread, which is why we must put the heavy computation in its own thread and use a Timer. The Timer is there so that the GUI thread wakes up every specified interval, updates the displays/responds to events, and then passes control back to the Thread. We have to make our own Timer (unlike with, for example, Java/Swing) because of the separation between Ruby and the wx library, but that's where it gets hazy for me. I don't think my previous example properly captured that separation, because a GUI update is being done in the computation Thread, and this perhaps makes the approach slow in your case. I experimented with my code from before, replacing the 'sleep' method with an intensive computation which returns partial results as it goes along. The best approach I could find, both in computing time and conceptually, was to move all the GUI updates into the Timer, and to reduce the calls to 'append_text' by aggregating the results. About this last point, adding 100_000 lines to the text control separately made the program 50 times slower than concatenating the same 100_000 lines and adding them to the text control in one go. My test code now looks like the following: class MyFrame < Wx::Frame def initialize super(nil, :title => "Heavy Computation Example") @text_field = Wx::TextCtrl.new(self, :style => Wx::TE_MULTILINE) button = Wx::Button.new(self, :label => "Show Values") evt_button(button) {print_value} main_sizer = Wx::BoxSizer.new Wx::VERTICAL main_sizer.add @text_field main_sizer.add button set_sizer main_sizer @results = [] # for collecting the results together # all the GUI updating is done here Wx::Timer.every(100) do # wake up every 100ms @text_field.append_text "#{@results.join("\n")}" # add text en bloc @results = [] # and clear results Thread.pass # return to calculation end end def print_value # all the computation is done here Thread.new do sum = 0 1.upto(N-1) do |i| sum += 1 if lots_of_work i # this is the 'busy computation' @results << sum # collect the result end end end end I quite like the final code. There's a conceptual separation of GUI update and computation: it's a traditional model-view separation. The GUI is updated only every 100ms, reporting every intermediate result, and the computation time(*) is indistinguishable from that of doing the calculation from a non-GUI Ruby program (although I've not tried anything taking longer than 10 seconds). Getting back to your application, my suggestion is to move the 'write_text' call out of the 'intensive_routine' and into the timer block. Then, reduce the number of calls to 'write_text' by collecting the update lines together, and join them to add in a single call to 'write_text'. Let me know if this is a better/worse solution for you. cheers, Peter. (*) Note, I did find execution times for the wxRuby program when the Thread was run a second or third time were dramatically quicker than the first run. I'm not sure why, or what to do about it. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Dec 4 14:33:51 2009 From: lists at ruby-forum.com (Seppo Sormunen) Date: Fri, 4 Dec 2009 20:33:51 +0100 Subject: [wxruby-users] static gem of wxruby 2.0.1 for OS X Snow Leopard In-Reply-To: <80d893c70911110552ye2c5e1ald5cec7b270ebd4b3@mail.gmail.com> References: <80d893c70911110552ye2c5e1ald5cec7b270ebd4b3@mail.gmail.com> Message-ID: <9092ec703cc81c78df64abe12210647b@ruby-forum.com> Antti Hakala wrote: > Hello, > I have a static gem of wxruby 2.0.1 that works on OS X Snow Leopard, > if somebody is interested. > I've tried it only on my own comp. It's about 9MB. T??ll? oltaisiin my?s kiinnostuneita tuosta! Ite aloittelemassa ruby koodailuja ja tuntuu silt? ett? wxRuby ois passeli GUIn v??nt??n. Lumilepardi vain sattuu hyrr??m??n t?ss? koodinv??nt?-masiinalla.. :) Eli jos voit laittaa maililla seppo.sormunen AT gmail.com kiits! -Jehvi.- -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Dec 4 16:15:25 2009 From: lists at ruby-forum.com (Gary Hasson) Date: Fri, 4 Dec 2009 22:15:25 +0100 Subject: [wxruby-users] wxRuby GUI textctrl not updating until end In-Reply-To: <60af4983810853ceee47b21582221aff@ruby-forum.com> References: <341cbaca604382ccdcb062990c197ead@ruby-forum.com> <1a4fbf3f055f382f01ae4cd4a974ab28@ruby-forum.com> <2a52e6f6360dd4b1455f05eff76ead67@ruby-forum.com> <60af4983810853ceee47b21582221aff@ruby-forum.com> Message-ID: <8d18a7c30e6e705c44b4aa58a1dae0e8@ruby-forum.com> Threads can be used to keep the GUI responsive during an I/O or CPU intensive operation, but I have now found what seems like a better way. The following command causes the GUI to be updated, with any pending GUI events being handled: Wx::THE_APP.yield() This is what I was looking for all along! No need for threads or timers. The "intensive routine" receives only a minor impact on its performance using this statement. Simplified example code outline: class Myframe < Wx::Frame def initialize normal stuff end def various other def's ... end # Very CPU intensive routine: def on_get_busy_btn_clicked update_rate = 1000 # Every 1000 iterations byte_number = 0 # Gets incremented on each iteration until done do thousands of disk accesses, and after each read: byte_number += 1 @msgbox.write_text( "Display status for user..." ) # Not on each iteration # Check GUI to see if it needs processing: Wx::THE_APP.yield() if byte_number%update_rate == 0 ... end end def on_init evt_button( @get_busy_btn ) { on_get_busy_btn_clicked } ... end end The above code is a greatly simplified representation of working code. The "intensive routine" gets nearly full CPU attention for quick processing. The occasional call to service the GUI keeps the GUI "alive" and responisve. The answer was in the WxRuby doc's under "miscellaneous, App", which brings up app.html. Regards, Gary -- Posted via http://www.ruby-forum.com/. From shs at demosophia.net Sat Dec 5 13:29:02 2009 From: shs at demosophia.net (Svend Haugaard =?UTF-8?B?U8O4cmVuc2Vu?=) Date: Sat, 5 Dec 2009 19:29:02 +0100 Subject: [wxruby-users] How to make a Grid reread the number of rows in a Table? Message-ID: <20091205192902.700bf752@cybert.demosophia.net> I have used GridTableBase to make and display a Table using a Grid. But if I add a new row to the Table the Grid will not display a new row. So if I start with 9 rows in the table and add a row, so there is 10 rows in the table. But the Grid will only display 9 rows. Is seems like the Grid don't reread the the numbers of rows from the Table. How can I force the Grid to reread the number of rows? From lists at ruby-forum.com Sat Dec 5 15:21:36 2009 From: lists at ruby-forum.com (Thomas Krampl) Date: Sat, 5 Dec 2009 21:21:36 +0100 Subject: [wxruby-users] Unable to use wxruby-ruby19 in Ruby 1.9.1-p129 on Windows In-Reply-To: <98714d1399262bf1ea2ef001bc763578@ruby-forum.com> References: <2a71bf63b4d6cad27b777ae11227122f@ruby-forum.com> <98714d1399262bf1ea2ef001bc763578@ruby-forum.com> Message-ID: Dit it now myself. And worked : ) -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Sun Dec 6 00:14:06 2009 From: alex at pressure.to (Alex Fenton) Date: Sun, 06 Dec 2009 05:14:06 +0000 Subject: [wxruby-users] How to make a Grid reread the number of rows in a Table? In-Reply-To: <20091205192902.700bf752@cybert.demosophia.net> References: <20091205192902.700bf752@cybert.demosophia.net> Message-ID: <4B1B3D9E.5070704@pressure.to> Svend Haugaard S?rensen wrote: > I have used GridTableBase to make and display a Table using a Grid. > > But if I add a new row to the Table the Grid will not display a new row. > > So if I start with 9 rows in the table and add a row, so there is > 10 rows in the table. But the Grid will only display 9 rows. > > Is seems like the Grid don't reread the the numbers of rows from > the Table. > > How can I force the Grid to reread the number of rows? grid.refresh(), I think alex From shs at demosophia.net Sun Dec 6 10:50:12 2009 From: shs at demosophia.net (Svend Haugaard =?UTF-8?B?U8O4cmVuc2Vu?=) Date: Sun, 6 Dec 2009 16:50:12 +0100 Subject: [wxruby-users] How to make a Grid reread the number of rows in a Table? In-Reply-To: <4B1B3D9E.5070704@pressure.to> References: <20091205192902.700bf752@cybert.demosophia.net> <4B1B3D9E.5070704@pressure.to> Message-ID: <20091206165012.37809f64@cybert.demosophia.net> On Sun, 06 Dec 2009 05:14:06 +0000 Alex Fenton wrote: > Svend Haugaard S?rensen wrote: > > I have used GridTableBase to make and display a Table using a Grid. > > > > But if I add a new row to the Table the Grid will not display a new > > row. > > > > So if I start with 9 rows in the table and add a row, so there is > > 10 rows in the table. But the Grid will only display 9 rows. > > > > Is seems like the Grid don't reread the the numbers of rows from > > the Table. > > > > How can I force the Grid to reread the number of rows? > > grid.refresh(), I think grid.refresh and grid.force_refresh only update the data in the cells but not the number of rows. > > alex > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users From lists at ruby-forum.com Sun Dec 6 13:17:45 2009 From: lists at ruby-forum.com (=?utf-8?Q?Marvin_G=c3=bclker?=) Date: Sun, 6 Dec 2009 19:17:45 +0100 Subject: [wxruby-users] ScreenDC doesn't draw text Message-ID: Hi, I'm doing some experiments with the ScreenDC class for on-screen drawing. Drawing shapes like a circle or rectangle works fine, but when I try to draw text onto the screen, nothing happens. I'm using the wxruby-ruby19 gem with ruby 1.9.1p243 (2009-07-16 revision 24175) [i686-linux] on an Ubuntu Karmic machine. My code looks like this (I know, it doesn't make much sense, but it's only to demonstrate the problem): ----------------------------------- #!/usr/bin/env ruby #Encoding: UTF-8 require "wx" class TestApp < Wx::App include Wx def on_init Timer.every(1000) do sc = ScreenDC.new sc.font = NORMAL_FONT #To ensure there's a font to draw with sc.draw_rectangle(0, 0, 100, 100) #This gets drawn... sc.draw_text("Test", 0, 150) #...but this doesn't end end end x = TestApp.new x.main_loop ----------------------------------- The rectangle is drawn without problems, but I can't find the text anywhere on my screen. Is this a bug? Marvin -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Mon Dec 7 13:23:59 2009 From: lists at ruby-forum.com (Timothy Palpant) Date: Mon, 7 Dec 2009 19:23:59 +0100 Subject: [wxruby-users] static gem of wxruby 2.0.1 for OS X Snow Leopard In-Reply-To: <80d893c70911110552ye2c5e1ald5cec7b270ebd4b3@mail.gmail.com> References: <80d893c70911110552ye2c5e1ald5cec7b270ebd4b3@mail.gmail.com> Message-ID: <4e31e493fc5ee81eeeff6f33f22886e3@ruby-forum.com> Antti Hakala wrote: > Hello, > I have a static gem of wxruby 2.0.1 that works on OS X Snow Leopard, > if somebody is interested. > I've tried it only on my own comp. It's about 9MB. I would greatly appreciate it if you could send the gem to me! timothypalpant AT gmail dot com Thanks, Tim Palpant -- Posted via http://www.ruby-forum.com/. From penguinroad at gmail.com Tue Dec 8 21:51:04 2009 From: penguinroad at gmail.com (hendra kusuma) Date: Wed, 9 Dec 2009 09:51:04 +0700 Subject: [wxruby-users] textbox for numeric Message-ID: <26dadb3d0912081851k18d4ae33k15d8e2a57d11c7e2@mail.gmail.com> Dear all Is there a good way to make a textbox that receive numeric only? something that limit the key it respond to or give sign (like red background or something) if the input is not numeric I wonder if validator can be used for that purpose an example would be very good :) btw is there a datepicker on windows? Thank you Regards Hendra -- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From plusgforce at gmail.com Fri Dec 11 03:35:49 2009 From: plusgforce at gmail.com (Philip Stephens) Date: Fri, 11 Dec 2009 02:35:49 -0600 Subject: [wxruby-users] 3 variables change after 1 'set' is called Message-ID: <536e2d6f0912110035o6cf2709u5037cab1e0e30e39@mail.gmail.com> require 'wx' # col_sample2.rb # this sets up the colour constants to be used in this program BLACK = Wx::Colour.new(0, 0, 0) RED = Wx::Colour.new(128, 0, 0) class Symbol_Class =begin This class will hold the variables and procedure necessary to change a symbol in a series of steps from a background colour to a foreground colour. For example: using black as the background colour and red as the foreground colour, the symbol colour will start out as the background colour and become the foreground colour in 128 steps. =end def initialize @background_colour = BLACK @symbol_colour = BLACK @foreground_colour = RED @delta_red = 0.0 @delta_green = 0.0 @delta_blue = 0.0 @float_red = 0.0 @float_green = 0.0 @float_blue = 0.0 @symbol_value = "@" end def set_symbol(bg_colour, fg_colour) if(bg_colour != @background_colour) then @background_colour = bg_colour end if(fg_colour != @foreground_colour) then @foreground_colour = fg_colour end @symbol_colour = @background_colour tempBC = @background_colour tempFC = @foreground_colour compute_delta_colours(tempBC, tempFC) update_forward_colours end def update_forward_colours =begin This routine has behaviour which I do not understand. When executed the symbol colour changes using the @symbol_colour.set routine. Unfortunately, both the background colour and temp colour change even though only one set command was executed. =end puts "ufc1: @background_colour #{@background_colour}" puts "ufc1: @symbol_colour #{@symbol_colour}" @float_red = (@float_red + @delta_red) @float_green = (@float_green + @delta_green) @float_blue = (@float_blue + @delta_blue) temp_colour = @background_colour puts "ufc2: @background_colour #{@background_colour}" puts "ufc2: @symbol_colour #{@symbol_colour}" puts "ufc2: temp_colour #{temp_colour}" @symbol_colour.set((@float_red + 0.5).to_i, (@float_green + 0.5).to_i, (@float_blue + 0.5).to_i) =begin Only the symbol_colour should change. Not the temp_colour nor the background colour however, all three change as shown in the 'puts' statements. =end puts "ufc3: temp_colour #{temp_colour}" puts "ufc3: @background_colour #{@background_colour}" puts "ufc3: @symbol_colour #{@symbol_colour}" end def compute_delta_colours(start_colour, end_colour) @delta_red = (end_colour.red - start_colour.red) / 128.0 @delta_green = 0.0 @delta_blue = 0.0 @float_red = @symbol_colour.red + 0.0 @float_green = @symbol_colour.green + 0.0 @float_blue = @symbol_colour.blue + 0.0 end end =begin output from program using ruby1.9 ufc1: @background_colour # ufc1: @symbol_colour # ufc2: @background_colour # ufc2: @symbol_colour # ufc2: temp_colour # ufc3: temp_colour # ufc3: @background_colour # ufc3: @symbol_colour # =end class MyApp < Wx::App @end_app = 0 def on_init @symbol = Symbol_Class.new bg = BLACK fg = RED @symbol.set_symbol(bg, fg) end end # class app = MyApp.new app.main_loop -------------- next part -------------- An HTML attachment was scrubbed... URL: From penguinroad at gmail.com Fri Dec 11 04:03:07 2009 From: penguinroad at gmail.com (hendra kusuma) Date: Fri, 11 Dec 2009 16:03:07 +0700 Subject: [wxruby-users] textbox for numeric In-Reply-To: <26dadb3d0912081851k18d4ae33k15d8e2a57d11c7e2@mail.gmail.com> References: <26dadb3d0912081851k18d4ae33k15d8e2a57d11c7e2@mail.gmail.com> Message-ID: <26dadb3d0912110103x69ac0704v9f22669fb26f1ab7@mail.gmail.com> No reply after 2 days? thats rare I would like to believe that some of you guys should already did this before and I expect to get some suggestion of course I can simply add value_change event and check if corresponding value is numeric or not but perhaps some of you guys have better ideas? On Wed, Dec 9, 2009 at 9:51 AM, hendra kusuma wrote: > Dear all > > Is there a good way to make a textbox that receive numeric only? > something that limit the key it respond to > or give sign (like red background or something) if the input is not > numeric > > I wonder if validator can be used for that purpose > > an example would be very good :) > > btw > is there a datepicker on windows? > > Thank you > Regards > Hendra > -- > Suka linux? > Kunjungi blog saya http://penguinroad.blogspot.com > -- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From penguinroad at gmail.com Fri Dec 11 04:19:32 2009 From: penguinroad at gmail.com (hendra kusuma) Date: Fri, 11 Dec 2009 16:19:32 +0700 Subject: [wxruby-users] making framework, need suggestion Message-ID: <26dadb3d0912110119p16947223o7ecc76f383d66dc5@mail.gmail.com> Dear all, right now I am in the middle of my personal project it is some kind of rails but for wx... well, not similar exactly for now, I simply call it fastwx (the name explain what we want to get) here is my plan I create some simple script that define the interface in simple way like :frame :panel :sizer:columns=2 name:label name:text birth:label birth:date :endsizer :endpanel :endframe then I run some script to generate it into xrc file after that another script to generate ruby file (i name it "meta" file) that load the xrc file then another script to generate view class (inheritance of "meta" class) which filled with function to define the widget and finally a script that generate a controller class (inheritance of view class) which filled with most used function of every widget therefore I some need suggestion regarding: 1. what did people usually do when they initialize their widget, you know, something like create_grid 2. what is a widget most used function? Please send your suggestion for it will help the development. right now I am still developing the controller class generator and I plan to release it as soon as the basic function of the controller done so we can add more feature to it anyway, I do not plan to add any model to the framework because in my early test, active record can work with this... perhaps and forgive me about using xrc file, my knowledge of wx is just not enough for me to directly generate the meta file as ruby script perhaps later we can fix this Thanks Regards Hendra -- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From fabio.petrucci at gmail.com Fri Dec 11 08:31:16 2009 From: fabio.petrucci at gmail.com (Fabio Petrucci) Date: Fri, 11 Dec 2009 14:31:16 +0100 Subject: [wxruby-users] textbox for numeric In-Reply-To: <26dadb3d0912110103x69ac0704v9f22669fb26f1ab7@mail.gmail.com> References: <26dadb3d0912081851k18d4ae33k15d8e2a57d11c7e2@mail.gmail.com> <26dadb3d0912110103x69ac0704v9f22669fb26f1ab7@mail.gmail.com> Message-ID: Set the textfied validator to this: your_text_field.validator = Wx::TextValidator.new(Wx::FILTER_NUMERIC) cheers. bio. On Fri, Dec 11, 2009 at 10:03 AM, hendra kusuma wrote: > No reply after 2 days? > thats rare > > I would like to believe that some of you guys should > already did this before > and I expect to get some suggestion > > of course I can simply add value_change event > and check if corresponding value is numeric or not > but perhaps some of you guys have better ideas? > > > On Wed, Dec 9, 2009 at 9:51 AM, hendra kusuma wrote: > >> Dear all >> >> Is there a good way to make a textbox that receive numeric only? >> something that limit the key it respond to >> or give sign (like red background or something) if the input is not >> numeric >> >> I wonder if validator can be used for that purpose >> >> an example would be very good :) >> >> btw >> is there a datepicker on windows? >> >> Thank you >> Regards >> Hendra >> -- >> Suka linux? >> Kunjungi blog saya http://penguinroad.blogspot.com >> > > > > -- > 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 shs at demosophia.net Fri Dec 11 16:08:30 2009 From: shs at demosophia.net (Svend Haugaard =?UTF-8?B?U8O4cmVuc2Vu?=) Date: Fri, 11 Dec 2009 22:08:30 +0100 Subject: [wxruby-users] How to make a Grid reread the number of rows in a Table? In-Reply-To: <20091206165012.37809f64@cybert.demosophia.net> References: <20091205192902.700bf752@cybert.demosophia.net> <4B1B3D9E.5070704@pressure.to> <20091206165012.37809f64@cybert.demosophia.net> Message-ID: <20091211220830.1592f1c7@cybert.demosophia.net> On Sun, 6 Dec 2009 16:50:12 +0100 Svend Haugaard S?rensen wrote: > On Sun, 06 Dec 2009 05:14:06 +0000 > Alex Fenton wrote: > > > Svend Haugaard S?rensen wrote: > > > I have used GridTableBase to make and display a Table using a > > > Grid. > > > > > > But if I add a new row to the Table the Grid will not display a > > > new row. Okay I solved it by dropping the table and making a subclass of Grid. And then using 'append_rows' and 'delete_rows' from the Grid class. It seems like 'set_table' in Grid makes a clone of the table, and thereby make it impossible to manipulate the table directly. Thanks for the help. From shs at demosophia.net Fri Dec 11 17:22:41 2009 From: shs at demosophia.net (Svend Haugaard =?UTF-8?B?U8O4cmVuc2Vu?=) Date: Fri, 11 Dec 2009 23:22:41 +0100 Subject: [wxruby-users] Closing event on a Notebook page. Message-ID: <20091211232241.68ff6ea8@cybert.demosophia.net> How do I catch a closing event for a Notebook page. I have added a number of pages (class Panel) to a Notebook and I can remove them via the default close button on the pane. But I what to run some code before the page(Panel) is closed, so I assumed that it gets a 'evt_close', but that seems not to be the case. How do I get to run some code before the page(Panel) closes? From penguinroad at gmail.com Fri Dec 11 20:59:22 2009 From: penguinroad at gmail.com (hendra kusuma) Date: Sat, 12 Dec 2009 08:59:22 +0700 Subject: [wxruby-users] textbox for numeric In-Reply-To: References: <26dadb3d0912081851k18d4ae33k15d8e2a57d11c7e2@mail.gmail.com> <26dadb3d0912110103x69ac0704v9f22669fb26f1ab7@mail.gmail.com> Message-ID: <26dadb3d0912111759s3cde0eecre8cdabb4c9a1be88@mail.gmail.com> Thanks, I'll try it On Fri, Dec 11, 2009 at 8:31 PM, Fabio Petrucci wrote: > Set the textfied validator to this: > > your_text_field.validator = Wx::TextValidator.new(Wx::FILTER_NUMERIC) > > cheers. > > bio. > > > On Fri, Dec 11, 2009 at 10:03 AM, hendra kusuma wrote: > >> No reply after 2 days? >> thats rare >> >> I would like to believe that some of you guys should >> already did this before >> and I expect to get some suggestion >> >> of course I can simply add value_change event >> and check if corresponding value is numeric or not >> but perhaps some of you guys have better ideas? >> >> >> On Wed, Dec 9, 2009 at 9:51 AM, hendra kusuma wrote: >> >>> Dear all >>> >>> Is there a good way to make a textbox that receive numeric only? >>> something that limit the key it respond to >>> or give sign (like red background or something) if the input is not >>> numeric >>> >>> I wonder if validator can be used for that purpose >>> >>> an example would be very good :) >>> >>> btw >>> is there a datepicker on windows? >>> >>> Thank you >>> Regards >>> Hendra >>> -- >>> Suka linux? >>> Kunjungi blog saya http://penguinroad.blogspot.com >>> >> >> >> >> -- >> 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 plusgforce at gmail.com Fri Dec 11 23:01:47 2009 From: plusgforce at gmail.com (Philip Stephens) Date: Fri, 11 Dec 2009 22:01:47 -0600 Subject: [wxruby-users] minimal Wx_Colour bug ? Message-ID: <536e2d6f0912112001o4aaad029j62b3cfd805d17384@mail.gmail.com> require 'wx' # col_sample4.rb BLACK = Wx::Colour.new(0,0,0) RED = Wx::Colour.new(128,0,0) @background_colour = BLACK @symbol_colour = BLACK temp_colour = BLACK temp2_colour = RED @symbol_colour = Wx::Colour.set(1, 0, 0) puts "@background_colour : #{@background_colour}" puts "@symbol_colour : #{@symbol_colour}" puts "temp_colour : #{temp_colour}" puts "temp2_colour : #{temp2_colour}" =begin Hypothetical Values: @background_colour : # @symbol_colour : # temp_colour : # temp2_colour : # Actual Values: @background_colour : # @symbol_colour : # temp_colour : # temp2_colour : # What's going on here and how do I correct this problem? =end -------------- next part -------------- An HTML attachment was scrubbed... URL: From plusgforce at gmail.com Fri Dec 11 23:32:05 2009 From: plusgforce at gmail.com (Philip Stephens) Date: Fri, 11 Dec 2009 22:32:05 -0600 Subject: [wxruby-users] minimal Wx_Colour bug ? In-Reply-To: <536e2d6f0912112001o4aaad029j62b3cfd805d17384@mail.gmail.com> References: <536e2d6f0912112001o4aaad029j62b3cfd805d17384@mail.gmail.com> Message-ID: <536e2d6f0912112032qdde18f1o466730c31e8da5d3@mail.gmail.com> The fix: @symbol_colour = Wx::Colour.new(1, 0, 0) instead of @symbol_colour.set(1, 0, 0) works but it doesn't it waste resources? Does someone have a better soloution? Thanks. On Fri, Dec 11, 2009 at 10:01 PM, Philip Stephens wrote: > require 'wx' > > # col_sample4.rb > > BLACK = Wx::Colour.new(0,0,0) > RED = Wx::Colour.new(128,0,0) > > @background_colour = BLACK > @symbol_colour = BLACK > temp_colour = BLACK > temp2_colour = RED > > @symbol_colour = Wx::Colour.set(1, 0, 0) > > puts "@background_colour : #{@background_colour}" > puts "@symbol_colour : #{@symbol_colour}" > puts "temp_colour : #{temp_colour}" > puts "temp2_colour : #{temp2_colour}" > > =begin > > Hypothetical Values: > > @background_colour : # > @symbol_colour : # > temp_colour : # > temp2_colour : # > > Actual Values: > > @background_colour : # > @symbol_colour : # > temp_colour : # > temp2_colour : # > > What's going on here and how do I correct this problem? > > =end > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From penguinroad at gmail.com Sat Dec 12 01:36:26 2009 From: penguinroad at gmail.com (hendra kusuma) Date: Sat, 12 Dec 2009 13:36:26 +0700 Subject: [wxruby-users] textbox for numeric In-Reply-To: <26dadb3d0912111759s3cde0eecre8cdabb4c9a1be88@mail.gmail.com> References: <26dadb3d0912081851k18d4ae33k15d8e2a57d11c7e2@mail.gmail.com> <26dadb3d0912110103x69ac0704v9f22669fb26f1ab7@mail.gmail.com> <26dadb3d0912111759s3cde0eecre8cdabb4c9a1be88@mail.gmail.com> Message-ID: <26dadb3d0912112236p3eb9397cy832ceb8ab8f50210@mail.gmail.com> Bad idea with this validator I can type 954.564.546..123eee23 that would not be valid number, right? On Sat, Dec 12, 2009 at 8:59 AM, hendra kusuma wrote: > Thanks, I'll try it > > > On Fri, Dec 11, 2009 at 8:31 PM, Fabio Petrucci wrote: > >> Set the textfied validator to this: >> >> your_text_field.validator = Wx::TextValidator.new(Wx::FILTER_NUMERIC) >> >> cheers. >> >> bio. >> >> >> On Fri, Dec 11, 2009 at 10:03 AM, hendra kusuma wrote: >> >>> No reply after 2 days? >>> thats rare >>> >>> I would like to believe that some of you guys should >>> already did this before >>> and I expect to get some suggestion >>> >>> of course I can simply add value_change event >>> and check if corresponding value is numeric or not >>> but perhaps some of you guys have better ideas? >>> >>> >>> On Wed, Dec 9, 2009 at 9:51 AM, hendra kusuma wrote: >>> >>>> Dear all >>>> >>>> Is there a good way to make a textbox that receive numeric only? >>>> something that limit the key it respond to >>>> or give sign (like red background or something) if the input is not >>>> numeric >>>> >>>> I wonder if validator can be used for that purpose >>>> >>>> an example would be very good :) >>>> >>>> btw >>>> is there a datepicker on windows? >>>> >>>> Thank you >>>> Regards >>>> Hendra >>>> -- >>>> Suka linux? >>>> Kunjungi blog saya http://penguinroad.blogspot.com >>>> >>> >>> >>> >>> -- >>> 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 > -- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From bureaux.sebastien at neuf.fr Sat Dec 12 04:03:06 2009 From: bureaux.sebastien at neuf.fr (Seb) Date: Sat, 12 Dec 2009 10:03:06 +0100 Subject: [wxruby-users] grid et boxsizer Message-ID: <4B235C4A.3040003@neuf.fr> Bonjour. Une fois mon application ouverte, je voudrais savoir, si cela est possible, comment dimensionner automatiquement la totalit? des colonnes du grid ? la taille de mon boxsizer, quand je change la taille de mon application? (puique mon grid est ins?r? dans mon boxsizer). merci From alex at pressure.to Sun Dec 13 10:40:37 2009 From: alex at pressure.to (Alex Fenton) Date: Sun, 13 Dec 2009 15:40:37 +0000 Subject: [wxruby-users] minimal Wx_Colour bug ? In-Reply-To: <536e2d6f0912112001o4aaad029j62b3cfd805d17384@mail.gmail.com> References: <536e2d6f0912112001o4aaad029j62b3cfd805d17384@mail.gmail.com> Message-ID: <4B250AF5.70908@pressure.to> Hi Philip What's happening is that you have multiple variables referring to the same object. When you change the object, all references change: Philip Stephens wrote: > # col_sample4.rb > > BLACK = Wx::Colour.new(0,0,0) A new object is created; the constant BLACK refers to this object > @background_colour = BLACK The instance variable @background_colour now also refers to this same object. > @symbol_colour = BLACK Now so does the variable @symbol_colour > @symbol_colour = Wx::Colour.set(1, 0, 0) Change the colour intensities of the (single) colour object. So all references to it will reflect the change. If you want to create an independent copy of a colour from a colour, use the constructor: my_black = Wx::Colour.new(Wx::BLACK) Wx::BLACK == my_black # true my_black.set(127, 127, 127) Wx::BLACK == my_black # false Don't worry too much about resource control with colours, they will get cleaned up automatically when they fall out of scope, and they are more light-weight objects than say Pens and Brushes. Sometimes I find it useful to declare a palette as a set of constants in a class. class MyDrawingThing SYMBOL_COLOUR = Wx::Colour.new(127,127,127) HIGHLIGHT_COLOUR = Wx::Colour.new(Wx::RED) etc hth a From chouti at gmail.com Mon Dec 14 02:45:10 2009 From: chouti at gmail.com (=?UTF-8?B?Q2hlbkppZXzmir3lsYk=?=) Date: Mon, 14 Dec 2009 15:45:10 +0800 Subject: [wxruby-users] How to get the debug information of wxRuby scripts Message-ID: Hello All I'm a newbie for wxRuby. I've tried wxRuby to make some of my little utilities. But, when I'm learning by doing...I've got one question. I have one piece of wxruby script. And after run this scripts, a "Microsoft Visual C++ Runtime error" with my ruby.exe My question would be how to get the information about this error? I've created a dump file for my ruby.exe and analyze with Windbg, but sorry I still can't recognize my error correctly :-( Can I output some kinds of log files make it easier? Please forgive me if this question was asked time and time again in the mail list :-( -------------- next part -------------- An HTML attachment was scrubbed... URL: From penguinroad at gmail.com Mon Dec 14 03:28:43 2009 From: penguinroad at gmail.com (hendra kusuma) Date: Mon, 14 Dec 2009 15:28:43 +0700 Subject: [wxruby-users] is it possible to get widget from it's id Message-ID: <26dadb3d0912140028o3ab66dfh61875b31f6aac02@mail.gmail.com> Dear all, is it possible to get widget from its id? to be clear, what I intent to do is something like below def widget_by_id_do_something(widget_id) widget(widget_id).do_something end -- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex at pressure.to Mon Dec 14 14:14:42 2009 From: alex at pressure.to (Alex Fenton) Date: Mon, 14 Dec 2009 19:14:42 +0000 Subject: [wxruby-users] is it possible to get widget from it's id In-Reply-To: <26dadb3d0912140028o3ab66dfh61875b31f6aac02@mail.gmail.com> References: <26dadb3d0912140028o3ab66dfh61875b31f6aac02@mail.gmail.com> Message-ID: <4B268EA2.8010506@pressure.to> hi hendra kusuma wrote: > is it possible to get widget from its id? Yes, Wx:Window.find_by_id http://wxruby.rubyforge.org/doc/window.html#Window_findwindowbyid It's documented as an instance method, but I think it's a class method: win = Wx::Window.find_by_id(ID_FOO) alex From lists at ruby-forum.com Mon Dec 14 14:48:06 2009 From: lists at ruby-forum.com (=?utf-8?Q?Marvin_G=c3=bclker?=) Date: Mon, 14 Dec 2009 20:48:06 +0100 Subject: [wxruby-users] ScreenDC doesn't draw text In-Reply-To: References: Message-ID: <6418915d49d444f73fefca783c8816fe@ruby-forum.com> Marvin G?lker wrote: > The rectangle is drawn without problems, but I can't find the text > anywhere on my screen. > > Is this a bug? > > Marvin Nobody experiencing the same problem? However, I've filed that as a bug now: http://rubyforge.org/tracker/index.php?func=detail&aid=27564&group_id=35&atid=218 Marvin -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Mon Dec 14 15:50:37 2009 From: alex at pressure.to (Alex Fenton) Date: Mon, 14 Dec 2009 20:50:37 +0000 Subject: [wxruby-users] How to get the debug information of wxRuby scripts In-Reply-To: References: Message-ID: <4B26A51D.20304@pressure.to> hi ChenJie|?? wrote: > I'm a newbie for wxRuby. I've tried wxRuby to make some of my little > utilities. Welcome! > I have one piece of wxruby script. And after run this scripts, a > "Microsoft Visual C++ Runtime error" with my ruby.exe > > My question would be how to get the information about this error? > > I've created a dump file for my ruby.exe and analyze with Windbg, but > sorry I still can't recognize my error correctly :-( Unfortunately Windbg won't help very much with the distributed gems, as the C++ debugging information is stripped out - otherwise the gem would be very large. > Can I output some kinds of log files make it easier? There are log functions in a class called Wx::Log, which can catch some errors if you set it to Log Level - DEBUG. But this might not help if you're getting a straight crash. You may want to compile a debug build of wxRuby - which needs some familiarity with compilers - but I guess you may have this is if you know about Windbg. Otherwise you just need to pin down where the error is occurring. Using Ruby's set_trace_func is one way, or ruby debugger to step through the code. But this can be slow. Or just judicious use of 'puts' to check what line is crashing. If you have a good idea what method etc the error is occuring in, please do post it on the list. alex From alex at pressure.to Mon Dec 14 15:56:49 2009 From: alex at pressure.to (Alex Fenton) Date: Mon, 14 Dec 2009 20:56:49 +0000 Subject: [wxruby-users] textbox for numeric In-Reply-To: <26dadb3d0912112236p3eb9397cy832ceb8ab8f50210@mail.gmail.com> References: <26dadb3d0912081851k18d4ae33k15d8e2a57d11c7e2@mail.gmail.com> <26dadb3d0912110103x69ac0704v9f22669fb26f1ab7@mail.gmail.com> <26dadb3d0912111759s3cde0eecre8cdabb4c9a1be88@mail.gmail.com> <26dadb3d0912112236p3eb9397cy832ceb8ab8f50210@mail.gmail.com> Message-ID: <4B26A691.8000407@pressure.to> hendra kusuma wrote: > Bad idea > with this validator > I can type 954.564.546..123eee23 > that would not be valid number, right? I think the validators only work by filtering characters - all of those characters (including e, for scientific notation) are potentially part of a valid number. But it won't test if the whole string is a valid number. If you need that level of sophisticated filtering, you could add an event handler to the textctrl which checks in Ruby that the string can be validly converted to a number. Something like (untested) evt_text(my_textctrl) do | e | begin num = Float(my_textctrl.value) rescue ArgumentError puts 'sorry that's a valid string' end end a From alex at pressure.to Mon Dec 14 16:02:05 2009 From: alex at pressure.to (Alex Fenton) Date: Mon, 14 Dec 2009 21:02:05 +0000 Subject: [wxruby-users] Closing event on a Notebook page. In-Reply-To: <20091211232241.68ff6ea8@cybert.demosophia.net> References: <20091211232241.68ff6ea8@cybert.demosophia.net> Message-ID: <4B26A7CD.2080508@pressure.to> Svend Haugaard S?rensen wrote: > I have added a number of pages (class Panel) to a Notebook and I > can remove them via the default close button on the pane. > But I what to run some code before the page(Panel) is closed, > so I assumed that it gets a 'evt_close', but that seems not to be > the case. > > How do I get to run some code before the page(Panel) closes? As far as I know, individual pages within the standard Wx::Notebook can't be closed via the user interface, only programmatically. There aren't individual 'close' buttons on each pane for the user to do this. If you're using Wx::AuiNotebook for this, which does have IDE-like tabs with their own close buttons, then there is an event specifically for this, something like evt_auibook_page_closing - have a look at the aui sample to check the name. a From lists at ruby-forum.com Mon Dec 14 19:27:54 2009 From: lists at ruby-forum.com (Jason Sandfield) Date: Tue, 15 Dec 2009 01:27:54 +0100 Subject: [wxruby-users] static gem of wxruby 2.0.1 for OS X Snow Leopard In-Reply-To: <80d893c70911110552ye2c5e1ald5cec7b270ebd4b3@mail.gmail.com> References: <80d893c70911110552ye2c5e1ald5cec7b270ebd4b3@mail.gmail.com> Message-ID: Can you send me the gem? Thanks! jason.sandfield AT gmail.com Thanks, Jason Antti Hakala wrote: > Hello, > I have a static gem of wxruby 2.0.1 that works on OS X Snow Leopard, > if somebody is interested. > I've tried it only on my own comp. It's about 9MB. -- Posted via http://www.ruby-forum.com/. From shs at demosophia.net Mon Dec 14 22:28:59 2009 From: shs at demosophia.net (Svend Haugaard =?UTF-8?B?U8O4cmVuc2Vu?=) Date: Tue, 15 Dec 2009 04:28:59 +0100 Subject: [wxruby-users] Closing event on a Notebook page. In-Reply-To: <4B26A7CD.2080508@pressure.to> References: <20091211232241.68ff6ea8@cybert.demosophia.net> <4B26A7CD.2080508@pressure.to> Message-ID: <20091215042859.5bc5ef06@cybert.demosophia.net> On Mon, 14 Dec 2009 21:02:05 +0000 Alex Fenton wrote: > Svend Haugaard S?rensen wrote: > > I have added a number of pages (class Panel) to a Notebook and I > > can remove them via the default close button on the pane. > > But I what to run some code before the page(Panel) is closed, > > so I assumed that it gets a 'evt_close', but that seems not to be > > the case. > > > > How do I get to run some code before the page(Panel) closes? > > As far as I know, individual pages within the standard Wx::Notebook > can't be closed via the user interface, only programmatically. There > aren't individual 'close' buttons on each pane for the user to do > this. > > If you're using Wx::AuiNotebook for this, which does have IDE-like > tabs with their own close buttons, then there is an event > specifically for this, something like evt_auibook_page_closing - have > a look at the aui sample to check the name. Ahh, I didn't know the where 2 different NoteBooks classes, that explain my problems. Thanks for the help. From penguinroad at gmail.com Mon Dec 14 23:48:00 2009 From: penguinroad at gmail.com (hendra kusuma) Date: Tue, 15 Dec 2009 11:48:00 +0700 Subject: [wxruby-users] textbox for numeric In-Reply-To: <4B26A691.8000407@pressure.to> References: <26dadb3d0912081851k18d4ae33k15d8e2a57d11c7e2@mail.gmail.com> <26dadb3d0912110103x69ac0704v9f22669fb26f1ab7@mail.gmail.com> <26dadb3d0912111759s3cde0eecre8cdabb4c9a1be88@mail.gmail.com> <26dadb3d0912112236p3eb9397cy832ceb8ab8f50210@mail.gmail.com> <4B26A691.8000407@pressure.to> Message-ID: <26dadb3d0912142048l139bb56eq9764b6ecab499d6c@mail.gmail.com> On Tue, Dec 15, 2009 at 3:56 AM, Alex Fenton wrote: > hendra kusuma wrote: > >> Bad idea >> with this validator I can type 954.564.546..123eee23 >> that would not be valid number, right? >> > > I think the validators only work by filtering characters - all of those > characters (including e, for scientific notation) are potentially part of a > valid number. But it won't test if the whole string is a valid number. > > If you need that level of sophisticated filtering, you could add an event > handler to the textctrl which checks in Ruby that the string can be validly > converted to a number. Something like (untested) > > evt_text(my_textctrl) do | e | > begin > num = Float(my_textctrl.value) > rescue ArgumentError > puts 'sorry that's a valid string' > end > end > > Yes, this is exactly what I think at first I just want to know if there is a build in library for that purpose Thanks anyway -- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From penguinroad at gmail.com Mon Dec 14 23:48:51 2009 From: penguinroad at gmail.com (hendra kusuma) Date: Tue, 15 Dec 2009 11:48:51 +0700 Subject: [wxruby-users] is it possible to get widget from it's id In-Reply-To: <4B268EA2.8010506@pressure.to> References: <26dadb3d0912140028o3ab66dfh61875b31f6aac02@mail.gmail.com> <4B268EA2.8010506@pressure.to> Message-ID: <26dadb3d0912142048n5e8274e9w552c54da325389f@mail.gmail.com> On Tue, Dec 15, 2009 at 2:14 AM, Alex Fenton wrote: > hi > > > hendra kusuma wrote: > > is it possible to get widget from its id? >> > > Yes, Wx:Window.find_by_id > > http://wxruby.rubyforge.org/doc/window.html#Window_findwindowbyid > > It's documented as an instance method, but I think it's a class method: > > win = Wx::Window.find_by_id(ID_FOO) > > alex > > Whoa, cool Thanks man -- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From penguinroad at gmail.com Tue Dec 15 00:48:54 2009 From: penguinroad at gmail.com (hendra kusuma) Date: Tue, 15 Dec 2009 12:48:54 +0700 Subject: [wxruby-users] menu event handler problem Message-ID: <26dadb3d0912142148q1f9aeeadhc176ebf57b7188ab@mail.gmail.com> Guys, I make a form with xrc file help I load, use lambda to get all my widgets, then set event handler somehow, it does not work well with menu with no clear sign of what the mistake is is there something I miss? here is the code require 'rubygems' require 'wx' require 'pathname' include Wx class MyForm < Wx::Frame def initialize(parent=nil) super() xrc_file = 'file.xrc' xml = Wx::XmlResource.get xml.flags = 2 xml.init_all_handlers xml.load(xrc_file) xml.load_frame_subclass(self, parent, 'my_frame') @finder = lambda do | x | int_id = Wx::xrcid(x) begin Wx::Window.find_window_by_id(int_id, self) rescue RuntimeError int_id end end @menuitem_new = @finder.call('menuitem_new') evt_menu(@menuitem_new.get_id) { | event | menuitem_new_clicked(event) } end def menuitem_new_clicked(event) puts 'Menu New is clicked' end end Thank you Regards Hendra -- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From penguinroad at gmail.com Tue Dec 15 01:22:33 2009 From: penguinroad at gmail.com (hendra kusuma) Date: Tue, 15 Dec 2009 13:22:33 +0700 Subject: [wxruby-users] menu event handler problem In-Reply-To: <26dadb3d0912142148q1f9aeeadhc176ebf57b7188ab@mail.gmail.com> References: <26dadb3d0912142148q1f9aeeadhc176ebf57b7188ab@mail.gmail.com> Message-ID: <26dadb3d0912142222w7385fd6fx44a19a20bb12e5a0@mail.gmail.com> done by changing evt_menu(@menuitem_new.get_id) { | event | menuitem_new_clicked(event) } into evt_menu(Wx::xrcid.('menuitem_new)) { | event | menuitem_new_clicked(event) } why does previous one does not work? anybody can tell? On Tue, Dec 15, 2009 at 12:48 PM, hendra kusuma wrote: > Guys, > > I make a form with xrc file help > I load, use lambda to get all my widgets, > then set event handler > > somehow, it does not work well with menu > with no clear sign of what the mistake is > > is there something I miss? > > here is the code > > require 'rubygems' > require 'wx' > require 'pathname' > include Wx > class MyForm < Wx::Frame > def initialize(parent=nil) > super() > xrc_file = 'file.xrc' > xml = Wx::XmlResource.get > xml.flags = 2 > xml.init_all_handlers > xml.load(xrc_file) > xml.load_frame_subclass(self, parent, 'my_frame') > @finder = lambda do | x | > int_id = Wx::xrcid(x) > begin > Wx::Window.find_window_by_id(int_id, self) > rescue RuntimeError > int_id > end > end > > @menuitem_new = @finder.call('menuitem_new') > evt_menu(@menuitem_new.get_id) { | event | > menuitem_new_clicked(event) } > > end > > def menuitem_new_clicked(event) > puts 'Menu New is clicked' > end > > end > > > Thank you > Regards > Hendra > > -- > Suka linux? > Kunjungi blog saya http://penguinroad.blogspot.com > -- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From penguinroad at gmail.com Tue Dec 15 02:04:45 2009 From: penguinroad at gmail.com (hendra kusuma) Date: Tue, 15 Dec 2009 14:04:45 +0700 Subject: [wxruby-users] menu event handler problem In-Reply-To: <26dadb3d0912142222w7385fd6fx44a19a20bb12e5a0@mail.gmail.com> References: <26dadb3d0912142148q1f9aeeadhc176ebf57b7188ab@mail.gmail.com> <26dadb3d0912142222w7385fd6fx44a19a20bb12e5a0@mail.gmail.com> Message-ID: <26dadb3d0912142304w5dc23a79ne51eac30fa1bd884@mail.gmail.com> Another question, I want to make an accelerator to call that menu, something like ctrl+n doc tells to add accelerator table and then assign, something like acc_table = Wx::AcceleratorTable[ [ Wx::MOD_CONTROL, "n".ord, @menuitem_new.get_id ] ] self.accelerator_table = acc_table but it does not work... How can I fix this? (i tried to replace @menuitem_new.get_id with Wx::xrcid('menuitem_new') but no luck...) On Tue, Dec 15, 2009 at 1:22 PM, hendra kusuma wrote: > done by changing > evt_menu(@menuitem_new.get_id) { | event | menuitem_new_clicked(event) } > into > evt_menu(Wx::xrcid.('menuitem_new)) { | event | > menuitem_new_clicked(event) } > > why does previous one does not work? > anybody can tell? > > > On Tue, Dec 15, 2009 at 12:48 PM, hendra kusuma wrote: > >> Guys, >> >> I make a form with xrc file help >> I load, use lambda to get all my widgets, >> then set event handler >> >> somehow, it does not work well with menu >> with no clear sign of what the mistake is >> >> is there something I miss? >> >> here is the code >> >> require 'rubygems' >> require 'wx' >> require 'pathname' >> include Wx >> class MyForm < Wx::Frame >> def initialize(parent=nil) >> super() >> xrc_file = 'file.xrc' >> xml = Wx::XmlResource.get >> xml.flags = 2 >> xml.init_all_handlers >> xml.load(xrc_file) >> xml.load_frame_subclass(self, parent, 'my_frame') >> @finder = lambda do | x | >> int_id = Wx::xrcid(x) >> begin >> Wx::Window.find_window_by_id(int_id, self) >> rescue RuntimeError >> int_id >> end >> end >> >> @menuitem_new = @finder.call('menuitem_new') >> evt_menu(@menuitem_new.get_id) { | event | >> menuitem_new_clicked(event) } >> >> end >> >> def menuitem_new_clicked(event) >> puts 'Menu New is clicked' >> end >> >> end >> >> >> Thank you >> Regards >> Hendra >> >> -- >> Suka linux? >> Kunjungi blog saya http://penguinroad.blogspot.com >> > > > > -- > Suka linux? > Kunjungi blog saya http://penguinroad.blogspot.com > -- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From penguinroad at gmail.com Tue Dec 15 02:39:27 2009 From: penguinroad at gmail.com (hendra kusuma) Date: Tue, 15 Dec 2009 14:39:27 +0700 Subject: [wxruby-users] menu event handler problem In-Reply-To: <26dadb3d0912142304w5dc23a79ne51eac30fa1bd884@mail.gmail.com> References: <26dadb3d0912142148q1f9aeeadhc176ebf57b7188ab@mail.gmail.com> <26dadb3d0912142222w7385fd6fx44a19a20bb12e5a0@mail.gmail.com> <26dadb3d0912142304w5dc23a79ne51eac30fa1bd884@mail.gmail.com> Message-ID: <26dadb3d0912142339xd7cc50amc562952fe2c5c4fc@mail.gmail.com> Sorry, somehow I find it myself using acc_table = Wx::AcceleratorTable[ [ Wx::MOD_CONTROL, ?n, Wx::xrcid'menuitem_new'] ] I really dont understand how is ?n different from "n".ord anyone can explain? On Tue, Dec 15, 2009 at 2:04 PM, hendra kusuma wrote: > Another question, > I want to make an accelerator to call that menu, something like ctrl+n > > doc tells to add accelerator table and then assign, > something like > acc_table = Wx::AcceleratorTable[ [ Wx::MOD_CONTROL, "n".ord, > @menuitem_new.get_id ] ] > self.accelerator_table = acc_table > > but it does not work... > How can I fix this? > (i tried to replace @menuitem_new.get_id with Wx::xrcid('menuitem_new') but > no luck...) > > On Tue, Dec 15, 2009 at 1:22 PM, hendra kusuma wrote: > >> done by changing >> evt_menu(@menuitem_new.get_id) { | event | menuitem_new_clicked(event) } >> into >> evt_menu(Wx::xrcid.('menuitem_new)) { | event | >> menuitem_new_clicked(event) } >> >> why does previous one does not work? >> anybody can tell? >> >> >> On Tue, Dec 15, 2009 at 12:48 PM, hendra kusuma wrote: >> >>> Guys, >>> >>> I make a form with xrc file help >>> I load, use lambda to get all my widgets, >>> then set event handler >>> >>> somehow, it does not work well with menu >>> with no clear sign of what the mistake is >>> >>> is there something I miss? >>> >>> here is the code >>> >>> require 'rubygems' >>> require 'wx' >>> require 'pathname' >>> include Wx >>> class MyForm < Wx::Frame >>> def initialize(parent=nil) >>> super() >>> xrc_file = 'file.xrc' >>> xml = Wx::XmlResource.get >>> xml.flags = 2 >>> xml.init_all_handlers >>> xml.load(xrc_file) >>> xml.load_frame_subclass(self, parent, 'my_frame') >>> @finder = lambda do | x | >>> int_id = Wx::xrcid(x) >>> begin >>> Wx::Window.find_window_by_id(int_id, self) >>> rescue RuntimeError >>> int_id >>> end >>> end >>> >>> @menuitem_new = @finder.call('menuitem_new') >>> evt_menu(@menuitem_new.get_id) { | event | >>> menuitem_new_clicked(event) } >>> >>> end >>> >>> def menuitem_new_clicked(event) >>> puts 'Menu New is clicked' >>> end >>> >>> end >>> >>> >>> Thank you >>> Regards >>> Hendra >>> >>> -- >>> Suka linux? >>> Kunjungi blog saya http://penguinroad.blogspot.com >>> >> >> >> >> -- >> Suka linux? >> Kunjungi blog saya http://penguinroad.blogspot.com >> > > > > -- > Suka linux? > Kunjungi blog saya http://penguinroad.blogspot.com > -- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex at pressure.to Tue Dec 15 22:26:47 2009 From: alex at pressure.to (Alex Fenton) Date: Wed, 16 Dec 2009 03:26:47 +0000 Subject: [wxruby-users] menu event handler problem In-Reply-To: <26dadb3d0912142339xd7cc50amc562952fe2c5c4fc@mail.gmail.com> References: <26dadb3d0912142148q1f9aeeadhc176ebf57b7188ab@mail.gmail.com> <26dadb3d0912142222w7385fd6fx44a19a20bb12e5a0@mail.gmail.com> <26dadb3d0912142304w5dc23a79ne51eac30fa1bd884@mail.gmail.com> <26dadb3d0912142339xd7cc50amc562952fe2c5c4fc@mail.gmail.com> Message-ID: <4B285377.8080805@pressure.to> hendra kusuma wrote: > Sorry, somehow I find it myself > using > > acc_table = Wx::AcceleratorTable[ [ Wx::MOD_CONTROL, ?n, > Wx::xrcid'menuitem_new'] ] > > I really dont understand > how is ?n different from "n".ord > > anyone can explain? I didn't know this before, but it seems the meaning of the ?x literal changed in Ruby 1.9 along with the meaning of "x"[0]. String#ord didn't exist in 1.8: abaddon:~ alex$ irb >> RUBY_VERSION => "1.8.7" >> ?n => 110 >> "n"[0] => 110 >> "n".ord NoMethodError: undefined method `ord' for "n":String from (irb):3 abaddon:~ alex$ ~/bleed/bin/irb irb(main):001:0> RUBY_VERSION => "1.9.1" irb(main):002:0> "n".ord => 110 irb(main):003:0> "n"[0] => "n" irb(main):004:0> ?n => "n" cheers alex From lists at ruby-forum.com Tue Dec 15 22:36:30 2009 From: lists at ruby-forum.com (Jette Chan) Date: Wed, 16 Dec 2009 04:36:30 +0100 Subject: [wxruby-users] static gem of wxruby 2.0.1 for OS X Snow Leopard In-Reply-To: <80d893c70911110552ye2c5e1ald5cec7b270ebd4b3@mail.gmail.com> References: <80d893c70911110552ye2c5e1ald5cec7b270ebd4b3@mail.gmail.com> Message-ID: Antti Hakala wrote: > Hello, > I have a static gem of wxruby 2.0.1 that works on OS X Snow Leopard, > if somebody is interested. > I've tried it only on my own comp. It's about 9MB. Hello it will be very appreciate if you could send this gem to me! I've just looking for it for days and weeks... chouti AT gmail.com Thank you again. Daniel -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Wed Dec 16 08:01:04 2009 From: alex at pressure.to (Alex Fenton) Date: Wed, 16 Dec 2009 13:01:04 +0000 Subject: [wxruby-users] ScreenDC doesn't draw text In-Reply-To: References: Message-ID: <4B28DA10.8060603@pressure.to> Hi Marvin Marvin G?lker wrote: > I'm doing some experiments with the ScreenDC class for on-screen > drawing. Drawing shapes like a circle or rectangle works fine, but when > I try to draw text onto the screen, nothing happens. I'm using the > wxruby-ruby19 gem with ruby 1.9.1p243 (2009-07-16 revision 24175) > [i686-linux] on an Ubuntu Karmic machine. > > My code looks like this ... > sc.draw_text("Test", 0, 150) #...but this doesn't I got round to trying your sample, running it with a debug build on Mac. The line above is causing an assertion in Wx to fail, and then a crash. The message I get is rather cryptic,: Assertion failed: ((min.y == p[0].y && max.y == p[order].y) || (min.y == p[order].y && max.y == p[0].y)), function crossing_count, file Paths/path-crossing.c, line 176. Abort trap But I'm not sure if this is because ScreenDC doesn't work properly on Mac, or if there's something else wrong with the usage. I've never tried drawing directly on the screen. sorry i can't be more hlepful alex From alex at pressure.to Wed Dec 16 08:27:29 2009 From: alex at pressure.to (Alex Fenton) Date: Wed, 16 Dec 2009 13:27:29 +0000 Subject: [wxruby-users] grid et boxsizer In-Reply-To: <4B235C4A.3040003@neuf.fr> References: <4B235C4A.3040003@neuf.fr> Message-ID: <4B28E041.1020302@pressure.to> Bonjour Seb wrote: > Une fois mon application ouverte, je voudrais savoir, si cela est > possible, comment dimensionner automatiquement la totalit? des > colonnes du grid ? la taille de mon boxsizer, quand je change la > taille de mon application? (puique mon grid est ins?r? dans mon > boxsizer). [When my application opens, I would like to know how to automatically size the total of columns in my grid to fit the sizer as the size of my application changes] Something like: --- require 'wx' class GridApp < Wx::App ROWS = 8 COLS = 5 def on_init frame = Wx::Frame.new(nil, -1, 'Resizing Grid') grid = Wx::Grid.new(frame) grid.create_grid(ROWS, COLS) grid.evt_size do | evt | cell_width = ( evt.size.width - grid.row_label_size - Wx::SystemSettings.metric(Wx::SYS_VSCROLL_X) ) / COLS grid.set_default_col_size(cell_width) cell_height = ( evt.size.height - grid.col_label_size - Wx::SystemSettings.metric(Wx::SYS_HSCROLL_Y) ) / ROWS grid.set_default_row_size(cell_height) grid.force_refresh end frame.show end end GridApp.new.main_loop --- alex From bureaux.sebastien at neuf.fr Wed Dec 16 13:51:16 2009 From: bureaux.sebastien at neuf.fr (Seb) Date: Wed, 16 Dec 2009 19:51:16 +0100 Subject: [wxruby-users] grid et boxsizer In-Reply-To: <4B28E041.1020302@pressure.to> References: <4B28E041.1020302@pressure.to> Message-ID: <4B292C24.3040408@neuf.fr> J'ai essayer, ?a fonctionne. merci From lists at ruby-forum.com Wed Dec 16 18:47:58 2009 From: lists at ruby-forum.com (Jason Sandfield) Date: Thu, 17 Dec 2009 00:47:58 +0100 Subject: [wxruby-users] Will wxRuby 2.0.2 be available before Xmas? Message-ID: This will make a nice Xmas present. Looking forward to get wxRuby working on Snow Leopard ... -- Posted via http://www.ruby-forum.com/. From bureaux.sebastien at neuf.fr Thu Dec 17 04:24:35 2009 From: bureaux.sebastien at neuf.fr (Seb) Date: Thu, 17 Dec 2009 10:24:35 +0100 Subject: [wxruby-users] grid et boxsizer In-Reply-To: <4B28E041.1020302@pressure.to> References: <4B28E041.1020302@pressure.to> Message-ID: <4B29F8D3.6060406@neuf.fr> A quoi correspond les valeurs retourn?es, ce sont des pixels? A quoi correspond "SystemSettings.metric(Wx::SYS_HSCROLL_Y)" ? merci From alex at pressure.to Thu Dec 17 04:38:22 2009 From: alex at pressure.to (Alex Fenton) Date: Thu, 17 Dec 2009 09:38:22 +0000 Subject: [wxruby-users] grid et boxsizer In-Reply-To: <4B29F8D3.6060406@neuf.fr> References: <4B28E041.1020302@pressure.to> <4B29F8D3.6060406@neuf.fr> Message-ID: <4B29FC0E.3050403@pressure.to> Seb wrote: > A quoi correspond les valeurs retourn?es, ce sont des pixels? [what do the values represent, pixels?] Oui - pixels. > A quoi correspond "SystemSettings.metric(Wx::SYS_HSCROLL_Y)" ? [What does SystemSettings.metric(Wx::SYS_HSCROLL_Y) correspond to?] C'est la taille du defilement horizontal du grid. On voit que Wx::Grid peut avoir des defilements quand la totalit? des colonnes est plus grande que le place disponible. [It's the size of the grid's horizontal scroll bar. You'll have seen that Wx::Grid can have scrollbars when the total size of the columns is greater than the space available.] a From bureaux.sebastien at neuf.fr Fri Dec 18 07:20:26 2009 From: bureaux.sebastien at neuf.fr (Seb) Date: Fri, 18 Dec 2009 13:20:26 +0100 Subject: [wxruby-users] rubyinstaller-1.9.1-p243-rc1.exe | wxruby-ruby19-2.0.1-x86-mingw32.gem | encodage Message-ID: <4B2B738A.5000309@neuf.fr> Bonjour Alex. Ce matin j'ai installer "rubyinstaller-1.9.1-p243-rc1.exe" "wxruby-ruby19-2.0.1-x86-mingw32.gem" "SciTE.exe 2.0.1.0" Quand j'ex?cute (avec scite) mon fichier "Rss-wxruby.rbw" qui est encod? en utf8 et qui habituellement(avec les anciennes versions de ruby, wxruby et scite) fonctionne correctement, j'obtient ce message d'erreur: C:\Users\seb\Desktop\Rss-wxruby-1.1.6>ruby rss-wxruby.rbw rss-wxruby.rbw:99: invalid multibyte char (US-ASCII) rss-wxruby.rbw:99: invalid multibyte char (US-ASCII) rss-wxruby.rbw:99: syntax error, unexpected $end, expecting ')' ..."Raz de l'archive", " Remise ?? z??ro de l'archivage des flu... ... ^ J'ai changer l'encodage du fichier avec scite plusieurs fois, mais rien ? faire, j'ai toujours ce probl?me. Pourquoi cela ne fonctionne plus avec les nouvelles versions? Comment pourrait on r?soudre ce probl?me? merci From lists at ruby-forum.com Sat Dec 19 09:42:16 2009 From: lists at ruby-forum.com (=?utf-8?Q?Marvin_G=c3=bclker?=) Date: Sat, 19 Dec 2009 15:42:16 +0100 Subject: [wxruby-users] Shaped frames (even the example) cause warning window Message-ID: <48f69d175b5f665689e592c6ca7c4ef0@ruby-forum.com> Hi, I just found that the "ShapedWindow.rbw" example (from bigdemo) causes a Warning Dialog window to appear when you click the display button, saying: "Ignoring attempt to set cHRM RGB triangle with zero area". After some experimenting with shaped frames I cannot make this window not to pop up - this is very annoying, since I don't want to click it away every time my application is run. Is there any way to get round it, or at least to suppress that? ruby -v: ruby 1.9.1p376 (2009-12-07 revision 26041) [i686-linux] Marvin -- Posted via http://www.ruby-forum.com/. From bureaux.sebastien at neuf.fr Sat Dec 19 13:09:26 2009 From: bureaux.sebastien at neuf.fr (Seb) Date: Sat, 19 Dec 2009 19:09:26 +0100 Subject: [wxruby-users] rubyinstaller-1.9.1-p243-rc1.exe | wxruby-ruby19-2.0.1-x86-mingw32.gem | encodage In-Reply-To: <4B2B738A.5000309@neuf.fr> References: <4B2B738A.5000309@neuf.fr> Message-ID: <4B2D16D6.5080705@neuf.fr> J'ai trouv? la solution. Il faut marquer en premi?re ligne de son fichier: #encoding: utf-8 et ensuite, il faut tout simplement marquer les caract?res accentu?s normalement et ne plus les convertir en utf-8 comme c'?tait le cas auparavant. merci quand m?me. From lists at ruby-forum.com Mon Dec 21 02:20:28 2009 From: lists at ruby-forum.com (=?utf-8?Q?Ilkka_M=c3=a4ki?=) Date: Mon, 21 Dec 2009 08:20:28 +0100 Subject: [wxruby-users] "msvcrt-ruby.ruby1818.dll not found" on wxruby-2.0.1 min In-Reply-To: <85693b4362480bb47072508c327fbfe2@ruby-forum.com> References: <85693b4362480bb47072508c327fbfe2@ruby-forum.com> Message-ID: Zhimin Zhan wrote: > Hi all, > > Just upgraded to wxruby-2.0.1-x86-mingw32 (from 2.0.0), got an error > when starting my app. > > "The application has failed to start because msvcrt-ruby1818.dll was > not found. Re-installing the application may fix this problem." > > Uninstalled v2.0.1, the application started OK. > > My env: > ruby 1.8.6 (2009-08-04 patchlevel 383) [i386-mingw32] on Windows XP > (from http://rubyforge.org/frs/?group_id=167&release_id=38052) > > Cheers, > Zhimin Hi! What I did, was: gem uninstall wxruby gem install wxruby-ruby19 Now the ruby started to use the *-ruby191.dll. I first installed the wxruby only. As a newbie I just followed the tutorials I found. But reading the INSTALL document from wxruby gem, pointed me to this direction.. And now at least samples will run. -- Posted via http://www.ruby-forum.com/. From bureaux.sebastien at neuf.fr Mon Dec 21 15:43:35 2009 From: bureaux.sebastien at neuf.fr (Seb) Date: Mon, 21 Dec 2009 21:43:35 +0100 Subject: [wxruby-users] =?iso-8859-1?q?probl=E8me_de_fermeture_d=27applica?= =?iso-8859-1?q?tion_via_l=27ic=F4ne_de_la_barre_de_lancement_rapide?= Message-ID: <4B2FDDF7.7020207@neuf.fr> Bonsoir Alex. Quand j'ouvre mes applications et que je clique sur l'item "quittez" de l'ic?ne de la barre de lancement rapide, l'ic?ne dispara?t mais mes applications ne se ferme pas. Il faut que je passe dessus avec le curseur pour que l'application se ferme. Voici le code que j'utilise pour mes applications: class Icone1 < TaskBarIcon def initialize(recettes) super() icone = Icon.new("images/icone.ico", BITMAP_TYPE_ICO) set_icon(icone, 'Cocktails-wxruby') evt_menu(Icone_Sortie) {onIcone_sortie} end def create_popup_menu menu = Menu.new menu.append(Icone_Sortie, "Quittez") return menu end def onIcone_sortie $icone.remove_icon() exit end end Je n'obtient aucun message d'erreur pour ce probl?me quand j'ex?cute mes applications avec scite. Est-ce moi qui a fait une erreur? La cause vient peut ?tre des changements effectu?s suivant les diff?rentes versions de wxruby? Ou peut on consulter les divers changements apport?s ? chaque version de wxruby? merci From plusgforce at gmail.com Wed Dec 23 19:34:42 2009 From: plusgforce at gmail.com (Philip Stephens) Date: Wed, 23 Dec 2009 18:34:42 -0600 Subject: [wxruby-users] Clean Application exits Message-ID: <536e2d6f0912231634r75a02ca7x93dde9c29bb3740f@mail.gmail.com> require 'wx' require 'Eyes.rb' =begin What I would like to be able to do is to first show a modal dialog where someone enters his name and password. I would like to exit the program if the user clicks cancel on the modal dialog box. then I would like to be able to show the main screen and after clicking on the close button, I would like to exit the application, not just close the dialog box. One time I used a timer but I don't think a timer is necessary. What can I do to make the following exit cleanly after closing both dialog boxes? Thanks for your help. Philip class Main_Frame < EyesFrame attr_accessor :score, :symbol def on_init @m_statusbar.set_fields_count(2) @score = 0 @m_statusbar.set_status_text("Score: #{@score}", 2) show_user_dialog end def show_user_dialog @screen1 = EW_Dialog.new temp = @screen1.show_modal @screen1.close @screen1.end_modal(2) end end class EW_Dialog < EW_dialog def get_username return @m_textctrl_username.value end def get_password return @m_textctrl_password.value end end class DLG_About < DLG_about end class MyApp < Wx::App @username = nil @password = nil def on_init @screen2 = Main_Frame.new self.set_exit_on_frame_delete(true) self.set_top_window(@screen2) @screen2.show end end # class app = MyApp.new app.main_loop =begin $ ruby1.9 mintest.rb ^Z [4]+ Stopped ruby1.9 mintest.rb # Eyes.rb # This class was automatically generated from XRC source. It is not # recommended that this file is edited directly; instead, inherit from # this class and extend its behaviour there. # # Source file: EyesGui.xrc # Generated at: 2009-12-03 18:01:35 -0600 class EyesFrame < Wx::Frame attr_reader :txtred, :m_textrednumber, :m_staticlblgreen, :m_textgreennumber, :m_staticlblblue, :m_textbluenumber, :m_staticlblsymbol, :m_textctrlguess, :m_buttondecrement, :m_buttonincrement, :m_statusbar def initialize(parent = nil) super() xml = Wx::XmlResource.get xml.flags = 2 # Wx::XRC_NO_SUBCLASSING xml.init_all_handlers xml.load("EyesGui.xrc") xml.load_frame_subclass(self, parent, "frmMain") finder = lambda do | x | int_id = Wx::xrcid(x) begin Wx::Window.find_window_by_id(int_id, self) || int_id # Temporary hack to work around regression in 1.9.2; remove # begin/rescue clause in later versions rescue RuntimeError int_id end end @txtred = finder.call("txtRed") @m_textrednumber = finder.call("m_textRedNumber") @m_staticlblgreen = finder.call("m_staticlblGreen") @m_textgreennumber = finder.call("m_textGreenNumber") @m_staticlblblue = finder.call("m_staticLBLBlue") @m_textbluenumber = finder.call("m_textBlueNumber") @m_staticlblsymbol = finder.call("m_staticLBLsymbol") @m_textctrlguess = finder.call("m_textCtrlGuess") @m_buttondecrement = finder.call("m_buttonDecrement") @m_buttonincrement = finder.call("m_buttonincrement") @m_statusbar = finder.call("m_statusBar") if self.class.method_defined? "on_init" self.on_init() end end end # This class was automatically generated from XRC source. It is not # recommended that this file is edited directly; instead, inherit from # this class and extend its behaviour there. # # Source file: EyesGui.xrc # Generated at: 2009-12-03 18:01:35 -0600 class EW_dialog < Wx::Dialog attr_reader :m_bitmap1, :m_staticlblinstr1, :m_staticlblinstr2, :m_staticlblusername, :m_textctrl_username, :m_staticlblpassword, :m_textctrl_password def initialize(parent = nil) super() xml = Wx::XmlResource.get xml.flags = 2 # Wx::XRC_NO_SUBCLASSING xml.init_all_handlers xml.load("EyesGui.xrc") xml.load_dialog_subclass(self, parent, "diab_welcome") finder = lambda do | x | int_id = Wx::xrcid(x) begin Wx::Window.find_window_by_id(int_id, self) || int_id # Temporary hack to work around regression in 1.9.2; remove # begin/rescue clause in later versions rescue RuntimeError int_id end end @m_bitmap1 = finder.call("m_bitmap1") @m_staticlblinstr1 = finder.call("m_staticLBLinstr1") @m_staticlblinstr2 = finder.call("m_staticLBLinstr2") @m_staticlblusername = finder.call("m_staticLBLusername") @m_textctrl_username = finder.call("m_textCtrl_username") @m_staticlblpassword = finder.call("m_staticLBLPassword") @m_textctrl_password = finder.call("m_textCtrl_Password") if self.class.method_defined? "on_init" self.on_init() end end end =end -------------- next part -------------- An HTML attachment was scrubbed... URL: From no-reply at dropbox.com Thu Dec 24 20:10:06 2009 From: no-reply at dropbox.com (Dropbox) Date: Fri, 25 Dec 2009 01:10:06 +0000 Subject: [wxruby-users] Timothy Mcdowell has invited you to Dropbox Message-ID: <20091225011006.7562130701D@mailman.dropbox.com> We're excited to let you know that Timothy Mcdowell has invited you to Dropbox! Timothy Mcdowell has been using Dropbox to sync and share files online and across computers, and thought you might want it too. Visit http://www.dropbox.com/link/20.ftpgPVIkHP/NjY5MjU5ODU3 to get started. - The Dropbox Team ____________________________________________________ To stop receiving invites from Dropbox, please go to http://www.dropbox.com/bl/b4bb41bf93a5/wxruby-users%40rubyforge.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Sun Dec 27 17:30:18 2009 From: lists at ruby-forum.com (Haris Bogdanovic) Date: Sun, 27 Dec 2009 23:30:18 +0100 Subject: [wxruby-users] wxscrolledwindow Message-ID: <8a1541df29743dd47759ceba8dd84ff9@ruby-forum.com> Hi. Could someone give me a simple example on how to use ScrolledWindow class ? I want to be able to draw on a panel that's many times higher than window holding it (which has vertical scroll bars). Thanks Haris -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sun Dec 27 20:54:53 2009 From: lists at ruby-forum.com (Haris Bogdanovic) Date: Mon, 28 Dec 2009 02:54:53 +0100 Subject: [wxruby-users] wxscrolledwindow In-Reply-To: <8a1541df29743dd47759ceba8dd84ff9@ruby-forum.com> References: <8a1541df29743dd47759ceba8dd84ff9@ruby-forum.com> Message-ID: <3db43b2ce7b371fef89607a994e3fd93@ruby-forum.com> Haris Bogdanovic wrote: > Hi. > > Could someone give me a simple example on how to use ScrolledWindow > class ? > I want to be able to draw on a panel that's many times higher than > window > holding it (which has vertical scroll bars). > > Thanks > Haris Why is this piece of code crashing: require "wx" class MainFrame < Wx::ScrolledWindow def initialize super nil end end class HelloWorld < Wx::App def on_init f = MainFrame.new f.show end end HelloWorld.new.main_loop Thanks Haris -- Posted via http://www.ruby-forum.com/. From fabio.petrucci at gmail.com Mon Dec 28 03:43:45 2009 From: fabio.petrucci at gmail.com (Fabio Petrucci) Date: Mon, 28 Dec 2009 09:43:45 +0100 Subject: [wxruby-users] Clean Application exits In-Reply-To: <536e2d6f0912231634r75a02ca7x93dde9c29bb3740f@mail.gmail.com> References: <536e2d6f0912231634r75a02ca7x93dde9c29bb3740f@mail.gmail.com> Message-ID: Hi, i've had the same problem and resolved as follow: in the app i have something like this class MyApp < App def on_init begin main = Views::MainFrame.new main.show main.login rescue Exception => e exit(1) end end end MyApp.new.main_loop ... and in the main frame module Views class MainFrame < Wx::Frame .... def login login_dlg = Views::Dialog::LoginDialog.new(self) answer = login_dlg.show_modal() login_dlg.destroy() if answer == Wx::ID_CANCEL Wx::get_app.exit_main_loop() else .... end end end end hope it helps. bio. On Thu, Dec 24, 2009 at 1:34 AM, Philip Stephens wrote: > require 'wx' > require 'Eyes.rb' > > =begin > What I would like to be able to do is to first show > a modal dialog where someone enters his name and > password. I would like to exit the program if the > user clicks cancel on the modal dialog box. > > then I would like to be able to show the main screen > and after clicking on the close button, I would like > to exit the application, not just close the dialog > box. One time I used a timer but I don't think a timer > is necessary. What can I do to make the following exit > cleanly after closing both dialog boxes? Thanks for > your help. > > Philip > > class Main_Frame < EyesFrame > > attr_accessor :score, :symbol > > def on_init > @m_statusbar.set_fields_count(2) > @score = 0 > @m_statusbar.set_status_text("Score: #{@score}", 2) > show_user_dialog > end > > def show_user_dialog > @screen1 = EW_Dialog.new > temp = @screen1.show_modal > @screen1.close > @screen1.end_modal(2) > end > end > > class EW_Dialog < EW_dialog > def get_username > return @m_textctrl_username.value > end > > def get_password > return @m_textctrl_password.value > end > end > > class DLG_About < DLG_about > end > > class MyApp < Wx::App > > @username = nil > @password = nil > > def on_init > @screen2 = Main_Frame.new > self.set_exit_on_frame_delete(true) > self.set_top_window(@screen2) > @screen2.show > end > end # class > > app = MyApp.new > app.main_loop > > =begin > $ ruby1.9 mintest.rb > ^Z > [4]+ Stopped ruby1.9 mintest.rb > > > # Eyes.rb > # This class was automatically generated from XRC source. It is not > # recommended that this file is edited directly; instead, inherit from > # this class and extend its behaviour there. > # > # Source file: EyesGui.xrc > # Generated at: 2009-12-03 18:01:35 -0600 > > class EyesFrame < Wx::Frame > > attr_reader :txtred, :m_textrednumber, :m_staticlblgreen, > :m_textgreennumber, :m_staticlblblue, :m_textbluenumber, > :m_staticlblsymbol, :m_textctrlguess, > :m_buttondecrement, :m_buttonincrement, :m_statusbar > > def initialize(parent = nil) > super() > xml = Wx::XmlResource.get > xml.flags = 2 # Wx::XRC_NO_SUBCLASSING > xml.init_all_handlers > xml.load("EyesGui.xrc") > xml.load_frame_subclass(self, parent, "frmMain") > > finder = lambda do | x | > int_id = Wx::xrcid(x) > begin > Wx::Window.find_window_by_id(int_id, self) || int_id > # Temporary hack to work around regression in 1.9.2; remove > # begin/rescue clause in later versions > rescue RuntimeError > int_id > end > end > > @txtred = finder.call("txtRed") > @m_textrednumber = finder.call("m_textRedNumber") > @m_staticlblgreen = finder.call("m_staticlblGreen") > @m_textgreennumber = finder.call("m_textGreenNumber") > @m_staticlblblue = finder.call("m_staticLBLBlue") > @m_textbluenumber = finder.call("m_textBlueNumber") > @m_staticlblsymbol = finder.call("m_staticLBLsymbol") > @m_textctrlguess = finder.call("m_textCtrlGuess") > @m_buttondecrement = finder.call("m_buttonDecrement") > @m_buttonincrement = finder.call("m_buttonincrement") > @m_statusbar = finder.call("m_statusBar") > if self.class.method_defined? "on_init" > self.on_init() > end > end > end > > > > # This class was automatically generated from XRC source. It is not > # recommended that this file is edited directly; instead, inherit from > # this class and extend its behaviour there. > # > # Source file: EyesGui.xrc > # Generated at: 2009-12-03 18:01:35 -0600 > > class EW_dialog < Wx::Dialog > > attr_reader :m_bitmap1, :m_staticlblinstr1, :m_staticlblinstr2, > :m_staticlblusername, :m_textctrl_username, > :m_staticlblpassword, :m_textctrl_password > > def initialize(parent = nil) > super() > xml = Wx::XmlResource.get > xml.flags = 2 # Wx::XRC_NO_SUBCLASSING > xml.init_all_handlers > xml.load("EyesGui.xrc") > xml.load_dialog_subclass(self, parent, "diab_welcome") > > finder = lambda do | x | > int_id = Wx::xrcid(x) > begin > Wx::Window.find_window_by_id(int_id, self) || int_id > # Temporary hack to work around regression in 1.9.2; remove > # begin/rescue clause in later versions > rescue RuntimeError > int_id > end > end > > @m_bitmap1 = finder.call("m_bitmap1") > @m_staticlblinstr1 = finder.call("m_staticLBLinstr1") > @m_staticlblinstr2 = finder.call("m_staticLBLinstr2") > @m_staticlblusername = finder.call("m_staticLBLusername") > @m_textctrl_username = finder.call("m_textCtrl_username") > @m_staticlblpassword = finder.call("m_staticLBLPassword") > @m_textctrl_password = finder.call("m_textCtrl_Password") > if self.class.method_defined? "on_init" > self.on_init() > end > end > end > =end > > > _______________________________________________ > 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 mario at ruby-im.net Mon Dec 28 06:29:07 2009 From: mario at ruby-im.net (Mario Steele) Date: Mon, 28 Dec 2009 06:29:07 -0500 Subject: [wxruby-users] wxscrolledwindow In-Reply-To: <3db43b2ce7b371fef89607a994e3fd93@ruby-forum.com> References: <8a1541df29743dd47759ceba8dd84ff9@ruby-forum.com> <3db43b2ce7b371fef89607a994e3fd93@ruby-forum.com> Message-ID: Hello Haris, On Sun, Dec 27, 2009 at 8:54 PM, Haris Bogdanovic wrote: > Haris Bogdanovic wrote: > > Hi. > > > > Could someone give me a simple example on how to use ScrolledWindow > > class ? > > I want to be able to draw on a panel that's many times higher than > > window > > holding it (which has vertical scroll bars). > > > > Thanks > > Haris > > Why is this piece of code crashing: > > require "wx" > > class MainFrame < Wx::ScrolledWindow > def initialize > super nil > ^^^^^^^ This specific line is what is causing the problems. end > > end > > class HelloWorld < Wx::App > def on_init > f = MainFrame.new > f.show > end > end > > HelloWorld.new.main_loop You can't create a ScrolledWindow as a Top Level Window, in Generic Terms. In specific terms relating to wxWidgets, only a Frame (Or TopLevelFrame or anything sub-classed from Frame or TopLevelFrame), or a Dialog (Same as with Frame) can be created without a parent. If you look at ScrolledWindow's Documentation here (http://wxruby.rubyforge.org/doc/scrolledwindow.html), near the top, there's a Derived from (Or specifically Subclassed from), you'll see a breakdown of the classes that ScrolledWindow inherits from, Wx::Object being the top of the Inheritance, followed by EvtHandler, Window, and Panel. Frame is not mentioned anywhere in there. So in order to create a ScrolledWindow, you need to have it as a child of a Frame. A simple example of this being: class MyFrame < Wx::Frame def initialize super nil # This is perfectly fine, cause Frame doesn't require a parent. @scrolled = Wx::ScrolledWindow.new(self) # This now creates a ScrolledWindow as a child, and only child of our frame. end end class HelloWorld < Wx::App def on_init f = MyFrame.new f.show end end HelloWorld.new.main_loop Keep this in mind whenever you go to create a widget in wxRuby without a parent, you ensure that it is Derived or Subclassed from a Frame. As to your previous post, take a look at the samples directory in your wxRuby gem directory, for an example of how to use Wx::ScrolledWindow. hth, Mario -- Mario Steele http://www.trilake.net http://www.ruby-im.net http://rubyforge.org/projects/wxruby/ http://rubyforge.org/projects/wxride/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Mon Dec 28 11:21:40 2009 From: lists at ruby-forum.com (Haris Bogdanovic) Date: Mon, 28 Dec 2009 17:21:40 +0100 Subject: [wxruby-users] wxscrolledwindow In-Reply-To: References: <8a1541df29743dd47759ceba8dd84ff9@ruby-forum.com> <3db43b2ce7b371fef89607a994e3fd93@ruby-forum.com> Message-ID: <3ef9cadab444093aeec5a9381bf2f316@ruby-forum.com> Thanks Mario. I figured out myself in the mean time that scrolled window has to have parent window but thanks anyway. I looked again and found ScrolledWindow sample in bigdemo folder. Thanks Haris -- Posted via http://www.ruby-forum.com/.