下面是wxPython的一個偉大的教程(我選擇的GUI API:非常強大,良好的社區/郵件列表,以及跨平臺(它包裝本機平臺的部件))
http://wiki.wxpython.org/Getting%20Started
http://downloads.sourceforge.net/wxpython/wxPython2.8-win32-unicode-2.8.10.1-py26.exe或
http://downloads.sourceforge.net/wxpython/wxPython2.8-win32-unicode-2.8.10.1-py25.exe
:安裝wxPython的,可以通過簡單的setup.exe進行
(取決於python版本)
下面是一個簡單的hello世界,一個簡單的事件綁定到按鈕。
import wx
class MyFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None)
text = wx.StaticText(self, label="hello, world!")
button = wx.Button(self, label="press me")
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(text, flag=wx.ALL, border=20)
sizer.Add(button, flag=wx.ALL, border=20)
self.SetSizer(sizer)
self.Layout()
self.Show(True)
self.Bind(wx.EVT_BUTTON, self.on_button, button)
def on_button(self, event):
wx.MessageBox("Hey!")
if __name__ == "__main__":
app = wx.App(False)
f = MyFrame()
,或者甚至更簡單的例子:
import wx
app = wx.PySimpleApp()
frame = wx.Frame(None, wx.ID_ANY, "Hello World")
frame.Show(True)
app.MainLoop()
app.MainLoop()