Convert Figma logo to code with AI

ying32 logogovcl

Cross-platform Go/Golang GUI library.

2,197
229
2,197
13

Top Related Projects

10,376

Qt binding for Go (Golang) with support for Windows / macOS / Linux / FreeBSD / Android / iOS / Sailfish OS / Raspberry Pi / AsteroidOS / Ubuntu Touch / JavaScript / WebAssembly

8,335

Platform-native GUI library for Go.

24,481

Cross platform GUI toolkit in Go inspired by Material Design

2,089

Go bindings for GTK3

6,817

A Windows GUI toolkit for the Go Programming Language

Quick Overview

GoVCL is a cross-platform GUI library for Go, based on Delphi VCL and LCL. It allows developers to create native GUI applications for Windows, Linux, and macOS using Go, leveraging the power and flexibility of the Visual Component Library (VCL) from Delphi.

Pros

  • Cross-platform support for Windows, Linux, and macOS
  • Rich set of pre-built UI components and controls
  • Familiar VCL-style programming for developers with Delphi experience
  • Native look and feel on each supported platform

Cons

  • Requires Lazarus/FPC libraries for Linux and macOS
  • Limited documentation, especially for advanced features
  • Smaller community compared to other Go GUI frameworks
  • May have a steeper learning curve for developers unfamiliar with VCL concepts

Code Examples

  1. Creating a simple window with a button:
package main

import (
    "github.com/ying32/govcl/vcl"
)

func main() {
    vcl.Application.Initialize()
    mainForm := vcl.Application.CreateForm()
    mainForm.SetCaption("Hello GoVCL")
    
    btn := vcl.NewButton(mainForm)
    btn.SetParent(mainForm)
    btn.SetCaption("Click me")
    btn.SetOnClick(func(sender vcl.IObject) {
        vcl.ShowMessage("Hello, World!")
    })
    
    vcl.Application.Run()
}
  1. Creating a menu:
package main

import (
    "github.com/ying32/govcl/vcl"
)

func main() {
    vcl.Application.Initialize()
    mainForm := vcl.Application.CreateForm()
    
    mainMenu := vcl.NewMainMenu(mainForm)
    fileMenu := vcl.NewMenuItem(mainForm)
    fileMenu.SetCaption("File")
    mainMenu.Items().Add(fileMenu)
    
    exitItem := vcl.NewMenuItem(mainForm)
    exitItem.SetCaption("Exit")
    exitItem.SetOnClick(func(sender vcl.IObject) {
        vcl.Application.Terminate()
    })
    fileMenu.Add(exitItem)
    
    vcl.Application.Run()
}
  1. Using a ListView:
package main

import (
    "github.com/ying32/govcl/vcl"
)

func main() {
    vcl.Application.Initialize()
    mainForm := vcl.Application.CreateForm()
    
    listView := vcl.NewListView(mainForm)
    listView.SetParent(mainForm)
    listView.SetAlign(vcl.AlClient)
    
    listView.Items().Add().SetCaption("Item 1")
    listView.Items().Add().SetCaption("Item 2")
    listView.Items().Add().SetCaption("Item 3")
    
    vcl.Application.Run()
}

Getting Started

  1. Install Go and set up your Go environment.
  2. Install GoVCL:
    go get github.com/ying32/govcl
    
  3. For Linux and macOS, install Lazarus/FPC libraries:
  4. Create a new Go file and import the GoVCL package:
    import "github.com/ying32/govcl/vcl"
    
  5. Start building your GUI application using the GoVCL components and run it with go run.

Competitor Comparisons

10,376

Qt binding for Go (Golang) with support for Windows / macOS / Linux / FreeBSD / Android / iOS / Sailfish OS / Raspberry Pi / AsteroidOS / Ubuntu Touch / JavaScript / WebAssembly

Pros of qt

  • Cross-platform support for desktop and mobile (iOS, Android)
  • Extensive set of UI components and widgets
  • Powerful signal/slot mechanism for event handling

Cons of qt

  • Larger binary size due to comprehensive feature set
  • Steeper learning curve, especially for Go developers new to Qt
  • Requires C++ toolchain for compilation

Code Comparison

govcl:

package main

import "github.com/ying32/govcl/vcl"

func main() {
    vcl.Application.Initialize()
    vcl.Application.CreateForm(&mainForm)
    vcl.Application.Run()
}

qt:

package main

import (
    "os"
    "github.com/therecipe/qt/widgets"
)

func main() {
    app := widgets.NewQApplication(len(os.Args), os.Args)
    window := widgets.NewQMainWindow(nil, 0)
    window.Show()
    app.Exec()
}

Both libraries provide ways to create GUI applications in Go, but qt offers a more comprehensive set of features at the cost of increased complexity. govcl focuses on simplicity and ease of use for Windows development, while qt provides broader platform support and a richer set of UI components. The choice between them depends on project requirements, target platforms, and developer preferences.

8,335

Platform-native GUI library for Go.

Pros of ui

  • Pure Go implementation, no CGo dependencies
  • Cross-platform support for Windows, macOS, and Linux
  • Simpler API design for basic UI elements

Cons of ui

  • Less mature and actively maintained compared to govcl
  • Limited set of UI controls and customization options
  • Lacks some advanced features available in govcl

Code Comparison

ui:

window := ui.NewWindow("Hello", 200, 100, false)
button := ui.NewButton("Click Me")
window.SetChild(button)
window.OnClosing(func(*ui.Window) bool {
    ui.Quit()
    return true
})

govcl:

form := vcl.Application.CreateForm()
form.SetCaption("Hello")
form.SetWidth(200)
form.SetHeight(100)
button := vcl.NewButton(form)
button.SetParent(form)
button.SetCaption("Click Me")

Both libraries provide ways to create windows and buttons, but ui has a more concise syntax, while govcl offers more granular control over UI elements. govcl's approach is closer to traditional desktop application development, whereas ui aims for simplicity and ease of use.

24,481

Cross platform GUI toolkit in Go inspired by Material Design

Pros of Fyne

  • Cross-platform support for desktop and mobile
  • Modern, material design-inspired UI
  • Active development and community support

Cons of Fyne

  • Larger binary sizes due to bundled resources
  • Limited native OS integration compared to Govcl

Code Comparison

Fyne:

package main

import (
    "fyne.io/fyne/v2/app"
    "fyne.io/fyne/v2/widget"
)

func main() {
    a := app.New()
    w := a.NewWindow("Hello")
    w.SetContent(widget.NewLabel("Hello Fyne!"))
    w.ShowAndRun()
}

Govcl:

package main

import (
    "github.com/ying32/govcl/vcl"
)

func main() {
    vcl.Application.Initialize()
    mainForm := vcl.Application.CreateForm()
    mainForm.SetCaption("Hello")
    lbl := vcl.NewLabel(mainForm)
    lbl.SetParent(mainForm)
    lbl.SetCaption("Hello Govcl!")
    vcl.Application.Run()
}

Both Fyne and Govcl are GUI frameworks for Go, but they have different approaches. Fyne focuses on cross-platform compatibility and modern design, while Govcl provides deeper integration with native OS components. Fyne's code tends to be more concise, while Govcl offers more fine-grained control over UI elements. The choice between them depends on specific project requirements and target platforms.

2,089

Go bindings for GTK3

Pros of gotk3

  • Uses GTK3, providing a native look and feel on Linux systems
  • Offers a more comprehensive set of widgets and controls
  • Supports cross-platform development (Linux, Windows, macOS)

Cons of gotk3

  • Steeper learning curve due to GTK3's complexity
  • Larger binary size and dependencies
  • Less seamless integration with Windows UI

Code Comparison

gotk3:

import "github.com/gotk3/gotk3/gtk"

win, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
btn, _ := gtk.ButtonNewWithLabel("Click Me")
win.Add(btn)
win.ShowAll()

govcl:

import "github.com/ying32/govcl/vcl"

form := vcl.Application.CreateForm()
btn := vcl.NewButton(form)
btn.SetParent(form)
btn.SetCaption("Click Me")
form.Show()

Additional Notes

govcl is based on Lazarus LCL, offering better Windows integration and smaller binaries. It's easier to use for Windows development but less suited for Linux. gotk3 provides a more native experience on Linux and offers more advanced widgets, but comes with increased complexity and larger dependencies.

6,817

A Windows GUI toolkit for the Go Programming Language

Pros of walk

  • Native Windows look and feel
  • More mature and established project with a larger community
  • Better documentation and examples available

Cons of walk

  • Limited to Windows platform only
  • Less frequent updates and maintenance compared to govcl

Code Comparison

walk:

MainWindow{
    Title:   "Hello",
    MinSize: Size{Width: 300, Height: 200},
    Layout:  VBox{},
    Children: []Widget{
        PushButton{Text: "Click Me"},
    },
}.Run()

govcl:

form := vcl.Application.CreateForm()
form.SetCaption("Hello")
form.SetWidth(300)
form.SetHeight(200)
btn := vcl.NewButton(form)
btn.SetParent(form)
btn.SetCaption("Click Me")
vcl.Application.Run()

Summary

walk is a mature Windows-only GUI toolkit for Go, offering a native look and feel with better documentation. govcl, on the other hand, provides cross-platform support and more frequent updates but may lack the polish and community support of walk. The code comparison shows that walk uses a more declarative approach, while govcl follows a more imperative style for creating user interfaces.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

中文 | English

GoVCL

Cross-platform Golang GUI library, The core binding is liblcl, a common cross-platform GUI library created by Lazarus.

GoVCL is a native GUI library, not based on HTML, let alone DirectUI library, everything is practical.

Full name: Go Language Visual Component Library

govcl minimum requirement is go1.9.2.


Because GoVCL has already entered a stable stage and is currently in a state of pure maintenance. Under normal circumstances, no new features or components will be added. If there are no bugs that need to be fixed (referring to the bugs in govcl), in principle, a new version will not be released. 2023/11/20


Screenshots | WIKI(Chinese) | What's-new(Chinese)


Ⅰ. Support Platform

Windows | Linux | macOS

If you want to support linux arm and linux 32bit, you need to compile the corresponding liblcl binary.

Ⅱ. Pre-compiled GUI library binary download (source code)

liblcl

Ⅲ. UI Designer(Two options)

  • 1、 Easy UI designer (single-page design, suitable for those who do not want to install Lazarus, and the project is not too complicated)

GoVCLDesigner.win

Note: This UI designer is no longer updated, but it does not affect use.

How to use: Installation method

Note: Designed in Lazarus, code written in Golang.

Ⅳ. usage:

Step 1: Get the govcl code

go get -u github.com/ying32/govcl

Note: You can also use go module mode, configure in go.mod, such as: github.com/ying32/govcl v2.2.3+incompatible.

Step 2: Write the code

  • Method 1(Use Lazarus to design the GUI. recommend):
package main


import (
   // Do not reference this package if you use custom syso files
   _ "github.com/ying32/govcl/pkgs/winappres"
   "github.com/ying32/govcl/vcl"
)

type TMainForm struct {
    *vcl.TForm
    Btn1     *vcl.TButton
}

type TAboutForm struct {
    *vcl.TForm
    Btn1    *vcl.TButton
}

var (
    mainForm *TMainForm
    aboutForm *TAboutForm
)

func main() {
    vcl.Application.Initialize()
    vcl.Application.SetMainFormOnTaskBar(true)
    vcl.Application.CreateForm(&mainForm)
    vcl.Application.CreateForm(&aboutForm)
    vcl.Application.Run()
}

// -- TMainForm

func (f *TMainForm) OnFormCreate(sender vcl.IObject) {
    
}

func (f *TMainForm) OnBtn1Click(sender vcl.IObject) {
    aboutForm.Show()
}

// -- TAboutForm

func (f *TAboutForm) OnFormCreate(sender vcl.IObject) {
 
}

func (f *TAboutForm) OnBtn1Click(sender vcl.IObject) {
    vcl.ShowMessage("Hello!")
}

Method 1 needs to be used in conjunction with the res2go tool.

  • Method 2(Pure code, imitating the way of FreePascal class):
package main


import (
   // Do not reference this package if you use custom syso files
   _ "github.com/ying32/govcl/pkgs/winappres"
   "github.com/ying32/govcl/vcl"
)

type TMainForm struct {
    *vcl.TForm
    Btn1     *vcl.TButton
}

type TAboutForm struct {
    *vcl.TForm
    Btn1    *vcl.TButton
}

var (
    mainForm *TMainForm
    aboutForm *TAboutForm
)

func main() {
    vcl.RunApp(&mainForm, &aboutForm)
}

// -- TMainForm

func (f *TMainForm) OnFormCreate(sender vcl.IObject) {
    f.SetCaption("MainForm")
    f.Btn1 = vcl.NewButton(f)
    f.Btn1.SetParent(f)
    f.Btn1.SetBounds(10, 10, 88, 28)
    f.Btn1.SetCaption("Button1")
    f.Btn1.SetOnClick(f.OnBtn1Click)  
}

func (f *TMainForm) OnBtn1Click(sender vcl.IObject) {
    aboutForm.Show()
}


// -- TAboutForm

func (f *TAboutForm) OnFormCreate(sender vcl.IObject) {
    f.SetCaption("About")
    f.Btn1 = vcl.NewButton(f)
    //f.Btn1.SetName("Btn1")
    f.Btn1.SetParent(f)
    f.Btn1.SetBounds(10, 10, 88, 28)
    f.Btn1.SetCaption("Button1")
    f.Btn1.SetOnClick(f.OnBtn1Click)  
}

func (f *TAboutForm) OnBtn1Click(sender vcl.IObject) {
    vcl.ShowMessage("Hello!")
}

Step 3: Copy the corresponding binary

  • Windows: Depending on whether the compiled binary is 32 or 64 bits, copy the corresponding liblcl.dll to the current executable file directory or system environment path.

    • Go environment variable: GOARCH = amd64 386 GOOS = windows CGO_ENABLED=0
  • Linux: Copy liblcl.so under the current executable file directory (you can also copy liblcl.so to /usr/lib/ (32bit liblcl) or /usr/lib/x86_64-linux-gnu/ (64bit liblcl) directory , Used as a public library).

    • Go environment variable: GOARCH = amd64 GOOS = linux CGO_ENABLED=1
  • MacOS: Copy liblcl.dylib to the current executable file directory (note under MacOS: you need to create info.plist file yourself), or refer to: App packaging on MacOS

    • Go environment variable: GOARCH = amd64 GOOS = darwin CGO_ENABLED=1

Note: The "current executable file directory" here refers to the location of the executable file generated by your currently compiled project.


Special Note: All UI components are non-threaded/non-coroutine safe. When used in goroutine, use vcl.ThreadSync to synchronize updates to the UI.

Special Note 2: If you use go>=1.15 to compile Windows executable files, you must use the -buildmode=exe compilation option, otherwise there will be errors.


Ⅴ. FAQ

Q: Why is there no English WIKI?
A: My English is bad. You can try using Google Translate Chinese WIKI.


Ⅵ. API document