Ejemplo n.º 1
0
func main() {
	runtime.GOMAXPROCS(4)

	app := wx.NewWxGoApp()

	frame := wx.NewWxFrame(wx.NullWindow(), -1, "Drawing")

	wx.BindPaintEvent(frame, func(event wx.WxPaintEvent) {
		pdc := wx.NewWxPaintDC(frame)
		pdc.DrawLine(10, 10, 50, 50+times%100)
		times += 1
		fmt.Printf("times: %d", times)
		wx.DeleteWxPaintDC(pdc)
	})

	frame.Show(true)

	app.MainLoop()
}
Ejemplo n.º 2
0
func main() {
	runtime.GOMAXPROCS(4)

	app := wx.NewWxGoApp()

	frame := wx.NewWxFrame(wx.NullWindow(), -1, "Minimal wxGo App")

	fileMenu := wx.NewWxMenu()
	fileMenu.Append(wx.WxID_EXIT, "E&xit\tAlt-X", "Quit this program")

	helpMenu := wx.NewWxMenu()
	helpMenu.Append(wx.WxID_ABOUT, "&About...\tF1", "Show about dialog")

	menuBar := wx.NewWxMenuBar()
	menuBar.Append(fileMenu, "&File")
	menuBar.Append(helpMenu, "&Help")

	wx.BindMenuEvent(frame, wx.WxID_ABOUT, func(event wx.WxEvent) {
		fmt.Printf("About Called")
		wx.WxMessageBox(fmt.Sprintf("Welcome to wxGo!\n\nThis is the minimal wxGo sample\nrunning under %s.",
			wx.WxGetOsDescription()),
			"About wxGo minimal sample\n",
			wx.WxOK|wx.WxICON_INFORMATION,
			frame)
	})

	wx.BindMenuEvent(frame, wx.WxID_EXIT, func(event wx.WxEvent) {
		frame.Close()
	})

	frame.SetMenuBar(menuBar)

	frame.CreateStatusBar(2)
	frame.SetStatusText("Welcome to wxGo!")

	frame.Show(true)

	app.MainLoop()
}