本文整理汇总了Golang中github.com/lxn/walk.NewMainWindow函数的典型用法代码示例。如果您正苦于以下问题:Golang NewMainWindow函数的具体用法?Golang NewMainWindow怎么用?Golang NewMainWindow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewMainWindow函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
walk.Initialize(walk.InitParams{PanicOnError: true})
defer walk.Shutdown()
mw, _ := walk.NewMainWindow()
mw.SetTitle("Walk External Widgets Example")
mw.SetLayout(walk.NewHBoxLayout())
a, _ := NewMyWidget(mw)
a.SetName("a")
b, _ := NewMyWidget(mw)
b.SetName("b")
c, _ := NewMyWidget(mw)
c.SetName("c")
mpb, _ := NewMyPushButton(mw)
mpb.SetText("MyPushButton")
mw.SetSize(walk.Size{400, 300})
mw.Show()
mw.Run()
}
开发者ID:etel,项目名称:walk,代码行数:26,代码来源:externalwidgets.go
示例2: init
func (mw *MyWindow) init() (err error) {
mw.SetMinimizeBox(true)
mw.SetMaximizeBox(false)
mw.SetFixedSize(true)
mw.MainWindow, _ = walk.NewMainWindow()
succeeded := false
defer func() {
if !succeeded {
mw.Dispose()
}
}()
mw.SetClientSize(walk.Size{260, 160})
mw.SetTitle("主窗体")
mw.ui.SecTitileLb, _ = walk.NewLabel(mw)
mw.ui.SecTitileLb.SetText("子窗体:")
mw.ui.SecTitileLb.SetBounds(walk.Rectangle{10, 50, 50, 20})
mw.ui.SecTitileLe, _ = walk.NewLineEdit(mw)
mw.ui.SecTitileLe.SetBounds(walk.Rectangle{60, 50, 160, 20})
mw.ui.SecTitileLe.SetWidth(150)
mw.ui.CreateBtn, _ = walk.NewPushButton(mw)
mw.ui.CreateBtn.SetText("生成子窗体")
mw.ui.CreateBtn.SetBounds(walk.Rectangle{90, 100, 75, 25})
succeeded = true
return nil
}
开发者ID:CodyGuo,项目名称:Go-Cody,代码行数:33,代码来源:master_ui.go
示例3: main
func main() {
walk.Initialize(walk.InitParams{PanicOnError: true})
defer walk.Shutdown()
myWindow, _ := walk.NewMainWindow()
myWindow.SetLayout(walk.NewVBoxLayout())
myWindow.SetTitle("LogView example")
logView, _ := NewLogView(myWindow)
logView.PostAppendText("XXX")
log.SetOutput(logView)
go func() {
for i := 0; i < 10000; i++ {
time.Sleep(100 * time.Millisecond)
log.Println("Text" + "\r\n")
}
}()
myWindow.Show()
myWindow.SetMinMaxSize(walk.Size{320, 240}, walk.Size{})
myWindow.SetSize(walk.Size{400, 500})
myWindow.Run()
}
开发者ID:etel,项目名称:walk,代码行数:25,代码来源:logviewapp.go
示例4: main
func main() {
walk.Initialize(walk.InitParams{PanicOnError: true})
defer walk.Shutdown()
mainWnd, _ := walk.NewMainWindow()
mw := &MainWindow{MainWindow: mainWnd}
mw.SetTitle("Walk WebView Example")
mw.SetLayout(walk.NewVBoxLayout())
mw.urlLineEdit, _ = walk.NewLineEdit(mw)
mw.urlLineEdit.ReturnPressed().Attach(func() {
mw.webView.SetURL(mw.urlLineEdit.Text())
})
mw.webView, _ = walk.NewWebView(mw)
mw.webView.SetURL("http://golang.org")
mw.SetMinMaxSize(walk.Size{600, 400}, walk.Size{})
mw.SetSize(walk.Size{800, 600})
mw.Show()
mw.Run()
}
开发者ID:hoperuin,项目名称:walk,代码行数:25,代码来源:webview.go
示例5: Create
func (mw MainWindow) Create() error {
w, err := walk.NewMainWindow()
if err != nil {
return err
}
w.SetSuspended(true)
tlwi := topLevelWindowInfo{
Name: mw.Name,
Font: mw.Font,
ToolTipText: "",
MinSize: mw.MinSize,
MaxSize: mw.MaxSize,
ContextMenuActions: mw.ContextMenuActions,
OnKeyDown: mw.OnKeyDown,
OnMouseDown: mw.OnMouseDown,
OnMouseMove: mw.OnMouseMove,
OnMouseUp: mw.OnMouseUp,
OnSizeChanged: mw.OnSizeChanged,
DataBinder: mw.DataBinder,
Layout: mw.Layout,
Children: mw.Children,
}
builder := NewBuilder(nil)
return builder.InitWidget(tlwi, w, func() error {
if err := w.SetTitle(mw.Title); err != nil {
return err
}
if err := w.SetSize(mw.Size.toW()); err != nil {
return err
}
if err := addToActionList(w.Menu().Actions(), mw.MenuActions); err != nil {
return err
}
imageList, err := walk.NewImageList(walk.Size{16, 16}, 0)
if err != nil {
return err
}
w.ToolBar().SetImageList(imageList)
if err := addToActionList(w.ToolBar().Actions(), mw.ToolBarActions); err != nil {
return err
}
w.Show()
if mw.AssignTo != nil {
*mw.AssignTo = w
}
return nil
})
}
开发者ID:bbqchickenrobot,项目名称:walk,代码行数:59,代码来源:mainwindow.go
示例6: main
func main() {
walk.Initialize(walk.InitParams{PanicOnError: true})
defer walk.Shutdown()
myWindow, _ := walk.NewMainWindow()
myWindow.SetLayout(walk.NewVBoxLayout())
myWindow.SetTitle("Listbox example")
splitter, _ := walk.NewSplitter(myWindow)
splitter.SetOrientation(walk.Vertical)
lb, _ := walk.NewListBox(splitter)
valueEdit, _ := walk.NewTextEdit(splitter)
valueEdit.SetReadOnly(true)
//env model
em := NewEnvModel()
for _, env := range os.Environ() {
i := strings.Index(env, "=")
if i == 0 {
continue
}
varName := env[0:i]
value := env[i+1:]
envItem := EnvItem{varName, value}
em.envItems = append(em.envItems, envItem)
}
fmt.Println("The len of Model", em.ItemCount())
lb.SetModel(em)
lb.CurrentIndexChanged().Attach(func() {
if curVar, ok := em.Value(lb.CurrentIndex()).(string); ok {
value := em.envItems[lb.CurrentIndex()].value
value = strings.Replace(value, ";", "\r\n", -1)
valueEdit.SetText(value)
fmt.Println("CurrentIndex:", lb.CurrentIndex())
fmt.Println("CurrentEnvVarName:", curVar)
}
})
lb.DblClicked().Attach(func() {
value := em.envItems[lb.CurrentIndex()].value
value = strings.Replace(value, ";", "\r\n", -1)
valueEdit.SetText(value)
walk.MsgBox(myWindow, "About", value, walk.MsgBoxOK|walk.MsgBoxIconInformation)
})
myWindow.Show()
myWindow.SetMinMaxSize(walk.Size{320, 240}, walk.Size{})
myWindow.SetSize(walk.Size{400, 500})
myWindow.Run()
}
开发者ID:etel,项目名称:walk,代码行数:54,代码来源:listbox.go
示例7: NewLoginWindow
func NewLoginWindow() {
walk.SetPanicOnError(true)
myWindow, _ := walk.NewMainWindow()
mw := &LoginWindow{MainWindow: myWindow}
//mw.SetLayout(walk.NewVBoxLayout())
mw.SetTitle("nsq client")
userLabel, _ := walk.NewLabel(mw)
userLabel.SetText("用户名:")
userLabel.SetX(20)
userLabel.SetY(10)
userLabel.SetSize(walk.Size{40, 20})
userEdit, _ := walk.NewLineEdit(mw)
userEdit.SetReadOnly(false)
userEdit.SetX(70)
userEdit.SetY(10)
userEdit.SetSize(walk.Size{200, 20})
userEdit.KeyDown().Attach(mw.onKeyDown)
mw.userEdit = userEdit
pwdLabel, _ := walk.NewLabel(mw)
pwdLabel.SetText("密码:")
pwdLabel.SetX(20)
pwdLabel.SetY(40)
pwdLabel.SetSize(walk.Size{40, 20})
pwdEdit, _ := walk.NewLineEdit(mw)
pwdEdit.SetReadOnly(false)
pwdEdit.SetX(70)
pwdEdit.SetY(40)
pwdEdit.SetSize(walk.Size{200, 20})
pwdEdit.KeyDown().Attach(mw.onKeyDown)
mw.pwdEdit = pwdEdit
loginBtn, _ := walk.NewPushButton(mw)
loginBtn.SetText("登陆")
loginBtn.SetX(120)
loginBtn.SetY(70)
loginBtn.SetSize(walk.Size{60, 30})
loginBtn.Clicked().Attach(mw.loginBtn_OnClick)
mw.loginBtn = loginBtn
mw.Show()
mw.userEdit.SetFocus()
mw.SetMinMaxSize(walk.Size{300, 150}, walk.Size{})
mw.SetSize(walk.Size{300, 150})
mw.Run()
os.Exit(0)
}
开发者ID:ibmendoza,项目名称:nsq-client,代码行数:50,代码来源:login_window.go
示例8: NewMainWindow
func NewMainWindow() *MyWindows {
mw := new(MyWindows)
mw.MainWindow, _ = walk.NewMainWindow()
mw.ni, err = walk.NewNotifyIcon()
checkErr(err)
icon, _ := walk.NewIconFromResourceId(3)
mw.setVipIcon(icon)
mw.addAction()
mw.ni.SetVisible(true)
return mw
}
开发者ID:CodyGuo,项目名称:Go-Cody,代码行数:14,代码来源:main.go
示例9: 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
示例10: Create
func (mw MainWindow) Create() error {
w, err := walk.NewMainWindow()
if err != nil {
return err
}
tlwi := topLevelWindowInfo{
Name: mw.Name,
Disabled: mw.Disabled,
Hidden: mw.Hidden,
Font: mw.Font,
MinSize: mw.MinSize,
MaxSize: mw.MaxSize,
ContextMenuActions: mw.ContextMenuActions,
DataBinder: mw.DataBinder,
Layout: mw.Layout,
Children: mw.Children,
}
return InitWidget(tlwi, w, func() error {
if err := w.SetTitle(mw.Title); err != nil {
return err
}
if err := w.SetSize(mw.Size.toW()); err != nil {
return err
}
if err := addToActionList(w.Menu().Actions(), mw.MenuActions); err != nil {
return err
}
imageList, err := walk.NewImageList(walk.Size{16, 16}, 0)
if err != nil {
return err
}
w.ToolBar().SetImageList(imageList)
if err := addToActionList(w.ToolBar().Actions(), mw.ToolBarActions); err != nil {
return err
}
if mw.AssignTo != nil {
*mw.AssignTo = w
}
return nil
})
}
开发者ID:yahame,项目名称:walk,代码行数:49,代码来源:mainwindow.go
示例11: main
func main() {
walk.Initialize(walk.InitParams{PanicOnError: true})
defer walk.Shutdown()
myWindow, _ := walk.NewMainWindow()
myWindow.SetLayout(walk.NewVBoxLayout())
myWindow.SetTitle("Go GUI example")
myButton1, _ := walk.NewPushButton(myWindow)
myButton1.SetText("XXXX")
lb, _ := walk.NewListBox(myWindow)
em := NewEnvModel()
for _, env := range os.Environ() {
i := strings.Index(env, "=")
if i == 0 {
continue
}
varName := env[0:i]
value := env[i+1:]
envItem := EnvItem{varName, value}
em.envItems = append(em.envItems, envItem)
}
fmt.Println("The len of Model", em.ItemCount())
lb.SetModel(em)
lb.CurrentIndexChanged().Attach(func() {
if curVar, ok := em.Value(lb.CurrentIndex()).(string); ok {
myButton1.SetText(curVar)
fmt.Println("CurrentIndex:", lb.CurrentIndex())
fmt.Println("CurrentEnvVarName:", curVar)
}
})
lb.DblClicked().Attach(func() {
value := em.envItems[lb.CurrentIndex()].value
walk.MsgBox(myWindow, "About", value, walk.MsgBoxOK|walk.MsgBoxIconInformation)
})
myWindow.Show()
myWindow.SetMinMaxSize(walk.Size{320, 240}, walk.Size{})
myWindow.SetSize(walk.Size{400, 500})
myWindow.Run()
}
开发者ID:hoperuin,项目名称:walk,代码行数:46,代码来源:listbox.go
示例12: NewPairChatWindow
func NewPairChatWindow(_usr, _partner User) {
walk.SetPanicOnError(true)
myWindow, _ := walk.NewMainWindow()
mw := &PairChatWindow{
MainWindow: myWindow,
usr: _usr,
partner: _partner,
msgChan: make(chan *NsqMsg, 1),
}
mw.SetTitle(fmt.Sprintf("与%s私聊", _partner.Nick))
msgEdit, _ := walk.NewTextEdit(mw)
mw.msgEdit = msgEdit
mw.msgEdit.SetSize(walk.Size{530, 100})
mw.msgEdit.SetX(10)
mw.msgEdit.SetY(360)
mw.msgEdit.SetReadOnly(false)
chatView, _ := NewChatMsgView(mw)
mw.chatView = chatView
mw.chatView.SetSize(walk.Size{530, 350})
mw.chatView.SetX(10)
mw.chatView.SetY(5)
sendBtn, _ := walk.NewPushButton(mw)
mw.sendBtn = sendBtn
mw.sendBtn.SetText("发送")
mw.sendBtn.SetX(480)
mw.sendBtn.SetY(470)
mw.sendBtn.SetSize(walk.Size{60, 30})
mw.sendBtn.Clicked().Attach(mw.sendBtn_OnClick)
mw.MainWindow.Show()
mw.msgEdit.SetFocus()
mw.SetMinMaxSize(walk.Size{565, 550}, walk.Size{565, 550})
mw.SetSize(walk.Size{565, 550})
pairChatMgr.register(mw.partner.Id, mw.msgChan)
go mw.msgRouter()
mw.MainWindow.Run()
pairChatMgr.unregister(mw.partner.Id)
}
开发者ID:ibmendoza,项目名称:nsq-client,代码行数:46,代码来源:pairchat_window.go
示例13: 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
示例14: main
func main() {
walk.Initialize(walk.InitParams{PanicOnError: true})
defer walk.Shutdown()
mainWnd, err := walk.NewMainWindow()
if err != nil {
return
}
mw := &MainWindow{MainWindow: mainWnd}
mw.SetTitle("SocketIm Example")
button1, _ := walk.NewPushButton(mw)
button1.SetText("start port 8000")
button1.SetX(10)
button1.SetY(10)
button1.SetWidth(100)
button1.SetHeight(30)
button1.Clicked().Attach(func() {
go NewTalkWindow(mw, 8000, 8001)
button1.SetEnabled(false)
})
button2, _ := walk.NewPushButton(mw)
button2.SetText("start port 8001")
button2.SetX(10)
button2.SetY(60)
button2.SetWidth(100)
button2.SetHeight(30)
button2.Clicked().Attach(func() {
go NewTalkWindow(mw, 8001, 8000)
button2.SetEnabled(false)
})
mw.SetSize(walk.Size{120, 150})
mw.Show()
mw.Run()
}
开发者ID:atree1987,项目名称:MyWorks,代码行数:42,代码来源:main.go
示例15: NewTalkWindow
func NewTalkWindow(mv *MainWindow, listenPort int, sendPort int) {
walk.Initialize(walk.InitParams{PanicOnError: true})
defer walk.Shutdown()
talkWnd, err := walk.NewMainWindow()
if err != nil {
return
}
tw := &TalkWindow{MainWindow: talkWnd, ListenPort: listenPort, SendPort: sendPort}
tw.SetTitle("I'm listing in" + strconv.Itoa(tw.ListenPort))
tw.ShowText, _ = walk.NewTextEdit(tw)
tw.ShowText.SetX(10)
tw.ShowText.SetY(10)
tw.ShowText.SetWidth(280)
tw.ShowText.SetHeight(300)
tw.ShowText.SetReadOnly(true)
tw.SendText, _ = walk.NewTextEdit(tw)
tw.SendText.SetX(10)
tw.SendText.SetY(320)
tw.SendText.SetWidth(200)
tw.SendText.SetHeight(30)
button1, _ := walk.NewPushButton(tw)
button1.SetText("发送")
button1.SetX(220)
button1.SetY(320)
button1.SetWidth(70)
button1.SetHeight(30)
button1.Clicked().Attach(func() {
tw.Send()
})
tw.SetSize(walk.Size{320, 400})
tw.Show()
go tw.Listen()
tw.Run()
}
开发者ID:atree1987,项目名称:MyWorks,代码行数:42,代码来源:im.go
示例16: downLoadXCGUIDll
func downLoadXCGUIDll() {
mw, _ := walk.NewMainWindow()
ret := walk.MsgBox(mw, "下载提示", "没有找到XCGUI.dll,是否要联网下载?", walk.MsgBoxIconQuestion+walk.MsgBoxOKCancel)
if ret != 1 {
walk.MsgBox(mw, "警告信息", "请在重新运行程序前将XCGUI.dll放到运行目录.", walk.MsgBoxIconWarning)
mw.Close()
os.Exit(1)
}
resp, err := http.Get("http://git.oschina.net/CodyGuo/xcgui/raw/master/lib/XCGUI.dll")
if err != nil {
log.Println("[ERROR] 下载失败,请检查网络.")
walk.MsgBox(mw, "错误信息", "XCGUI.dll 下载失败,请检查网络.", walk.MsgBoxIconError)
mw.Close()
}
if resp.StatusCode == http.StatusOK {
log.Println("[INFO] 正在下载 XCGUI.dll .")
downFile, err := os.Create("XCGUI.dll")
if err != nil {
log.Fatal(err)
}
// 不要忘记关闭打开的文件.
defer downFile.Close()
body, err := ioutil.ReadAll(resp.Body)
io.Copy(downFile, bytes.NewReader(body))
log.Println("[INFO] XCGUI.dll 下载成功.正在运行主程序.")
walk.MsgBox(mw, "提示信息", "下载成功, 请点击确定继续运行程序.", walk.MsgBoxIconInformation)
mw.Close()
} else {
log.Printf("[ERROR] 下载失败,%s.\n", resp.Status)
walk.MsgBox(mw, "错误信息", "[ERROR] 下载失败,请检查网络.", walk.MsgBoxIconError)
mw.Close()
}
mw.Run()
}
开发者ID:CodyGuo,项目名称:xcgui,代码行数:41,代码来源:download.go
示例17: main
func main() {
walk.Initialize(walk.InitParams{PanicOnError: true})
defer walk.Shutdown()
rand.Seed(time.Now().UnixNano())
mainWnd, _ := walk.NewMainWindow()
mw := &MainWindow{
MainWindow: mainWnd,
model: NewFooModel(),
}
mw.SetLayout(walk.NewVBoxLayout())
mw.SetTitle("Walk TableView Example")
resetRowsButton, _ := walk.NewPushButton(mw)
resetRowsButton.SetText("Reset Rows")
resetRowsButton.Clicked().Attach(func() {
// Get some fresh data.
mw.model.ResetRows()
})
tableView, _ := walk.NewTableView(mw)
tableView.SetAlternatingRowBGColor(walk.RGB(255, 255, 224))
tableView.SetReorderColumnsEnabled(true)
// Everybody loves check boxes.
tableView.SetCheckBoxes(true)
// Don't forget to set the model.
tableView.SetModel(mw.model)
mw.SetMinMaxSize(walk.Size{320, 240}, walk.Size{})
mw.SetSize(walk.Size{800, 600})
mw.Show()
mw.Run()
}
开发者ID:etel,项目名称:walk,代码行数:41,代码来源:tableview.go
示例18: main
func main() {
walk.SetPanicOnError(true)
mainWnd, _ := walk.NewMainWindow()
mw := &MainWindow{MainWindow: mainWnd}
mw.SetTitle("Walk Drawing Example")
mw.SetLayout(walk.NewVBoxLayout())
mw.paintWidget, _ = walk.NewCustomWidget(mw, 0, func(canvas *walk.Canvas, updateBounds walk.Rectangle) error {
return mw.drawStuff(canvas, updateBounds)
})
mw.paintWidget.SetClearsBackground(true)
mw.paintWidget.SetInvalidatesOnResize(true)
mw.SetMinMaxSize(walk.Size{320, 240}, walk.Size{})
mw.SetSize(walk.Size{800, 600})
mw.Show()
mw.Run()
}
开发者ID:IniZio,项目名称:Go,代码行数:22,代码来源:walkerGUI.go
示例19: Create
func (mw MainWindow) Create(parent walk.Container) error {
w, err := walk.NewMainWindow()
if err != nil {
return err
}
return InitWidget(mw, w, func() error {
if err := w.SetTitle(mw.Title); err != nil {
return err
}
if err := w.SetSize(mw.Size.toW()); err != nil {
return err
}
if err := addToActionList(w.Menu().Actions(), mw.MenuActions); err != nil {
return err
}
imageList, err := walk.NewImageList(walk.Size{16, 16}, 0)
if err != nil {
return err
}
w.ToolBar().SetImageList(imageList)
if err := addToActionList(w.ToolBar().Actions(), mw.ToolBarActions); err != nil {
return err
}
if mw.AssignTo != nil {
*mw.AssignTo = w
}
return nil
})
}
开发者ID:etel,项目名称:walk,代码行数:36,代码来源:mainwindow.go
示例20: initPoseInfo
//.........这里部分代码省略.........
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)
mw.uiAddBoundY, _ = walk.NewNumberEdit(sp)
mw.uiAddBoundY.SetRange(1, 1000)
mw.uiAddBoundY.SetValue(0)
mw.uiAddBoundY.SetDecimals(0)
mw.uiAddBoundY.ValueChanged().Attach(func() {
yBoundAdd = int(mw.uiAddBoundY.Value())
if yBoundAdd < -imageH {
yBoundAdd = -imageH
}
if yBoundAdd > (imageH - boundary.Max.Y) {
yBoundAdd = imageH - boundary.Max.Y
}
mw.uiAddBoundY.SetValue(float64(yBoundAdd))
mw.setImageSize()
})
mw.uiConvirm, _ = walk.NewPushButton(sp)
mw.uiConvirm.SetText("OK")
mw.uiConvirm.Clicked().Attach(func() {
// Get some fresh data.
// mw.onUiSetFrameCnt()
})
walk.InitWidget(sp, mw, FREEZEIZE_CLASS,
winapi.CCS_NORESIZE,
winapi.WS_EX_TOOLWINDOW|winapi.WS_EX_WINDOWEDGE)
}
func newMainWindow() {
walk.SetPanicOnError(true)
mainWnd, _ := walk.NewMainWindow()
mw := &MainWindow{MainWindow: mainWnd}
mw.viewGrid = walk.NewGridLayout()
mw.SetLayout(mw.viewGrid)
mw.viewGrid.SetRowStretchFactor(GRID_CNT, 2)
mw.viewGrid.SetColumnStretchFactor(GRID_CNT, 2)
mw.viewGrid.SetMargins(walk.Margins{6, 28, 2, 6})
mw.SetTitle("Image composer")
mw.initMenu()
mw.initOtherBars()
mw.initCanvas()
mw.SetMinMaxSize(walk.Size{800, 600}, walk.Size{})
mw.SetSize(walk.Size{800, 600})
mw.refreshToolBar(MODE_INVALID)
mw.Show()
mw.Run()
}
func init() {
walk.MustRegisterWindowClass(FREEZEIZE_CLASS)
runtime.GOMAXPROCS(2)
screenW = int(winapi.GetSystemMetrics(winapi.SM_CXSCREEN))
screenH = int(winapi.GetSystemMetrics(winapi.SM_CYSCREEN))
}
func main() {
newMainWindow()
}
开发者ID:hemaolong,项目名称:Rabbit,代码行数:101,代码来源:main.go
注:本文中的github.com/lxn/walk.NewMainWindow函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论