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.
53d92b745872afea4142b50f1d7e6c83?d=identicon&s=25 Tian R. (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?
3f2958dc96a3c756fb1b584a302c80cd?d=identicon&s=25 Simon A. (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
53d92b745872afea4142b50f1d7e6c83?d=identicon&s=25 Tian R. (africwildman)
on 2015-01-11 02:51
thank you very much! i'll try later.
7e17d370dc95b48cd82944a62f1caf76?d=identicon&s=25 Robert H. (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.