Hi there:

I have two simple classes in two diferent files:

$ cat first.py

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

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

import second

class first:

  def close_program(self, widget, data=None):
      gtk.main_quit()
      return False
  def open_second(self, widget):
      second_window = eval("second.second")(self)

  def __init__(self):
      window = gtk.Window(gtk.WINDOW_TOPLEVEL)
      window.connect("delete_event", self.close_program)
      window.set_title("First")
      window.set_border_width(10)
      button = gtk.Button("Open")
      button.connect("clicked", self.open_second)
      window.add(button)
      window.show_all()

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

if __name__ == "__main__":
  first()      main()


That's the second one:

$ cat second.py

#/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.hide()
      #self.destroy()
      #gtk.main_quit()
      return False

  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())
      window2 = gtk.Window(gtk.WINDOW_TOPLEVEL)
      window2.set_title("Second")
      window2.set_border_width(10)
      window2.set_modal(True)
      window2.set_resizable(False)
      button2 = gtk.Button("Second")
      button2.connect("clicked", self.close_second)
      window2.add(button2)
      window2.show_all()

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

if __name__ == "__main__":
  second()      main()

The question is simple:

How can I close/hide/destroy the second window without to destroy the first window when I click the button2?? When I close the second window it works, but when I click the button2 it doesn't.

A lot of thanks...
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to