Ver Mensaje Individual
  #2 (permalink)  
Antiguo 15/07/2011, 23:29
Avatar de razpeitia
razpeitia
Moderador
 
Fecha de Ingreso: marzo-2005
Ubicación: Monterrey, México
Mensajes: 7.321
Antigüedad: 19 años, 2 meses
Puntos: 1360
Respuesta: Destruir ventana desde otro modulo en wxpython

Entonces quieres crear una instancia de Frame2 en Frame1 y luego cerrar Frame1.

Algo mas o menos así.

Código Python:
Ver original
  1. import wx
  2.  
  3. class MyFrame1(wx.Frame):
  4.     def __init__(self):
  5.         wx.Frame.__init__(self, None, -1, "Frame1")
  6.         button = wx.Button(self, -1, "Frame2")
  7.        
  8.         button.Bind(wx.EVT_BUTTON, self.OnClick)
  9.         self.Bind(wx.EVT_MENU, self.OnExit)
  10.  
  11.     def OnClick(self,evt):
  12.         frame2 = MyFrame2()
  13.         frame2.Show()
  14.         self.Close()
  15.    
  16.     def OnExit(self, evt):
  17.         self.Close(True)
  18.  
  19. class MyFrame2(wx.Frame):
  20.     def __init__(self):
  21.         wx.Frame.__init__(self, None, -1, "Frame2")
  22.        
  23.     def OnExit(self, evt):
  24.         self.Close(True)
  25.  
  26. app = wx.PySimpleApp()
  27. frame1 = MyFrame1()
  28. frame1.Show()
  29.  
  30. app.MainLoop()