# Questions on multiple windows in Glade

**URL:** <https://www.ruby-forum.com/t/questions-on-multiple-windows-in-glade/131638>\
**Category:** Ruby-Gnome 2\
**Created:** [March 12, 2008, 2:42am UTC](https://www.ruby-forum.com/t/questions-on-multiple-windows-in-glade/131638 "2008-03-12T02:42:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shinwoo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/df705f/32.png) [@shinwoo](https://www.ruby-forum.com/u/shinwoo)\
**Post date:** [March 12, 2008, 2:42am UTC](https://www.ruby-forum.com/t/questions-on-multiple-windows-in-glade/131638/1 "2008-03-12T02:42:19Z")

</div>

I created a glade file with multiple windows. When the glade launch, it  
will shows all the windows and this is not desire by me. Currently, I  
set others windows’ visibility to false and set it to true when needed.  
I just start using glade for creating user’s interface. Previously I  
just using coding the generate all the UI. I have a small utility with 2  
windows. Using glade can save me 100+ lines of code and I still can  
alter the UI without touching my code and this is great for me. But  
there are some problems for me to use glade.

So, how do I:

1. Initialize the windows only when I needed? I don’t want to initialize  
all the windows when the program start. Is there any equivalent methods  
to @glade[‘some\_window’].new to initialize the windows?

2. This question is related to the first question. After I close the  
window, the window will call the destroy function and destroy it self  
and set to nil. So, I am using the ‘delete-event’ signal to prevent it  
to destroy and set it to invisible. So, how do I reinitialize a window  
in glade after the window being destroy?

Thanks in advance.

Regards,  
Shin Guey

---

<div class="post-metadata">

**Author:** ![shinwoo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/df705f/32.png) [@shinwoo](https://www.ruby-forum.com/u/shinwoo)\
**Post date:** [March 12, 2008, 5:16pm UTC](https://www.ruby-forum.com/t/questions-on-multiple-windows-in-glade/131638/2 "2008-03-12T17:16:51Z")

</div>

Am Mittwoch, den 12.03.2008, 02:42 +0100 schrieb Shin guey Wong:

> 1. Initialize the windows only when I needed? I don’t want to initialize  
> all the windows when the program start. Is there any equivalent methods  
> to @glade[‘some\_window’].new to initialize the windows?

Hi,

the simpest way is to put every window / dialog in its own glade file.

If you want all your windows /dialogs in a single file (i can not  
recommend it, if the project gets bigger) you can process single windows  
like this:

@glade = GladeXML.new(@glade\_file, ‘main\_window’)

That will pharse @glade\_file to the point, where it finds main\_window  
and will only show this window. But be aware, that this does not work  
with the stable version, cause there is a bug in it.

> 1. This question is related to the first question. After I close the  
> window, the window will call the destroy function and destroy it self  
> and set to nil. So, I am using the ‘delete-event’ signal to prevent it  
> to destroy and set it to invisible. So, how do I reinitialize a window  
> in glade after the window being destroy?

To show the window again just recall the glade command from above.

Cheers, detlef

---

<div class="post-metadata">

**Author:** ![shinwoo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/df705f/32.png) [@shinwoo](https://www.ruby-forum.com/u/shinwoo)\
**Post date:** [March 13, 2008, 3:42am UTC](https://www.ruby-forum.com/t/questions-on-multiple-windows-in-glade/131638/3 "2008-03-13T03:42:44Z")

</div>

Detlef R. wrote:

> Am Mittwoch, den 12.03.2008, 02:42 +0100 schrieb Shin guey Wong:
> 
> Cheers, detlef

Thanks for the advice! It works great now. 😉  
I will split to different glade file in future. Currently I only have a  
main windows and another dialog windows which contains few widget only,  
so I put all them in a single glade file. Anyway, thanks again.

Regards,  
Shin Guey
