本文整理汇总了Golang中github.com/lxn/walk.TextEdit.SetText方法的典型用法代码示例。如果您正苦于以下问题:Golang TextEdit.SetText方法的具体用法?Golang TextEdit.SetText怎么用?Golang TextEdit.SetText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/lxn/walk.TextEdit
的用法示例。
在下文中一共展示了TextEdit.SetText方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
var mw *walk.MainWindow
var outTE *walk.TextEdit
animal := new(Animal)
if _, err := (MainWindow{
AssignTo: &mw,
Title: "Walk Data Binding Example",
MinSize: Size{300, 200},
Layout: VBox{},
Children: []Widget{
PushButton{
Text: "Edit Animal",
OnClicked: func() {
if cmd, err := RunAnimalDialog(mw, animal); err != nil {
log.Print(err)
} else if cmd == walk.DlgCmdOK {
outTE.SetText(fmt.Sprintf("%+v", animal))
}
},
},
Label{
Text: "animal:",
},
TextEdit{
AssignTo: &outTE,
ReadOnly: true,
Text: fmt.Sprintf("%+v", animal),
},
},
}.Run()); err != nil {
log.Fatal(err)
}
}
示例2: main
func main() {
var outTE *walk.TextEdit
mw := new(MyMainWindow)
MainWindow{
Title: "简易加密文件",
AssignTo: &mw.MainWindow,
MinSize: Size{300, 140},
Layout: VBox{},
Children: []Widget{
HSplitter{
Children: []Widget{
TextEdit{AssignTo: &outTE, ReadOnly: true},
},
},
PushButton{
Text: "选择文件求反",
OnClicked: func() {
dlg := new(walk.FileDialog)
dlg.Title = "选择文件"
if ok, err := dlg.ShowOpen(mw); err != nil {
outTE.SetText(err.Error())
} else if !ok {
outTE.SetText("未选择文件")
} else {
fileName := dlg.FilePath
file, err := os.Open(fileName)
defer file.Close()
if err != nil {
outTE.SetText("未找到待处理文件")
}
//读取文件内容
plain, _ := ioutil.ReadAll(file)
//求反
for i, b := range plain {
plain[i] = ^b
}
//写入文件
if fileName[len(fileName)-1:] != "+" {
fileName += "+"
} else {
fileName = fileName[:len(fileName)-1]
}
err = ioutil.WriteFile(fileName, plain, 0777)
if err != nil {
outTE.SetText(dlg.FilePath + " 保存转换后文件失败!")
} else {
outTE.SetText(dlg.FilePath + " 文件已转换!")
}
}
},
},
},
}.Run()
}
示例3: main
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)
}
}
示例4: main
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()
}
示例5: openstomp
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)
}
示例6: main
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()
}
示例7: main
func main() {
var textEdit *walk.TextEdit
MainWindow{
Title: "Walk DropFiles Example",
MinSize: Size{320, 240},
Layout: VBox{},
OnDropFiles: func(files []string) {
textEdit.SetText(strings.Join(files, "\r\n"))
},
Children: []Widget{
TextEdit{
AssignTo: &textEdit,
ReadOnly: true,
Text: "Drop files here, from windows explorer...",
},
},
}.Run()
}
示例8: main
//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()
}
示例9: sendThread
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")
}
示例10: main
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()
}
示例11: main
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()
}
示例12: main
func main() {
mw := new(MyMainWindow)
var openButton *walk.PushButton
var hostEdit, destEdit, portEdit *walk.LineEdit
var logTextEdit *walk.TextEdit
closeMessage := make(chan int)
MainWindow{
AssignTo: &mw.MainWindow,
Title: "SCREAMO",
MinSize: Size{600, 400},
Layout: VBox{},
Children: []Widget{
Composite{
Layout: Grid{},
Children: []Widget{
Label{
Row: 0,
Column: 0,
Text: "JmsHost:",
},
LineEdit{
AssignTo: &hostEdit,
Row: 0,
Column: 1,
Text: "192.168.1.105",
},
Label{
Row: 1,
Column: 0,
Text: "JmsDest:",
},
LineEdit{
AssignTo: &destEdit,
Row: 1,
Column: 1,
Text: "/topic/IDC.QuoteExchange.bond2app",
},
Label{
Row: 2,
Column: 0,
Text: "JmsPort:",
},
LineEdit{
AssignTo: &portEdit,
Row: 2,
Column: 1,
Text: "61612",
},
},
},
Composite{
Layout: HBox{},
Children: []Widget{
PushButton{
AssignTo: &openButton,
Text: "Open",
OnClicked: func() {
if openButton.Text() == "Open" {
go openstomp(hostEdit.Text(), destEdit.Text(), portEdit.Text(), logTextEdit, closeMessage)
openButton.SetText("Close")
} else {
go stopstomp(closeMessage)
openButton.SetText("Open")
}
},
},
PushButton{
Text: "Clear",
OnClicked: func() {
logTextEdit.SetText("")
},
},
},
},
TextEdit{
AssignTo: &logTextEdit,
MinSize: Size{100, 50},
Text: "",
ReadOnly: true,
},
},
}.Run()
}