中文|英语
跨平台Gulang GUI库,核心绑定是Liblcl,这是Lazarus创建的常见跨平台GUI库。
GovCl是一个本地GUI库,不是基于HTML,更不用说Directui库了,一切都是实用的。
全名: Go Language Visual Component Library
GovCl最低要求是GO1.9.2。
因为GoVCL已经进入了稳定的阶段,目前处于纯维护状态。在正常情况下,不会添加新功能或组件。如果没有需要修复的错误(参考GovCl中的错误),则原则上不会发布新版本。 2023/11/20
屏幕截图| Wiki(中文)|什么是新的(中文)
Windows | Linux | macos
如果要支持Linux Arm和Linux 32bit,则需要编译相应的Liblcl二进制文件。
注意:该UI设计器不再更新,但不会影响使用。
如何使用:安装方法
注意:用拉撒路设计,用戈兰编写的代码。
去获取-u github.com/ying32/govcl
注意:您还可以使用GO模块模式,在Go.Mod中进行配置,例如: github.com/ying32/govcl v2.2.3+incompatible 。
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!" )
}方法1需要与RES2GO工具一起使用。
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!" )
}Windows:根据编译的二进制文件是32还是64位,将相应的liblcl.dll复制到当前可执行文件目录或系统环境路径。
GOARCH = amd64 386 GOOS = windows CGO_ENABLED=0 linux:在当前可执行文件目录下复制liblcl.so (您还可以将liblcl.so复制到/usr/lib/ (32bit liblcl)或/usr/lib/x86_64-linux-gnu/ (64bit liblcl)目录,用作公共库)。
GOARCH = amd64 GOOS = linux CGO_ENABLED=1 MACOS:将liblcl.dylib复制到当前可执行文件目录(在macos下注:您需要自己创建info.plist文件),或参考:macos上的应用程序包装
GOARCH = amd64 GOOS = darwin CGO_ENABLED=1注意:此处的“当前可执行文件目录”是指您当前编译的项目生成的可执行文件的位置。
特别说明:所有UI组件都是非线程/非核心安全的。在Goroutine中使用时,使用VCL.ThreadSync将更新与UI同步。
特殊注释2:如果使用GO> = 1.15来编译Windows可执行文件,则必须使用-buildmode=exe编译选项,否则会有错误。
问:为什么没有英语Wiki?
答:我的英语不好。您可以尝试使用Google翻译中文Wiki。