Try Wxpython for a while and try to pyqt to see if the two are better. Online praise PyQt Many, should also not groundless, I saw a few pyqt demo, indeed very powerful, although wxpython is not bad. The more important reason is that wxwidgets the MFC message mechanism in Python seems a bit cumbersome, want to try Qt signal-slot way.
First, MDI-PYQT Demo
1. main window inherits from Qtgui.qmainwindow
2. Initialization process __init__ (self):
2.1 Code
Super (MainWindow, self). __init__ ()
Self.mdiarea = Qtgui.qmdiarea ()
Self.mdiArea.setHorizontalScrollBarPolicy (QtCore.Qt.ScrollBarAsNeeded)
Self.mdiArea.setVerticalScrollBarPolicy (QtCore.Qt.ScrollBarAsNeeded)
self.setcentralwidget (Self.mdiarea)
The middle two long lines of code are clearly set when the sliding rails appear. In addition, we see the model of the QT MDI, create an MDI area first, then set the central component of the main window as it.
2.2 Code
Self.mdiArea.subWindowActivated.connect (self.updatemenus)
self.windowmapper = Qtcore.qsignalmapper (self)
Self.windowmapper.mapped[qtgui.qwidget].connect (Self.setactivesubwindow)
First line: Triggers the updatemenus operation when the child window is activated.
Second line: Creating a signal Mapper
Third line: The binding signal is mapped to the Setactivesubwindow function, and the parameter passed into the function is the Qtgui.qwidget type.
Additional Instructions:
Action.triggered.connect (Self.windowMapper.map)
self.windowMapper.setMapping (Action, window)
Where the action is a menu item and window is a child window object. When you click on a menu item trigger action, the trigger itself is taken as a key value, and the value is searched for value in Windowmapper.map, which is the Windows Object window (SetMapping (Action, window) Bind the two to a dictionary, and then pass the window value into the Setactivesubwindow of the unified processing function that is bound by the mapper.
3. Add child windows
Child = MDIChild ()
Self.mdiArea.addSubWindow (child)
4. Get a list of child windows
Windows = Self.mdiArea.subWindowList ()
5. Add menu items
Self.filemenu = Self.menubar (). AddMenu ("&file")
self.fileMenu.addAction (self.newact)
Self.fileMenu.addAction (self.openact)
self.fileMenu.addAction (self.saveact)
self.fileMenu.addAction ( Self.saveasact)
Self.fileMenu.addSeparator ()
The Menu subkey is:
Self.newact = Qtgui.qaction (Qtgui.qicon (':/images/new.png '), "&new",
Self, shortcut=qtgui.qkeysequence.new ,
statustip= "Create A new file", Triggered=self.newfile)