Golang UI template note.
I use golang framework lxn/walk
Walk currently requires Go 1.11.x or later.
DEFAULT
test.go
package main import ( "github.com/lxn/walk" . "github.com/lxn/walk/declarative" "strings" ) func main() { var inTE, outTE *walk.TextEdit MainWindow{ Title: "SCREAMO", MinSize: Size{600, 400}, Layout: VBox{}, Children: []Widget{ HSplitter{ Children: []Widget{ TextEdit{AssignTo: &inTE}, TextEdit{AssignTo: &outTE, ReadOnly: true}, }, }, PushButton{ Text: "SCREAM", OnClicked: func() { outTE.SetText(strings.ToUpper(inTE.Text())) }, }, }, }.Run() }Create Manifest test.manifest
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly manifestversion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"> <assemblyidentity name="SomeFunkyNameHere" processorarchitecture="*" type="win32" version="1.0.0.0"> <dependency> <dependentassembly> <assemblyidentity language="*" name="Microsoft.Windows.Common-Controls" processorarchitecture="*" publickeytoken="6595b64144ccf1df" type="win32" version="6.0.0.0"> </assemblyidentity></dependentassembly> </dependency> <application xmlns="urn:schemas-microsoft-com:asm.v3"> <windowssettings> <dpiawareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiawareness> <dpiaware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">True</dpiaware> </windowssettings> </application> </assemblyidentity></assembly>Then either compile the manifest using the rsrc tool, like this:
go get github.com/akavel/rsrc rsrc -manifest test.manifest -o rsrc.sysoor rename the test.manifest file to test.exe.manifest and distribute it with the application instead.
MY OWN MODIFIED Dialog
package main import ( "log" "github.com/lxn/walk" . "github.com/lxn/walk/declarative" ) func main() { var dlg *walk.Dialog var acceptPB, cancelPB *walk.PushButton Dialog{ Title: "Scremo", DefaultButton: &acceptPB, CancelButton: &cancelPB, MinSize: Size{300, 300}, Layout: VBox{}, Children: []Widget{ Composite{ Layout: Grid{Columns: 2}, Children: []Widget{ Label{ Text: "Name:", }, LineEdit{ Text: Bind("Name"), }, Label{ Text: "Arrival Date:", }, DateEdit{ Date: Bind("ArrivalDate"), }, Label{ Text: "Species:", }, ComboBox{ Value: Bind("SpeciesId", SelRequired{}), BindingMember: "Id", DisplayMember: "Name", //Model: KnownSpecies(), }, Label{ Text: "Speed:", }, Slider{ Value: Bind("Speed"), }, RadioButtonGroupBox{ ColumnSpan: 2, Title: "Sex", Layout: HBox{}, DataMember: "Sex", Buttons: []RadioButton{ RadioButton{ Name: "aRB", Text: "A", Value: "a", }, RadioButton{ Name: "bRB", Text: "B", Value: "b", }, }, }, Label{ Text: "Weight:", }, NumberEdit{ Value: Bind("Weight", Range{0.01, 9999.99}), Suffix: " kg", Decimals: 2, }, Label{ Text: "Preferred Food:", }, ComboBox{ Editable: true, Value: Bind("PreferredFood"), Model: []string{"Fruit", "Grass", "Fish", "Meat"}, }, Label{ Text: "Domesticated:", }, CheckBox{ Checked: Bind("Domesticated"), }, VSpacer{ ColumnSpan: 2, Size: 8, }, Label{ ColumnSpan: 2, Text: "Remarks:", }, TextEdit{ ColumnSpan: 2, MinSize: Size{100, 50}, Text: Bind("Remarks"), }, Label{ ColumnSpan: 2, Text: "Patience:", }, LineEdit{ ColumnSpan: 2, Text: Bind("PatienceField"), }, }, }, Composite{ Layout: HBox{}, Children: []Widget{ HSpacer{}, PushButton{ AssignTo: &acceptPB, Text: "OK", OnClicked: func() { dlg.Accept() }, }, PushButton{ AssignTo: &cancelPB, Text: "Cancel", OnClicked: func() { dlg.Cancel() }, }, }, }, }, }.Run(nil) } func RunAnimalDialog(owner walk.Form) (int, error) { var dlg *walk.Dialog var db *walk.DataBinder var acceptPB, cancelPB *walk.PushButton return Dialog{ AssignTo: &dlg, Title: Bind("'Animal Details' + (animal.Name == '' ? '' : ' - ' + animal.Name)"), DefaultButton: &acceptPB, CancelButton: &cancelPB, DataBinder: DataBinder{ AssignTo: &db, Name: "animal", //DataSource: animal, ErrorPresenter: ToolTipErrorPresenter{}, }, MinSize: Size{300, 300}, Layout: VBox{}, Children: []Widget{ Composite{ Layout: Grid{Columns: 2}, Children: []Widget{ Label{ Text: "Name:", }, LineEdit{ Text: Bind("Name"), }, Label{ Text: "Arrival Date:", }, DateEdit{ Date: Bind("ArrivalDate"), }, Label{ Text: "Species:", }, ComboBox{ Value: Bind("SpeciesId", SelRequired{}), BindingMember: "Id", DisplayMember: "Name", //Model: KnownSpecies(), }, Label{ Text: "Speed:", }, Slider{ Value: Bind("Speed"), }, RadioButtonGroupBox{ ColumnSpan: 2, Title: "Sex", Layout: HBox{}, DataMember: "Sex", Buttons: []RadioButton{ RadioButton{ Name: "aRB", Text: "A", Value: "a", }, RadioButton{ Name: "bRB", Text: "B", Value: "b", }, }, }, Label{ Text: "Weight:", }, NumberEdit{ Value: Bind("Weight", Range{0.01, 9999.99}), Suffix: " kg", Decimals: 2, }, Label{ Text: "Preferred Food:", }, ComboBox{ Editable: true, Value: Bind("PreferredFood"), Model: []string{"Fruit", "Grass", "Fish", "Meat"}, }, Label{ Text: "Domesticated:", }, CheckBox{ Checked: Bind("Domesticated"), }, VSpacer{ ColumnSpan: 2, Size: 8, }, Label{ ColumnSpan: 2, Text: "Remarks:", }, TextEdit{ ColumnSpan: 2, MinSize: Size{100, 50}, Text: Bind("Remarks"), }, Label{ ColumnSpan: 2, Text: "Patience:", }, LineEdit{ ColumnSpan: 2, Text: Bind("PatienceField"), }, }, }, Composite{ Layout: HBox{}, Children: []Widget{ HSpacer{}, PushButton{ AssignTo: &acceptPB, Text: "OK", OnClicked: func() { if err := db.Submit(); err != nil { log.Print(err) return } dlg.Accept() }, }, PushButton{ AssignTo: &cancelPB, Text: "Cancel", OnClicked: func() { dlg.Cancel() }, }, }, }, }, }.Run(owner) }