I can''t construct a Wx::Font object, because it leads to a Runtime Error, though it seems that I use it as per documentation of WxRuby. Strangely, many mistakes lead to such an error instead of a verbose Ruby exception :( Could you please help me with this? Thanks a lot in advance. Please see the sample code below. ===================require ''wx'' class TestFrame < Wx::Frame def initialize() super(nil, -1, "CMD") Wx::Font.new(12, Wx::Font::FONTFAMILY_DECORATIVE) end end class TestApp < Wx::App def on_init TestFrame.new().show() end end TestApp.new.main_loop =================== Enviroment: Windows XP SP-2 Ruby 1.8.6 WxRuby 1.9.8 _______________________________________________ wxruby-users mailing list wxruby-users@rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users
?????? ????????? wrote:> Wx::Font.new(12, Wx::Font::FONTFAMILY_DECORATIVE)Try replacing that line with: Wx::Font.new(12, Wx::FONTFAMILY_DECORATIVE, Wx::FONTSTYLE_NORMAL, Wx::FONTWEIGHT_NORMAL) - andreas -- Posted via http://www.ruby-forum.com/.
Кирилл Лиходедов
2008-Oct-13 13:31 UTC
[wxruby-users] Wx::Font.new fails in a Runtime Error
That worked (but why? Aren''t there default values for the rest of the parameters?), but setting this font as the default style of TextCtrl leads to the same error: text = Wx::TextCtrl.new(self, -1, "text", :style => Wx::TE_RICH|Wx::TE_RICH2|Wx::TE_PROCESS_ENTER|Wx::TE_PROCESS_TAB) font = Wx::Font.new(12, Wx::FONTFAMILY_DECORATIVE, Wx::FONTSTYLE_NORMAL, Wx::FONTWEIGHT_NORMAL) text.set_default_style(Wx::TextAttr.new(font)) #This leads to error By the way, why is it a Runtime threatening error, not an exception? 2008/10/13 Andreas Garn?s <lists at ruby-forum.com>> ?????? ????????? wrote: > > Wx::Font.new(12, Wx::Font::FONTFAMILY_DECORATIVE) > > Try replacing that line with: > > Wx::Font.new(12, Wx::FONTFAMILY_DECORATIVE, Wx::FONTSTYLE_NORMAL, > Wx::FONTWEIGHT_NORMAL) > > - andreas > -- > Posted via http://www.ruby-forum.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: <http://rubyforge.org/pipermail/wxruby-users/attachments/20081013/ccc60947/attachment.html>
Кирилл Лиходедов
2008-Oct-13 13:36 UTC
[wxruby-users] Wx::Font.new fails in a Runtime Error
Oops, sorry, that should be text.set_default_style(Wx::TextAttr.new(Wx::BLACK, Wx::WHITE, font)) OK, I understand, it works now, thanks for the hint! But the main problem still exists: it is very hard to determine when you use wrong or incomplete method signature, when it just silently fails.Is it some configuration problem of mine or it is WxRuby feature? 2008/10/13 ?????? ????????? <kirill.likhodedov at gmail.com>> > That worked (but why? Aren''t there default values for the rest of the > parameters?), but setting this font as the default style of TextCtrl leads > to the same error: > text = Wx::TextCtrl.new(self, -1, "text", :style => > Wx::TE_RICH|Wx::TE_RICH2|Wx::TE_PROCESS_ENTER|Wx::TE_PROCESS_TAB) > font = Wx::Font.new(12, > Wx::FONTFAMILY_DECORATIVE, Wx::FONTSTYLE_NORMAL, Wx::FONTWEIGHT_NORMAL) > text.set_default_style(Wx::TextAttr.new(font)) #This leads to error > > By the way, why is it a Runtime threatening error, not an exception? > > 2008/10/13 Andreas Garn?s <lists at ruby-forum.com> > > ?????? ????????? wrote: >> > Wx::Font.new(12, Wx::Font::FONTFAMILY_DECORATIVE) >> >> Try replacing that line with: >> >> Wx::Font.new(12, Wx::FONTFAMILY_DECORATIVE, Wx::FONTSTYLE_NORMAL, >> Wx::FONTWEIGHT_NORMAL) >> >> - andreas >> -- >> Posted via http://www.ruby-forum.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: <http://rubyforge.org/pipermail/wxruby-users/attachments/20081013/9e1c4320/attachment.html>
?????? ????????? wrote:> Oops, sorry, that should be > text.set_default_style(Wx::TextAttr.new(Wx::BLACK, > Wx::WHITE, font)) > > OK, I understand, it works now, thanks for the hint! > > But the main problem still exists: it is very hard to determine when you > use > wrong or incomplete method signature, when it just silently fails.Is it > some > configuration problem of mine or it is WxRuby feature? > > 2008/10/13 ?????? ????????? <kirill.likhodedov at gmail.com>I guess you just have to read the documentation very carefully. I get significantly better error messages on Ubuntu, however, eg:> Wx::Font.new(20)ArgumentError: Wrong arguments for overloaded method ''wxFont.new''. Possible C/C++ prototypes are: wxFont.new() wxFont.new(int pointSize, int family, int style, int weight, bool const underline, wxString const &faceName, wxFontEncoding encoding) -- Posted via http://www.ruby-forum.com/.
Кирилл Лиходедов
2008-Oct-14 07:28 UTC
[wxruby-users] Wx::Font.new fails in a Runtime Error
Andreas, you definitely have much more descriptive messages.It looks like a problem of Windows version WxRuby, because Ruby itself doesn''t have these problems. Does anybody know if anything can be done with it, maybe in future releases? 2008/10/13 Andreas Garn?s <lists at ruby-forum.com>> ?????? ????????? wrote: > > Oops, sorry, that should be > > text.set_default_style(Wx::TextAttr.new(Wx::BLACK, > > Wx::WHITE, font)) > > > > OK, I understand, it works now, thanks for the hint! > > > > But the main problem still exists: it is very hard to determine when you > > use > > wrong or incomplete method signature, when it just silently fails.Is it > > some > > configuration problem of mine or it is WxRuby feature? > > > > 2008/10/13 ?????? ????????? <kirill.likhodedov at gmail.com> > > I guess you just have to read the documentation very carefully. I get > significantly better error messages on Ubuntu, however, eg: > > > Wx::Font.new(20) > ArgumentError: Wrong arguments for overloaded method ''wxFont.new''. > Possible C/C++ prototypes are: > wxFont.new() > wxFont.new(int pointSize, int family, int style, int weight, bool > const underline, wxString const &faceName, wxFontEncoding encoding) > -- > Posted via http://www.ruby-forum.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: <http://rubyforge.org/pipermail/wxruby-users/attachments/20081014/0cbe4489/attachment.html>
?????? ????????? wrote:> > Andreas, you definitely have much more descriptive messages. > It looks like a problem of Windows version WxRuby, because Ruby itself > doesn''t have these problems. > > Does anybody know if anything can be done with it, maybe in future > releases?The quality of error messages related to wrong types of arguments was improved in recent versions of SWIG. I''ll double-check that the next windows build is done with the latest version. But when doing some development on Windows recently I had some similar problems - ie I was getting a segfault where it should be raising an exception. Which is pretty annoying b/c it''s hard to track these down. I''ll investigate further. cheers alex
Kirill Likhodedov
2008-Oct-25 20:48 UTC
[wxruby-users] Wx::Font.new fails in a Runtime Error
Thank you very much, Alex. That would be very great if the problem will be fixed or at least improved. :) 25.10.2008, ? 17:45, Alex Fenton ???????(?):> ?????? ????????? wrote: >> >> Andreas, you definitely have much more descriptive messages. >> It looks like a problem of Windows version WxRuby, because Ruby >> itself doesn''t have these problems. >> >> Does anybody know if anything can be done with it, maybe in future >> releases? > > The quality of error messages related to wrong types of arguments > was improved in recent versions of SWIG. I''ll double-check that the > next windows build is done with the latest version. > > But when doing some development on Windows recently I had some > similar problems - ie I was getting a segfault where it should be > raising an exception. Which is pretty annoying b/c it''s hard to > track these down. I''ll investigate further. > > cheers > alex > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users