Ejemplo n.º 1
0
func main() {
	var (
		msgbox  *walk.TextEdit
		inputUN *walk.LineEdit //input username
		inputPW *walk.LineEdit //input password
		myPB    *walk.PushButton
	)

	MainWindow{

		Title:   "soramail",
		MinSize: Size{640, 480},
		Layout:  VBox{},
		Children: []Widget{
			TextEdit{
				AssignTo: &msgbox,
				Text:     "Hello, World",
				ReadOnly: true,
			},
			HSplitter{
				MaxSize: Size{640, 20},
				Children: []Widget{
					LineEdit{
						AssignTo: &inputUN,
						Text:     "username",
					},
					LineEdit{
						AssignTo: &inputPW,
						Text:     "password",
					},
					PushButton{
						AssignTo: &myPB,
						Text:     "Push",
						OnClicked: func() {
							msgbox.AppendText("\r\nHello," + inputUN.Text() + ".\r\nYour password is " + inputPW.Text())
						},
					},
				},
			},
		},
	}.Run()
}
Ejemplo n.º 2
0
func sendThread(msgbox, es *walk.TextEdit) {
	sendTo := strings.Split(SJ.Send, "\r\n")
	susscess := 0
	count := len(sendTo)
	for index, to := range sendTo {
		if runing == false {
			break
		}
		msgbox.SetText("发送到" + to + "..." + strconv.Itoa((index/count)*100) + "%")
		err := SendMail(SJ.Name, SJ.Pwd, SJ.Host, to, SJ.Subject, SJ.Body, "html")
		if err != nil {
			msgbox.AppendText("\r\n失败:" + err.Error() + "\r\n")
			if err.Error() == "550 Mailbox not found or access denied" {
				SJ.Send = strings.Join(DelArrayVar(strings.Split(SJ.Send, "\r\n"), to), "\r\n")
				es.SetText(SJ.Send)
			}
			time.Sleep(1 * time.Second)
			continue
		} else {
			susscess++
			msgbox.AppendText("\r\n发送成功!")
			SJ.Send = strings.Join(DelArrayVar(strings.Split(SJ.Send, "\r\n"), to), "\r\n")
			es.SetText(SJ.Send)
		}
		time.Sleep(1 * time.Second)
	}
	SaveData()
	msgbox.AppendText("停止发送!成功 " + strconv.Itoa(susscess) + " 条\r\n")
}
Ejemplo n.º 3
0
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()
}