本文整理匯總了Golang中github.com/lxn/walk.LineEdit.SetText方法的典型用法代碼示例。如果您正苦於以下問題:Golang LineEdit.SetText方法的具體用法?Golang LineEdit.SetText怎麽用?Golang LineEdit.SetText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/lxn/walk.LineEdit
的用法示例。
在下文中一共展示了LineEdit.SetText方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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()
}
示例2: 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()
}
示例3: CreateVersion_Triggered
/**
*添加版本的方法
*/
func CreateVersion_Triggered(owner walk.Form, model *xorm.VersionModel) {
var dlg *walk.Dialog
var db *walk.DataBinder
var dph *walk.LineEdit
var ep walk.ErrorPresenter
var version = new(xorm.Version)
var acceptPB, cancelPB *walk.PushButton
var dialog = Dialog{}
dialog.AssignTo = &dlg
dialog.Title = "創建版本"
dialog.DataBinder = DataBinder{
AssignTo: &db,
DataSource: version,
ErrorPresenter: ErrorPresenterRef{&ep},
}
dialog.MinSize = Size{300, 200}
dialog.Layout = VBox{}
dialog.DefaultButton = &acceptPB
dialog.CancelButton = &cancelPB
dirPath := LineEdit{
AssignTo: &dph,
Text: Bind("Path"),
ReadOnly: true,
}
childrens := []Widget{
Composite{
Layout: Grid{Columns: 5},
Children: []Widget{
Label{
Text: "工程:",
MinSize: Size{42, 0},
},
ComboBox{
MinSize: Size{108, 0},
Value: Bind("ProjectName", SelRequired{}),
BindingMember: "Key",
DisplayMember: "Name",
Model: xorm.FindAllProjDataCombox(),
},
dirPath,
PushButton{
Text: "選擇版本",
OnClicked: func() {
filDlg := new(walk.FileDialog)
filDlg.ShowBrowseFolder(owner)
dph.SetText(filDlg.FilePath)
},
},
},
},
Composite{
Layout: Grid{Columns: 2},
Children: []Widget{
Label{
Text: "名稱:",
},
LineEdit{
Text: Bind("Name"),
MaxLength: 10,
},
Label{
Text: "創建者:",
},
LineEdit{
Text: Bind("CreateUser"),
MaxLength: 10,
},
Label{
Text: "描述:",
},
TextEdit{
Text: Bind("Desc"),
MinSize: Size{300, 50},
},
LineErrorPresenter{
AssignTo: &ep,
ColumnSpan: 2,
},
},
},
Composite{
Layout: HBox{},
Children: []Widget{
HSpacer{},
PushButton{
AssignTo: &acceptPB,
Text: "保存",
OnClicked: func() {
if err := db.Submit(); err != nil {
log.Print(err)
return
}
xorm.SaveVersionByParam(version.Name, version.CreateUser, version.Desc)
model.ResetRows()
dlg.Accept()
//.........這裏部分代碼省略.........