Computer Aided Automation

Full Version: GUI button in Python - wxpython sample
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
import  wx


class TestPanel(wx.Panel):
    def __init__(self, parent, log):
        wx.Panel.__init__(self, parent, -1,
        self.log = log

        b = wx.Button(self, 10, "Default Button", (20, 20))
        self.Bind(wx.EVT_BUTTON, self.OnClick, b)


        #b = wx.Button(self, 60, "Multi-line\nbutton", (20, 280))
        #b = wx.Button(self, 70, pos=(160, 280))
    def OnClick(self, event):
        self.log.write("Click! (%d)\n" % event.GetId())


def runTest(frame, nb, log):
    win = TestPanel(nb, log)
    return win


overview = """<html><body>

A button is a control that contains a text string or a bitmap and can be
placed on nearly any kind of window.


if __name__ == '__main__':
    import sys,os
    import run
    run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])