A problem when init Gtk::Dialog

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?

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

thank you very much! i’ll try later.

Typo in “def initialize” is hard to spot - I also sometimes write “def
intialize”.