WxPython

From Wikipedia, the free encyclopedia

The correct title of this article is wxPython. The initial letter is shown capitalized due to technical restrictions.

wxPython is an implementation of the wxWidgets GUI API (often referred to as a 'toolkit') for the Python programming language. It is the main alternative to Tkinter, which is an implementation of the Tcl based Tk API.

[edit] Feature

wxPython uses widgets provided by the underlying operating system, and therefore provides a native look similar to other programs running on that particular platform. Tkinter, on the other hand, provides a uniform look on all platforms, because it draws its widgets from scratch using the graphics facilities.

[edit] Example

# -*- coding: utf-8 -*-

import wx

class TestFrame(wx.Frame):
    def __init__(self, parent, ID, title):
        wx.Frame.__init__(self, parent, -1, title, pos=(0, 0), size=(320, 240))
        panel = wx.Panel(self, -1)
        text = wx.StaticText(panel, -1, "Test", wx.Point(10, 5), wx.Size(-1, -1))

class TestApp(wx.App):
    def OnInit(self):
        frame = TestFrame(None, -1, "Hello, world!")
        self.SetTopWindow(frame)
        frame.Show(True)
        return True

if __name__ == '__main__':
    app = TestApp(0)
    app.MainLoop()

[edit] External links