Пример #1
0
// The example translation file was generated by executing
// cd l10n
// polyglot -dir=".." -locales="de" -name="hellopolyglot"
func main() {
	var err error
	if trDict, err = polyglot.NewDict("l10n", "de"); err != nil {
		log.Fatal(err)
	}

	// The polyglot command scans Go code for calls to a "tr" function like this
	// one. If context args are provided, they are used for disambiguation.
	fmt.Println(tr("Hello"))
}
Пример #2
0
func main() {
	walk.SetTranslationFunc(tr)

	var err error
	if trDict, err = polyglot.NewDict("../../l10n", "en"); err != nil {
		log.Fatal(err)
	}

	mw := new(MyMainWindow)

	var openAction *walk.Action
	var recentMenu *walk.Menu

	menuActions, err := CreateActions(
		Menu{
			Text: "&File",
			Items: []MenuItem{
				Action{
					AssignTo:    &openAction,
					Text:        "&Open",
					Image:       "../img/open.png",
					OnTriggered: func() { mw.openAction_Triggered() },
				},
				Menu{
					AssignTo: &recentMenu,
					Text:     "Recent",
				},
				Separator{},
				Action{
					Text:        "E&xit",
					OnTriggered: func() { walk.App().Exit(0) },
				},
			},
		})
	if err != nil {
		log.Fatal(err)
	}

	openRecent1Action := walk.NewAction()
	openRecent1Action.SetText("Blah")
	recentMenu.Actions().Add(openRecent1Action)

	openRecent2Action := walk.NewAction()
	openRecent2Action.SetText("Yadda")
	recentMenu.Actions().Add(openRecent2Action)

	openRecent3Action := walk.NewAction()
	openRecent3Action.SetText("Oink")
	recentMenu.Actions().Add(openRecent3Action)

	toolBarActions, err := CreateActions(
		ActionRef{openAction},
		Separator{},
		Action{Text: "Show Dialog", OnTriggered: func() { mw.showDialogAction_Triggered() }})
	if err != nil {
		log.Fatal(err)
	}

	if err := (MainWindow{
		AssignTo:       &mw.MainWindow,
		Title:          "Walk Declarative Example",
		MenuActions:    menuActions,
		ToolBarActions: toolBarActions,
		MinSize:        Size{600, 400},
		Size:           Size{1024, 768},
		Layout:         HBox{MarginsZero: true},
		Children: []Widget{
			TabWidget{
				ContentMarginsZero: true,
				Pages: []TabPage{
					//					TabPage{Title: "golang.org/doc/", Content: WebView{URL: "http://golang.org/doc/"}},
					//					TabPage{Title: "golang.org/ref/", Content: WebView{URL: "http://golang.org/ref/"}},
					//					TabPage{Title: "golang.org/pkg/", Content: WebView{URL: "http://golang.org/pkg/"}},
					TabPage{
						Title:  "Composite Stuff",
						Layout: Grid{},
						Children: []Widget{
							TextEdit{Row: 0, Column: 0, RowSpan: 4},
							PushButton{Row: 0, Column: 1, Text: "Foo"},
							PushButton{Row: 1, Column: 1, Text: "Bar"},
							PushButton{Row: 2, Column: 1, Text: "Baz"},
							VSpacer{Row: 3, Column: 1},
						},
					},
				},
			},
		},
	}.Create()); err != nil {
		log.Fatal(err)
	}

	mw.Run()
}