import os import sys import wx class TopPanel(wx.Panel) : def __init__(self, parent, *args, **kwargs) : wx.Panel.__init__(self, parent, wx.ID_ANY) button1 = wx.Button(self, wx.ID_ANY, 'button1', name='button1') button2 = wx.Button(self, wx.ID_ANY, 'button2', name='button2') layout = wx.BoxSizer(wx.VERTICAL) layout.Add(button1, 1, flag=wx.EXPAND) layout.Add(button2, 1, flag=wx.EXPAND) self.SetSizer(layout) self.Bind(wx.EVT_BUTTON, self.onButton) def onButton(self, event) : buttonObject = event.GetEventObject() print ("pushed: ", buttonObject.GetName()) class MainFrame(wx.Frame) : def __init__(self) : super().__init__(None, title="exFrame") topPanel = TopPanel(self) layout = wx.BoxSizer(wx.VERTICAL) layout.Add(topPanel, 1, flag=wx.EXPAND) self.SetSizer(layout) self.SetSize(500,500) self.SetMinSize((100, 100)) self.Center(wx.BOTH) self.Show() def main() : app = wx.App() MainFrame() app.MainLoop() return if __name__ == '__main__' : main()