Original: "Sciter:gui application with Golang USING html/css"
Author: Manish Champaneri
Golang Visual Library Sciter
Here are a few words from the Sciter website,
Sciter Desktop UI Development brings a range of web technologies. Web designers and developers can reuse their experience and expertise to build seemingly modern desktop applications.
A variety of GUI frameworks provide different UI declarations and format languages, such as QML and XAML (Microsoft WPF). The difference is that Sciter uses long-proven, robust, flexible HTML and CSS to define the GUI and support GPU acceleration.
Before I used Sciter, I tried several other options, but none of them met my requirements. For example, in the beginning, I used Andlabs/ui, I wrote an article about this library, you can read this "Golang graphical interface programming." However, this library is still under development and is not sufficient to support applications in production environments.
In addition I used the Eletron, however the problem is a simple calculator software to occupy 150MB, where 15MB is the Go program, the rest is the Electron itself.
Not long ago, I found another replacement, which is sciter. There is also a free trial of commercially available content (with a certain period of time).
I assume you've read the first two paragraphs of the quote, and if you want to learn more about Sciter, you can visit the website https://sciter.com/.
Here is a simple example of the Sciter application
Simple GUI program built using Sciter & Golang
Next I share the source code for Go and HTML files (in the same directory).
Go file
Package Mainimport ("FMT" "Github.com/fatih/color" Sciter "Github.com/sciter-sdk/go-sciter" "github.com/sciter-sdk/ Go-sciter/window ")//specifying havily used//singltons to make them//package wide Availablevar root *sciter. Elementvar rootselectorerr Errorvar W *window. Windowvar windowerr error//preapare scitre for execution///func init () {//Initlzigin windows for downloaer//app with AP Propriate propertiesrect: = Sciter. Newrect (0, +, +) W, windowerr = window. New (sciter.sw_titlebar|sciter.sw_controls|sciter.sw_main|sciter.sw_glassy,rect) if windowerr! = nil {fmt. Println ("Can not create New window") return}//Loading main HTML file for Apphtloaderr: = W.loadfile ("./main.html") if Htloa Derr! = Nil {fmt. Println ("Can not load HTML in the screens", Htloaderr.error ()) return}//initializng Selector at global level as we are go ing to need//it mostly and as it isroot, Rootselectorerr = W.getrootelement () if rootselectorerr! = nil {fmt. Println ("Can not select root element") return}//Set tItle of the Appliaction Windoww. Settitle ("Simple Calc")}//Preaprare program for execution///func main () {AddButton, _: = root. Selectbyid ("Add") out1, errout1: = root. Selectbyid ("OUTPUT1") if errout1! = nil {color. Red ("failed to bound output 1", errout1. Error ())}addbutton. OnClick (func () {Output: = Add () out1. SetText (FMT. Sprint (Output)}) W.show () W.run ()}/////////////////////////////////////////////////////Function of Calc Func Add () int {//refreshing and fetching inputs () in1, Errin 1: = root. Selectbyid ("input1") if errin1! = nil {color. Red ("Failed to bound input 1", errin1. Error ())}in2, errin2: = root. Selectbyid ("Input2") if errin2! = nil {color. Red ("Failed to bound input 2", errin2. Error ())}in1val, Errv1: = in1. GetValue () color. Green (In1val. String ()) if errv1! = nil {color. Red (ERRV1. Error ())}in2val, Errv2: = in2. GetValue () if errv2! = nil {color. Red (Errv2. Error ())}color. Green (In2val. String ()) return in1val. Int () + In2val. Int ()}///////////////////////////////////////////////////
HTML file
In fact, one of the problems I've found is that I need to refresh the HTML element bindings in order to get the latest values from them.
Maybe I've done something wrong, and maybe someone else has come across this problem, there's no way.
In any case, Sciter is the most promising GUI library for using Go to build a visual application.
Hope to help you!