HaHa, I know why this code is wrong, I should not add code like these:

showWindow :: IO()
showWindow = do
  initGUI

  window <- windowNew

  widgetShowAll window
  onDestroy window mainQuit
  mainGUI

The code with red are wrong!

2008/4/1, ˳ <knifewolf@gmail.com>:
Hi Peter,
  Thanks a lot! I will try to test this weekend when I come back home on my own computer under UBUNTU. Actually I think you are right, for when I test on my another loptap which the OS environment is WindowsXP, it popuped two window when I launch my program, the fisrt is a command line window, the second is the GUI window. After I close the command line window, the whole program stop. And the below is my test code:

import Graphics.UI.Gtk

main :: IO ()
main = do
  initGUI
  window <- windowNew
  set window [windowTitle := "Pix", containerBorderWidth := 10]
  button <- buttonNew
  onClicked button (showWindow)
  containerAdd window button
  widgetShowAll window
  onDestroy window mainQuit
  mainGUI

showWindow :: IO()
showWindow = do
  initGUI

  window <- windowNew

  widgetShowAll window
  onDestroy window mainQuit
  mainGUI


Message: 8
Date: Mon, 31 Mar 2008 19:55:28 +0200
From: Peter Hercek <phercek@gmail.com>
Subject: Re: [Gtk2hs-users] How to close all of the windows
To: gtk2hs-users@lists.sourceforge.net
Message-ID: <fsr8ii$kap$1@ger.gmane.org>
Content-Type: text/plain; charset=UTF-8; format=flowed

Did you try to call mainQuit in the onDestroy event of the main windows?
That should do it.

Peter.

?? wrote:
> Hi all,
>   This may be a simple question. I create a main window, which contains
> a button, after clicked the button, there will be show another window.
> But how can I implement such a function that is when I close the main
> window, all the other windows will also be closed? Thanks!
>
> --
> Deng Chao




------------------------------

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

------------------------------

_______________________________________________
Gtk2hs-users mailing list
Gtk2hs-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gtk2hs-users


End of Gtk2hs-users Digest, Vol 22, Issue 5
*******************************************



--
Deng Chao



--
Deng Chao