All Projects → dontpanic92 → Wxgo

dontpanic92 / Wxgo

Licence: other
Golang wxWidgets Wrapper

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Wxgo

Wxformbuilder
RAD tool for wxWidgets GUI design
Stars: ✭ 1,167 (+204.7%)
Mutual labels:  gui, wxwidgets
Wxwidgets
wxWidgets is a free and open source cross-platform C++ framework for writing advanced GUI applications using native controls.
Stars: ✭ 3,994 (+942.82%)
Mutual labels:  gui, wxwidgets
Phoenix
wxPython's Project Phoenix. A new implementation of wxPython, better, stronger, faster than he was before.
Stars: ✭ 1,698 (+343.34%)
Mutual labels:  gui, wxwidgets
Moneymanagerex
Money Manager Ex is an easy to use, money management application built with wxWidgets
Stars: ✭ 836 (+118.28%)
Mutual labels:  gui, wxwidgets
Wxphp
Build cross-platform software with rich native GUIs using the combined power of the PHP language and the wxWidgets library.
Stars: ✭ 328 (-14.36%)
Mutual labels:  gui, wxwidgets
Ghost
Ghost, a micro-kernel based hobby operating system for the x86 architecture.
Stars: ✭ 353 (-7.83%)
Mutual labels:  gui
Kondo
Save disk space by cleaning non-essential files from software projects.
Stars: ✭ 373 (-2.61%)
Mutual labels:  gui
Controlp5
A gui library for processing.org
Stars: ✭ 356 (-7.05%)
Mutual labels:  gui
Myra
UI Library for MonoGame, FNA and Stride
Stars: ✭ 348 (-9.14%)
Mutual labels:  gui
Nord Emacs
An arctic, north-bluish clean and elegant Emacs theme.
Stars: ✭ 379 (-1.04%)
Mutual labels:  gui
Wxsqlite3
wxSQLite3 - SQLite3 database wrapper for wxWidgets (including SQLite3 encryption extension)
Stars: ✭ 373 (-2.61%)
Mutual labels:  wxwidgets
Wattmangtk
A Wattman-like GTK3+ GUI
Stars: ✭ 368 (-3.92%)
Mutual labels:  gui
Interactive slam
Interactive Map Correction for 3D Graph SLAM
Stars: ✭ 372 (-2.87%)
Mutual labels:  gui
Ricochet
Anonymous peer-to-peer instant messaging
Stars: ✭ 3,570 (+832.11%)
Mutual labels:  gui
Sofi
an OS agnostic UI module for Python
Stars: ✭ 378 (-1.31%)
Mutual labels:  gui
Jqview
simplest possible native GUI for inspecting JSON objects with jq
Stars: ✭ 355 (-7.31%)
Mutual labels:  gui
Threepenny Gui
GUI framework that uses the web browser as a display.
Stars: ✭ 368 (-3.92%)
Mutual labels:  gui
Tgui
Cross-platform modern c++ GUI
Stars: ✭ 371 (-3.13%)
Mutual labels:  gui
Sqlectron Gui
A simple and lightweight SQL client desktop with cross database and platform support.
Stars: ✭ 3,852 (+905.74%)
Mutual labels:  gui
Unity Winforms
A Windows Forms port for Unity3d
Stars: ✭ 365 (-4.7%)
Mutual labels:  gui

wxGo

Golang wxWidgets Wrapper

Travis CI Build Status AppVeyor Build status

Not actively maintained

Please feel free to folk and make your changes. I'm still available through GitHub Issues for any questions.

Notes

For Golang 1.10.0 and 1.9.4, there is a "Invalid flag" issue which causes the build fails. Please check Here for workaround.

Compilation

Currently wxGo can compile and run on Windows, Linux and Mac OS X on amd64 architecture.

1. Requisites

  • 64-bit Go
  • GCC / MinGW ver > 5 for Linux / Windows
  • > 5GB Memory space

Remarks

32-bit go will run out of memory due to ~5GB memory consumption when compiling and I have no idea on how to decline the memory usage. Any suggestion or discussion will help.

The precompiled wxWidgets is compiled with gcc > 5 ( 6.2.1 on Linux, 5.3.0 on Windows using tdm-gcc). So if you want to use the precompiled wxWidgets, your gcc version has also to be > 5, because GCC changed its ABI since GCC 5 release series.

2. Build & Install

go get github.com/dontpanic92/wxGo/wx

You can add -x option to print each command it executes.

Custom Compilation

This section will introduce how to customize wxGo.

1. Compilation phases

wxGo needs a 2-phase compilation. The first is the SWIG phase, that is using SWIG to generate the wrapper code. And the second is the Go phase, which has been described above.

2. Customize SWIG phase

You can regenerate the wrapper code using SWIG. Compilation dependencies are:

  • python 2 or 3
  • sed
  • make
  • A customized SWIG

We use a customized SWIG to generate the wrapper code. Please clone https://github.com/dontpanic92/SWIG and simply ./configure && make && sudo make install. Then you can modify the source as you want, and run make in the build folder.

3. Customize wxWidgets build

If you want to use other wxWidgets build rather than the precompiled one, what you have to do is quite simple.

  • Compile wxWidgets
  • Run go get -d github.com/dontpanic92/wxGo/wx to let the go-tool just download the source
  • Open wx/setup_OS_ARCH.go, change the CPPFLAGS and LDFLAGS
  • Run go install github.com/dontpanic92/wxGo/wx

Done!

Usage

After importing github.com/dontpanic92/wxGo/wx, the following code will create an empty dialog with a "Hello World" as its caption.

    wx.NewApp()
    f := wx.NewDialog(wx.NullWindow, -1, "Hello World")
    f.ShowModal()
    f.Destroy()

All the wx-Classes' objects can be created using wx.NewCLASS. Now let us add some controls on it :

    wx.NewApp()
    f := wx.NewDialog(wx.NullWindow, -1, "Hello World")

    bSizer := wx.NewBoxSizer(wx.VERTICAL)

    checkBox := wx.NewCheckBox(f, wx.ID_ANY, "Check Me!", wx.DefaultPosition, wx.DefaultSize, 0)
    bSizer.Add(checkBox, 0, wx.ALL|wx.EXPAND, 5)

    textCtrl := wx.NewTextCtrl(f, wx.ID_ANY, "", wx.DefaultPosition, wx.DefaultSize, 0)
    bSizer.Add(textCtrl, 0, wx.ALL|wx.EXPAND, 5)

    f.SetSizer(bSizer)
    f.Layout()
    f.ShowModal()
    f.Destroy()

And then we can bind an event on the checkbox :

func checkboxClicked(e wx.Event) {
    wx.MessageBox("Checkbox clicked!")
}

//....
    wx.Bind(f, wx.EVT_CHECKBOX, checkboxClicked, checkBox.GetId())
//....

Bravo!

Remarks : about the memory management

All wx.NewCLASS functions will allocate memory on C++ side (on heap), thus it will not be tracked by Go's garbage collector. However, in most cases we don't need to worry about it, because wxWidgets will handle it. Some common cases are listed below:

  • √ When a wxWindow (or its subclasses) being deleted , it will automatically delete all of its children.

  • √ When we click the close button of a wxFrame, by default the Destroy will be called and it will be deleted by itself (and also all children).

  • × However when we close a wxDialog, the Destroy won't be called by default and we have to manually destroy it.

  • × If an object isn't in the GUI hierarchy, we have to free the memory by calling DeleteCLASS.

In a word, p := wx.NewCLASS in Go acts the same as p = new wxCLASS() in C++. Where we need a delete p, then we need a wx.DeleteCLASS.

More Info:

Examples

Examples are in the examples folder. Dapeton is a simple notepad, and controls is a dialog that contains several widgets.

ScreenShot

screenshot

License

wxGo is licensed under the wxWindows Library Licence.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].