govcl

module
v0.0.0-...-f46019e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2022 License: Apache-2.0

README

中文 | English


Next release: no plans, maybe wait until Lazarus 2.4? , If you want to use the new code that can use the dev branch in advance.

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.

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

res2go IDE plugin source code(source code

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.0+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


jetbrains
Thanks jetbrains

Directories

Path Synopsis
Tools
genbinres command
pkgs
samples
OSVersion command
Windows/listviewitemedit command
由res2go自动生成,不要编辑。
由res2go自动生成,不要编辑。
Windows/miniblinkWebview command
由GOVCL UI设计器自动生成,不要编辑
由GOVCL UI设计器自动生成,不要编辑
Windows/taskbar command
Windows/winole command
action command
basic command
basicResForm command
checklistbox command
clipbrd command
clock command
comboboxEx command
由res2go自动生成,不要编辑。
由res2go自动生成,不要编辑。
customLibTest command
draganddrop command
draw command
drawchart command
drawrose command
drawusegg command
dropfiles command
eventpublic command
fileshelltree command
formEvents command
formscale command
govcl command
govcl project main.go go.exe build -i -ldflags="-H windowsgui"
govcl project main.go go.exe build -i -ldflags="-H windowsgui"
grids/drawgrid command
imagebutton command
imageviewer command
inifile command
intfTest command
jsonTogo command
jsonViewer command
labeledit command
layout command
listview command
login command
macOS/nswindowTest command
由res2go自动生成,不要编辑。
由res2go自动生成,不要编辑。
markdownEd command
memstream command
menu command
messageTest command
miniwebview command
由GOVCL UI设计器自动生成,不要编辑
由GOVCL UI设计器自动生成,不要编辑
mp3Player command
msgbox command
multilanguage command
notepad command
printer command
redisViewer command
由res2go自动生成,不要编辑。
由res2go自动生成,不要编辑。
res2goTest/Lazarus/gocode command
由res2go自动生成,不要编辑。
由res2go自动生成,不要编辑。
res2goTest/Test/gocode command
由res2go自动生成,不要编辑。
由res2go自动生成,不要编辑。
richedit command
simplecalc command
由res2go自动生成,不要编辑。
由res2go自动生成,不要编辑。
simplelibvlc command
statusbar command
stdcontrols command
sysdialog command
syslocale command
taskdialog command
testEmbed command
Automatically generated by the res2go IDE plug-in.
Automatically generated by the res2go IDE plug-in.
threadid command
trayicon command
treeview command
valuelisteditor command
videosrtgui command
Automatically generated by the res2go, do not edit.
Automatically generated by the res2go, do not edit.
xbuttonTest command
vcl
api
---------------------------------------- 加载文件或者内存中的窗口资源文件功能 需要配合窗口设计器使用 ----------------------------------------
---------------------------------------- 加载文件或者内存中的窗口资源文件功能 需要配合窗口设计器使用 ----------------------------------------
bitmap
实现一些Go的Image转lcl的
实现一些Go的Image转lcl的
rtl
win

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL