# A problem when init Gtk::Dialog

**URL:** <https://www.ruby-forum.com/t/a-problem-when-init-gtk-dialog/234883>\
**Category:** Ruby-Gnome 2\
**Created:** [January 7, 2015, 8:58am UTC](https://www.ruby-forum.com/t/a-problem-when-init-gtk-dialog/234883 "2015-01-07T08:58:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alcina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@alcina](https://www.ruby-forum.com/u/alcina)\
**Post date:** [January 7, 2015, 8:58am UTC](https://www.ruby-forum.com/t/a-problem-when-init-gtk-dialog/234883/1 "2015-01-07T08:58:02Z")

</div>

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:🎏: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:🎏: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?

---

<div class="post-metadata">

**Author:** ![africwildman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e95f7d/32.png) [@africwildman](https://www.ruby-forum.com/u/africwildman)\
**Post date:** [January 7, 2015, 9:54am UTC](https://www.ruby-forum.com/t/a-problem-when-init-gtk-dialog/234883/2 "2015-01-07T09:54:58Z")

</div>

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:🎏: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

---

<div class="post-metadata">

**Author:** ![africwildman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e95f7d/32.png) [@africwildman](https://www.ruby-forum.com/u/africwildman)\
**Post date:** [January 11, 2015, 2:51am UTC](https://www.ruby-forum.com/t/a-problem-when-init-gtk-dialog/234883/3 "2015-01-11T02:51:50Z")

</div>

thank you very much! i’ll try later.

---

<div class="post-metadata">

**Author:** ![africwildman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e95f7d/32.png) [@africwildman](https://www.ruby-forum.com/u/africwildman)\
**Post date:** [March 27, 2015, 9:53pm UTC](https://www.ruby-forum.com/t/a-problem-when-init-gtk-dialog/234883/4 "2015-03-27T21:53:51Z")

</div>

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