看板 LinuxDev 關於我們 聯絡資訊
打聽到了 linux wxWidget(gtk) 手工 build 的方法 g++ file.cpp `wx-config --libs --cxxflags` -o file 其中 wx-config --libs --cxxflags 等於 -I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread -pthread -lwx_gtk2u_aui-2.8 -lwx_gtk2u_xrc-2.8 -lwx_gtk2u_qa-2.8 -lwx_gtk2u_html-2.8 -lwx_gtk2u_adv-2.8 -lwx_gtk2u_core-2.8 -lwx_baseu_xml-2.8 -lwx_baseu_net-2.8 -lwx_baseu-2.8 但不知為何 在term下./wxhello GUI確實出現 但滑鼠點選不能執行 糟糕 哪位先進指點一下吧 code如下(應該沒問題) #include "wx/wx.h" class MyApp: public wxApp{ virtual bool OnInit(); }; class MyFrame: public wxFrame{ public: MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size); void OnQuit(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); DECLARE_EVENT_TABLE() /// ????? why not ';' }; enum{ ID_Quit=1, ID_About, }; BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(ID_Quit, MyFrame::OnQuit) EVT_MENU(ID_About, MyFrame::OnAbout) END_EVENT_TABLE() IMPLEMENT_APP(MyApp) bool MyApp::OnInit(){ MyFrame *frame=new MyFrame("Hello World", wxPoint(50, 50), wxSize(450, 340)); frame->Show(TRUE); SetTopWindow(frame); return TRUE; } MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size):wxFrame((wxFrame*)NULL, -1, title, pos, size){ wxMenu *menuFile=new wxMenu; menuFile->Append(ID_About, "&About..."); menuFile->AppendSeparator(); menuFile->Append(ID_Quit, "E&xit"); wxMenuBar *menuBar=new wxMenuBar; menuBar->Append(menuFile, "&File"); SetMenuBar(menuBar); CreateStatusBar(); SetStatusText("Welcome To wxWidget!"); } void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)){ Close(TRUE); } void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)){ wxMessageBox("This is an wxWidgets Hello world sample", "About hello ", wxOK|wxICON_INFORMATION, this); } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 125.225.115.200
yhuiyang:這 code 看起來沒什麼問題。你說的滑鼠點選不能執行意思 06/02 10:07
yhuiyang:是說點了X、點了menu bar的about或exit都沒反應? 06/02 10:09
yhuiyang:還是說只能由console keyin command, 滑鼠點選icon無用? 06/02 10:11
aguai:是我自己build wx時 ./configure沒下好參數 Orz 06/14 07:36