Foros del Web » Programando para Internet » Python »

ayuda MDIChildFrame

Estas en el tema de ayuda MDIChildFrame en el foro de Python en Foros del Web. hola me sale un error cuando le pongo nuevo a mi aplicacion Traceback (most recent call last): File "C:\Python25\w-xprog.py", line 49, in OnNuev new = ...
  #1 (permalink)  
Antiguo 30/12/2008, 17:28
 
Fecha de Ingreso: mayo-2008
Mensajes: 499
Antigüedad: 15 años, 11 meses
Puntos: 1
Pregunta ayuda MDIChildFrame

hola me sale un error cuando le pongo nuevo a mi aplicacion

Traceback (most recent call last):
File "C:\Python25\w-xprog.py", line 49, in OnNuev
new = wx.MDIChildFrame(self)
File "C:\Python25\lib\site-packages\wx-2.8-msw-ansi\wx\_windows.py", line 3303, in __init__
_windows_.MDIChildFrame_swiginit(self,_windows_.ne w_MDIChildFrame(*args, **kwargs))
TypeError: in method 'new_MDIChildFrame', expected argument 1 of type 'wxMDIParentFrame *'


mi codigo es este tambien no sale el boton de cerrar al MiniFrame

Código python:
Ver original
  1. # serie de nero 1A20-020E-0000-1349-1210-6697
  2.  
  3. import wx
  4. ID_TOOL = 1
  5. class prog(wx.MDIParentFrame):
  6.     def __init__(self, parent, id, title):
  7.         wx.Frame.__init__(self, parent, id, title, size=(500, 620))
  8. #menu
  9.         menubar = wx.MenuBar()
  10.         file = wx.Menu()
  11.         file.Append(10, '&Nuevo\tCtrl+N', 'Nuevo Archivo')
  12.         file.AppendSeparator()
  13.         file.Append(11, '&Salir\tCtrl+S', 'Salir del programa')
  14.         ver = wx.Menu()
  15.         self. shst = ver.Append(ID_TOOL, 'herramientas\tCtrl+T', 'Show Toolbox', kind=wx.ITEM_CHECK)
  16.         ver.Check(ID_TOOL, True)
  17.        
  18.         help = wx.Menu()
  19.         help.Append(20, 'A&yuda\tCtrl+H', 'ayuda' )
  20.        
  21.         menubar.Append(file, "&Archivo")
  22.         menubar.Append(ver, "V&er")
  23.         menubar.Append(help, 'A&yuda')
  24.         self.SetMenuBar(menubar)
  25. #erramientas
  26.         toolbar = wx.ToolBar(self)
  27.         toolbar.AddLabelTool(wx.ID_ANY, 'Nuevo', wx.Bitmap('icns/Nuevo.png'))
  28.         toolbar.AddLabelTool(wx.ID_ANY, '', wx.Bitmap('icns/Guardar.png'))
  29.         toolbar.AddLabelTool(wx.ID_ANY, '', wx.Bitmap('icns/Abrir.png'))
  30.         toolbar.AddLabelTool(wx.ID_ANY, '', wx.Bitmap('icns/Cortar.png'))
  31.         toolbar.Realize()
  32.        
  33. #Eventos
  34.         self.Bind(wx.EVT_MENU, self.OnNuev, id=10)
  35.         self.Bind(wx.EVT_MENU, self.OnSalir, id=11)
  36.         self.Bind(wx.EVT_MENU, self.ToogleTool, id=ID_TOOL)
  37.         self.Bind(wx.EVT_MENU, self.OnDial, id=20)
  38. #mostrar
  39.         self.Centre()
  40.         self.CreateStatusBar()
  41.         self.Show(True)
  42.  
  43.    
  44.         self.mini = wx.MiniFrame(self, -1, "ToolBox", size=(130, 230))
  45.         self.pnl = wx.Panel(self.mini)
  46.  
  47.  
  48.     def OnNuev(self, evt):
  49.         new = wx.MDIChildFrame(self)
  50.         new.Show(True)
  51.        
  52.     def OnSalir(self, event):
  53.         self.Close()
  54.        
  55.     def OnDial(self, event):
  56.         dial = wx.Dialog(self)
  57.         dial.Show(True)
  58.  
  59.     def ToogleTool(self, event):
  60.         if self.shst.IsChecked():
  61.             self.mini.Show()
  62.         else:
  63.             self.mini.Hide()
  64.  
  65. app = wx.App()
  66. prog(None, -1, 'Mi aplicacion #1')
  67. app.MainLoop()
  #2 (permalink)  
Antiguo 31/12/2008, 16:18
AlvaroG
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: ayuda MDIChildFrame

Hola iozk,
Antes que nada permíteme decirte que si la primera línea del programa es lo que parece ser, por favor borrala.

Segundo, la llamada a la función se 'queja' de que no le pasaste un objeto de tipo wxMDIParentFrame. Para probar agregué un
Código python:
Ver original
  1. print self
como primera línea del método OnNuev. La salida fue
Código:
<__main__.prog; proxy of <Swig Object of type 'wxFrame *' at 0x83b1be8> >
Lo cual indica que el objeto es de tipo wxFrame, no wxMDIParentFrame. Ahora, más allá de que puede que uno sea hijo del otro, esto no está del todo bien.

Noté que la línea 7 hace una inicialización de un objeto wxFrame, así que, por probar, cambié esa línea por:
Código python:
Ver original
  1. wx.MDIParentFrame.__init__(self, parent, id, title, size=(500, 620))

Quizás tuve suerte, perfectamente podría no haber funcionado.
Pero lo cierto es que ahora funciona, crea la nueva pestaña y no devuelve ningún error al hacerlo.


Saludos
  #3 (permalink)  
Antiguo 01/01/2009, 14:48
 
Fecha de Ingreso: mayo-2008
Mensajes: 499
Antigüedad: 15 años, 11 meses
Puntos: 1
Respuesta: ayuda MDIChildFrame

le pongo un panel al MDIParentFrame y el MDICildFrame lo borra

como lo hago para que no lo borre?
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:42.