示例#1
0
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)
	}
}
示例#2
0
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()
}
示例#3
0
文件: main.go 项目: CodyGuo/Go-Cody
func (mw *MyWindows) remoteClipboard() error {
	remoteAction := walk.NewAction()
	if err := remoteAction.SetText("复制远程访问地址"); err != nil {
		return err
	}
	remoteAction.Triggered().Attach(func() {
		ip, err := getIP()
		if err != nil {
			log.Fatal(err)
		}
		// 先清空粘贴板
		walk.Clipboard().Clear()
		err = walk.Clipboard().SetText(fmt.Sprintf("http://%s%s", ip, port))
		checkErr(err)
	})
	if err := mw.ni.ContextMenu().Actions().Add(remoteAction); err != nil {
		return err
	}

	return nil

}
示例#4
0
文件: mdf.go 项目: kurtqiao/go
func main() {
	flag.Parse()
	fn := flag.Arg(0)

	fl, err := os.Open(fn)
	if err != nil {
		fmt.Println(fn, err)
		return
	}
	defer fl.Close()
	fmt.Printf("%s:\n", fn)
	md5h := md5.New()
	io.Copy(md5h, fl)
	fmt.Printf("MD5: 0x%X\n", md5h.Sum([]byte("")))
	c := crc32.NewIEEE()
	fl.Seek(0, os.SEEK_SET) //reset file pointer to start
	io.Copy(c, fl)
	crch := c.Sum32()
	fmt.Printf("CRC32: 0x%X", crch)
	//set crc32 result to windows clipboard
	walk.Clipboard().SetText(fmt.Sprintf("0x%X", crch))
}
示例#5
0
func main() {
	var le, le2 *walk.LineEdit
	var lb1, lb2 *walk.Label
	var ck1 *walk.CheckBox
	var mw *walk.MainWindow

	copytext, _ := walk.Clipboard().Text()

	updateIcon := func() {
		mainIcon, err := walk.NewIconFromResource("101")
		if err != nil {
			// do some work
		}
		mw.SetIcon(mainIcon)
	}

	if err := (MainWindow{
		AssignTo: &mw,
		Title:    "模板下载器",
		MinSize:  Size{400, 100},
		Layout:   VBox{},
		Children: []Widget{
			CheckBox{
				AssignTo: &ck1,
				Name:     "cksnap",
				Text:     "带截图抓取",
				Checked:  false,
			},
			Label{
				AssignTo: &lb1,
				Text:     "网址",
			},
			LineEdit{
				AssignTo: &le,
				Text:     copytext,
			},
			Label{
				AssignTo: &lb2,
				Text:     "保存目录",
			},
			LineEdit{
				AssignTo: &le2,
				Text:     `D:\APMServ5.2.6\www\htdocs\down\tpls\`,
			},
			PushButton{
				Text: "开始抓取",
				OnClicked: func() {
					fmt.Println(ck1.Checked())
					if ck1.Checked() {
						command := flag.String("cmd", "phantomjs", "Set the command.")
						patharr := strings.Split(le2.Text(), "\\")

						args := flag.String("args", "rasterize.js "+le.Text()+" "+le2.Text()+"\\"+patharr[len(patharr)-1]+".png", "Set the args. (separated by spaces)")
						var argArray []string
						if *args != "" {
							argArray = strings.Split(*args, " ")
						} else {
							argArray = make([]string, 0)
						}

						flag.Parse()
						cmd := exec.Command(*command, argArray...)

						buf, err := cmd.Output()
						if err != nil {
							fmt.Fprintf(os.Stderr, "The command failed to perform: %s (Command: %s, Arguments: %s)", err, *command, *args)
							return
						}
						fmt.Fprintf(os.Stdout, "Result: %s", buf)

					}
					getTemplate(le.Text(), le2.Text())
				},
			},