Browse Source

学习xsgui

master
VIVIMAN 2 years ago
parent
commit
506f06bb38
  1. BIN
      golang_learn/data_func/go_to_xcgui/main02/demo.zip
  2. 17
      golang_learn/data_func/go_to_xcgui/main02/main.go
  3. BIN
      golang_learn/data_func/go_to_xcgui/main03/demo.zip
  4. 40
      golang_learn/data_func/go_to_xcgui/main03/main.go

BIN
golang_learn/data_func/go_to_xcgui/main02/demo.zip

Binary file not shown.

17
golang_learn/data_func/go_to_xcgui/main02/main.go

@ -5,24 +5,19 @@ import (
"github.com/twgh/xcgui/app" "github.com/twgh/xcgui/app"
"github.com/twgh/xcgui/widget" "github.com/twgh/xcgui/widget"
"github.com/twgh/xcgui/window" "github.com/twgh/xcgui/window"
"github.com/twgh/xcgui/xc"
) )
// TODO 失败 // TODO 失败
//go:embed XCGUI.dll
var dll []byte
//go:embed demo.zip
var zip []byte
func main() { func main() {
// 把 xcgui.dll 写出到windows临时目录
_ = xc.WriteDll(dll)
a := app.New(true) a := app.New(true)
// 创建窗口从内存压缩包中的布局文件 // 添加文件搜索路径, 因为main.xml没有在程序运行目录
w := window.NewByLayoutZipMem(zip, "main.xml", "123456", 0, 0) a.AddFileSearchPath(`D:\XcCodes\demo`)
// 创建窗口从布局文件
w := window.NewByLayout("main.xml", 0, 0)
// 获取窗口布局文件中的按钮 // 获取窗口布局文件中的按钮
// btn := widget.NewButtonByHandle(1000)
// btn := widget.NewButtonByUID(1000)
btn := widget.NewButtonByName("viviman") btn := widget.NewButtonByName("viviman")
// 注册按钮被单击事件 // 注册按钮被单击事件
btn.Event_BnClick(func(pbHandled *bool) int { btn.Event_BnClick(func(pbHandled *bool) int {

BIN
golang_learn/data_func/go_to_xcgui/main03/demo.zip

Binary file not shown.

40
golang_learn/data_func/go_to_xcgui/main03/main.go

@ -0,0 +1,40 @@
package main
import (
_ "embed"
"github.com/twgh/xcgui/app"
"github.com/twgh/xcgui/widget"
"github.com/twgh/xcgui/window"
"github.com/twgh/xcgui/xc"
)
// TODO 失败
//go:embed XCGUI.dll
var dll []byte
//go:embed demo.zip
var zip []byte
func main() {
// 把 xcgui.dll 写出到windows临时目录
_ = xc.WriteDll(dll)
a := app.New(true)
// 创建窗口从内存压缩包中的布局文件
w := window.NewByLayoutZipMem(zip, "main.xml", "123456", 0, 0)
// 获取窗口布局文件中的按钮
btn := widget.NewButtonByUID(0)
// btn := widget.NewButtonByName("viviman")
// 注册按钮被单击事件
btn.Event_BnClick(func(pbHandled *bool) int {
a.Alert("提示", btn.GetText()+"被点击")
return 0
})
// 调整布局, 必须
w.AdjustLayout()
// 显示窗口
w.Show(true)
a.Run()
a.Exit()
}
Loading…
Cancel
Save