Add wml demo

This commit is contained in:
Lea Anthony
2023-02-16 20:16:20 +11:00
parent 0881914244
commit af5e383905
2 changed files with 69 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Wails ML Demo</title>
</head>
<body style="margin-top:50px; color: white;">
<h2>Wails ML Demo</h2>
<p>This application contains no Javascript!</p>
<button data-wml-event="button-pressed">Press me!</button>
<button data-wml-event="delete-things" data-wml-confirm="Are you sure?">Delete all the things!</button>
<button data-wml-window="Close" data-wml-confirm="Are you sure?">Close the Window?</button>
<button data-wml-window="Center">Center</button>
<button data-wml-window="Minimise">Minimise</button>
<button data-wml-window="Maximise">Maximise</button>
<button data-wml-window="Fullscreen">Fullscreen</button>
<div style="width: 200px; height: 200px; border: 2px solid white;" data-wml-event="hover" data-wml-trigger="mouseover">Hover over me</div>
</body>
</html>
+50
View File
@@ -0,0 +1,50 @@
package main
import (
"embed"
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed assets/*
var assets embed.FS
func main() {
app := application.New(application.Options{
Name: "Wails ML Demo",
Description: "A demo of the Wails ML API",
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Title: "Wails ML Demo",
Width: 800,
Height: 600,
Assets: application.AssetOptions{
FS: assets,
},
Mac: application.MacWindow{
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInsetUnified,
InvisibleTitleBarHeight: 50,
},
})
app.Events.On("button-pressed", func(_ *application.CustomEvent) {
println("Button Pressed!")
})
app.Events.On("hover", func(_ *application.CustomEvent) {
println("Hover time!")
})
err := app.Run()
if err != nil {
log.Fatal(err.Error())
}
}