I''m using wx_sugar 0.1.2 with wxruby2-preview 0.0.37 on OSX and am
coming up with an error when trying to create a SpinCtrl (and quite a
few others have exactly the same prob.):
#file date_picker.rb
class DatePicker < Wx::Dialog
def initialize
super(nil, :title => "Pick a date...")
@cal = Wx::CalendarCtrl.new(self)
add(@cal)
#works fine up to this point, will make a lovely calendar in the
window if I comment the next 2 lines out...
@month = Wx::SpinCtrl.new(self) # line 9 - doesn''t like this!
add(@month)
end
end
gives error:
ArgumentError:
Error initializing #<Wxruby2::SpinCtrl:0x6267a4>
Sent paramters: [#<DatePicker:0x626934>, -1, #<Wxruby2::Point:
0x690474>, #<Wxruby2::Size:0x6904b0>, 4, -1, #<Wxruby2::Point:
0x690474>, #<Wxruby2::Size:0x6904b0>, 4096, 0, 100, 0]
correct parameters are:
id (Fixnum)
pos (Wxruby2::Point)
size (Wxruby2::Size)
style (Fixnum)
id (Fixnum)
pos (Wxruby2::Point)
size (Wxruby2::Size)
style (Fixnum)
min (Fixnum)
max (Fixnum)
initial (Fixnum)
method initialize
in keyword_constructors.rb at line 238
method initialize
in date_picker.rb at line 9
method initialize
in main_window.rb at line 9
method listen
in event_connector.rb at line 125
at top level
in - at line 16
Ruby version: ruby 1.8.4 (2005-12-24) [powerpc-darwin8.7.0]
The SpinCtrl is working fine in the Big Demo, and other types of
controls can be added in this particular dialog fine. I have tried
hacking around in keyword_constructors.rb - my idea was to handle the
above error, and instead of raising it the first time, I tried to
catch it and then initialize the object just using the parameters
passed in - so that you could just revert to the normal wxruby (i.e.
c-style) params if there are any problems with wxsugar. Unfortunately
this didn''t work and lead to some strange recursion stuff that hurt
my head.
Anyone got any ideas as to what might be going wrong?
Thanks,
Alex Speller
Hi Alex Alex Speller wrote:> I''m using wx_sugar 0.1.2 with wxruby2-preview 0.0.37 on OSX and am > coming up with an error when trying to create a SpinCtrlThanks for the report, sorry for the bug. It''s down to a wrong definition of the constructor parameters in wx_sugar. I''ve checked in the correction, but if you want to patch yourself the error is in wx_sugar/lib/keyword_classes.rb Around line 321 there are two definitions of SpinCtrl''s constructor; this is a mistake itself, and worse, neither is quite right. Delete them both and replace with: # wxSpinCtrl A spin control - i.e. spin button and text control WxSugar.define_keyword_ctors(''SpinCtrl'') do wx_ctor_params :value => '''' wx_ctor_params :pos, :size, :style => Wx::SP_ARROW_KEYS wx_ctor_params :min => 0 wx_ctor_params :max => 100 wx_ctor_params :initial => 0 wx_ctor_params :name => ''spinCtrl'' end> (and quite a > few others have exactly the same prob.): >Oops, please let me know. I had to manually copy these so it''s not unlikely I''ve made some mistakes or omissions. If you get weird ''correct parameters'' - eg with two Size arguments, or ArgumentErrors about ''arg 2 of type XXX'' please check against the docs, have a look in keyword_classes and report. The docs should be correct as they were translated automatically from the C++ onees. Thanks again Alex>
Hi Alex,> Oops, please let me know. I had to manually copy these so it''s not > unlikely I''ve made some mistakes or omissions. If you get weird > ''correct > parameters'' - eg with two Size arguments, or ArgumentErrors about > ''arg 2 > of type XXX'' please check agaiFirstly, thank you for your amazingly swift reply. I''m slightly pleased that it wasn''t just me doing something really stupid ;) I''ve gone through most of the controls on the docs index page, and have come up with these changes: line (371 on mine, but then I''ve fiddled a bit...) change: WxSugar.define_keyword_ctors(''RadioBox'') do to WxSugar.define_keyword_ctors(''RadioButton'') do and then both radio boxes and radio buttons will work ;) This helps with SpinButtons: (Missing AFAIK) WxSugar.define_keyword_ctors(''SpinButton'') do wx_ctor_params :pos, :size, :style => Wx::SP_VERTICAL wx_ctor_params :name => ''spinButton'' end Change the Slider to this.... WxSugar.define_keyword_ctors(''Slider'') do wx_ctor_params :value => 0 wx_ctor_params :min_value, :max_value wx_ctor_params :pos, :size, :style => Wx::SL_HORIZONTAL # wx_ctor_params :validator, :name => ''radioButton'' end ... and all of the controls are now working (N.B. I haven''t tested the BitmapButton and the StaticBitmap because I''m not in the mood to figure out bitmaps in wx right now ;) Please note that I''m far from a ruby expert and so I have no idea if I''m doing the right thing above. All I can say is that the mods seem to work for me! Would quite like to get involved more in the project - perhaps more on the documentation side than the voodoo coding side - when I have some more free time after Christmas. I''ve been meaning to write some kind of wxSugar intro / tutorial, simply because it seems so much easier to pick up if you''re used to ruby syntax. WxRuby in general is very promising, especially with the nice syntax, and once everything is a little smoother it will be miles ahead of the other toolkits I''ve looked at. Good work guys ;) Alex
also added:
# Window
WxSugar.define_keyword_ctors(''Window'') do
wx_ctor_params :pos, :size, :style
wx_ctor_params :name => ''window''
end
Is this not there for a reason (i.e. just creating windows on their
own is a "bad thing")? I''ve just been using them as an area
to draw on.
Regards,
Alex
On 30 Nov 2006, at 1:19 am, Alex Speller wrote:
> Hi Alex,
>
>> Oops, please let me know. I had to manually copy these so it''s
not
>> unlikely I''ve made some mistakes or omissions. If you get
weird
>> ''correct
>> parameters'' - eg with two Size arguments, or ArgumentErrors
about
>> ''arg 2
>> of type XXX'' please check agai
>
>
> Firstly, thank you for your amazingly swift reply. I''m slightly
> pleased that it wasn''t just me doing something really stupid ;)
>
> I''ve gone through most of the controls on the docs index page, and
> have come up with these changes:
>
> line (371 on mine, but then I''ve fiddled a bit...)
> change:
> WxSugar.define_keyword_ctors(''RadioBox'') do
>
> to
> WxSugar.define_keyword_ctors(''RadioButton'') do
>
> and then both radio boxes and radio buttons will work ;)
>
> This helps with SpinButtons: (Missing AFAIK)
>
> WxSugar.define_keyword_ctors(''SpinButton'') do
> wx_ctor_params :pos, :size, :style => Wx::SP_VERTICAL
> wx_ctor_params :name => ''spinButton''
> end
>
>
> Change the Slider to this....
>
> WxSugar.define_keyword_ctors(''Slider'') do
> wx_ctor_params :value => 0
> wx_ctor_params :min_value, :max_value
> wx_ctor_params :pos, :size, :style => Wx::SL_HORIZONTAL
> # wx_ctor_params :validator, :name =>
''radioButton''
> end
>
> ... and all of the controls are now working (N.B. I haven''t tested
> the BitmapButton and the StaticBitmap because I''m not in the mood
to
> figure out bitmaps in wx right now ;)
>
>
> Please note that I''m far from a ruby expert and so I have no idea
if
> I''m doing the right thing above. All I can say is that the mods
seem
> to work for me!
>
> Would quite like to get involved more in the project - perhaps more
> on the documentation side than the voodoo coding side - when I have
> some more free time after Christmas. I''ve been meaning to write
some
> kind of wxSugar intro / tutorial, simply because it seems so much
> easier to pick up if you''re used to ruby syntax.
>
> WxRuby in general is very promising, especially with the nice syntax,
> and once everything is a little smoother it will be miles ahead of
> the other toolkits I''ve looked at. Good work guys ;)
>
> Alex
>
>
> _______________________________________________
> wxruby-users mailing list
> wxruby-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/wxruby-users
Alex Speller wrote:> I''ve gone through most of the controls on the docs index page, and > have come up with these changes: >... Thanks very much for the fixes. I''ve applied those to SVN and also added a few other classes that are now available in wxruby2 eg HtmlWindow, PrintDialog. I''ll put a release out shortly with these fixes in.> I''ve been meaning to write some > kind of wxSugar intro / tutorial, simply because it seems so much > easier to pick up if you''re used to ruby syntax. >Glad to hear it''s doing what it''s meant to do... I think an intro would be very welcome. It''s on my todo list but stabilising the core wxruby2 is our priority for now alex
Alex Speller wrote:> Is this not there for a reason (i.e. just creating windows on their > own is a "bad thing")? I''ve just been using them as an area to draw onA lot of WxWidgets/WxPython code uses Panels rather than Windows to draw on. I think there is a reason for this but I don''t know what it is... alex
Reasonably Related Threads
- [764] trunk/wxsugar/lib/wx_sugar/keyword_classes.rb: Correct duplicate and incorrect definition of SpinCtrl constructor
- (no subject)
- [770] trunk/wxsugar/lib/wx_sugar/keyword_classes.rb: Fix some broken ones (Alex Spelling), add some new & missing ones; add
- [836] trunk/wxsugar/lib/wx_sugar: Make :validator and :name sugary ctor args work for Controls classes
- Next swig problem