Product Promotion
0x5a.live
for different kinds of informations and explorations.
GitHub - dtylman/gowd: Build cross platform GUI apps with GO and HTML/JS/CSS (powered by nwjs)
Build cross platform GUI apps with GO and HTML/JS/CSS (powered by nwjs) - dtylman/gowd
Visit SiteGitHub - dtylman/gowd: Build cross platform GUI apps with GO and HTML/JS/CSS (powered by nwjs)
Build cross platform GUI apps with GO and HTML/JS/CSS (powered by nwjs) - dtylman/gowd
Powered by 0x5a.live ๐
gowd
Build cross platform GUI apps with GO and HTML/JS/CSS (powered by nwjs)
How to use this library:
- Download and install nwjs
- Install this library
go get github.com/dtylman/gowd
- Clone this repo.
- Place
package.json
,index.html
,main.go
andmain.js
from template in a new folder. go build
- Edit
main.js
and setgoBinary
to your your executable name:var goBinary = "./template"; //or template.exe
- Run
nw .
, the hello world template should appear:
Usage
Simplest "hello world":
import "github.com/dtylman/gowd"
func main() {
body, err := gowd.ParseElement("<h1>Hello world</h1>", nil)
if err != nil {
panic(err)
}
gowd.Run(body)
}
Adding a button:
import (
"github.com/dtylman/gowd"
)
func main() {
body, err := gowd.ParseElement("<h1>Hello world</h1>", nil)
if err != nil {
panic(err)
}
p := body.AddElement(gowd.NewElement("p"))
btn := p.AddElement(gowd.NewElement("button"))
btn.SetText("Click me")
btn.OnEvent(gowd.OnClick, btnClicked)
gowd.Run(body)
}
func btnClicked(sender *gowd.Element, event *gowd.EventElement) {
sender.SetText("Clicked!")
}
Creating and binding from HTML:
import (
"github.com/dtylman/gowd"
"fmt"
)
func main() {
body, err := gowd.ParseElement("<h1>Hello world</h1>", nil)
if err != nil {
panic(err)
}
p := body.AddElement(gowd.NewElement("p"))
em := gowd.NewElementMap()
p.AddHtml(`<select id="select1">
<option value="" disabled="disabled" selected="selected">Please select a name</option>
<option value="1">One</option>
<option value="2">Two</option>
</select>`, em)
em["select1"].OnEvent(gowd.OnChange, btnClicked)
em["select1"].Object = body
gowd.Run(body)
}
func btnClicked(sender *gowd.Element, event *gowd.EventElement) {
body := sender.Object.(*gowd.Element)
body.AddElement(gowd.NewStyledText(fmt.Sprintf("Selected %s", event.GetValue()), gowd.BoldText))
body.AddElement(gowd.NewElement("br"))
}
Using bootstrap:
'gowd' supports creating bootstrap elements using the bootstrap package.
First, add bootsrap css and js to your index.html
file:
<script type="text/javascript" src="js/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
Then you can create bootsrap items:
import (
"github.com/dtylman/gowd"
"github.com/dtylman/gowd/bootstrap"
"time"
"fmt"
)
var body *gowd.Element
func main() {
//creates a new bootstrap fluid container
body = bootstrap.NewContainer(false)
// add some elements using the object model
div := bootstrap.NewElement("div", "well")
row := bootstrap.NewRow(bootstrap.NewColumn(bootstrap.ColumnLarge, 6, div))
body.AddElement(row)
// add some other elements from HTML
div.AddHTML(`<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Dropdown Example
<span class="caret"></span></button>
<ul class="dropdown-menu" id="dropdown-menu">
<li><a href="#">HTML</a></li>
<li><a href="#">CSS</a></li>
<li><a href="#">JavaScript</a></li>
</ul>
</div>`, nil)
// add a button to show a progress bar
btn := bootstrap.NewButton(bootstrap.ButtonPrimary, "Start")
btn.OnEvent(gowd.OnClick, btnClicked)
row.AddElement(bootstrap.NewColumn(bootstrap.ColumnLarge, 4, bootstrap.NewElement("div", "well", btn)))
//start the ui loop
gowd.Run(body)
}
// happens when the 'start' button is clicked
func btnClicked(sender *gowd.Element, event *gowd.EventElement) {
// adds a text and progress bar to the body
text := body.AddElement(gowd.NewStyledText("Working...", gowd.BoldText))
progressBar := bootstrap.NewProgressBar()
body.AddElement(progressBar.Element)
// makes the body stop responding to user events
body.Disable()
// clean up - remove the added elements
defer func() {
body.RemoveElement(text)
body.RemoveElement(progressBar.Element)
body.Enable()
}()
// render the progress bar
for i := 0; i <= 123; i++ {
progressBar.SetValue(i, 123)
text.SetText(fmt.Sprintf("Working %v", i))
time.Sleep(time.Millisecond * 20)
// this will cause the body to be refreshed
body.Render()
}
}
This will yield the following app:
More a more advanced usage, see the Todo sample
GoLang Resources
are all listed below.
GitHub - GuilhermeCaruso/anko: :crystal_ball: Simple application watcher
resource
~/github.com
resource
GitHub - jidicula/go-fuzz-action: GitHub Action for Go 1.18 fuzz testing
resource
~/github.com
resource
GitHub - tucnak/climax: Climax is an alternative CLI with the human face
resource
~/github.com
resource
GitHub - lawrencewoodman/roveralls: A Go recursive coverage testing tool
resource
~/github.com
resource
GitHub - nakagami/firebirdsql: Firebird RDBMS sql driver for Go (golang)
resource
~/github.com
resource
GitHub - liweiyi88/onedump: Effortlessly database dump with one command.
resource
~/github.com
resource
GitHub - beefsack/go-astar: Go implementation of the A* search algorithm
resource
~/github.com
resource
GitHub - lxn/walk: A Windows GUI toolkit for the Go Programming Language
resource
~/github.com
resource
GitHub - mongodb/mongo-go-driver: The Official Golang driver for MongoDB
resource
~/github.com
resource
GitHub - bykof/gostradamus: Gostradamus: Better DateTimes for Go ๐ฐ๏ธ
resource
~/github.com
resource
GitHub - mozillazg/go-unidecode: ASCII transliterations of Unicode text.
resource
~/github.com
resource
GitHub - bolknote/go-gd: Go bingings for GD (http://www.boutell.com/gd/)
resource
~/github.com
resource
GitHub - mosajjal/dnsmonster: Passive DNS Capture and Monitoring Toolkit
resource
~/github.com
resource
GitHub - haxpax/gosms: :mailbox_closed: Your own local SMS gateway in Go
resource
~/github.com
resource
GitHub - wajox/gobase: This is a simple skeleton for golang applications
resource
~/github.com
resource
GitHub - VividCortex/gohistogram: Streaming approximate histograms in Go
resource
~/github.com
resource
GitHub - malaschitz/randomForest: Random Forest implementation in golang
resource
~/github.com
resource
GitHub - google/gopacket: Provides packet processing capabilities for Go
resource
~/github.com
resource
GitHub - khezen/evoli: Genetic Algorithm and Particle Swarm Optimization
resource
~/github.com
resource
GitHub - didip/tollbooth: Simple middleware to rate-limit HTTP requests.
resource
~/github.com
resource
GitHub - mustafaakin/gongular: A different approach to Go web frameworks
resource
~/github.com
resource
GitHub - songgao/colorgo: Colorize (highlight) `go build` command output
resource
~/github.com
resource
Made with โค๏ธ
to provide different kinds of informations and resources.