Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/02/2012, 17:56
samuelb1311
 
Fecha de Ingreso: diciembre-2011
Mensajes: 26
Antigüedad: 12 años, 4 meses
Puntos: 5
Pregunta Problema PyQt4

tengo un programa hecho en wxPython, y quiero tambien hacerlo en PyQt4, el problema es que no me abre la ventana desde la ventana principal, aqui les dejo los codigos espero me puedan ayudar.

wxPython:
Código Python:
Ver original
  1. import wx
  2.  
  3. class Editor(wx.Frame):
  4.     def __init__(self, parent, id, title):
  5.         wx.Frame.__init__(self, parent, id, title, size=(600, 500))
  6.  
  7.         menubar = wx.MenuBar()
  8.  
  9.         file = wx.Menu()
  10.         new = wx.MenuItem(file, 101, '&New\tCtrl+N', 'Creates a new document')
  11.         file.AppendItem(new)
  12.  
  13.         menubar.Append(file, '&File')
  14.         self.SetMenuBar(menubar)
  15.  
  16.         self.Bind(wx.EVT_MENU, self.NewApplication, id=101)
  17.  
  18.         self.text = wx.TextCtrl(self, 1000, '', size=(-1, -1), style=wx.TE_MULTILINE | wx.TE_PROCESS_ENTER)
  19.         self.text.SetFocus()
  20.  
  21.         self.Bind(wx.EVT_CLOSE, self.QuitApplication)
  22.  
  23.         self.Centre()
  24.         self.Show(True)
  25.  
  26.     def NewApplication(self, event):
  27.         editor = Editor(None, -1, 'Editor')
  28.         editor.Centre()
  29.         editor.Show()
  30.        
  31.     def QuitApplication(self, event):
  32.         self.Destroy()
  33.  
  34. app = wx.App()
  35. Editor(None, -1, 'Editor')
  36. app.MainLoop()

PyQt4:
Código Python:
Ver original
  1. import sys
  2. from PySide import QtGui, QtCore
  3.  
  4. class Editor(QtGui.QMainWindow):
  5.     def __init__(self):
  6.         QtGui.QMainWindow.__init__(self)
  7.        
  8.         self.setWindowTitle("Editor")
  9.         self.resize(600, 500)
  10.        
  11.         new = QtGui.QAction("New", self)
  12.         new.setShortcut("Ctrl+N")
  13.         new.triggered.connect(self.NewApplication)
  14.        
  15.         menubar = self.menuBar()
  16.         file = QtGui.QMenu("File", self)
  17.         file.addAction(new)
  18.         menubar.addMenu(file)
  19.        
  20.         self.setMenuBar(menubar)
  21.    
  22.     def NewApplication(self):
  23.         e = Editor()
  24.         e.show()
  25.  
  26. app = QtGui.QApplication(sys.argv)
  27. e = Editor()
  28. e.show()
  29. sys.exit(app.exec_())

el problema figura en que la ventana que tiene que crearse en PyQt4 se abre pero se vuelve a cerrar a diferencia de wxPython, espero me puedan ayudar.