中文 | ภาษาอังกฤษ
Cross-Platform Golang GUI Library, Core Binding คือ Liblcl ซึ่งเป็นห้องสมุด GUI ข้ามแพลตฟอร์มทั่วไปที่สร้างโดย Lazarus
Govcl เป็นห้องสมุด GUI พื้นเมืองไม่ได้ขึ้นอยู่กับ HTML ซึ่งเป็นห้องสมุด DirectUI เพียงอย่างเดียวทุกอย่างเป็นประโยชน์
ชื่อเต็ม: Go Language Visual Component Library
ข้อกำหนดขั้นต่ำของ Govcl คือ GO1.9.2
เนื่องจาก Govcl ได้เข้าสู่ขั้นตอนที่มั่นคงแล้วและปัจจุบันอยู่ในสถานะของการบำรุงรักษาที่บริสุทธิ์ ภายใต้สถานการณ์ปกติจะไม่มีการเพิ่มคุณสมบัติหรือส่วนประกอบใหม่ หากไม่มีข้อบกพร่องที่จำเป็นต้องได้รับการแก้ไข (หมายถึงข้อบกพร่องใน Govcl) โดยหลักการแล้วเวอร์ชันใหม่จะไม่ถูกปล่อยออกมา 2023/11/20
ภาพหน้าจอ | วิกิ (จีน) | อะไรใหม่ (จีน)
Windows | Linux | แม็กอส
หากคุณต้องการรองรับ Linux Arm และ Linux 32bit คุณต้องรวบรวมไบนารี liblcl ที่เกี่ยวข้อง
หมายเหตุ: นักออกแบบ UI นี้ไม่ได้รับการอัปเดตอีกต่อไป แต่จะไม่มีผลต่อการใช้งาน
วิธีใช้: วิธีการติดตั้ง
หมายเหตุ: ออกแบบใน Lazarus รหัสที่เขียนใน Golang
ไปรับ -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 to /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 ทั้งหมดนั้นไม่ปลอดภัย/ไม่ใช่ coroutine เมื่อใช้ใน goroutine ให้ใช้ vcl.threadsync เพื่อซิงโครไนซ์การอัปเดตเป็น UI
หมายเหตุพิเศษ 2: หากคุณใช้ GO> = 1.15 เพื่อรวบรวมไฟล์ปฏิบัติการ Windows คุณต้องใช้ตัวเลือกการรวบรวม -buildmode=exe มิฉะนั้นจะมีข้อผิดพลาด
ถาม: ทำไมไม่มีวิกิภาษาอังกฤษ?
A: ภาษาอังกฤษของฉันไม่ดี คุณสามารถลองใช้ Google Translate Chinese Wiki