我有这个编译的WxWidgets测试源代码,在运行时,它显示了一个简单的框架:
/*
* hworld.cpp
* Hello world sample by Robert Roebling
*/
#include "wx-2.8/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()
};
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( _T("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, _T("&About...") );
menuFile->AppendSeparator();
menuFile->Append( ID_Quit, _T("E&xit") );
wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append( menuFile, _T("&File") );
SetMenuBar( menuBar );
CreateStatusBar();
SetStatusText( _T("Welcome to wxWindows!") );
}
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
wxMessageBox(_T("This is a wxWindows Hello world sample"),
_T("About Hello World"), wxOK | wxICON_INFORMATION, this);
}
使用这个简单的SCons脚本创建:
env = Environment()
env.ParseConfig('wx-config --cxxflags --libs')
env.Program(target='wxTest/wxTest.exe',source=['src/Wxwidgets.cpp'])
问题:当我运行它时它不会集中注意力。我唯一能关注的是左上角的红色,黄色和绿色按钮。 我使用Eclipse作为我的IDE,并在构建它时将scons作为外部工具运行。
那里有人知道我做错了什么吗?如何让框架聚焦?
希望有人可以帮助我。
答案 0 :(得分:4)
我假设您启动了创建的原始可执行文件?这在Mac OS X上不起作用,请参阅My app can't be brought to the front!
您必须为您的应用创建一个应用程序包才能在Mac OS X上正常运行。我对SCons一无所知,但wiki可能有帮助吗?