1 2 3 4 5 | bool DemoApp::OnInit() { DemoFrame *frame = new DemoFrame("DeveloperWorks Demo"); frame->Show(true); return true; } |
1 2 3 4 5 6 7 8 | DemoFrame:emoFrame(const wxString& title) : wxFrame(NULL, wxID_ANY, title) { wxSizer *sizer = new wxBoxSizer(wxVERTICAL); this->SetSizer(sizer); wxButton *button = new wxButton(this, wxID_CLOSE, "Click Me"); sizer->Add(50, 50); sizer->Add(button, 0, wxALL, 50); } |
1 2 3 | void DemoFrame::OnButtonPress(wxCommandEvent& event) { Close(true); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #!/usr/bin/env python import wx class DemoApp(wx.App): def OnInit(self): frame = DemoFrame(parent=None, id=-1, title='DeveloperWorks') frame.Show() return True class DemoFrame(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title) sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(sizer) button = wx.Button(self, wx.ID_CLOSE, "Click Me") sizer.Add((50, 50)) sizer.Add(button, 0, wx.ALL, 50) self.Bind(wx.EVT_BUTTON, self.OnButtonClick) def OnButtonClick(self, event): self.Close(True) if __name__ == "__main__": app = DemoApp() app.MainLoop() |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | package MyFrame; use base 'Wx::Frame'; use Wx::Event qw(EVT_BUTTON); sub new { my $class = shift; my $self = $class->SUPER::new(undef, -1, 'Trying wxPerl', [-1, -1], [250, 200]); my $sizer = Wx::BoxSizer->new(wxVERTICAL); my $button = Wx::Button->new($self, -1, 'Click me!', [-1, -1], [-1, -1]); EVT_BUTTON($self, $button, \&OnButtonClick); $sizer->Add($button); $self->SetSizer($sizer); return $self; } sub OnButtonClick { my($self, $event) = @_; $self->SetTitle('You Did It'); } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |