func main() { var te *walk.TextEdit if _, err := (MainWindow{ Title: "Walk Clipboard Example", MinSize: Size{300, 200}, Layout: VBox{}, Children: []Widget{ PushButton{ Text: "Copy", OnClicked: func() { if err := walk.Clipboard().SetText(te.Text()); err != nil { log.Print("Copy: ", err) } }, }, PushButton{ Text: "Paste", OnClicked: func() { if text, err := walk.Clipboard().Text(); err != nil { log.Print("Paste: ", err) } else { te.SetText(text) } }, }, TextEdit{ AssignTo: &te, }, }, }).Run(); err != nil { log.Fatal(err) } }
func main() { var inTE, outTE *walk.TextEdit MainWindow{ Title: "PHP Interpreter", MinSize: Size{600, 400}, Layout: VBox{}, Children: []Widget{ Label{ Text: "Escriba codigo PHP sin etiquetas de <?php apertura y cierre ?>", }, HSplitter{ Children: []Widget{ TextEdit{AssignTo: &inTE}, TextEdit{AssignTo: &outTE, ReadOnly: true}, }, }, PushButton{ Text: "Let the magic happen!", OnClicked: func() { input := strings.Replace(inTE.Text(), "\n", " ", -1) out, err := exec.Command("php", "-r", input).Output() if err != nil { log.Println(err) } outTE.SetText(string(out)) }, }, }, }.Run() }
func openstomp(host, dest, port string, logTextEdit *walk.TextEdit, closeMessage chan int) { stomputils.JmsHost = host stomputils.JmsDest = dest stomputils.JmsPort = port handleMessage := func(body []byte) { //fmt.Println(string(body)) logTextEdit.SetText(logTextEdit.Text() + string(body)) } stomputils.Handle(handleMessage, closeMessage) }
func main() { var ( te *walk.TextEdit le *walk.LineEdit ) MainWindow{ Title: _WIN_TITLE, MinSize: Size{300, 400}, Layout: VBox{}, Children: []Widget{ Label{ Text: _WIN_LABEL_HOST, }, LineEdit{ AssignTo: &le, Text: GetHttpHost(), }, Label{ Text: _WIN_LABEL_LINK, }, TextEdit{ AssignTo: &te, }, Composite{ Layout: HBox{}, Children: []Widget{ PushButton{ Text: _WIN_GEN_BUTTON, OnClicked: func() { URL, err := url.Parse(te.Text()) if err != nil { return } genURL := generateURL(URL, le.Text()) if genURL != nil { te.SetText(genURL.String()) } }, }, PushButton{ Text: _WIN_COPY_BUTTON, OnClicked: func() { walk.Clipboard().SetText(te.Text()) }, }, }, }, }, }.Run() }
func main() { LoadData() chEnd = make(chan bool) var emails, body, msgbox *walk.TextEdit var user, password, host, subject *walk.LineEdit var startBtn *walk.PushButton MainWindow{ Title: "邮件群发器 By 一曲忧伤", MinSize: Size{800, 600}, Layout: HBox{}, Children: []Widget{ TextEdit{AssignTo: &emails, Text: SJ.Send, ToolTipText: "待发送邮件列表,每行一个"}, VSplitter{ Children: []Widget{ LineEdit{AssignTo: &user, Text: SJ.Name, CueBanner: "请输入邮箱用户名"}, LineEdit{AssignTo: &password, Text: SJ.Pwd, PasswordMode: true, CueBanner: "请输入邮箱登录密码"}, LineEdit{AssignTo: &host, Text: SJ.Host, CueBanner: "SMTP服务器:端口"}, LineEdit{AssignTo: &subject, Text: SJ.Subject, CueBanner: "请输入邮件主题……"}, TextEdit{AssignTo: &body, Text: SJ.Body, ToolTipText: "请输入邮件内容", ColumnSpan: 2}, TextEdit{AssignTo: &msgbox, ReadOnly: true}, PushButton{ AssignTo: &startBtn, Text: "开始群发", OnClicked: func() { SJ.Name = user.Text() SJ.Pwd = password.Text() SJ.Host = host.Text() SJ.Subject = subject.Text() SJ.Body = body.Text() SJ.Send = emails.Text() SaveData() if runing == false { runing = true startBtn.SetText("停止发送") go sendThread(msgbox, emails) } else { runing = false startBtn.SetText("开始群发") } }, }, }, }, }, }.Run() }
func main() { var inTE, outTE *walk.TextEdit MainWindow{ Title: "SCREAMO", MinSize: Size{600, 400}, Layout: VBox{}, Children: []Widget{ HSplitter{ Children: []Widget{ TextEdit{AssignTo: &inTE}, TextEdit{AssignTo: &outTE, ReadOnly: true}, }, }, PushButton{ Text: "SCREAM", OnClicked: func() { outTE.SetText(strings.ToUpper(inTE.Text())) }, }, }, }.Run() }
//please check intel host bridge for PCIEBAR (0:0:0:60) //usualy it's 0xE0000000 func main() { var Busno, Devno, Funcno, Regno, outTE *walk.TextEdit PCIEBAR := 14 MainWindow{ Title: "PCI address Calculator", MinSize: Size{500, 150}, Layout: VBox{}, Children: []Widget{ HSplitter{ Children: []Widget{ Label{Text: "Bus:"}, TextEdit{ AssignTo: &Busno, }, Label{Text: "Dev:"}, TextEdit{ AssignTo: &Devno, }, Label{Text: "Func:"}, TextEdit{ AssignTo: &Funcno, }, Label{Text: "Reg:"}, TextEdit{ AssignTo: &Regno, }, PushButton{ Text: "Get", OnClicked: func() { BB, _ := strconv.Atoi(Busno.Text()) DD, _ := strconv.Atoi(Devno.Text()) FF, _ := strconv.Atoi(Funcno.Text()) RR, _ := strconv.Atoi(Regno.Text()) pcimmaddr := PCIEBAR<<28 + BB<<20 + DD<<15 + FF<<12 + (RR & 0xfc) pciaddr := 1<<31 + BB<<16 + DD<<11 + FF<<8 + (RR & 0xfc) outTE.SetText(fmt.Sprintf("pci io address: %X\r\npci mmio address: %X", pciaddr, pcimmaddr)) }, }, }, }, TextEdit{AssignTo: &outTE, ReadOnly: true}, }, }.Run() }
func main() { var aTE, bTE, cTE, dTE *walk.LineEdit var outTE *walk.TextEdit var mw *walk.MainWindow defer func() { if e := recover(); e != nil { walk.MsgBox(mw, "Error", fmt.Sprintf("%v", e), walk.MsgBoxIconInformation) } }() MainWindow{ AssignTo: &mw, Title: "24 Game", MinSize: Size{600, 400}, Layout: VBox{}, Children: []Widget{ Composite{ Layout: HBox{}, Children: []Widget{ Label{Text: "a"}, LineEdit{AssignTo: &aTE}, Label{Text: "b"}, LineEdit{AssignTo: &bTE}, Label{Text: "c"}, LineEdit{AssignTo: &cTE}, Label{Text: "d"}, LineEdit{AssignTo: &dTE}, PushButton{ Text: "Go", OnClicked: func() { rand.Seed(time.Now().Unix()) aTE.SetText(fmt.Sprint(rand.Intn(13) + 1)) bTE.SetText(fmt.Sprint(rand.Intn(13) + 1)) cTE.SetText(fmt.Sprint(rand.Intn(13) + 1)) dTE.SetText(fmt.Sprint(rand.Intn(13) + 1)) }, }, }, }, TextEdit{AssignTo: &outTE, ReadOnly: true}, PushButton{ Text: "Compute", OnClicked: func() { a, err := strconv.ParseInt(aTE.Text(), 10, 64) b, err := strconv.ParseInt(bTE.Text(), 10, 64) c, err := strconv.ParseInt(cTE.Text(), 10, 64) d, err := strconv.ParseInt(dTE.Text(), 10, 64) if err != nil { walk.MsgBox(mw, "Error", err.Error(), walk.MsgBoxIconInformation) } outTE.SetText("") for solution := range findSolution(a, b, c, d) { outTE.AppendText(fmt.Sprintf("%s = 24\r\n", solution)) } if outTE.Text() == "" { outTE.SetText("No solution.") } }, }, }, }.Run() }
func main() { LoadData() chEnd = make(chan bool) var emails, body, msgbox *walk.TextEdit var user, password, host, subject *walk.LineEdit var db *walk.DataBinder var ep walk.ErrorPresenter var startBtn *walk.PushButton mw := new(MyMainWindow) mw.SetFixedSize(false) mw.SetMaximizeBox(false) MainWindow{ Title: "邮件群发器 By 一曲忧伤", MinSize: Size{300, 200}, AssignTo: &mw.MainWindow, DataBinder: DataBinder{ AssignTo: &db, DataSource: SJ, ErrorPresenter: ErrorPresenterRef{&ep}, }, ScreenCenter: true, Layout: HBox{}, Children: []Widget{ TextEdit{ AssignTo: &emails, Text: SJ.Send, ToolTipText: "待发送邮件列表,每行一个", }, VSplitter{ Children: []Widget{ LineEdit{ AssignTo: &user, Text: Bind(SJ.Name, Regexp{"^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$"}), CueBanner: "请输入邮箱用户名", }, LineEdit{ AssignTo: &password, Text: SJ.Pwd, PasswordMode: true, CueBanner: "请输入邮箱登录密码", }, LineEdit{ AssignTo: &host, Text: Bind(SJ.Host, Regexp{"^(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])$"}), CueBanner: "SMTP服务器:端口", }, LineEdit{AssignTo: &subject, MaxLength: 10, Text: Bind(SJ.Subject, Regexp{"^([a-z0-9A-Z])+$"}), CueBanner: "请输入邮件主题……", }, TextEdit{AssignTo: &body, Text: Bind(SJ.Body, SelRequired{}), ToolTipText: "请输入邮件内容", ColumnSpan: 2, }, TextEdit{AssignTo: &msgbox, ReadOnly: true, }, LineErrorPresenter{ AssignTo: &ep, ColumnSpan: 2, ToolTipText: "测试", }, PushButton{ AssignTo: &startBtn, Text: "开始群发", OnClicked: func() { if err := db.Submit(); err == nil { SJ.Name = user.Text() SJ.Pwd = password.Text() SJ.Host = host.Text() SJ.Subject = subject.Text() SJ.Body = body.Text() SJ.Send = emails.Text() SaveData() if runing == false { runing = true startBtn.SetText("停止发送") go sendThread(msgbox, emails) } else { runing = false startBtn.SetText("开始群发") } } else { return } }, }, }, }, }, }.Run() }