func main() { var mw *walk.MainWindow if err := (MainWindow{ AssignTo: &mw, Title: "Walk LogView Example", MinSize: Size{320, 240}, Size: Size{400, 600}, Layout: VBox{MarginsZero: true}, }.Create()); err != nil { log.Fatal(err) } lv, err := NewLogView(mw) if err != nil { log.Fatal(err) } lv.PostAppendText("XXX") log.SetOutput(lv) go func() { for i := 0; i < 10000; i++ { time.Sleep(100 * time.Millisecond) log.Println("Text" + "\r\n") } }() mw.Run() }
func main() { var mw *walk.MainWindow var windowIcon *walk.Icon counter := 0 if _, err := (MainWindow{ AssignTo: &mw, Title: "Walk Image Icon Example", Layout: HBox{}, Children: []Widget{ HSpacer{}, PushButton{ Text: "Push me", OnClicked: func() { ic, err := walk.NewIconFromImage(makeDigitImage(counter)) if err != nil { return } counter++ mw.SetIcon(ic) if windowIcon != nil { windowIcon.Dispose() } windowIcon = ic }, }, HSpacer{}, }, }.Run()); err != nil { log.Fatal(err) } }
func main() { var mw *walk.MainWindow if err := (MainWindow{ AssignTo: &mw, Title: "Walk External Widgets Example", Size: Size{400, 300}, Layout: HBox{}, }).Create(); err != nil { log.Fatal(err) } for _, name := range []string{"a", "b", "c"} { if w, err := NewMyWidget(mw); err != nil { log.Fatal(err) } else { w.SetName(name) } } mpb, err := NewMyPushButton(mw) if err != nil { log.Fatal(err) } mpb.SetText("MyPushButton") mw.Run() }
func main() { var mainWindow *walk.MainWindow var treeView *walk.TreeView var tableView *walk.TableView var webView *walk.WebView treeModel, err := NewDirectoryTreeModel() if err != nil { log.Fatal(err) } tableModel := NewFileInfoModel() if err := (MainWindow{ AssignTo: &mainWindow, Title: "Walk File Browser Example", MinSize: Size{600, 400}, Size: Size{800, 600}, Layout: HBox{MarginsZero: true}, Children: []Widget{ HSplitter{ Children: []Widget{ TreeView{ AssignTo: &treeView, Model: treeModel, OnCurrentItemChanged: func() { dir := treeView.CurrentItem().(*Directory) if err := tableModel.SetDirPath(dir.Path()); err != nil { walk.MsgBox( mainWindow, "Error", err.Error(), walk.MsgBoxOK|walk.MsgBoxIconError) } }, }, TableView{ AssignTo: &tableView, Columns: []TableViewColumn{ TableViewColumn{ DataMember: "Name", Width: 200, }, TableViewColumn{ DataMember: "Size", Format: "%d", Alignment: AlignFar, Width: 80, }, TableViewColumn{ DataMember: "Modified", Format: "2006-01-02 15:04:05", Width: 120, }, }, Model: tableModel, OnCurrentIndexChanged: func() { var url string if index := tableView.CurrentIndex(); index > -1 { name := tableModel.items[index].Name dir := treeView.CurrentItem().(*Directory) url = filepath.Join(dir.Path(), name) } webView.SetURL(url) }, }, WebView{ AssignTo: &webView, }, }, }, }, }.Create()); err != nil { log.Fatal(err) } mainWindow.Run() }