中文|英語
跨平台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。