About dialog
dialog.ShowAbout
builds an About box from your app’s metadata. At the top it shows the app
icon, the name and the version. Your content goes under them, and your links
are placed in a row along the bottom.
site, _ := url.Parse("https://bellui.com")
source, _ := url.Parse("https://github.com/belluikit")
links := []*widget.Hyperlink{
widget.NewHyperlink("Website", site),
widget.NewHyperlink("Source", source),
}
content := "A small **example** app.\n\nReleased under the BSD 3-Clause license."
inWindow := widget.NewButton("About (dialog)", func() {
dialog.ShowAbout(content, links, a, w)
})
separate := widget.NewButton("About (window)", func() {
dialog.ShowAboutWindow(content, links, a)
})- The content is Markdown, so you can use bold text, lists and links in it. Images from the network are not loaded.
- The links are
widget.Hyperlinkvalues. - The title is “About” followed by the app name.
dialog.ShowAboutWindow
shows the same content in a new window instead of a dialog over an existing
one. NewAbout and NewAboutWindow return the dialog or window without
showing it.
Where the name, version and icon come from
They are read from App.Metadata,
which comes from your app’s manifest.pxf file. When metadata is missing, the
dialog leaves out what it does not have, and the title is just “About”. See
App metadata for the manifest format and for when
the metadata is available in this release.
The complete example
// An About dialog built from the app's metadata.
package main
import (
"net/url"
"github.com/belluikit/bellui"
"github.com/belluikit/bellui/app"
"github.com/belluikit/bellui/container"
"github.com/belluikit/bellui/dialog"
"github.com/belluikit/bellui/widget"
)
func main() {
a := app.NewWithID("com.example.about")
w := a.NewWindow("About")
site, _ := url.Parse("https://bellui.com")
source, _ := url.Parse("https://github.com/belluikit")
links := []*widget.Hyperlink{
widget.NewHyperlink("Website", site),
widget.NewHyperlink("Source", source),
}
content := "A small **example** app.\n\nReleased under the BSD 3-Clause license."
inWindow := widget.NewButton("About (dialog)", func() {
dialog.ShowAbout(content, links, a, w)
})
separate := widget.NewButton("About (window)", func() {
dialog.ShowAboutWindow(content, links, a)
})
w.SetContent(container.NewVBox(inWindow, separate))
bellui.ShowAndRun(w)
}