本文整理汇总了Golang中github.com/lxn/walk.Menu类的典型用法代码示例。如果您正苦于以下问题:Golang Menu类的具体用法?Golang Menu怎么用?Golang Menu使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Menu类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
var tool *walk.Action
var menutool *walk.Menu
var mw *walk.MainWindow
mw.SetMaximizeBox(false)
mw.SetFixedSize(true)
mw, _ = walk.NewMainWindowCody()
mw.SetTitle("测试")
mw.SetSize(walk.Size{300, 200})
menutool, _ = walk.NewMenu()
tool = walk.NewMenuAction(menutool)
tool.SetText("文件")
open := walk.NewAction()
open.SetText("打开")
exit := walk.NewAction()
exit.SetText("退出")
menutool.Actions().Add(open)
menutool.Actions().Add(exit)
men2, _ := walk.NewMenu()
too2 := walk.NewMenuAction(men2)
too2.SetText("工具")
mw.Menu().Actions().Add(tool)
mw.Menu().Actions().Add(too2)
mw.Show()
mw.Run()
}
开发者ID:CodyGuo,项目名称:Go-Cody,代码行数:34,代码来源:main.go
示例2: createAction
func (m Menu) createAction(builder *Builder, menu *walk.Menu) (*walk.Action, error) {
subMenu, err := walk.NewMenu()
if err != nil {
return nil, err
}
action, err := menu.Actions().AddMenu(subMenu)
if err != nil {
return nil, err
}
if err := action.SetText(m.Text); err != nil {
return nil, err
}
if err := setActionImage(action, m.Image); err != nil {
return nil, err
}
for _, item := range m.Items {
if _, err := item.createAction(builder, subMenu); err != nil {
return nil, err
}
}
if m.AssignActionTo != nil {
*m.AssignActionTo = action
}
if m.AssignTo != nil {
*m.AssignTo = subMenu
}
return action, nil
}
开发者ID:bonyz,项目名称:walk,代码行数:33,代码来源:action.go
示例3: createAction
func (a Action) createAction(menu *walk.Menu) (*walk.Action, error) {
action := walk.NewAction()
if err := action.SetText(a.Text); err != nil {
return nil, err
}
if err := setActionImage(action, a.Image); err != nil {
return nil, err
}
if a.OnTriggered != nil {
action.Triggered().Attach(a.OnTriggered)
}
if menu != nil {
if err := menu.Actions().Add(action); err != nil {
return nil, err
}
}
if a.AssignTo != nil {
*a.AssignTo = action
}
return action, nil
}
开发者ID:karlma,项目名称:walk,代码行数:26,代码来源:action.go
示例4: createAction
func (a Action) createAction(builder *Builder, menu *walk.Menu) (*walk.Action, error) {
action := walk.NewAction()
if err := action.SetText(a.Text); err != nil {
return nil, err
}
if err := setActionImage(action, a.Image); err != nil {
return nil, err
}
if a.Enabled != nil {
if b, ok := a.Enabled.(bool); ok {
if err := action.SetEnabled(b); err != nil {
return nil, err
}
} else if s := builder.conditionOrProperty(a.Enabled); s != nil {
if c, ok := s.(walk.Condition); ok {
action.SetEnabledCondition(c)
} else {
return nil, fmt.Errorf("value of invalid type bound to Action.Enabled: %T", s)
}
}
}
if a.Visible != nil {
if b, ok := a.Visible.(bool); ok {
if err := action.SetVisible(b); err != nil {
return nil, err
}
} else if s := builder.conditionOrProperty(a.Visible); s != nil {
if c, ok := s.(walk.Condition); ok {
action.SetVisibleCondition(c)
} else {
return nil, fmt.Errorf("value of invalid type bound to Action.Visible: %T", s)
}
}
}
s := a.Shortcut
if err := action.SetShortcut(walk.Shortcut{s.Modifiers, s.Key}); err != nil {
return nil, err
}
if a.OnTriggered != nil {
action.Triggered().Attach(a.OnTriggered)
}
if menu != nil {
if err := menu.Actions().Add(action); err != nil {
return nil, err
}
}
if a.AssignTo != nil {
*a.AssignTo = action
}
return action, nil
}
开发者ID:jeffycf,项目名称:walk,代码行数:58,代码来源:action.go
示例5: createAction
func (a Action) createAction(menu *walk.Menu) (*walk.Action, error) {
action := walk.NewAction()
if _, err := a.initAction(action); err != nil {
return nil, err
}
if menu != nil {
if err := menu.Actions().Add(action); err != nil {
return nil, err
}
}
return action, nil
}
开发者ID:etel,项目名称:walk,代码行数:15,代码来源:action.go
示例6: createAction
func (m Menu) createAction(builder *Builder, menu *walk.Menu) (*walk.Action, error) {
subMenu, err := walk.NewMenu()
if err != nil {
return nil, err
}
var action *walk.Action
if menu == nil {
action = walk.NewMenuAction(subMenu)
} else if action, err = menu.Actions().AddMenu(subMenu); err != nil {
return nil, err
}
if err := action.SetText(m.Text); err != nil {
return nil, err
}
if err := setActionImage(action, m.Image); err != nil {
return nil, err
}
for _, item := range m.Items {
if _, err := item.createAction(builder, subMenu); err != nil {
return nil, err
}
}
if m.OnTriggered != nil {
action.Triggered().Attach(m.OnTriggered)
}
if m.AssignActionTo != nil {
*m.AssignActionTo = action
}
if m.AssignTo != nil {
*m.AssignTo = subMenu
}
return action, nil
}
开发者ID:Ryanker,项目名称:walk,代码行数:39,代码来源:action.go
示例7: main
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()
}
开发者ID:Robin3D,项目名称:walk,代码行数:93,代码来源:declarative.go
示例8: main
func main() {
walk.Initialize(walk.InitParams{})
defer walk.Shutdown()
mw := new(MyMainWindow)
openImage, err := walk.NewBitmapFromFile("../img/open.png")
if err != nil {
log.Fatal(err)
}
var openAction *walk.Action
var recentMenu *walk.Menu
menuActions, err := CreateActions(
Menu{
Text: "&File",
Items: []MenuItem{
Action{
AssignTo: &openAction,
Text: "&Open",
Image: openImage,
OnTriggered: func() { mw.openAction_Triggered() },
},
Menu{
AssignTo: &recentMenu,
Text: "Recent",
},
Action{},
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},
Action{Text: "Show Dialog", OnTriggered: func() { mw.showDialogAction_Triggered() }})
if err != nil {
log.Fatal(err)
}
if err := (MainWindow{
AssignTo: &mw.MainWindow,
Title: "FTPS cycle finder",
MenuActions: menuActions,
ToolBarActions: toolBarActions,
MinSize: Size{600, 400},
Size: Size{800, 600},
Layout: HBox{Margins: Margins{6, 6, 6, 6}},
Children: []Widget{
ToolBar{Orientation: Vertical, Actions: toolBarActions},
Composite{
Layout: VBox{MarginsZero: true},
Children: []Widget{
Composite{
Layout: HBox{MarginsZero: true},
Children: []Widget{
Label{Text: "File"},
LineEdit{ContextMenuActions: []*walk.Action{openAction}},
ToolButton{Text: "..."},
},
},
Composite{
Layout: HBox{MarginsZero: true},
Children: []Widget{
PushButton{Text: "Check"},
PushButton{Text: "Check and Fix"},
PushButton{Text: "Clear"},
HSpacer{},
Label{Text: "Parameter"},
LineEdit{MaxLength: 10},
},
},
Composite{
Layout: HBox{MarginsZero: true},
Children: []Widget{
LineEdit{Text: "Ready.", ReadOnly: true},
ProgressBar{StretchFactor: 10},
},
},
TextEdit{ReadOnly: true},
},
},
//.........这里部分代码省略.........
开发者ID:etel,项目名称:walk,代码行数:101,代码来源:declarative.go
示例9: main
func main() {
MustRegisterCondition("isSpecialMode", isSpecialMode)
mw := new(MyMainWindow)
var openAction, showAboutBoxAction *walk.Action
var recentMenu *walk.Menu
var toggleSpecialModePB *walk.PushButton
if err := (MainWindow{
AssignTo: &mw.MainWindow,
Title: "Walk Actions Example",
MenuItems: []MenuItem{
Menu{
Text: "&File",
Items: []MenuItem{
Action{
AssignTo: &openAction,
Text: "&Open",
Image: "../img/open.png",
Enabled: Bind("enabledCB.Checked"),
Visible: Bind("openVisibleCB.Checked"),
Shortcut: Shortcut{walk.ModControl, walk.KeyO},
OnTriggered: mw.openAction_Triggered,
},
Menu{
AssignTo: &recentMenu,
Text: "Recent",
},
Separator{},
Action{
Text: "E&xit",
OnTriggered: func() { mw.Close() },
},
},
},
Menu{
Text: "&Help",
Items: []MenuItem{
Action{
AssignTo: &showAboutBoxAction,
Text: "About",
OnTriggered: mw.showAboutBoxAction_Triggered,
},
},
},
},
ToolBarItems: []MenuItem{
ActionRef{&openAction},
Menu{
Text: "New A",
Image: "../img/document-new.png",
Items: []MenuItem{
Action{
Text: "A",
OnTriggered: mw.newAction_Triggered,
},
Action{
Text: "B",
OnTriggered: mw.newAction_Triggered,
},
Action{
Text: "C",
OnTriggered: mw.newAction_Triggered,
},
},
OnTriggered: mw.newAction_Triggered,
},
Separator{},
Menu{
Text: "View",
Image: "../img/document-properties.png",
Items: []MenuItem{
Action{
Text: "X",
OnTriggered: mw.changeViewAction_Triggered,
},
Action{
Text: "Y",
OnTriggered: mw.changeViewAction_Triggered,
},
Action{
Text: "Z",
OnTriggered: mw.changeViewAction_Triggered,
},
},
},
Separator{},
Action{
Text: "Special",
Image: "../img/system-shutdown.png",
Enabled: Bind("isSpecialMode && enabledCB.Checked"),
OnTriggered: mw.specialAction_Triggered,
},
},
ContextMenuItems: []MenuItem{
ActionRef{&showAboutBoxAction},
},
MinSize: Size{300, 200},
Layout: VBox{},
//.........这里部分代码省略.........
开发者ID:2105666566,项目名称:walk,代码行数:101,代码来源:actions.go
示例10: main
func main() {
walk.Initialize(walk.InitParams{})
defer walk.Shutdown()
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{
MarginsZero: true,
PageTitles: []string{"golang.org/doc/", "golang.org/ref/", "golang.org/pkg/"},
Pages: []Widget{
WebView{URL: "http://golang.org/doc/"},
WebView{URL: "http://golang.org/ref/"},
WebView{URL: "http://golang.org/pkg/"},
},
},
},
}.Create()); err != nil {
log.Fatal(err)
}
mw.Show()
mw.Run()
}
开发者ID:yahame,项目名称:walk,代码行数:80,代码来源:declarative.go
注:本文中的github.com/lxn/walk.Menu类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论