Oden is a cross-platform desktop GUI toolkit for Gophers.
The goal of Oden is to provide a single fine framework for gophers easy to create and distribute desktop GUI applications for several OS platforms. The idea of Oden is to successfully achieve the goal by combining browser technology available on most platforms with the easy cross-compilation that is an important feature of Go.
- Oden is a pure Go library without cgo.
- Oden utilizes a browser that is already installed on the desktop where an Oden app is installed.
- Oden's
widget
module doesn't require Gophers to have any knowledge of HTML/CSS/JS (you can also use knowledge of HTML/CSS/JS). - The
widget
module supports declarative UI style programming.
This example is a very simple counter app using Oden.
package main
import (
"github.com/i2y/oden/core"
. "github.com/i2y/oden/widget"
)
func main() {
app := core.NewApp(
"Counter",
300, 300,
counter(0),
)
app.Run()
}
func counter(value int) Widget {
opBtn := func(label string) Widget {
return Button(label).
BorderRadius(0).
FontSize(TwoXLarge)
}
// When Go 1.18 is released and generics-related syntax is available,
// this will be a State, not an IntState. Maybe.
count := IntState(0)
return Column(
Text(count).
FgColor(White).
BgColor(Orange).
BorderColor(Gray).
FontSize(TwoXLarge),
Row(
opBtn("+").OnClick(func(_ core.Event) {
count.Increment()
}),
opBtn("-").OnClick(func(_ core.Event) {
count.Decrement()
}),
),
)
}
$ go build main.go
$ ./main
Oden source code repository is a multi-module repository.
Oden is composed of two modules: core
module and widget
module.
- The
core
module provides interaction with a browser required for widgets,Widget
interface needed to be implemented by widget module, etc. - The
widget
module provides a standard set of widgets for Oden.
Note: You do not necessarily need to use the widget
module. If you want, you can define and use your own widget set module. For this purpose, Oden provides core
and widget
as independent modules, to make the boundary between them clear. This also reduces the size of the generated binary when combining core module with your own widget module, without having to include the standard widget
module.
- WebView2
- Chrome
- Edge
- Chromium
- Firefox
When an Oden application starts, Oden will try to detect a browser installed on the host machine in the order of the list above.
In other words, the order of priority is as follows.
WebView2 > Chrome > Edge > Chromium > Firefox
- If you use a browser other than WebView2, the app window will be opened as the browser's one.
- If you use Firefox, address/tool bar won't be hidden.
Oden currently depends on the following packages. Thanks to the creators and contributors of each package.
- go-webview2
- Shoelace
- Hotwired Turbo
- EventBus
- and libraries that the above libraries depend on
These dependencies may be changed for internal implementation reasons.
Basically, you just need to run go build
with appropriate GOOS
and GOARCH
, but there are a few tips for each platform.
You can create a application bundle (.app
package) using appify or macappshell.
You can run your app in background by specifying the -ldflags "-H windowsgui"
option in go build
.
For example:
> go build -ldflags "-H windowsgui" main.go
You can also use go-winres, rsrc, or GoVersionInfo to embed resources (such as the application icon) into your windows app.
- Add documentation
- Add more widgets
- Refine Oden's API a little bit after Generics related features is introduced in Go 1.18