|
Project Information
Members
Featured
Downloads
Wiki pages
|
WxPita is a a wrapper library for wxPython, which is itself a wrapper library for the wxWidgets cross-platform GUI framework. WxPita has two main goals:
By accomplishing these two goals, wxPita lets you write simpler, more maintainable GUI code. Let's take a look at a simple example:
The code for this example: from wxpita import *
import time
f = SizedFrame [
Button(name='btn1', label='Button 1'),
Button(name='btn2', label='Button 2'),
TextCtrl(name='textc', style='te_multiline', expand=True, proportion=1),
]
@f.btn1.button_clicked
@f.btn2.button_clicked
def _(evt):
text = 'You clicked on "%s" at %s\n' % (
evt.EventObject.GetLabel(), time.ctime())
f.textc.AppendText(text)
f.Show("A Simple WxPita Example", size=(400,250))Compare with the equivalent code, written using wxPython: import wx
import wxaddons.sized_controls as sc
import time
app = wx.PySimpleApp()
frame = sc.SizedFrame(None, title="A Simple WxPython Example")
panel = frame.GetContentsPane()
btn1 = wx.Button(panel, label='Button 1')
btn2 = wx.Button(panel, label='Button 2')
textc = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
textc.SetSizerProps(expand=True, proportion=1)
def onclick(evt):
text = 'You clicked on "%s" at %s\n' % (
evt.EventObject.GetLabel(), time.ctime())
textc.AppendText(text)
btn1.Bind(wx.EVT_BUTTON, onclick)
btn2.Bind(wx.EVT_BUTTON, onclick)
frame.Show()
app.MainLoop()
|