wxPython:
Código Python:
Ver original
import wx class Editor(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, size=(600, 500)) menubar = wx.MenuBar() file = wx.Menu() new = wx.MenuItem(file, 101, '&New\tCtrl+N', 'Creates a new document') file.AppendItem(new) menubar.Append(file, '&File') self.SetMenuBar(menubar) self.Bind(wx.EVT_MENU, self.NewApplication, id=101) self.text = wx.TextCtrl(self, 1000, '', size=(-1, -1), style=wx.TE_MULTILINE | wx.TE_PROCESS_ENTER) self.text.SetFocus() self.Bind(wx.EVT_CLOSE, self.QuitApplication) self.Centre() self.Show(True) def NewApplication(self, event): editor = Editor(None, -1, 'Editor') editor.Centre() editor.Show() def QuitApplication(self, event): self.Destroy() app = wx.App() Editor(None, -1, 'Editor') app.MainLoop()
PyQt4:
Código Python:
Ver original
import sys from PySide import QtGui, QtCore class Editor(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) self.setWindowTitle("Editor") self.resize(600, 500) new = QtGui.QAction("New", self) new.setShortcut("Ctrl+N") new.triggered.connect(self.NewApplication) menubar = self.menuBar() file = QtGui.QMenu("File", self) file.addAction(new) menubar.addMenu(file) self.setMenuBar(menubar) def NewApplication(self): e = Editor() e.show() app = QtGui.QApplication(sys.argv) e = Editor() e.show() 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.