本文整理汇总了Golang中github.com/lxn/walk.LineEdit.Text方法的典型用法代码示例。如果您正苦于以下问题:Golang LineEdit.Text方法的具体用法?Golang LineEdit.Text怎么用?Golang LineEdit.Text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/lxn/walk.LineEdit
的用法示例。
在下文中一共展示了LineEdit.Text方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
var le *walk.LineEdit
var wv *walk.WebView
MainWindow{
Title: "Walk WebView Example",
MinSize: Size{800, 600},
Layout: VBox{MarginsZero: true},
Children: []Widget{
LineEdit{
AssignTo: &le,
Text: Bind("wv.URL"),
OnKeyDown: func(key walk.Key) {
if key == walk.KeyReturn {
wv.SetURL(le.Text())
}
},
},
WebView{
AssignTo: &wv,
Name: "wv",
URL: "http://golang.org",
},
},
}.Run()
}
示例2: osOpenWindow
func osOpenWindow(window *Window, url string, styleFlags int) {
fmt.Println("osOpenWindow: ", window, url, styleFlags)
var dia *walk.Dialog
var le *walk.LineEdit
var wv *walk.WebView
windowStore[window.handle] = dia
Dialog{
AssignTo: &dia,
Title: "Window Title",
MinSize: Size{800, 600},
Layout: VBox{MarginsZero: true},
Children: []Widget{
LineEdit{
AssignTo: &le,
Text: Bind("wv.URL"),
OnKeyDown: func(key walk.Key) {
if key == walk.KeyReturn {
wv.SetURL(le.Text())
}
},
},
WebView{
AssignTo: &wv,
Name: "wv",
URL: url,
},
},
}.Run(mainWindow)
}
示例3: ParseNumber
func ParseNumber(textbox *walk.LineEdit) float64 {
number, err := strconv.ParseFloat(textbox.Text(), 64)
widgets := textbox.Parent().Children()
index := widgets.Index(textbox)
label := widgets.At(index + 1).(*walk.Label)
if err != nil {
label.SetText("需要填入数字")
} else {
label.SetText("")
}
return number
}
示例4: 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()
}
示例5: main
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()
}
示例6: showDialogAction_Triggered
func (mw *MyMainWindow) showDialogAction_Triggered() {
dlg := new(MyDialog)
var acceptPB *walk.PushButton
var le1, le2 *walk.LineEdit
widgets := []Widget{
Label{Row: 0, Column: 0, Text: "A LineEdit:"},
LineEdit{Row: 0, Column: 1, AssignTo: &le1, OnTextChanged: func() { le2.SetText(le1.Text()) }},
ToolButton{Row: 0, Column: 2, Text: "..."},
Label{Row: 1, Column: 0, Text: "Another LineEdit:"},
LineEdit{Row: 1, Column: 1, AssignTo: &le2},
Label{Row: 2, Column: 0, Text: "A ComboBox:"},
ComboBox{Row: 2, Column: 1},
VSpacer{Row: 3, Column: 0, Size: 10},
Label{Row: 4, Column: 0, ColumnSpan: 2, Text: "A TextEdit:"},
TextEdit{Row: 5, Column: 0, ColumnSpan: 2},
}
dd := &DialogDecl{
Title: "My Dialog",
Owner: mw,
Dialog: &dlg.Dialog,
AcceptPB: &acceptPB,
Widgets: widgets,
MinSize: Size{400, 300},
}
if err := dd.Create(); err != nil {
log.Fatal(err)
}
acceptPB.Clicked().Attach(func() {
dlg.Accept()
})
dlg.Run()
}
示例7: main
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()
}
示例8: main
func main() {
var le *walk.LineEdit
var wv *walk.WebView
MainWindow{
Title: "Walk WebView Example",
MinSize: Size{800, 600},
Layout: VBox{},
Children: []Widget{
LineEdit{
AssignTo: &le,
Text: Bind("wv.URL"),
OnReturnPressed: func() {
wv.SetURL(le.Text())
},
},
WebView{
AssignTo: &wv,
Name: "wv",
URL: "http://golang.org",
},
},
}.Run()
}
示例9: 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()
}
示例10: main
func main() {
fout, _ := os.Create("dialer.log")
defer fout.Close()
bo := bufio.NewWriter(fout)
defer bo.Flush()
util.INFO.SetOutput(bo)
util.ERROR.SetOutput(bo)
bin, err := ioutil.ReadFile("config.json")
if err == nil {
json.Unmarshal(bin, config)
} else {
util.ERROR.Log(err)
err = nil
}
var usr, pwd *walk.LineEdit
var raddr, rusr, rpwd *walk.LineEdit
var lb, rb *walk.PushButton
var mode *walk.ComboBox
var mw *walk.MainWindow
var db *walk.DataBinder
var laddr, lusr, lpwd *walk.Splitter
go func() {
for mw == nil {
runtime.Gosched()
}
ic, err := walk.NewIconFromResourceId(6)
if err == nil {
// func onLoad() {
db.SetAutoSubmit(true)
mw.SetIcon(ic)
switch config.RouterType {
case "hiwifi":
laddr.SetVisible(true)
lusr.SetVisible(false)
lpwd.SetVisible(true)
case "openwrt":
laddr.SetVisible(true)
lusr.SetVisible(true)
lpwd.SetVisible(true)
case "asus":
laddr.SetVisible(true)
lusr.SetVisible(true)
lpwd.SetVisible(true)
default:
laddr.SetVisible(false)
lusr.SetVisible(false)
lpwd.SetVisible(false)
}
mw.SetSize(walk.Size{0, 0})
// }
}
}()
MainWindow{
AssignTo: &mw,
Title: TITLE,
MinSize: Size{340, 0},
Layout: VBox{},
DataBinder: DataBinder{
AssignTo: &db,
DataSource: config,
},
Children: []Widget{
HSplitter{
Children: []Widget{
Label{Text: "用户名", MaxSize: Size{60, 20}},
LineEdit{Text: Bind("Username"), AssignTo: &usr, MaxSize: Size{0, 20}},
}, MaxSize: Size{0, 20},
},
HSplitter{
Children: []Widget{
Label{Text: "密码", MaxSize: Size{60, 20}},
LineEdit{Text: Bind("Password"), AssignTo: &pwd, MaxSize: Size{0, 20}, PasswordMode: true,
OnMouseDown: func(x, y int, button walk.MouseButton) {
pwd.SetPasswordMode(false)
},
OnMouseUp: func(x, y int, button walk.MouseButton) {
pwd.SetPasswordMode(true)
},
},
}, MaxSize: Size{0, 20},
},
HSplitter{
Children: []Widget{
Label{Text: "模式", MaxSize: Size{60, 20}},
ComboBox{AssignTo: &mode,
Editable: true, Value: Bind("RouterType"),
Model: []string{"local", "10.0.x.x(手动填写)", "openwrt", "hiwifi", "asus"},
MaxSize: Size{0, 20},
OnCurrentIndexChanged: func() {
switch mode.CurrentIndex() {
case 2: //"openwrt":
laddr.SetVisible(true)
lusr.SetVisible(true)
lpwd.SetVisible(true)
case 3: //"hiwifi":
config.RouterAddr = "192.168.199.1"
laddr.SetVisible(true)
lusr.SetVisible(false)
//.........这里部分代码省略.........
示例11: 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()
}
示例12: newToolBar
func newToolBar() ToolBar {
tb := ToolBar{
ButtonStyle: ToolBarButtonImageBeforeText,
Items: []MenuItem{
Action{
AssignTo: &(context.addButton),
Text: "新增",
Image: "res/add.png",
// Enabled: Bind("isSpecialMode && enabledCB.Checked"),
OnTriggered: func() {
var dlg *walk.Dialog
var hostsNameEdit *walk.LineEdit
Dialog{
AssignTo: &dlg,
Title: "新增",
MinSize: Size{300, 150},
Layout: VBox{},
Children: []Widget{
Composite{
Layout: Grid{Columns: 2},
Children: []Widget{
Label{
ColumnSpan: 2,
Text: "Hosts名字:",
},
LineEdit{
AssignTo: &hostsNameEdit,
ColumnSpan: 2,
// Text: Bind("PatienceField"),
},
},
},
HSpacer{},
Composite{
Layout: HBox{},
Children: []Widget{
PushButton{
// AssignTo: &acceptPB,
Text: "确定",
OnClicked: func() {
// if err := db.Submit(); err != nil {
// log.Print(err)
// return
// }
item := &model.HostConfigItem{Name: hostsNameEdit.Text(), Icon: common.IconMap[common.ICON_NEW]}
conf.Config.HostConfigModel.Insert(item)
context.treeView.SetCurrentItem(item)
dlg.Accept()
},
},
PushButton{
// AssignTo: &cancelPB,
Text: "取消",
OnClicked: func() { dlg.Cancel() },
},
},
},
},
}.Run(context.mw)
},
},
//FIXME 去除刷新按钮是因为点击以后, 双击hosts不再生效
// Action{
// Text: "刷新",
// Image: "res/refresh.png",
// // Enabled: Bind("isSpecialMode && enabledCB.Checked"),
// OnTriggered: func() {
// conf.Load()
// },
// },
// Action{
// Text: "修改",
// Image: "res/pencil.png",
// // Enabled: Bind("isSpecialMode && enabledCB.Checked"),
// // OnTriggered: mw.specialAction_Triggered,
// },
Action{
AssignTo: &(context.deleteButton),
Text: "删除",
Image: "res/delete.png",
// Enabled: Bind("isSpecialMode && enabledCB.Checked"),
OnTriggered: func() {
if context.treeView.CurrentItem() == nil {
walk.MsgBox(context.mw, "删除hosts", "请选择左边列表后再删除", walk.MsgBoxIconInformation)
context.deleteButton.SetEnabled(false)
return
}
current := context.treeView.CurrentItem().(*model.HostConfigItem)
message := fmt.Sprintf("确定要删除hosts '%s'?", current.Text())
ret := walk.MsgBox(context.mw, "删除hosts", message, walk.MsgBoxYesNo)
if ret == win.IDYES {
if !conf.Config.HostConfigModel.Remove(current) {
common.Error("Fail to remove current item: %v", current.Text())
// TODO notify user
return
}
if context.treeView.Model().RootCount() > 0 {
context.treeView.SetCurrentItem(context.treeView.Model().RootAt(0))
}
file := "conf/hosts/" + current.Text() + ".hosts"
//.........这里部分代码省略.........
示例13: main
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())
},
},
示例14: main
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()
}