[pygtk] Close/hide a child window

Chris Cole ccole2 at mix.wvu.edu
Sat Jun 30 15:13:17 WST 2007


Cubells,
here would be an acceptable second.py with minimal changes made:

#/usr/bin/env python
# -*- coding: utf-8 -*-

import pygtk
pygtk.require('2.0')
import gtk

class second(gtk.Window):

   def close_second(self,widget):
       self.window2.destroy()


   def __init__(self, parent=None):
       gtk.Window.__init__(self)
       try:
           self.set_screen(parent.get_screen())
       except:
           self.connect("destroy", lambda *w: gtk.main_quit())
       self.window2 = gtk.Window(gtk.WINDOW_TOPLEVEL)
       self.window2.set_title("Second")
       self.window2.set_border_width(10)
       self.window2.set_modal(True)
       self.window2.set_resizable(False)
       button2 = gtk.Button("Second")
       button2.connect("clicked", self.close_second)
       self.window2.add(button2)
       self.window2.show_all()

def main():
   gtk.main()
   return 0



More information about the pygtk mailing list