gui toolkit for go

Simple GUI toolkit with go

Install

You will need to install gtk-dev files.

go get github.com/zozor/hgui

The idea

This is a gui toolkit that relies on HTML, CSS, and javascript. But as a user of this toolkit you do not have to worry about that although it helps understanding it.

The compiled program will, when you run it, start a server at 127.0.0.1:randomport, and connect to it with gtk-webkit.

To make a simple interface, no knowledge of html, javascript or css is needed. For styling some CSS knowledge is needed, but not much.

Here is a simple program. An advanced one can be found in examples

package main

import "github.com/zozor/hgui"

func main() {
	label := hgui.NewLabel("Simple label")
	input := hgui.NewTextinput("", hgui.TextType_Text)
	hgui.Topframe.Add(
		input, 
		hgui.NewButton("New Text!", nil, func() {
			label.SetValue(input.Value())
			label.SetStyle(hgui.Style{"color":"blue"})
		}),
		hgui.Html("<br/>"), 
		label,
	)
	hgui.StartServer(800, 600, "Simple program!")
}

How it works

We start with server for clarity

StartServer(width, height, title)

Starts a http server, creates a window with gtk, adds webkit to that window and make webkit connect to the server.

The two first lines in main() creates two widgets for use.

hgui.Topframe.Add(...HTMLer)

Adds widgets between <body></body> in the outputtet html. We first add input to the body. Then we make a button widget with an onclick event. HTMLer is an

type interface HTMLer {
	HTML() string
}

When this button is created, it puts the function in a map[id.onclick]func(), puts javascript on the button in webkit onclick="callhandler(id.onclick)". An ajax query is then sent, when button is clicked, with the ID to call the function specified in the map.

label.SetValue(value)

This sends a javascript event to webkit. All events are send through a bufferede channel with some javascript code to run and a reply channel. This can also be done using the function SendEvent(javascript, replychannel). But the widgets do this for you.

This event channel is emptied by webkit 100 times a second, and runs the javascript inside them in the order they came in.

input.GetValue()

This will use the replychannel, the SetX methods has a nil reply channel. Events that require a reply have to include the variable reply in the javascript. So the events look like this SendEvent("reply = ...", replychannel). Webkit runs the javascript, and returns a String(reply) to the return channel. In the package's various Value() methods, it usually looks like this

reply := make(chan string)
events <- Event("reply = ...", reply)
return <-reply

And ofcourse, jquery is part of the package, making everything extremely easy.

Features

Widgets

  • Frames / Container
  • Tables
  • Radio and Check boxes
  • Fieldset
  • Labels
  • Text input
  • Textarea
  • Selectform
  • Buttons
  • Links
  • Images
  • Modal Dialogs
  • Gauge

Other

  • Styling with css
  • Raw javascript
  • Resources (it actually does not allow anything else)
  • Everything that can be made in html/css/javascript can be used here. Making it somewhat more powerfull than GTK?.

Contribution - Help me out!

If you are badass to css, javascript and html, please contribute, as we need more widgets. If you do not want to work with the internals of the package, you can just send the html/css/js and i will make it happen.

If you got any ideas for widgets, API change, design or whatever, please speak your mind.

All help and contribution is appriciated :)

Issues

Gtk sucks. It spams my face with errors.

I can remove the 100 requests per second and deal with events on time if i could get this to work

gchar* k = "some code;";
webkit_web_view_execute_script(WEBKIT_WEB_VIEW(webview), k);

This call i supposed to run the script in k in webkit. I could make it run GetEvents(), which is now being called with setInterval() to fetch the events. But it crashes all the time. And it also seems that GetEvents or jquery object is not part of the scope.. I do not know what to do here.. I hate GTK.

Similar Resources

Cross platform GUI in Go based on Material Design

Cross platform GUI in Go based on Material Design

About Fyne is an easy to use UI toolkit and app API written in Go. It is designed to build applications that run on desktop and mobile devices with a

Jan 3, 2023

Go wrapper around the Iup GUI toolset

Iup Go Wrapper iup is a Go wrapper around the Iup GUI toolkit. The project was started on April 27, 2011. Fork https://github.com/grd/iup is a fork of

Nov 28, 2020

Platform-native GUI library for Go.

ui: platform-native GUI library for Go This is a library that aims to provide simple GUI software development in Go. It is based on my libui, a simple

Jan 9, 2023

Go Wrapper for the wxWidgets GUI

This is the source code for wxGo a Go wrapper of the wxWidgets library. The actuall wxWidgets source code is not included and will need to be downloa

Nov 30, 2022

Build cross platform GUI apps with GO and HTML/JS/CSS (powered by Electron)

Thanks to go-astilectron build cross platform GUI apps with GO and HTML/JS/CSS. It is the official GO bindings of astilectron and is powered by Electr

Jan 9, 2023

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)

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 g

Dec 11, 2022

RobotGo, Go Native cross-platform GUI automation @vcaesar

Robotgo Golang Desktop Automation. Control the mouse, keyboard, bitmap, read the screen, Window Handle and global event listener. RobotGo supports Mac

Jan 7, 2023

Provides AWS STS credentials based on Google Apps SAML SSO auth with interactive GUI support

Provides AWS STS credentials based on Google Apps SAML SSO auth with interactive GUI support

What's this This command-line tool allows you to acquire AWS temporary (STS) credentials using Google Apps as a federated (Single Sign-On, or SSO) pro

Sep 29, 2022

GUI frontend for Delve

GUI frontend for Delve

GUI frontend for Delve

Jan 5, 2023

A fork of the simple WireGuard VPN server GUI community maintained

A fork of the simple WireGuard VPN server GUI community maintained

Subspace - A simple WireGuard VPN server GUI Subspace - A simple WireGuard VPN server GUI Slack Screenshots Features Contributing Setup 1. Get a serve

Dec 25, 2022

Common library for Go GUI apps on Windows

Common library for Go GUI apps on Windows

winc Common library for Go GUI apps on Windows. It is for Windows OS only. This makes library smaller than some other UI libraries for Go.

Dec 12, 2022

Cross-platform GUI for go is never this easy and clean.

Cross-platform GUI for go is never this easy and clean.

gimu Strongly suggest NOT to use this project anymore, the auto-generated cgo wrapper of Nuklear has a random crash issue which is hard to fix (becaus

Jul 12, 2022

GUI frontend for Delve

GUI frontend for Delve

Gdlv is a graphical frontend to Delve for Linux, Windows and macOS. Demo video here. Setup First install the current version of Delve, following Delve

Dec 23, 2022

Windows GUI framework for Go.

gform is an easy to use Windows GUI toolkit for Go It provides two approaches to create UI. 1. Pure code. gform.Init() mainWindow := gform.NewForm(ni

Jan 1, 2023

Easy Go GUI wrapper for interactive manipulation of visual algorithms/backend code.

Easy Go GUI wrapper for interactive manipulation of visual algorithms/backend code.

RenderView ================ Install: go get github.com/TheGrum/renderview Needs either Shiny (limited functionality), Gio, go-gtk, or gotk3. The latt

Aug 4, 2022

Windows GUI library for Go (Golang). Comes with a graphical UI designer.

Version 2 Please go to Version 2 of this library for the latest version. Windows GUI Library This is a pure Go library to create native Windows GUIs.

Jan 1, 2023

Super minimal, rock-solid foundation for concurrent GUI in Go.

Super minimal, rock-solid foundation for concurrent GUI in Go.

faiface/gui Super minimal, rock-solid foundation for concurrent GUI in Go. Installation go get -u github.com/faiface/gui Currently uses GLFW under th

Dec 23, 2022

Cross platform rapid GUI framework for golang based on Dear ImGui.

Cross platform rapid GUI framework for golang based on Dear ImGui.

giu Cross platform rapid GUI framework for golang based on Dear ImGui and the great golang binding imgui-go. Any contribution (features, widgets, tuto

Dec 28, 2022

This project provides Go bindings for nuklear.h — a small ANSI C GUI library.

This project provides Go bindings for nuklear.h — a small ANSI C GUI library.

Nuklear Package nk provides Go bindings for nuklear.h — a small ANSI C gui library. See github.com/vurtun/nuklear. All the binding code has automatica

Jan 1, 2023
Comments
  • example/demo/main.go : compilation error

    example/demo/main.go : compilation error

    src/github.com/zozor/hgui/examples/demo$ go run main.go

    command-line-arguments

    ./main.go:11: undefined: BILLEDE

    can't understand why. I am new to golang. I understand this var is declared in rc.go.

  • Compiling for Windows does not work

    Compiling for Windows does not work

    GOOS=windows GOARCH=386 go build test.go gives output: ../../src/github.com/zozor/hgui/server.go:68: undefined: startGui

    While compiling for 64 bit Linux works fine (32 bit causes same problem like with a Windows).

    My Go version is 1.2.1 (from stock Ubuntu Trusty repositories). gccgo (Ubuntu 4.9-20140406-0ubuntu1) 4.9.0 20140405 (experimental) [trunk revision 209157]

    On the other hand, compiling (for Windows) fails even with Go 1.3.0. Output: For Windows: ../../src/github.com/zozor/hgui/hgui.go:10: can't find import: "encoding/json"

    For Linux: ../src/pkg/net/dial.go:8: can't find import: "errors"

  • Onyx as default CSS style?

    Onyx as default CSS style?

    Since the project is looking for styling with CSS, I think a good default CSS style would be HP/Gram's Onyx from the Enyo framework. It really is a nice set of widgets, imo.

    https://github.com/enyojs/onyx http://enyojs.com/sampler/

Related tags
Go Image Filtering Toolkit
Go Image Filtering Toolkit

GO IMAGE FILTERING TOOLKIT (GIFT) Package gift provides a set of useful image processing filters. Pure Go. No external dependencies outside of the Go

Dec 23, 2022
An image server toolkit in Go (Golang)
An image server toolkit in Go (Golang)

Image Server An image server toolkit in Go (Golang) Features HTTP server Resize (GIFT, nfnt resize, Graphicsmagick) Rotate Crop Convert (JPEG, GIF (an

Dec 22, 2022
gui toolkit for go

Simple GUI toolkit with go Install You will need to install gtk-dev files. go get github.com/zozor/hgui The idea This is a gui toolkit that relies on

Feb 14, 2021
A Windows GUI toolkit for the Go Programming Language
A Windows GUI toolkit for the Go Programming Language

About Walk Walk is a "Windows Application Library Kit" for the Go Programming Language. Its primarily useful for Desktop GUI development, but there is

Dec 30, 2022
GUI toolkit for go
GUI toolkit for go

Mostly-immediate-mode GUI library for Go. Source port to go of an early version of nuklear. ⚠️ Subject to backwards incompatible changes. ⚠️ ⚠️ Featur

Jan 1, 2023
A chess GUI build using the Fyne toolkit.
A chess GUI build using the Fyne toolkit.

Chess The subject of my current live stream series. A simple chess UI built with Fyne. Thanks to: Chess Go library by Logan Spears github.com/notnil/c

Dec 20, 2022
Kita is a declarative, reactive GUI toolkit for build cross platform apps with web technology with single codebase
Kita is a declarative, reactive GUI toolkit for build cross platform apps with web technology with single codebase

Kita is a declarative, reactive GUI toolkit for build cross platform apps with web technology with single codebase. Inspired by Flutter, React. S

Apr 18, 2022
UIKit - A declarative, reactive GUI toolkit for build cross platform apps with web technology with single codebase
 UIKit - A declarative, reactive GUI toolkit for build cross platform apps with web technology with single codebase

UIKit - A declarative, reactive GUI toolkit for build cross platform apps with web technology with single codebase

Apr 18, 2022
Tpf2-tpnetmap-toolkit - A toolkit to create svg map images from TransportFever2 world data
Tpf2-tpnetmap-toolkit - A toolkit to create svg map images from TransportFever2 world data

tpf2-tpnetmap-toolkit TransportFever2 のワールドデータから svg のマップ画像を作成するツールキットです。 1. 導入方

Feb 17, 2022
gide is an IDE framework in pure Go, using the GoGi gui. It extensively adopts emacs keybindings.
gide is an IDE framework in pure Go, using the GoGi gui.  It extensively adopts emacs keybindings.

Gide Gide is a flexible IDE (integrated development environment) framework in pure Go, using the GoGi GUI (for which it serves as a continuous testing

Jan 8, 2023