Use wxpython gui framework
version newer than wxpython2.8 Use wxpython tp build python GUI
Basic document structure:

  • My Program
    • Layout
    • Resources
    • lib

main entrance

“”⇒ Note that you should write like this to make compiler know the file is the main entrance of the program:

if __name__=='__main__':
Create object. Initiate other classes(suggested) and enter MainLoop of the program.
import app
import Class
if __name__=='__main__':
    thisClass = Class.init()
    thisapp = app.App(...)

Class overwrite : app

“”⇒Do not forget to import module wx .Two functions that must be overloaded:

import wx
import mainFrame
class App(wx.App):
    def __init__(self,redirect=False,...):
    def OnInit(self):
        mainFrame = mainframe(parent=None,name='myprogram',...)
        self.SetTopWindow(mainFrame)   # Set top window of this app, do not forget it!
        ... # initiate parameters or load configurations here
        return True

Class overwrite: Main Frame

“”⇒The main frame that used to initiate your app. This is the basic frame of our program which must exits. You can put menus, panels and all other controls/windows in it.

import wx
from panel1 import p1
from panel2 import p2
import ...
class mainFrame(wx.Frame):  # overwrite original class "wx.Frame"
    def __init__(self,parent,...):
        wx.Frame.__init__(self,parent,-1,name,style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER & wx.MAXIMIZE_BOX))
        self.panel_1 = p1(self,-1,...)
        self.panel_2 = p2(self,-1,...)
    def setMenu(self):
        menuBar = wx.MenuBar()
        startmenu = wx.Menu() = startmenu.Append(wx.ID_ANY,'O&pen')  # append menu selections to menu and return menu items
        self.quit = startmenu.Append(wx.ID_EXIT,'&Quit')
        menuBar.Append(startmenu,'&Start')           # append menu to menubar
        self.Bind(wx.EVT_MENU,self.OnOpen,     # bind event handler to menu item
    # Other functions and event handlers.

Event Handlers

Richard Feynman

“everything that is living can be understood in terms of the jiggling and wiggling of atoms”.

and now, we want to watch atoms jiggling and wiggling.

X-rays, electrons, fluorescence light, the advances of photon sciences, together with computational modeling, are making this happen.