本文整理汇总了Golang中github.com/lxn/walk.NewMenu函数的典型用法代码示例。如果您正苦于以下问题:Golang NewMenu函数的具体用法?Golang NewMenu怎么用?Golang NewMenu使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewMenu函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: main
func main() {
walk.Initialize(walk.InitParams{PanicOnError: true})
defer walk.Shutdown()
mainWnd, _ := walk.NewMainWindow()
mw := &MainWindow{MainWindow: mainWnd}
mw.SetLayout(walk.NewVBoxLayout())
mw.SetTitle("Walk Image Viewer Example")
mw.tabWidget, _ = walk.NewTabWidget(mw)
imageList, _ := walk.NewImageList(walk.Size{16, 16}, 0)
mw.ToolBar().SetImageList(imageList)
fileMenu, _ := walk.NewMenu()
fileMenuAction, _ := mw.Menu().Actions().AddMenu(fileMenu)
fileMenuAction.SetText("&File")
openBmp, _ := walk.NewBitmapFromFile("../img/open.png")
openAction := walk.NewAction()
openAction.SetImage(openBmp)
openAction.SetText("&Open")
openAction.Triggered().Attach(func() { mw.openImage() })
fileMenu.Actions().Add(openAction)
mw.ToolBar().Actions().Add(openAction)
exitAction := walk.NewAction()
exitAction.SetText("E&xit")
exitAction.Triggered().Attach(func() { walk.App().Exit(0) })
fileMenu.Actions().Add(exitAction)
helpMenu, _ := walk.NewMenu()
helpMenuAction, _ := mw.Menu().Actions().AddMenu(helpMenu)
helpMenuAction.SetText("&Help")
aboutAction := walk.NewAction()
aboutAction.SetText("&About")
aboutAction.Triggered().Attach(func() {
walk.MsgBox(mw, "About", "Walk Image Viewer Example", walk.MsgBoxOK|walk.MsgBoxIconInformation)
})
helpMenu.Actions().Add(aboutAction)
mw.SetMinMaxSize(walk.Size{320, 240}, walk.Size{})
mw.SetSize(walk.Size{800, 600})
mw.Show()
mw.Run()
}
开发者ID:hoperuin,项目名称:walk,代码行数:50,代码来源:imageviewer.go
示例3: 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
示例4: createAction
func (m Menu) createAction(menu *walk.Menu) (*walk.Action, error) {
if menu == nil {
var err error
if menu, err = walk.NewMenu(); err != nil {
return nil, err
}
}
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 := action.SetImage(m.Image); err != nil {
return nil, err
}
for _, item := range m.Items {
if _, err := item.createAction(subMenu); err != nil {
return nil, err
}
}
if m.AssignActionTo != nil {
*m.AssignActionTo = action
}
if m.AssignTo != nil {
*m.AssignTo = subMenu
}
return action, nil
}
开发者ID:etel,项目名称:walk,代码行数:40,代码来源:action.go
示例5: switchEngine
func (mw *MyWindows) switchEngine() error {
menuEngine, _ := walk.NewMenu()
engine, _ := mw.ni.ContextMenu().Actions().AddMenu(menuEngine)
engine.SetText("切换视频源")
engineAction1 := walk.NewAction()
engineAction1.SetText("资源一")
engineAction2 := walk.NewAction()
engineAction2.SetText("资源二")
engineAction3 := walk.NewAction()
engineAction3.SetText("资源三")
engineAction1.SetChecked(true)
engineAction2.SetChecked(false)
engineAction3.SetChecked(false)
engineAction1.Triggered().Attach(func() {
requestUrl = engine1
engineAction1.SetChecked(true)
engineAction2.SetChecked(false)
engineAction3.SetChecked(false)
mw.OpenVip()
})
engineAction2.Triggered().Attach(func() {
requestUrl = engine2
engineAction1.SetChecked(false)
engineAction2.SetChecked(true)
engineAction3.SetChecked(false)
mw.OpenVip()
})
engineAction3.Triggered().Attach(func() {
requestUrl = engine3
engineAction1.SetChecked(false)
engineAction2.SetChecked(false)
engineAction3.SetChecked(true)
mw.OpenVip()
})
menuEngine.Actions().Add(engineAction1)
menuEngine.Actions().Add(engineAction2)
menuEngine.Actions().Add(engineAction3)
return nil
}
开发者ID:CodyGuo,项目名称:Go-Cody,代码行数:49,代码来源:main.go
示例6: NewTable
func NewTable(parent walk.Container, width, height, x, y int) *Table {
t := new(Table)
t.model = NewTableModel()
t.TableView, _ = walk.NewTableView(parent)
t.SetWidth(width)
t.SetHeight(height)
t.SetX(x)
t.SetY(y)
t.SetModel(t.model)
t.AddExStyle(win.LVS_EX_GRIDLINES)
t.SetColumnsOrderable(false)
menu, _ := walk.NewMenu()
t.TableView.SetContextMenu(menu)
return t
}
开发者ID:joy999,项目名称:walkwrap,代码行数:17,代码来源:Table.go
示例7: 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
示例8: InitWidget
func (b *Builder) InitWidget(d Widget, w walk.Widget, customInit func() error) error {
b.level++
defer func() {
b.level--
}()
var succeeded bool
defer func() {
if !succeeded {
w.Dispose()
}
}()
b.declWidgets = append(b.declWidgets, declWidget{d, w})
// Widget
name, _, _, font, toolTipText, minSize, maxSize, stretchFactor, row, rowSpan, column, columnSpan, contextMenuActions, onKeyDown, onMouseDown, onMouseMove, onMouseUp, onSizeChanged := d.WidgetInfo()
w.SetName(name)
if name != "" {
b.name2Widget[name] = w
}
if toolTipText != "" {
if err := w.SetToolTipText(toolTipText); err != nil {
return err
}
}
if err := w.SetMinMaxSize(minSize.toW(), maxSize.toW()); err != nil {
return err
}
if len(contextMenuActions) > 0 {
cm, err := walk.NewMenu()
if err != nil {
return err
}
if err := addToActionList(cm.Actions(), contextMenuActions); err != nil {
return err
}
w.SetContextMenu(cm)
}
if onKeyDown != nil {
w.KeyDown().Attach(onKeyDown)
}
if onMouseDown != nil {
w.MouseDown().Attach(onMouseDown)
}
if onMouseMove != nil {
w.MouseMove().Attach(onMouseMove)
}
if onMouseUp != nil {
w.MouseUp().Attach(onMouseUp)
}
if onSizeChanged != nil {
w.SizeChanged().Attach(onSizeChanged)
}
if p := w.Parent(); p != nil {
switch l := p.Layout().(type) {
case *walk.BoxLayout:
if stretchFactor < 1 {
stretchFactor = 1
}
if err := l.SetStretchFactor(w, stretchFactor); err != nil {
return err
}
case *walk.GridLayout:
cs := columnSpan
if cs < 1 {
cs = 1
}
rs := rowSpan
if rs < 1 {
rs = 1
}
r := walk.Rectangle{column, row, cs, rs}
if err := l.SetRange(w, r); err != nil {
return err
}
}
}
oldParent := b.parent
// Container
var db *walk.DataBinder
if dc, ok := d.(Container); ok {
if wc, ok := w.(walk.Container); ok {
dataBinder, layout, children := dc.ContainerInfo()
//.........这里部分代码省略.........
开发者ID:Robin3D,项目名称:walk,代码行数:101,代码来源:builder.go
示例9: InitWidget
func (b *Builder) InitWidget(d Widget, w walk.Window, customInit func() error) error {
b.level++
defer func() {
b.level--
}()
var succeeded bool
defer func() {
if !succeeded {
w.Dispose()
}
}()
b.declWidgets = append(b.declWidgets, declWidget{d, w})
// Widget
name, _, _, font, toolTipText, minSize, maxSize, stretchFactor, row, rowSpan, column, columnSpan, alwaysConsumeSpace, contextMenuItems, onKeyDown, onKeyPress, onKeyUp, onMouseDown, onMouseMove, onMouseUp, onSizeChanged := d.WidgetInfo()
w.SetName(name)
if name != "" {
b.name2Window[name] = w
}
if toolTipText != "" {
if widget, ok := w.(walk.Widget); ok {
if err := widget.SetToolTipText(toolTipText); err != nil {
return err
}
}
}
if err := w.SetMinMaxSize(minSize.toW(), maxSize.toW()); err != nil {
return err
}
if len(contextMenuItems) > 0 {
cm, err := walk.NewMenu()
if err != nil {
return err
}
b.deferBuildMenuActions(cm, contextMenuItems)
w.SetContextMenu(cm)
}
if onKeyDown != nil {
w.KeyDown().Attach(onKeyDown)
}
if onKeyPress != nil {
w.KeyPress().Attach(onKeyPress)
}
if onKeyUp != nil {
w.KeyUp().Attach(onKeyUp)
}
if onMouseDown != nil {
w.MouseDown().Attach(onMouseDown)
}
if onMouseMove != nil {
w.MouseMove().Attach(onMouseMove)
}
if onMouseUp != nil {
w.MouseUp().Attach(onMouseUp)
}
if onSizeChanged != nil {
w.SizeChanged().Attach(onSizeChanged)
}
if widget, ok := w.(walk.Widget); ok {
if err := widget.SetAlwaysConsumeSpace(alwaysConsumeSpace); err != nil {
return err
}
type SetStretchFactorer interface {
SetStretchFactor(widget walk.Widget, factor int) error
}
if p := widget.Parent(); p != nil {
if stretchFactor < 1 {
stretchFactor = 1
}
switch l := p.Layout().(type) {
case SetStretchFactorer:
if err := l.SetStretchFactor(widget, stretchFactor); err != nil {
return err
}
case *walk.GridLayout:
csf := l.ColumnStretchFactor(column)
if csf < stretchFactor {
csf = stretchFactor
}
//.........这里部分代码省略.........
开发者ID:linhua55,项目名称:walk,代码行数:101,代码来源:builder.go
示例10: initPoseInfo
//.........这里部分代码省略.........
col := i % frame
row := i / frame
drawBound := singleBound.Add(image.Point{sw * col, sh * row})
draw.Draw(result, drawBound, _subImg, _subImg.Bounds().Min, draw.Src)
}
// Modify stride
// fmt.Println("Stride ", result.Stride)
f, err := os.OpenFile(fullname, os.O_RDWR|os.O_CREATE, os.ModePerm)
if err != nil {
panic(err)
return
}
defer f.Close()
f.Truncate(0)
// buf := bufio.NewWriterSize(f, 1024 * 1000)
buf := bufio.NewWriter(f)
png.Encode(buf, result)
}
func setIcon(ui *walk.Action, fname string) {
fpath := "./img/" + fname
_, err := os.Stat(fpath)
if err != nil {
fmt.Println(err)
return
}
img, _ := walk.NewBitmapFromFile(fpath)
ui.SetImage(img)
}
func (mw *MainWindow) initMenu() {
fileMenu, _ := walk.NewMenu()
fileMenuAction, _ := mw.Menu().Actions().AddMenu(fileMenu)
fileMenuAction.SetText("&File")
imageList, _ := walk.NewImageList(walk.Size{TB_H, TB_H}, 0)
mw.ToolBar().SetImageList(imageList)
openAction := walk.NewAction()
setIcon(openAction, "open.png")
openAction.SetText("&Open")
openAction.Triggered().Attach(func() { go mw.openImage(MODE_COMPOSE) })
fileMenu.Actions().Add(openAction)
mw.ToolBar().Actions().Add(openAction)
///
// Load
loadAction := walk.NewAction()
setIcon(loadAction, "load.png")
loadAction.SetText("&Load")
loadAction.Triggered().Attach(func() { mw.openImage(MODE_PLAY) })
fileMenu.Actions().Add(loadAction)
mw.ToolBar().Actions().Add(loadAction)
helpMenu, _ := walk.NewMenu()
helpMenuAction, _ := mw.Menu().Actions().AddMenu(helpMenu)
helpMenuAction.SetText("&Help")
aboutAction := walk.NewAction()
helpMenu.Actions().Add(aboutAction)
aboutAction.SetText("&About")
aboutAction.Triggered().Attach(func() {
walk.MsgBox(mw, "About", "Image composer V0.1\nAuthor:heml",
walk.MsgBoxOK|walk.MsgBoxIconInformation)
开发者ID:hemaolong,项目名称:Rabbit,代码行数:67,代码来源:main.go
示例11: InitWidget
func InitWidget(d Widget, w walk.Widget, customInit func() error) error {
var succeeded bool
defer func() {
if !succeeded {
w.Dispose()
}
}()
// Widget
name, disabled, hidden, font, minSize, maxSize, stretchFactor, row, rowSpan, column, columnSpan, contextMenuActions := d.WidgetInfo()
w.SetName(name)
if err := w.SetMinMaxSize(minSize.toW(), maxSize.toW()); err != nil {
return err
}
if len(contextMenuActions) > 0 {
cm, err := walk.NewMenu()
if err != nil {
return err
}
if err := addToActionList(cm.Actions(), contextMenuActions); err != nil {
return err
}
w.SetContextMenu(cm)
}
if p := w.Parent(); p != nil {
switch l := p.Layout().(type) {
case *walk.BoxLayout:
if stretchFactor < 1 {
stretchFactor = 1
}
if err := l.SetStretchFactor(w, stretchFactor); err != nil {
return err
}
case *walk.GridLayout:
cs := columnSpan
if cs < 1 {
cs = 1
}
rs := rowSpan
if rs < 1 {
rs = 1
}
r := walk.Rectangle{column, row, cs, rs}
if err := l.SetRange(w, r); err != nil {
return err
}
}
}
// Container
if dc, ok := d.(Container); ok {
if wc, ok := w.(walk.Container); ok {
layout, children := dc.ContainerInfo()
if layout != nil {
l, err := layout.Create()
if err != nil {
return err
}
if err := wc.SetLayout(l); err != nil {
return err
}
}
for _, child := range children {
if err := child.Create(wc); err != nil {
return err
}
}
}
}
// Widget continued
w.SetEnabled(!disabled)
w.SetVisible(!hidden)
if font != nil {
if f, err := font.Create(); err != nil {
return err
} else if f != nil {
w.SetFont(f)
}
}
// Custom
if customInit != nil {
if err := customInit(); err != nil {
return err
}
}
succeeded = true
//.........这里部分代码省略.........
开发者ID:etel,项目名称:walk,代码行数:101,代码来源:util.go
示例12: init
func (mw *MyDialog) init(owner walk.Form) (err error) {
// 设置最小化
mw.SetMinimizeBox(true)
// 禁用最大化
mw.SetMaximizeBox(false)
// 设置窗口固定
mw.SetFixedSize(true)
// // 设置窗口前置
// mw.SetWindowPos(true)
mw.Dialog, err = walk.NewDialog(owner)
mw.checkError(err)
succeeded := false
defer func() {
if !succeeded {
mw.Dispose()
}
}()
// 设置主窗体大小
err = mw.SetClientSize(walk.Size{700, 560})
mw.checkError(err)
// 设置主窗体标题
err = mw.SetTitle("iMan-打包工具 V【" + _VERSION_ + "】")
mw.checkError(err)
// 设置
mw.ui.SettingMenu, _ = walk.NewMenu()
mw.ui.SettingAction = walk.NewMenuAction(mw.ui.SettingMenu)
mw.ui.SettingAction.SetText("设置")
mw.ui.ServerAction = walk.NewAction()
mw.ui.ServerAction.SetText("服务器")
mw.ui.SettingMenu.Actions().Add(mw.ui.ServerAction)
// 帮助
mw.ui.HelpMenu, _ = walk.NewMenu()
mw.ui.HelpAction = walk.NewMenuAction(mw.ui.HelpMenu)
mw.ui.HelpAction.SetText("帮助")
mw.ui.AboutAction = walk.NewAction()
mw.ui.AboutAction.SetText("关于")
mw.ui.HelpMenu.Actions().Add(mw.ui.AboutAction)
// 菜单配置
mw.Menu().Actions().Add(mw.ui.SettingAction)
mw.Menu().Actions().Add(mw.ui.HelpAction)
// 设置字体和图标
fountTitle, _ := walk.NewFont("幼圆", 10, walk.FontBold)
otherFont, _ := walk.NewFont("幼圆", 10, 0)
// 开始打包
mw.ui.StartPackingBtn, err = walk.NewPushButton(mw)
mw.checkError(err)
mw.ui.StartPackingBtn.SetText("开始打包")
mw.ui.StartPackingBtn.SetBounds(walk.Rectangle{310, 20, 75, 30})
// 版本配置
mw.ui.VersionGb, err = walk.NewGroupBox(mw)
mw.checkError(err)
mw.ui.VersionGb.SetTitle("版本配置")
mw.ui.VersionGb.SetFont(otherFont)
err = mw.ui.VersionGb.SetBounds(walk.Rectangle{10, 60, 330, 260})
mw.checkError(err)
// 版本类型
mw.ui.VersionTypeLb, err = walk.NewLabel(mw.ui.VersionGb)
mw.checkError(err)
mw.ui.VersionTypeLb.SetText("版本类型:")
mw.ui.VersionTypeLb.SetFont(fountTitle)
mw.ui.VersionTypeLb.SetBounds(walk.Rectangle{10, 20, 70, 25})
// 测试版
mw.ui.VersionTestRadio, err = walk.NewRadioButton(mw.ui.VersionGb)
mw.checkError(err)
mw.ui.VersionTestRadio.SetText("测试版")
mw.ui.VersionTestRadio.SetBounds(walk.Rectangle{110, 20, 60, 25})
mw.ui.VersionTestRadio.SetChecked(true)
// 正式版
mw.ui.VersionOffRadio, err = walk.NewRadioButton(mw.ui.VersionGb)
mw.checkError(err)
mw.ui.VersionOffRadio.SetText("正式版")
mw.ui.VersionOffRadio.SetBounds(walk.Rectangle{180, 20, 70, 25})
// 主版本号
mw.ui.MasterVersionLb, err = walk.NewLabel(mw.ui.VersionGb)
//.........这里部分代码省略.........
开发者ID:CodyGuo,项目名称:Go-Cody,代码行数:101,代码来源:upgrideiMan_ui.go
示例13: main
func main() {
walk.Initialize(walk.InitParams{PanicOnError: true})
defer walk.Shutdown()
mainWnd, _ := walk.NewMainWindow()
mw := &MainWindow{
MainWindow: mainWnd,
fileInfoModel: &FileInfoModel{},
}
mw.SetTitle("Walk File Browser Example")
mw.SetLayout(walk.NewHBoxLayout())
fileMenu, _ := walk.NewMenu()
fileMenuAction, _ := mw.Menu().Actions().AddMenu(fileMenu)
fileMenuAction.SetText("&File")
exitAction := walk.NewAction()
exitAction.SetText("E&xit")
exitAction.Triggered().Attach(func() { walk.App().Exit(0) })
fileMenu.Actions().Add(exitAction)
helpMenu, _ := walk.NewMenu()
helpMenuAction, _ := mw.Menu().Actions().AddMenu(helpMenu)
helpMenuAction.SetText("&Help")
aboutAction := walk.NewAction()
aboutAction.SetText("&About")
aboutAction.Triggered().Attach(func() {
walk.MsgBox(mw, "About", "Walk File Browser Example", walk.MsgBoxOK|walk.MsgBoxIconInformation)
})
helpMenu.Actions().Add(aboutAction)
splitter, _ := walk.NewSplitter(mw)
mw.treeView, _ = walk.NewTreeView(splitter)
mw.treeView.ItemExpanded().Attach(func(item *walk.TreeViewItem) {
children := item.Children()
if children.Len() == 1 && children.At(0).Text() == "" {
mw.populateTreeViewItem(item)
}
})
mw.treeView.SelectionChanged().Attach(func(old, new *walk.TreeViewItem) {
mw.selTvwItem = new
mw.showError(mw.fileInfoModel.ResetRows(pathForTreeViewItem(new)))
})
drives, _ := walk.DriveNames()
mw.treeView.SetSuspended(true)
for _, drive := range drives {
driveItem := newTreeViewItem(drive[:2])
mw.treeView.Items().Add(driveItem)
}
mw.treeView.SetSuspended(false)
mw.tableView, _ = walk.NewTableView(splitter)
mw.tableView.SetModel(mw.fileInfoModel)
mw.tableView.SetSingleItemSelection(true)
mw.tableView.CurrentIndexChanged().Attach(func() {
var url string
index := mw.tableView.CurrentIndex()
if index > -1 {
name := mw.fileInfoModel.items[index].Name
url = path.Join(pathForTreeViewItem(mw.selTvwItem), name)
}
mw.preview.SetURL(url)
})
mw.preview, _ = walk.NewWebView(splitter)
mw.SetMinMaxSize(walk.Size{600, 400}, walk.Size{})
mw.SetSize(walk.Size{800, 600})
mw.Show()
mw.Run()
}
开发者ID:hoperuin,项目名称:walk,代码行数:83,代码来源:filebrowser.go
注:本文中的github.com/lxn/walk.NewMenu函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论