GithubHelp home page GithubHelp logo

dontpanic92 / wxgo Goto Github PK

View Code? Open in Web Editor NEW
403.0 37.0 51.0 192.83 MB

Golang wxWidgets Wrapper

License: Other

Go 51.41% C 0.88% C++ 43.09% Objective-C 4.61% Makefile 0.01% Python 0.01% Shell 0.01% sed 0.01%
wxwidgets go gui

wxgo's Introduction

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.

wxgo's People

Contributors

blazeeboy avatar dontpanic92 avatar k-takata avatar matiasinsaurralde avatar palumacil avatar rakslice avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wxgo's Issues

Grid example

Hi there, not an issue, but a request.

I was wondering if you could post a simple example of displaying a Struct into a Grid?

Missing wx.NewListBox overload

According to wxWidgets reference, there should be a two-argument version of the wx.NewListBox call. The C++ constructor is documented here: http://docs.wxwidgets.org/3.0/classwx_list_box.html#a4a86e0f4b5ed9ebea4ca2156941fb2e9

When I try to do something like the following:

listBox := wx.NewListBox(myFrame, wx.ID_ANY)

I get:

panic: No match for overloaded function call

This is not a severe problem, as you can always use other overloads instead. Just for completeness’ sake…

Goland: Getting autocompletion

Hi,
currently, there is no auto completion with this library in Goland. I assume it's because of the C-Code?
Example:
screen shot 2018-04-01 at 15 48 34

Pre-compiled release for Go 1.8.3

After having trouble with the main branch, I tried downloading a release, but it targets 1.8, and I've already updated to the latest patch release. Could you release a version for 1.8.3 please?

Go 1.9.x Support

Hello and thank you for your work!
Is it planned to support Go 1.9.x?

wx.Grid – accessing selection

I've created a wx.Grid and want to retrieve a user-defined selection of cells using GetSelectionBlockBottomRight and GetSelectionBlockTopLeft. The type (from my understanding) is a wx.WxGridCellCoordsArray but I cannot figure out how to access the values.

With wxPython, a tuple is returned containing 2 integers, row and column, and I would just index these. If I try to index a returned value in Go, I get an error: ("type *wx.WxGridCellCoordsArray does not support indexing"). Using GetSelectedRows or GetSelectedCols works fine.

What have I missed and how would I access the values? I'm sure the solution is obvious but I only started Go a few weeks ago so I'm still learning.

There's another function, GetSelectedCells which returns an array of selected cells. Would this be different?

wx.Swiglscolour wx.WHITE

I use code "SetBackgroundColour(wx.WHITE)".
Error is "wx.WHITE - undefined".
What are the values of type wx.Gwiglscolour?

Failed to convert wx.Event to wx.MouseEvent in wx.EVT_LEFT_DCLICK

I have following code snippet to handle double clicks:

wx.Bind(panel, wx.EVT_LEFT_DCLICK, func(e wx.Event) {
    mouseEvt := wx.MouseEvent(e)
    // ...
}

But the compiler complains about the conversion:

./main.go:12:28: cannot convert e (type wx.Event) to type wx.MouseEvent:
	wx.Event does not implement wx.MouseEvent (missing AltDown method)

I checked wxGo/src/wxGoInterface/event.h but didn't find AltDown method in wx.MouseEvent. Is there anything I did wrong?

Thanks!

A MenuItem ID of Zero does not work under Mac 『macOS 10.12.6』

./src/osx/menuitem_osx.cpp(39): assert "id != 0 || pSubMenu != __null" failed in wxMenuItem(): A MenuItem ID of Zero does not work under Mac

Call stack:
[01] wxMenuItem::wxMenuItem(wxMenu*, int, wxString const&, wxString const&, wxItemKind, wxMenu*)
[02] wxAuiGenericToolBarArt::ShowDropDown(wxWindow*, wxAuiToolBarItemArray const&)
[03] wxAuiToolBar::OnLeftDown(wxMouseEvent&)
[04] wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*)
[05] wxEvtHandler::ProcessEventLocally(wxEvent&)
[06] wxEvtHandler::ProcessEvent(wxEvent&)
[07] wxEvtHandler::SafelyProcessEvent(wxEvent&)
[08] wxWidgetCocoaImpl::DoHandleMouseEvent(NSEvent*)
[09] wxWidgetCocoaImpl::mouseEvent(NSEvent*, NSView*, void*)
[10] -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:]
[11] -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:]
[12] -[NSWindow(NSEventRouting) sendEvent:]
[13] -[wxNSWindow sendEvent:]
[14] -[NSApplication(NSEvent) sendEvent:]
[15] -[wxNSApplication sendEvent:]
[16] -[NSApplication run]
[17] wxGUIEventLoop::OSXDoRun()
[18] wxCFEventLoop::DoRun()
[19] wxEventLoopBase::Run()
[20] wxAppConsoleBase::MainLoop()
[21] _wrap_App_MainLoop_wx_d5626d6e57cb98ce

Do you want to stop the program?
You can also choose [Cancel] to suppress further warnings.

Debugging WxGo

I wrote a class to wrap a wx.Window, i must be doing something wrong because my program stopped running. all i got was exit status 2. i cant write to stdout or stderr so its difficult for me to trace the problem.
i decided to run a debugger and that failed too with error "go build github.com/dontpanic92/wxGo/wx: invalid flag in #cgo LDFLAGS: -Wl,--subsystem,windows".
i am stuck. how do we debug our code if it fails before showing a window?

How to use DataViewCtrl?

Hello,
I'm new to wxwidet and gui's. I'm trying to build a dataviewctrl but i'm running into some errors.

dataViewCtrl := wx.NewDataViewCtrl(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 5, wx.DefaultValidator)
dataViewCtrl.AppendToggleColumn("toggle")
dataViewCtrl.AppendTextColumn("text")

But I end up getting the follow error:

panic: No match for overloaded function call

goroutine 1 [running]:
github.com/dontpanic92/wxGo/wx.SwigClassDataViewCtrl.AppendTextColumn(0x63599c0, 0x63599c0, 0x63599c0, 0x63599c0, 0x63599c0, 0x63599d0, 0xc420011130, 0x1, 0x1, 0xc42004fd90, ...)
...

If anyone could help me out that would be great!

opening controls.exe from GUI vs. mingw64 command line

now that I can build windows wxGo projects I made the example controls project and can run the controls.exe from mingw64 command line like:

$ ./controls

and it works great! But when I double click on the exe from windows GUI it says:

"The program can't start because libstdc++-6.dll" is missing from your computer"

When I distribute my app to other windows users, how can I get error not to happen?

packaging, signing, and Mac AppStore

contents

when I right click on a normal MacOS app I get "Show Package Contents" menu option and then all this inside the .app file ^

But with my wxGo file there is no Show Package Contents option. What's the process for distributing apps created with wxGo to the Mac App Store?

Set program name for OS X menu bar

I'm trying to include a very basic menu bar, mostly just to be able to quit with Command-Q on OS X. The main menu has the title of my program, but the items under the menu say "Quit Wxgo" and "Hide Wxgo". How do I make it say "Quit MyProgram"? Attached is a picture of how it looks from the aui.go sample.

screen shot 2017-11-10 at 3 01 07 pm

NewFileDialog with wx.FD_MULTIPLE - can't get []string of selected files

trying to do:

  fd := wx.NewFileDialog(wx.NullWindow, "Select File(s)", "", "", "*", wx.FD_MULTIPLE,
    wx.DefaultPosition, wx.DefaultSize, "Open")
  fd.ShowModal()
  list := make([]string, 0)
  fd.GetFilenames(&list)
  fmt.Println(len(list))
fatal error: unexpected signal during runtime execution
[signal 0xa code=0x2 addr=0x5416138 pc=0x5416138]

runtime stack:
runtime.throw(0x4e0ea20, 0x2a)
    /usr/local/go/src/runtime/panic.go:527 +0x90
runtime.sigpanic()
    /usr/local/go/src/runtime/sigpanic_unix.go:12 +0x5a

goroutine 1 [syscall, locked to thread]:
runtime.cgocall(0x44a1300, 0xc82004d9e8, 0x0)
    /usr/local/go/src/runtime/cgocall.go:120 +0x11b fp=0xc82004d9a0 sp=0xc82004d970
github.com/dontpanic92/wxGo/wx._Cfunc__wrap_FileDialog_GetFilenames_wx_c37cfa1345d8cfbe(0x6825800, 0xc820078060)
    ??:0 +0x35 fp=0xc82004d9e8 sp=0xc82004d9a0
github.com/dontpanic92/wxGo/wx.SwigcptrFileDialog.GetFilenames(0x6825800, 0xc820078060)
    /Users/aa/dev/src/github.com/dontpanic92/wxGo/wx/wx_darwin.go:100730 +0x2b fp=0xc82004da00 sp=0xc82004d9e8
github.com/dontpanic92/wxGo/wx.(*SwigcptrFileDialog).GetFilenames(0xc820064750, 0xc820078060)
    <autogenerated>:15872 +0x99 fp=0xc82004da38 sp=0xc82004da00

Program name cannot be changed from "wxGo" for standard menu items on Mac

When running on Mac, the application name "wxGo" is shown in standard application menu items ("Quit wxGo", "Hide wxGo").

Speculating, it seems that this is based on the program name that is passed into wxEntryStart(), which is hardcoded to "wxGo" in src/wxApp.i, as that is the only place the string "wxGo" appears under src. If so, it would be nice if wx.NewApp() could take the application name as a parameter, so that these menu items get names that will make sense to the user.

which file to edit to turn on static linking

I used wxGo about a year ago, using it again for a new project and I forget 1 detail. Each time I compile it takes a long time. I remember there was some flag in some file to turn on --static something and that made it not have to compile all the c++ stuff each and every time.

i.e. the very first time I compile wxGo on this computer it should take a long time. But then each time I compile my own program that uses wxGo as a library, it should be fast. Right?

How do I capture a panic backtrace?

I am probably missing something very obvious here…
I have a wxGo application under Windows that simply vanishes at some point. I suspect that there is a panic somewhere, but I cannot see it. How can I capture the panic backtrace? (I saw in another issue here that this is apparently possible.)

32-bit go compiler runs out of memory

I've no idea on how to solve this. I'm not sure whether splitting the wrap file into multiple files can help -- golang will compile all go files in a package together so I don't think it works.

How to get in Windows OS?

I used following command in Windows 10.
go get github.com/dontpanic92/wxGo/wx

But showed following error.
package github.com/dontpanic92/wxGo/wx: no buildable Go source files in D:\Projects\GoUI\src\github.com\dontpanic92\wxGo\wx

How to run long function without blocking UI, but updating it?

First of all, thank you for this project. It's the only viable cross-platform GUI for Go I've found. I've been using it in my project (https://github.com/spieglt/flyingcarpet/tree/wxgo) the last few days and am confused on a couple things. How should I start a long-running function from my main frame without blocking the frame? And how should I allow that function to update the frame? Right now I have the function running in a goroutine, and have put the UI bits I need to update in globals, but I know that's not the right way to do it and I think it's causing stability issues.

I don't see how to do the threading/event model like you would do in C++ because we're in Go. I also couldn't find any parallel cases in the examples. Thanks for any help you can provide!

go get compile error

Any idea why I would get this on go get? (Ubuntu 18.04 fresh install)

WORK=/tmp/go-build168990271
mkdir -p $WORK/b001/
cd /home/myusername/go/src/github.com/dontpanic92/wxGo/wx
CGO_LDFLAGS='"-g" "-O2" "-L/home/myusername/go/src/github.com/dontpanic92/wxGo/wx/linux_amd64/lib" "-lwx_gtk3u_xrc-3.1" "-lwx_gtk3u_webview-3.1" "-lwx_gtk3u_stc-3.1" "-lwx_gtk3u_richtext-3.1" "-lwx_gtk3u_ribbon-3.1" "-lwx_gtk3u_propgrid-3.1" "-lwx_gtk3u_aui-3.1" "-lwx_gtk3u_media-3.1" "-lwx_gtk3u_gl-3.1" "-lwx_gtk3u_qa-3.1" "-lwx_baseu_net-3.1" "-lwx_gtk3u_html-3.1" "-lwx_gtk3u_adv-3.1" "-lwx_gtk3u_core-3.1" "-lwx_baseu_xml-3.1" "-lwx_baseu-3.1" "-lwxscintilla-3.1" "-lwxregexu-3.1" "-lgtk-3" "-lgdk-3" "-lcairo-gobject" "-lwebkitgtk-3.0" "-pthread" "-lstdc++" "-lGL" "-lGLU" "-lgthread-2.0" "-lX11" "-lXxf86vm" "-lSM" "-lpangocairo-1.0" "-lpango-1.0" "-latk-1.0" "-lcairo" "-lnotify" "-lgdk_pixbuf-2.0" "-lgio-2.0" "-lgobject-2.0" "-lglib-2.0" "-lpng" "-ljpeg" "-ltiff" "-lexpat" "-lz" "-ldl" "-lm" "-lgstreamer-1.0" "-lgstvideo-1.0"' /usr/lib/go-1.10/pkg/tool/linux_amd64/cgo -objdir $WORK/b001/ -importpath github.com/dontpanic92/wxGo/wx -- -I/home/myusername/go/src/github.com/dontpanic92/wxGo/wx/../wxWidgets/wxWidgets-3.1.0/include -D_FILE_OFFSET_BITS=64 -D__WXGTK__ -I/home/myusername/go/src/github.com/dontpanic92/wxGo/wx/linux_amd64/ -I $WORK/b001/ -g -O2 ./setup_linux_amd64.go ./wx_linux.go
cd $WORK
gcc -fno-caret-diagnostics -c -x c - || true
gcc -Qunused-arguments -c -x c - || true
gcc -fdebug-prefix-map=a=b -c -x c - || true
gcc -gno-record-gcc-switches -c -x c - || true
cd $WORK/b001
gcc -I /home/myusername/go/src/github.com/dontpanic92/wxGo/wx -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I/home/myusername/go/src/github.com/dontpanic92/wxGo/wx/../wxWidgets/wxWidgets-3.1.0/include -D_FILE_OFFSET_BITS=64 -D__WXGTK__ -I/home/myusername/go/src/github.com/dontpanic92/wxGo/wx/linux_amd64/ -I ./ -g -O2 -o ./_x001.o -c _cgo_export.c
gcc -I /home/myusername/go/src/github.com/dontpanic92/wxGo/wx -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I/home/myusername/go/src/github.com/dontpanic92/wxGo/wx/../wxWidgets/wxWidgets-3.1.0/include -D_FILE_OFFSET_BITS=64 -D__WXGTK__ -I/home/myusername/go/src/github.com/dontpanic92/wxGo/wx/linux_amd64/ -I ./ -g -O2 -o ./_x002.o -c setup_linux_amd64.cgo2.c
gcc -I /home/myusername/go/src/github.com/dontpanic92/wxGo/wx -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I/home/myusername/go/src/github.com/dontpanic92/wxGo/wx/../wxWidgets/wxWidgets-3.1.0/include -D_FILE_OFFSET_BITS=64 -D__WXGTK__ -I/home/myusername/go/src/github.com/dontpanic92/wxGo/wx/linux_amd64/ -I ./ -g -O2 -o ./_x003.o -c wx_linux.cgo2.c
cd $WORK
g++ -fno-caret-diagnostics -c -x c - || true
g++ -Qunused-arguments -c -x c - || true
g++ -fdebug-prefix-map=a=b -c -x c - || true
g++ -gno-record-gcc-switches -c -x c - || true
cd /home/myusername/go/src/github.com/dontpanic92/wxGo/wx
g++ -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I/home/myusername/go/src/github.com/dontpanic92/wxGo/wx/../wxWidgets/wxWidgets-3.1.0/include -D_FILE_OFFSET_BITS=64 -D__WXGTK__ -I/home/myusername/go/src/github.com/dontpanic92/wxGo/wx/linux_amd64/ -I $WORK/b001/ -g -O2 -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -o $WORK/b001/_x004.o -c wx_wrap_linux.cxx
cd $WORK/b001
gcc -I /home/myusername/go/src/github.com/dontpanic92/wxGo/wx -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I/home/myusername/go/src/github.com/dontpanic92/wxGo/wx/../wxWidgets/wxWidgets-3.1.0/include -D_FILE_OFFSET_BITS=64 -D__WXGTK__ -I/home/myusername/go/src/github.com/dontpanic92/wxGo/wx/linux_amd64/ -I ./ -g -O2 -o ./_cgo_main.o -c _cgo_main.c
cd /home/myusername/go/src/github.com/dontpanic92/wxGo/wx
g++ -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -o $WORK/b001/_cgo_.o $WORK/b001/_cgo_main.o $WORK/b001/_x001.o $WORK/b001/_x002.o $WORK/b001/_x003.o $WORK/b001/_x004.o -g -O2 -L/home/myusername/go/src/github.com/dontpanic92/wxGo/wx/linux_amd64/lib -lwx_gtk3u_xrc-3.1 -lwx_gtk3u_webview-3.1 -lwx_gtk3u_stc-3.1 -lwx_gtk3u_richtext-3.1 -lwx_gtk3u_ribbon-3.1 -lwx_gtk3u_propgrid-3.1 -lwx_gtk3u_aui-3.1 -lwx_gtk3u_media-3.1 -lwx_gtk3u_gl-3.1 -lwx_gtk3u_qa-3.1 -lwx_baseu_net-3.1 -lwx_gtk3u_html-3.1 -lwx_gtk3u_adv-3.1 -lwx_gtk3u_core-3.1 -lwx_baseu_xml-3.1 -lwx_baseu-3.1 -lwxscintilla-3.1 -lwxregexu-3.1 -lgtk-3 -lgdk-3 -lcairo-gobject -lwebkitgtk-3.0 -pthread -lstdc++ -lGL -lGLU -lgthread-2.0 -lX11 -lXxf86vm -lSM -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo -lnotify -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lpng -ljpeg -ltiff -lexpat -lz -ldl -lm -lgstreamer-1.0 -lgstvideo-1.0
# github.com/dontpanic92/wxGo/wx
/usr/bin/x86_64-linux-gnu-ld: cannot find -lwebkitgtk-3.0
/usr/bin/x86_64-linux-gnu-ld: cannot find -lGLU
/usr/bin/x86_64-linux-gnu-ld: cannot find -lnotify
/usr/bin/x86_64-linux-gnu-ld: cannot find -ljpeg
/usr/bin/x86_64-linux-gnu-ld: cannot find -ltiff
/usr/bin/x86_64-linux-gnu-ld: cannot find -lgstreamer-1.0
/usr/bin/x86_64-linux-gnu-ld: cannot find -lgstvideo-1.0
collect2: error: ld returned 1 exit status
# github.com/dontpanic92/wxGo/wx
wx_wrap_linux.cxx: In function ‘void _wrap_SVGFileDC_SetClippingRegion__SWIG_3_wx_d5626d6e57cb98ce(wxSVGFileDC*, wxRegion*)’:
wx_wrap_linux.cxx:28836:52: warning: ‘void wxDC::SetClippingRegion(const wxRegion&)’ is deprecated [-Wdeprecated-declarations]
   (arg1)->SetClippingRegion((wxRegion const &)*arg2);
                                                    ^
In file included from dontpanic92/wxGo/wx/../wxWidgets/wxWidgets-3.1.0/include/wx/wx.h:14:0,
                 from wx_wrap_linux.cxx:254:
dontpanic92/wxGo/wx/../wxWidgets/wxWidgets-3.1.0/include/wx/dc.h:949:30: note: declared here
     wxDEPRECATED_INLINE(void SetClippingRegion(const wxRegion& region),
                              ^
dontpanic92/wxGo/wx/../wxWidgets/wxWidgets-3.1.0/include/wx/defs.h:642:43: note: in definition of macro ‘wxDEPRECATED’
 #define wxDEPRECATED(x) wxDEPRECATED_DECL x
                                           ^
dontpanic92/wxGo/wx/../wxWidgets/wxWidgets-3.1.0/include/wx/dc.h:949:5: note: in expansion of macro ‘wxDEPRECATED_INLINE’
     wxDEPRECATED_INLINE(void SetClippingRegion(const wxRegion& region),
     ^~~~~~~~~~~~~~~~~~~
wx_wrap_linux.cxx: In function ‘bool _wrap_DataViewCustomRenderer_LeftClick_wx_d5626d6e57cb98ce(wxDataViewCustomRenderer*, wxPoint*, wxRect*, wxDataViewModel*, wxDataViewItem*, intgo)’:
wx_wrap_linux.cxx:69640:85: warning: ‘virtual bool wxDataViewCustomRendererBase::LeftClick(wxPoint, wxRect, wxDataViewModel*, const wxDataViewItem&, unsigned int)’ is deprecated [-Wdeprecated-declarations]
   result = (bool)(arg1)->LeftClick(arg2,arg3,arg4,(wxDataViewItem const &)*arg5,arg6);
                                                                                     ^
In file included from dontpanic92/wxGo/wx/../wxWidgets/wxWidgets-3.1.0/include/wx/wx.h:14:0,
                 from wx_wrap_linux.cxx:254:
dontpanic92/wxGo/wx/../wxWidgets/wxWidgets-3.1.0/include/wx/dvrenderers.h:284:22: note: declared here
         virtual bool LeftClick(wxPoint WXUNUSED(cursor),
                      ^
dontpanic92/wxGo/wx/../wxWidgets/wxWidgets-3.1.0/include/wx/defs.h:642:43: note: in definition of macro ‘wxDEPRECATED’
 #define wxDEPRECATED(x) wxDEPRECATED_DECL x
                                           ^
dontpanic92/wxGo/wx/../wxWidgets/wxWidgets-3.1.0/include/wx/dvrenderers.h:283:5: note: in expansion of macro ‘wxDEPRECATED_BUT_USED_INTERNALLY_INLINE’
     wxDEPRECATED_BUT_USED_INTERNALLY_INLINE(
     ^
wx_wrap_linux.cxx: In function ‘bool _wrap_DataViewCustomRenderer_Activate_wx_d5626d6e57cb98ce(wxDataViewCustomRenderer*, wxRect*, wxDataViewModel*, wxDataViewItem*, intgo)’:
wx_wrap_linux.cxx:69668:79: warning: ‘virtual bool wxDataViewCustomRendererBase::Activate(wxRect, wxDataViewModel*, const wxDataViewItem&, unsigned int)’ is deprecated [-Wdeprecated-declarations]
   result = (bool)(arg1)->Activate(arg2,arg3,(wxDataViewItem const &)*arg4,arg5);
                                                                               ^
In file included from dontpanic92/wxGo/wx/../wxWidgets/wxWidgets-3.1.0/include/wx/wx.h:14:0,
                 from wx_wrap_linux.cxx:254:
dontpanic92/wxGo/wx/../wxWidgets/wxWidgets-3.1.0/include/wx/dvrenderers.h:276:22: note: declared here
         virtual bool Activate(wxRect WXUNUSED(cell),
                      ^
dontpanic92/wxGo/wx/../wxWidgets/wxWidgets-3.1.0/include/wx/defs.h:642:43: note: in definition of macro ‘wxDEPRECATED’
 #define wxDEPRECATED(x) wxDEPRECATED_DECL x
                                           ^
dontpanic92/wxGo/wx/../wxWidgets/wxWidgets-3.1.0/include/wx/dvrenderers.h:275:5: note: in expansion of macro ‘wxDEPRECATED_BUT_USED_INTERNALLY_INLINE’
     wxDEPRECATED_BUT_USED_INTERNALLY_INLINE(
     ^
wx_wrap_linux.cxx: In function ‘intgo _wrap_PGProperty_GetFlags_wx_d5626d6e57cb98ce(wxPGProperty*)’:
wx_wrap_linux.cxx:260533:75: warning: ‘wxPGProperty::FlagType wxPGProperty::GetFlags() const’ is deprecated: Use HasFlag or HasFlagsExact functions instead. [-Wdeprecated-declarations]
   result = (wxPGProperty::FlagType)((wxPGProperty const *)arg1)->GetFlags();
                                                                           ^
In file included from dontpanic92/wxGo/wx/../wxWidgets/wxWidgets-3.1.0/include/wx/propgrid/propgridiface.h:18:0,
                 from wx_wrap_linux.cxx:913:
dontpanic92/wxGo/wx/../wxWidgets/wxWidgets-3.1.0/include/wx/propgrid/property.h:1794:14: note: declared here
     FlagType GetFlags() const
              ^~~~~~~~

Invalid flag in #cgo

I was just updating my wxGo by doing

go get -u -v github.com/dontpanic92/wxGo/wx

Then I got this:

github.com/dontpanic92/wxGo (download)
github.com/dontpanic92/wxGo/wx
go build github.com/dontpanic92/wxGo/wx: invalid flag in #cgo LDFLAGS: -s

I have Go version 1.9.4 on Ubuntu Linux 17.10.

Any idea?

stop terminal window from opening

when I double click on an executable in the finder, the gui program opens just fine, but there is a terminal window also opened. Can I get my app to behavior like other MacOS apps and run without the terminal visible?

Go get (building) on linux_amd64

Hi,
i have problem compiling/installing wxGo on 64-bit linux (tested on: debian 8 with gcc 6.3.0 from unstable and 64-bit alpine linux muslc lib based). There are many messages such as:

relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC

and at the end I got:

/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status

Do you have any idea if this can be fixed?

Here is full output: compilation error.

Embedding images

In wxWidgets in C, I've used the wxBITMAP_PNG_FROM_DATA macro along with xpm files. Obviously this doesn't work in go so can anyone recommend an approach that does?

I'd like to keep the images embedded in the executable and not separate. Also I'd prefer something cross platform (why I liked xpm so much).

can't force window to Repaint from within thread

Here's some sample code that puts a Gauge on the screen and make the progress bar increase 1 value every second. On MacOS I don't see the progress bar update unless I drag the window around or resize it manually with the mouse. Any idea how to force the whole thing to repaint? I'm calling f.Refresh() and f.Update()

package main

import "github.com/dontpanic92/wxGo/wx"
import "time"

var g wx.Gauge

type MyFrame struct {
    wx.Frame
}

func (f *MyFrame) startUpload() {
    for {
        time.Sleep(time.Second)
        g.SetValue(g.GetValue() + 1)
        f.Refresh()
        f.Update()
    }
}

func NewMyFrame() MyFrame {
    f := MyFrame{}
    f.Frame = wx.NewFrame(wx.NullWindow, -1, "Test Thread")
    mainSizer := wx.NewBoxSizer(wx.HORIZONTAL)
    g = wx.NewGauge(f, wx.ID_ANY, 100, wx.DefaultPosition, wx.NewSize(600, 40), 0)
    f.SetSizer(mainSizer)
    mainSizer.Add(g, 100, wx.ALL|wx.EXPAND, 50)
    f.Layout()
    go f.startUpload()
    return f
}

func main() {
    wx1 := wx.NewApp()
    f := NewMyFrame()
    f.Show()
    wx1.MainLoop()
    return
}

Certain controls crash(?) wxGo application

I have found that using certain controls (TreeListCtrl and WebView in particular) makes a wxGo application simply exit without displaying anything. Now I don’t know whether I am doing anything wrong (some missing initialization before using such controls, perhaps?) or whether these controls are just not yet supported or whether we have a bug in wxGo on our hands. I am testing under Windows 7 64-bit with Go 1.7.4. Here is a sample program that is supposed to show a frame with at least a bit of TreeListCtrl in it, but which simply shows nothing and exits:

`package main

import "github.com/dontpanic92/wxGo/wx"

func main() {
app := wx.NewApp()
frame := wx.NewFrame(wx.NullWindow, -1, "Hello, world!")
sizer := wx.NewBoxSizer(wx.VERTICAL)
tlc := wx.NewTreeListCtrl(frame)
sizer.Add(tlc, 0, wx.ALL|wx.EXPAND, 5)
frame.SetSizer(sizer)
frame.Layout()
frame.Show()
app.MainLoop()
}
`

(The preview does not show the code nicely, but I do hope it will be better in the actual post.)

MacOS: Customizing the label of the quit application menu item

Hi,
on MacOS, there is this application menu, here labeled "Hello_World" containing the quit application menu item labeled "Quit Wxgo":
screen shot 2018-04-01 at 15 15 28
How can I programmatically change the label of "Hello_World"?
How can I change this quit application menu item label to "Quit <MyApplicationName>"?
And "Hide Wxgo"?

Closed Source Usage

Hi,
assuming I want to write aclosed source program and publich it using this library.
Am I allowed to do so license wise? Especially with the license of wxWidgets?

Can't Printf in a Bind.

Why debugging, I can't see any Println or Printf in the console. In in Win10 x64.

wx.Bind(w, wx.EVT_BUTTON, func(e wx.Event) {
fd := wx.NewDirDialog(wx.NullWindow, "Select Folder")
if fd.ShowModal() == wx.ID_OK {
fmt.Printf("Folder: %v", fd.GetPath())
}
fmt.Println("Whatever")
},

This doesn't display anything on the console.

Any ideas?

Can't get WebView started in wx.Frame

I've written a small program to check out the working of the WebView but have failed to get it going after trying a fair few options. Here is some basic code (cribbed from dapeton). I'm learning Go so am probably missing something basic.

package main

import "github.com/dontpanic92/wxGo/wx"

//Frame Struct def
type MyFrame struct {
    wx.Frame
    myhtml wx.WebView
}

//Frame Init def
func NewMyFrame() *MyFrame {
    f := &MyFrame{}
    f.Frame = wx.NewFrame(wx.NullWindow, -1, "Brwsrrr")
    mainSizer := wx.NewBoxSizer(wx.HORIZONTAL )
    f.SetSizer(mainSizer)
	
    f.myhtml.Create()
    mainSizer.Add(f.myhtml, 1, wx.EXPAND, 5)
    f.myhtml.LoadURL("http://www.salstat.com")

    f.Layout()

    return f
}

//Main Function
func main() {
    wx1 := wx.NewApp()
    f := NewMyFrame()
    f.Show()
    wx1.MainLoop()
    return
}

This builds but running the executable produces:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x140 pc=0x431a254]

goroutine 1 [running]:
main.NewMyFrame(0x0)
/Users/alan/Projects/GSalstat/WebViewTest/WebViewTest.go:18 +0x1b4
main.main()
/Users/alan/Projects/GSalstat/WebViewTest/WebViewTest.go:30 +0x59

I've tried using f.myhtml = NewWebView() but that's not building. What am I missing here?

Platform: OSX 10.12.6
Go: 1.9.2
wxGo: Downloaded over the weekend.

How to add data to DataViewListCtrl?

I tried to use appendItem to add to a dataviewlist that has two text columns.
In the docs it says it requires a wxVector.
I tried a few things but I'm not sure how to implement that.
How does append a row to the list?

Sorry, if its a trivial question.

Best way to make popup dialogs?

Hello!

I am fairly unfamiliar with wx in general and have looked around a decent bit but I am currently have my main application as a wx.Frame and I want to have a popup window where I can edit the settings.

Is the best or most accepted way to do this a wx.Dialog? If so, how should I structure it?

This is what I am currently using and it doesn't feel correct.

type Client struct {
	wx.Frame
	statusbar wx.StatusBar
	menubar   wx.MenuBar
	listenBtn    wx.Button
	saveDialog SaveDialog
}

type SaveDialog struct {
	wx.Dialog
	hostCtrl wx.TextCtrl
	portCtrl wx.TextCtrl
	saveBtn wx.Button
	loadBtn wx.Button
}

From the save dialog I take the hostCtrl and portCtrl's text fields and save/load them with a JSON file.

How to show icon?

I've found a couple different methods for embedding an .ico file in a Go executable on Windows (for example: https://github.com/akavel/rsrc). They show up as the program's icon before running it, but how do I get an icon to show in the top-left of the Frame while the program is running?

Archlinux has deprecated Webkitgtk; wxGo won't compile

So webkitgtk ("webkit1gtk") is being thrown out in favor of webkit2gtk and this is set to
compile against the old version through ldflags.

WxGTK can and will compile with webkit2gtk in mind, so wxGo should also compile against Webkit2gtk

The line of code that contains the problem is here: https://github.com/dontpanic92/wxGo/blob/master/wx/setup_linux_amd64.go#L9

webkitgtk-3.0 should be something like webkit2gtk-4.0 (?) now.

EDIT: Actually, since you precompile everything, that probably be won't be that easy..., you'd need to provide two .a libs, one for a webkit2gtk patched source and one for webkitgtk.

Using wxLocale causes a crash

Using wxLocale features seems to cause problems. wxWidgets fails while it is calling wxLocale::GetInfo(int, int), or if you call it manually. (The attached program shows the second case.) Since wxWidgets calls this all over the place, the program quickly crashes if you do anything significant after initializing a wxLocale object.

The following error is thrown from wxWidgets during the call:

../../src/common/intl.cpp(1546): assert "wxString::Format("%.3f", 1.23).find(str) != wxString::npos" failed in GetInfoFromLCID(): Decimal separator mismatch -- did you use setlocale()?If so, use wxLocale to change the locale instead.

To be perfectly honest, I'm not actually sure if this is a problem in wxWidgets, wxGo, or some weird interaction between them and Go. I traced through the program in gdb, and nothing seems to call setlocale() directly after initializing the wxLocale, but I'm not very sure.

Here is an example backtrace from a crash while creating a bitmap (I tried to clean it up a little.):

//Native backtrace
0x00000000016b3c3d in wxOnAssert(char const*, int, char const*, char const*, char const*) ()
0x000000000170fe52 in (anonymous namespace)::GetInfoFromLCID(unsigned long, wxLocaleInfo, wxLocaleCategory) ()
0x0000000001712e47 in wxLocale::GetInfo(wxLocaleInfo, wxLocaleCategory) ()
0x000000000173699f in wxString::FromCDouble(double, int) ()
0x00000000019c08e9 in wxPNGHandler::LoadFile(wxImage*, wxInputStream&, bool, int) ()
0x00000000019aa2f3 in wxImage::DoLoad(wxImageHandler&, wxInputStream&, int) ()
0x00000000019acb58 in wxImage::LoadFile(wxInputStream&, wxBitmapType, int) ()
0x0000000001916352 in (anonymous namespace)::wxTangoArtProvider::CreateBitmap(wxString const&, wxString const&, wxSize const&) ()
0x0000000001912ab5 in wxArtProvider::GetBitmap(wxString const&, wxString const&, wxSize const&) ()
0x0000000001687426 in _wrap_ArtProvider_GetBitmap__SWIG_2_wx_d5626d6e57cb98ce (_swig_go_0=...) at wx_wrap_windows.cxx:167403
0x0000000001409c3d in _cgo_a6fcac6c7ab6_Cfunc__wrap_ArtProvider_GetBitmap__SWIG_2_wx_d5626d6e57cb98ce (v=0xc0420819d8) at cgo-gcc-prolog:4626
0x0000000000457aa3 in runtime.asmcgocall ()

//Go backtrace
runtime.asmcgocall () at C:/Go/src/runtime/asm_amd64.s:610
0x0000000000402b62 in runtime.cgocall (
fn=0x1409c10 <_cgo_a6fcac6c7ab6_Cfunc__wrap_ArtProvider_GetBitmap__SWIG_2_wx_d5626d6e57cb98ce>, arg=0xc0420819d8, ~r2=6795318)
at C:/Go/src/runtime/cgocall.go:133
0x00000000004ac485 in github.com/dontpanic92/wxGo/wx._Cfunc__wrap_ArtProvider_GetBitmap__SWIG_2_wx_d5626d6e57cb98ce (p0=..., r1=0)
at github.com/dontpanic92/wxGo/wx/_obj/_cgo_gotypes.go:12874
0x00000000006a6a0f in github.com/dontpanic92/wxGo/wx.ArtProviderGetBitmap__SWIG_2 (arg1="wxART_MISSING_IMAGE", _swig_ret=...)
at github.com/dontpanic92/wxGo/wx/wx_windows.go:215402
0x00000000006a6b44 in github.com/dontpanic92/wxGo/wx.ArtProviderGetBitmap
(a= []interface {} = {...}, ~r1=...)
at github.com/dontpanic92/wxGo/wx/wx_windows.go:215413
0x0000000000b2bca7 in main.NewAuiToolBarFile (parent=..., ~r1=0x1)

My environment is Windows 10, with wxGo compiled with a Windows native Go installation, and GCC from MSYS2 MinGW. Everything else I've tried up to this point has worked fine.

(The attached program is named .txt so GitHub will accept the upload.)
wxLocaleTest.go.txt

Link problem with latest mingw and uuid

Apparently they have been aware of a problem with their uuid libraries for months, but latest version from March still fails. Fix was trivial in the wx/setup_windows_amd64.go (and wx/setup_windows_386.go I suppose), add the "--allow-multiple-definition" flag to the existing -Wl LDFLAG in line 5 so it looks like:

-Wl,--subsystem,windows,--allow-multiple-definition

As this is a workaround to their problem, I'm not submitting a pull request but leaving this here to inform others.

strange output file on windows

Thanks for your job, it is a great project! I think go and wxwidgets is an excellent combination. But I meet some problem when using it. I am testing on Windows 7 ( go 1.7, tdm64-gcc-5.1.0-2), and I install wxGo using the following command:

go get github.com/dontpanic92/wxGo/wx

the installtion meets some warnings but no errors, and then I try the example "control":
I change the cmd current directory to "control" and run
go build

after a long time, the exe file is created. It is 60M, very large, and when I run it, It do open a window, but the ui is very strage, some text like "existsfloat32nan2float64nan1...", I upload a picture here. Where is the problem?
demo

getting a window dev environment building wxGO

well my MacOS app is coming along great :)

But now it's time to see how it looks on Windows. I read:

http://mingw.org/wiki/Getting_Started

got the basic package installed so I have a c++.exe compiler now. I ran:

C:\MinGW\msys\1.0\msys.bat

and it opened this whole new shell thing where I typed:

$ go get -x "github.com/dontpanic92/wxGo"
can't load package: package github.com/dontpanic92/wxGo: no buildable Go source files in C:\dev\src\github.com\dontpanic92\wxGo

I am able to compile a simple go program that just prints hello world so golang is installed and working. Any ideas where to go next?

Updates:

  1. trying mingw-w64
C:\dev\src\github.com\dontpanic92\wxGo\examples\src\controls>go build
# github.com/dontpanic92/wxGo/wx
cc1.exe: sorry, unimplemented: 64-bit mode not compiled in

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.