本文整理汇总了Golang中github.com/lxn/walk.App函数的典型用法代码示例。如果您正苦于以下问题:Golang App函数的具体用法?Golang App怎么用?Golang App使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了App函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
app := walk.App()
// These specify the app data sub directory for the settings file.
app.SetOrganizationName("The Walk Authors")
app.SetProductName("Walk Settings Example")
// Settings file name.
settings := walk.NewIniFileSettings("settings.ini")
// All settings marked as expiring will expire after this duration w/o use.
// This applies to all widgets settings.
settings.SetExpireDuration(time.Hour * 24 * 30 * 3)
if err := settings.Load(); err != nil {
log.Fatal(err)
}
app.SetSettings(settings)
if err := RunMainWindow(); err != nil {
log.Fatal(err)
}
if err := settings.Save(); err != nil {
log.Fatal(err)
}
}
开发者ID:2105666566,项目名称:walk,代码行数:28,代码来源:settings.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: newNotify
func newNotify() {
var err error
context.notifyIcon, err = walk.NewNotifyIcon()
if err != nil {
common.Error("Error invoking NewNotifyIcon: %v", err)
}
icon, _ := walk.NewIconFromFile("res/lily.ico")
if err := context.notifyIcon.SetIcon(icon); err != nil {
common.Error("Error setting notify icon: %v", err)
}
if err := context.notifyIcon.SetToolTip("Click for info or use the context menu to exit."); err != nil {
common.Error("Fail to set tooltip: %v", err)
}
f := func() {
if !context.mw.Visible() {
context.mw.Show()
} else {
context.mw.SwitchToThisWindow()
}
}
go core.Triggered(f)
context.notifyIcon.MouseUp().Attach(func(x, y int, button walk.MouseButton) {
if button == walk.LeftButton {
f()
}
// if err := context.notifyIcon.ShowCustom(
// "Walk NotifyIcon Example",
// "There are multiple ShowX methods sporting different icons."); err != nil {
// common.Error("Fail to show custom notify: %v", err)
// }
})
exitAction := walk.NewAction()
if err := exitAction.SetText("退出"); err != nil {
common.Error("Error setting exitAction text: %v", err)
}
exitAction.Triggered().Attach(func() {
context.notifyIcon.Dispose()
// os.Exit(-1)
walk.App().Exit(0)
})
if err := context.notifyIcon.ContextMenu().Actions().Add(exitAction); err != nil {
common.Error("Error Adding exitAction: %v", err)
}
if err := context.notifyIcon.SetVisible(true); err != nil {
common.Error("Error setting notify visible: %v", err)
}
// if err := context.notifyIcon.ShowInfo("Walk NotifyIcon Example", "Click the icon to show again."); err != nil {
// common.Error("Error showing info: %v", err)
// }
}
开发者ID:tinycedar,项目名称:lily,代码行数:50,代码来源:notify.go
示例4: exitAction
func (mw *MyWindows) exitAction() error {
exitAction := walk.NewAction()
if err := exitAction.SetText("退出VIP"); err != nil {
return err
}
exitAction.Triggered().Attach(func() {
mw.ni.Dispose()
walk.App().Exit(0)
})
if err := mw.ni.ContextMenu().Actions().Add(exitAction); err != nil {
return err
}
return nil
}
开发者ID:CodyGuo,项目名称:Go-Cody,代码行数:15,代码来源:main.go
示例5: main
func main() {
// Initialize walk and specify that we want errors to be panics.
walk.Initialize(walk.InitParams{PanicOnError: true})
defer walk.Shutdown()
// We need either a walk.MainWindow or a walk.Dialog for their message loop.
// We will not make it visible in this example, though.
mw, _ := walk.NewMainWindow()
// We load our icon from a file.
icon, _ := walk.NewIconFromFile("../img/x.ico")
// Create the notify icon and make sure we clean it up on exit.
ni, _ := walk.NewNotifyIcon()
defer ni.Dispose()
// Set the icon and a tool tip text.
ni.SetIcon(icon)
ni.SetToolTip("Click for info or use the context menu to exit.")
// When the left mouse button is pressed, bring up our balloon.
ni.MouseDown().Attach(func(x, y int, button walk.MouseButton) {
if button != walk.LeftButton {
return
}
ni.ShowCustom(
"Walk NotifyIcon Example",
"There are multiple ShowX methods sporting different icons.")
})
// We put an exit action into the context menu.
exitAction := walk.NewAction()
exitAction.SetText("E&xit")
exitAction.Triggered().Attach(func() { walk.App().Exit(0) })
ni.ContextMenu().Actions().Add(exitAction)
// The notify icon is hidden initially, so we have to make it visible.
ni.SetVisible(true)
// Now that the icon is visible, we can bring up an info balloon.
ni.ShowInfo("Walk NotifyIcon Example", "Click the icon to show again.")
// Run the message loop.
mw.Run()
}
开发者ID:etel,项目名称:walk,代码行数:46,代码来源:notifyicon.go
示例6: AddMyNotifyAction
func (mw *MyDialog) AddMyNotifyAction() (err error) {
// We put an exit action into the context menu.
exitAction := walk.NewAction()
err = exitAction.SetText("退出程序")
mw.checkError(err)
exitAction.Triggered().Attach(func() {
mw.Dispose() // 释放主程序
mw.ni.Dispose() // 右下角图标退出
walk.App().Exit(1)
})
// 增加快捷键
exitAction.SetShortcut(walk.Shortcut{walk.ModShift, walk.KeyB})
// 提示信息
exitAction.SetToolTip("退出程序.")
err = mw.ni.ContextMenu().Actions().Add(exitAction)
mw.checkError(err)
return nil
}
开发者ID:CodyGuo,项目名称:Go-Cody,代码行数:20,代码来源:upgrideiMan_ui.go
示例7: OnWndMenuSelect
func OnWndMenuSelect(nID int, pBool bool) int {
switch nID {
case 1011:
ni.ShowInfo("提示信息", "炫彩菜单101-1")
xcgui.MessageBox(xcgui.XWnd_GetHWND(hWindow), "提示信息", "炫彩菜单101-1", xcgui.MB_ICONINFORMATION)
case 1012:
ni.ShowWarning("警告信息", "炫彩菜单101-2")
xcgui.MessageBox(xcgui.XWnd_GetHWND(hWindow), "警告信息", "炫彩菜单101-2", xcgui.MB_ICONWARNING)
case 102:
ni.ShowError("错误信息", "炫彩菜单102")
xcgui.MessageBox(xcgui.XWnd_GetHWND(hWindow), "错误信息", "炫彩菜单102", xcgui.MB_ICONERROR)
case 106:
ni.ShowMessage("退出程序", "正在退出程序...")
ni.Dispose()
walk.App().Exit(0)
xcgui.XExitXCGUI()
default:
ni.ShowMessage("其他信息", "您选择的菜单:"+fmt.Sprint(nID))
xcgui.MessageBox(xcgui.XWnd_GetHWND(hWindow), "其他信息", "您选择了其他菜单.", xcgui.MB_USERICON)
}
return 0
}
开发者ID:CodyGuo,项目名称:xcgui,代码行数:23,代码来源:notifyicon.go
示例8: initPoseInfo
//.........这里部分代码省略.........
///
// 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)
})
// Image operations
// Save
mw.uiComposeAction = walk.NewAction()
setIcon(mw.uiComposeAction, "save.png")
mw.uiComposeAction.SetText("&Save")
mw.uiComposeAction.Triggered().Attach(func() { mw.saveImage() })
fileMenu.Actions().Add(mw.uiComposeAction)
mw.ToolBar().Actions().Add(mw.uiComposeAction)
// Exit
exitAction := walk.NewAction()
exitAction.SetText("E&xit")
exitAction.Triggered().Attach(func() { walk.App().Exit(0) })
fileMenu.Actions().Add(exitAction)
}
func (mw *MainWindow) initCanvas() {
for i := 0; i < POSE_CNT_MAX; i++ {
iv, _ := selfWidget.NewMyImageView(mw)
mw.imageView[i] = iv
}
}
func (mw *MainWindow) initOtherBars() {
sp, _ := walk.NewSplitter(mw)
sp.SetSize(walk.Size{400, 20})
lab, _ := walk.NewLabel(sp)
lab.SetSize(walk.Size{16, 30})
// lab.SetText("Pose")
// others
mw.uiFrameCnt, _ = walk.NewNumberEdit(sp)
//mw.uiFrameCnt.SetSize(walk.Size{42, TB_H})
mw.uiFrameCnt.SetRange(1, 100)
mw.uiFrameCnt.SetDecimals(0)
mw.uiFrameCnt.SetValue(8)
mw.uiFrameCnt.SetEnabled(false)
mw.uiFrameCnt.SetToolTipText(ttPlayPose)
mw.uiPoseCnt, _ = walk.NewNumberEdit(sp)
//mw.uiPoseCnt.SetSize(walk.Size{42, TB_H})
mw.uiPoseCnt.SetRange(1, 100)
mw.uiPoseCnt.SetValue(1)
mw.uiPoseCnt.SetDecimals(0)
mw.uiPoseCnt.SetToolTipText(ttPosCnt)
开发者ID:hemaolong,项目名称:Rabbit,代码行数:67,代码来源:main.go
示例9: runNotify
func runNotify() {
// We need either a walk.MainWindow or a walk.Dialog for their message loop.
// We will not make it visible in this example, though.
mw, err := walk.NewMainWindow()
if err != nil {
log.Fatal(err)
}
// We load our icon from a file.
iconPlay, err = walk.NewIconFromFile("play.ico")
if err != nil {
log.Fatal(err)
}
// We load our icon from a file.
iconStop, err = walk.NewIconFromFile("stop.ico")
if err != nil {
log.Fatal(err)
}
// Create the notify icon and make sure we clean it up on exit.
notifyIcon, err = walk.NewNotifyIcon()
if err != nil {
log.Fatal(err)
}
defer notifyIcon.Dispose()
if err := notifyIcon.SetToolTip("Direct Print Server"); err != nil {
log.Fatal(err)
}
// We put an exit action into the context menu.
startAction = walk.NewAction()
startAction.Triggered().Attach(func() {
if stoped {
start()
} else {
stop()
}
})
if err := notifyIcon.ContextMenu().Actions().Add(startAction); err != nil {
log.Fatal(err)
}
// We put an exit action into the context menu.
exitAction := walk.NewAction()
if err := exitAction.SetText("E&xit"); err != nil {
log.Fatal(err)
}
exitAction.Triggered().Attach(func() {
//stop()
walk.App().Exit(0)
})
if err := notifyIcon.ContextMenu().Actions().Add(exitAction); err != nil {
log.Fatal(err)
}
// The notify icon is hidden initially, so we have to make it visible.
if err := notifyIcon.SetVisible(true); err != nil {
log.Fatal(err)
}
start()
// Run the message loop.
mw.Run()
}
开发者ID:procks,项目名称:direct_print_server,代码行数:66,代码来源:print_server.go
示例10: InterfaceStart
//.........这里部分代码省略.........
ni.ShowMessage(_PROG_TITLE, _NOTICE_PROXY_ENABLED)
}
if err = startServerAction.SetEnabled(true); err != nil {
log.Println(err)
}
}
updateServerButtons()
})
stopServerAction.Triggered().Attach(func() {
if server.IsRunning() {
stopServer()
ni.ShowMessage(_PROG_TITLE, _NOTICE_PROXY_DISABLED)
}
updateServerButtons()
})
updateFilterButtons := func() {
if config.IsFilterEnabled() {
err = filterEnableAction.SetVisible(false)
if err != nil {
log.Println(err)
}
err = filterDisabledAction.SetVisible(true)
if err != nil {
log.Println(err)
}
} else {
err = filterDisabledAction.SetVisible(false)
if err != nil {
log.Println(err)
}
err = filterEnableAction.SetVisible(true)
if err != nil {
log.Println(err)
}
}
}
filterEnableAction.Triggered().Attach(func() {
if !config.IsFilterEnabled() {
config.SetFilterEnabled(true)
ni.ShowInfo(_PROG_TITLE, _NOTICE_ENABLED_FILTERS)
}
updateFilterButtons()
})
filterDisabledAction.Triggered().Attach(func() {
if config.IsFilterEnabled() {
config.SetFilterEnabled(false)
ni.ShowInfo(_PROG_TITLE, _NOTICE_DISABLED_FILTERS)
}
updateFilterButtons()
})
removeCacheAction.Triggered().Attach(func() {
if err = server.RemoveCache(); err != nil {
log.Println("Cannot remove cache:", err)
} else {
ni.ShowInfo(_PROG_TITLE, _NOTICE_CACHE_REMOVED)
}
})
openURLGenAction.Triggered().Attach(func() {
err = exec.Command(_PROG_URL_GENER_FILE_NAME).Start()
if err != nil {
log.Println("Cannot open url generator:", err)
}
})
openDirAction.Triggered().Attach(func() {
err = exec.Command("cmd", "/C", "start", ".").Start()
if err != nil {
log.Println("Cannot open program directory:", err)
} else {
ni.ShowInfo(_PROG_TITLE, _NOTICE_CONFIGS)
}
})
openReadMeAction.Triggered().Attach(func() {
err = exec.Command(
"cmd", "/C", "start", _PROG_DESCRIPTION_FILE_NAME,
).Start()
if err != nil {
log.Println("Cannot open README:", err)
}
})
exitAction.Triggered().Attach(func() {
walk.App().Exit(0)
})
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* END EVENT HANDLERS *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
mw.Run()
return
}
开发者ID:ivan1993spb,项目名称:ru-supplier,代码行数:101,代码来源:windows.go
示例11: 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
示例12: 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() { walk.App().Exit(0) },
},
},
},
Menu{
Text: "&Help",
Items: []MenuItem{
Action{
AssignTo: &showAboutBoxAction,
Text: "About",
OnTriggered: mw.showAboutBoxAction_Triggered,
},
},
},
},
ToolBarItems: []MenuItem{
ActionRef{&openAction},
Separator{},
ActionRef{&showAboutBoxAction},
Action{
Text: "Special",
Enabled: Bind("isSpecialMode && enabledCB.Checked"),
OnTriggered: mw.specialAction_Triggered,
},
},
ContextMenuItems: []MenuItem{
ActionRef{&showAboutBoxAction},
},
MinSize: Size{300, 200},
Layout: VBox{},
Children: []Widget{
CheckBox{
Name: "enabledCB",
Text: "Open / Special Enabled",
Checked: true,
},
CheckBox{
Name: "openVisibleCB",
Text: "Open Visible",
Checked: true,
},
PushButton{
AssignTo: &toggleSpecialModePB,
Text: "Enable Special Mode",
OnClicked: func() {
isSpecialMode.SetSatisfied(!isSpecialMode.Satisfied())
if isSpecialMode.Satisfied() {
toggleSpecialModePB.SetText("Disable Special Mode")
} else {
toggleSpecialModePB.SetText("Enable Special Mode")
}
},
},
},
}.Create()); err != nil {
log.Fatal(err)
}
addRecentFileActions := func(texts ...string) {
for _, text := range texts {
a := walk.NewAction()
a.SetText(text)
a.Triggered().Attach(mw.openAction_Triggered)
recentMenu.Actions().Add(a)
}
}
//.........这里部分代码省略.........
开发者ID:richardjoo,项目名称:walk,代码行数:101,代码来源:actions.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
示例14: exit
// 退出程序
func (mw *MyWindow) exit() {
mw.Dispose()
mw.notifyIcon.Dispose()
walk.App().Exit(0)
}
开发者ID:CodyGuo,项目名称:Go-Cody,代码行数:6,代码来源:main.go
示例15: main
func main() {
xcgui.XWnd_Create(0, 0, 0, 0, "炫彩界面库窗口", 0, xcgui.XC_WINDOW_STYLE_NOTHING)
// We load our icon from a file.
icon, err := walk.NewIconFromFile("../../img/x.ico")
if err != nil {
log.Fatal(err)
}
// Create the notify icon and make sure we clean it up on exit.
ni, err := walk.NewNotifyIcon()
if err != nil {
log.Fatal(err)
}
defer ni.Dispose()
// Set the icon and a tool tip text.
if err := ni.SetIcon(icon); err != nil {
log.Fatal(err)
}
if err := ni.SetToolTip("托盘"); err != nil {
log.Fatal(err)
}
// When the left mouse button is pressed, bring up our balloon.
ni.MouseDown().Attach(func(x, y int, button walk.MouseButton) {
if button != walk.LeftButton {
return
}
if err := ni.ShowCustom(
"自定义消息",
"这是一个带图标的自定义消息."); err != nil {
log.Fatal(err)
}
})
// 菜单使用walk的,主程序为xcgui.
exitAction := walk.NewAction()
if err := exitAction.SetText("退出"); err != nil {
log.Fatal(err)
}
exitAction.Triggered().Attach(func() {
ni.Dispose()
walk.App().Exit(0)
xcgui.XExitXCGUI()
})
if err := ni.ContextMenu().Actions().Add(exitAction); err != nil {
log.Fatal(err)
}
// 托盘图标默认为隐藏状态,需设置为显示。
if err := ni.SetVisible(true); err != nil {
log.Fatal(err)
}
// Now that the icon is visible, we can bring up an info balloon.
if err := ni.ShowInfo("托盘", "正在运行中."); err != nil {
log.Fatal(err)
}
// Run the message loop.
xcgui.XRunXCGUI()
}
开发者ID:CodyGuo,项目名称:xcgui,代码行数:65,代码来源:notifyicon.go
示例16: 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
示例17: 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.App函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论