Forum: Ruby-Gnome 2 a problem when init Gtk::Dialog

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
900521af6978ad3cd073c6634b3ab84b?d=identicon&s=25 Tian Ruiguo (africwildman)
on 2015-01-07 08:58
if write code like this:
#########
class LoginDialog < Gtk::Dialog
  def initliaze
    super
    show_all
  end
end
l=LoginDialog.new  :title=>"login",
  :parent=>nil,
  :flags=>Gtk::Dialog::Flags::MODAL,
  :buttons=>[[Gtk::Stock::OK,Gtk::ResponseType::OK],
                  [Gtk::Stock::CANCEL,Gtk::ResponseType::CANCEL]]
l.run
l.destroy
Gtk.main
##########
the code will work well.
when i init paramet in the class, write code like this:
##########
class LoginDialog < Gtk::Dialog
  def initliaze
    super  :title=>"login",
  :parent=>nil,
  :flags=>Gtk::Dialog::Flags::MODAL,
  :buttons=>[[Gtk::Stock::OK,Gtk::ResponseType::OK],
                  [Gtk::Stock::CANCEL,Gtk::ResponseType::CANCEL]]
    show_all
  end
end
l=LoginDialog.new
l.run
l.destroy
Gtk.main
##########
the class can't be init,why?
B985bf8029d396259f579c70f809269a?d=identicon&s=25 Simon Arnaud (sarnaud)
on 2015-01-07 09:54
None works for me.

From the docs, GtkDialog does not take a hash as options. Unless you use
type_register, which does not seem the case.

Here is a working example :

require 'gtk2'

class LoginDialog < Gtk::Dialog
  def initialize
    super  "Test Login Dialog",
      nil,
      Gtk::Dialog::Flags::MODAL,
      [Gtk::Stock::OK,Gtk::ResponseType::OK],
            [Gtk::Stock::CANCEL,Gtk::ResponseType::CANCEL]
    show_all
  end
end

l = LoginDialog.new

l.run
l.destroy
Gtk.main

NB : There is a typo in your 'initialize' also.

regards

Simon
900521af6978ad3cd073c6634b3ab84b?d=identicon&s=25 Tian Ruiguo (africwildman)
on 2015-01-11 02:51
thank you very much! i'll try later.
4828d528e2e46f7c8160c336eb332836?d=identicon&s=25 Robert Heiler (shevegen)
on 2015-03-27 21:53
Typo in "def initialize" is hard to spot - I also sometimes write "def
intialize".
This topic is locked and can not be replied to.