教程:
http://zetcode.com/tutorials/wxwidgetstutorial/
http://www.wxwidgets.org/docs/tutorials.htm
OS: Ubuntu 8.04,
compiler:g++ 4.2.4
1、安装wxgtk开发包
sudo aptitude install libwxgtk2.8-dev
2、编辑源代码
// basic.h
#ifndef BASIC_H
#define BASIC_H
class BasicApplication : public wxApp
{
public:
virtual bool OnInit();
};
class BasicFrame : public wxFrame
{
public:
BasicFrame( const wxChar *title, int xpos, int ypos,
int width, int height);
~BasicFrame();
};
#endif
// basic.cpp
#include <wx/wx.h>
#include "basic.h"
IMPLEMENT_APP(BasicApplication)
bool BasicApplication::OnInit()
{
BasicFrame *frame = new BasicFrame((wxChar *)"Basic", 50, 50, 450, 300);
frame->Show(TRUE);
SetTopWindow(frame);
return TRUE;
}
BasicFrame::BasicFrame (const wxChar *title,
int xpos,
int ypos,
int width,
int height)
: wxFrame ( (wxFrame *) NULL,
-1,
title,
wxPoint(xpos, ypos),
wxSize(width, height) )
{
}
BasicFrame::~BasicFrame()
{
}
3、编译
g++ -Wall -g `wx-config --cflags --libs` basic.cpp -o basic
4、运行
./basic