All Projects β†’ Equanox β†’ Gotron

Equanox / Gotron

Licence: mit
Go Api for Electron

Programming Languages

javascript
184084 projects - #8 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Gotron

Walk
A Windows GUI toolkit for the Go Programming Language
Stars: ✭ 5,813 (+657.89%)
Mutual labels:  gui
Prettyzoo
πŸ˜‰ Pretty nice Zookeeper GUI, Support Win / Mac / Linux Platform
Stars: ✭ 671 (-12.52%)
Mutual labels:  gui
Vim Quickui
The missing UI extensions for Vim 8.2 (and NeoVim 0.4) !! 😎
Stars: ✭ 714 (-6.91%)
Mutual labels:  gui
Copperspice
Cross platform C++ libraries
Stars: ✭ 630 (-17.86%)
Mutual labels:  gui
Goggles
πŸ”­ Goggles is a cross-platform GUI for your $GOPATH!
Stars: ✭ 672 (-12.39%)
Mutual labels:  gui
Openlabeling
Label images and video for Computer Vision applications
Stars: ✭ 706 (-7.95%)
Mutual labels:  gui
Sixtyfps
SixtyFPS is a toolkit to efficiently develop fluid graphical user interfaces for any display: embedded devices and desktop applications. We support multiple programming languages, such as Rust, C++ or JavaScript.
Stars: ✭ 605 (-21.12%)
Mutual labels:  gui
Redis Tui
A Redis Text-based UI client in CLI
Stars: ✭ 757 (-1.3%)
Mutual labels:  gui
React Nodegui
Build performant, native and cross-platform desktop applications with native React + powerful CSS like styling.πŸš€
Stars: ✭ 5,914 (+671.06%)
Mutual labels:  gui
Ns Usbloader
Awoo Installer/TinFoil/GoldLeaf NSPs (and other files) uploader and RCM tool. Also a tool for split files and merge them back.
Stars: ✭ 708 (-7.69%)
Mutual labels:  gui
Lvgl
Powerful and easy-to-use embedded GUI library with many widgets, advanced visual effects (opacity, antialiasing, animations) and low memory requirements (16K RAM, 64K Flash).
Stars: ✭ 8,172 (+965.45%)
Mutual labels:  gui
Textractor
Extracts text from video games and visual novels. Highly extensible.
Stars: ✭ 656 (-14.47%)
Mutual labels:  gui
Debotnet
πŸ”₯πŸš€ Debotnet is a tiny portable tool for controlling Windows 10's many privacy-related settings and keep your personal data private.
Stars: ✭ 707 (-7.82%)
Mutual labels:  gui
Cvui
A (very) simple UI lib built on top of OpenCV drawing primitives
Stars: ✭ 619 (-19.3%)
Mutual labels:  gui
Webview deno
🌐 Deno bindings for webview, a tiny library for creating web-based desktop GUIs
Stars: ✭ 729 (-4.95%)
Mutual labels:  gui
Guilite
βœ”οΈThe smallest header-only GUI library(4 KLOC) for all platforms
Stars: ✭ 5,841 (+661.54%)
Mutual labels:  gui
Python Progressbar
Progressbar 2 - A progress bar for Python 2 and Python 3 - "pip install progressbar2"
Stars: ✭ 682 (-11.08%)
Mutual labels:  gui
Garbro
Visual Novels resource browser
Stars: ✭ 764 (-0.39%)
Mutual labels:  gui
Bmw Tensorflow Training Gui
This repository allows you to get started with a gui based training a State-of-the-art Deep Learning model with little to no configuration needed! NoCode training with TensorFlow has never been so easy.
Stars: ✭ 736 (-4.04%)
Mutual labels:  gui
Cimgui
c-api for imgui (https://github.com/ocornut/imgui) Look at: https://github.com/cimgui for other widgets
Stars: ✭ 707 (-7.82%)
Mutual labels:  gui

Build Status

Gotron

Go Api for Electron.

⚠️ This project is no longer maintained. ⚠️

Feel free to fork and make your own changes if needed.

Example Projects

A list of boilerplate projects using gotron.

Prerequisites

go1.11 with modules enabled, nodejs and npm must be available on your system.

Quick Start

On the first run it will download Electron and stores it in .gotron in your working directory.

package main

import (
    "github.com/Equanox/gotron"
)

func main() {
    // Create a new browser window instance
    window, err := gotron.New()
    if err != nil {
        panic(err)
    }

    // Alter default window size and window title.
    window.WindowOptions.Width = 1200
    window.WindowOptions.Height = 980
    window.WindowOptions.Title = "Gotron"

    // Start the browser window.
    // This will establish a golang <=> nodejs bridge using websockets,
    // to control ElectronBrowserWindow with our window object.
    done, err := window.Start()
    if err != nil {
        panic(err)
    }
    
    // Open dev tools must be used after window.Start 
    // window.OpenDevTools()
    
    // Wait for the application to close
    <-done
}

When everything worked you should see this

Hello Gotron

Use Your Own WebUI

gotron expects a folder containing your HTML/JS/CSS code and passes it to electronJS. make sure it contains at least a index.html as entrypoint.

Pass a path to your webUI on gotrons New(uiFolder ...string) function.

window, err := gotron.New("path/to/your/webui")
if err != nil {
    panic(err)
}

Communicate between backend and frontend

Frontend to backend communication is realized through javascript like event driven apporach.

Backend

Handle incoming events

window.On(&gotron.Event{Event: "event-name"}, func(bin []byte) {
	//Handle event here
}

Send event to frontend

// Create a custom event struct that has a pointer to gotron.Event
type CustomEvent struct {
    *gotron.Event
    CustomAttribute string 'json:"AtrNameInFrontend"'
}

window.Send(&CustomEvent{
    Event: &gotron.Event{Event: "event-name"},
    CustomAttribute: "Hello World!",
    })

Frontend

In frontend a websocket needs to be created. Adress is always localhost and port can be taken from global variable global.backendPort

let ws = new WebSocket("ws://localhost:" + global.backendPort + "/web/app/events");

Handle incoming events

// This is being called for all incoming messages
ws.onmessage = (message) => {
    let obj = JSON.parse(message.data);
    
    // event name
    console.log(obj.event);

    // event data
    console.log(obj.AtrNameInFrontend);
}

Send event to backend

ws.send(JSON.stringify({
    "event": "event-name",
    "AtrNameInFrontend": "Hello World!",
}))

Distribution/Packaging

To package a go application together with electornjs use gotron-builder.

Install gotron-builder

We provide executables for Linux, MacOS and Windows.
Download the newest release from https://github.com/Equanox/gotron/releases and add it to your $PATH.

Using gotron-builder

It expects...

  • a directory containing a golang main package
  • and a directory with a webUI containing at least a index.html

By default it will implicitly use...

  • golang main package from the current directory
  • webUI from .gotron/assets

To pack the code from Quick Start use

gotron-builder

in the root of your repo.

Pass your go code and webUI explicitly.

gotron-builder --go=your/go/dir --app=your/webapp/dir

For cross compilation you can use the same flags as electron-builder would expect them

gotron-builder --win 

Read about the requirements for cross-compilation in electron-builders documentation.

Tasks

  • [x] Basic js + webpack example
  • [x] React example
  • [x] Typescript-React example
  • [x] Vue.js example
  • [ ] Elm example
  • [ ] Flutter Hummingbird example
  • [X] Hide nodejs/Electron behind go api
  • [X] Create executables for Win, Linux, MacOS
  • [X] Hide nodejs/Electron behind go api
  • [ ] Msgs between golang and Electron renderer process, abstracted in a javascript/typescript package
  • [ ] Implement complete BrowserWindow api see => BrowserWindow.md
  • [ ] Implement complete electron-builder api in gotron-builder

Sponsors

benchkram-logo

License

MIT

Except Roboto (ui/js/src/Roboto-Light.ttf , ui/react/src/Roboto-Light.ttf) which is licensed under Apache 2.0
https://github.com/google/roboto

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].