本文整理匯總了Golang中github.com/lxn/walk.PushButton.SetText方法的典型用法代碼示例。如果您正苦於以下問題:Golang PushButton.SetText方法的具體用法?Golang PushButton.SetText怎麽用?Golang PushButton.SetText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/lxn/walk.PushButton
的用法示例。
在下文中一共展示了PushButton.SetText方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
// Main entry and GUI construction
func main() {
LANG = queryRegLayoutId(LANG_ID)
var (
mw *walk.MainWindow
currentLayout = getKeyboardLayout() // Get current system layout.
layoutPresent = checkLanguage() // Check if installed language is present and can be loaded.
triggered = true
infoText string
ldtMain *walk.LineEdit
btnMain *walk.PushButton
)
if layoutPresent {
infoText = INFO_TEXT
} else {
infoText = "The layout does not seem to be present on your system. Please install it first."
}
MainWindow{
AssignTo: &mw,
Title: "kasahorow " + LANG_STRING + " Writer",
MaxSize: Size{600, 200},
MinSize: Size{600, 200},
Layout: VBox{},
Children: []Widget{
MultilineLabel{Text: infoText},
LineEdit{AssignTo: &ldtMain},
PushButton{
AssignTo: &btnMain,
Enabled: layoutPresent,
Text: "Switch back to default layout.",
OnClicked: func() {
if triggered {
triggered = false
activateKeyboardLayout(currentLayout, KFL_SETFORPROCESS)
btnMain.SetText("Switch to " + LANG_STRING + ".")
} else {
triggered = true
loadLanguage()
btnMain.SetText("Switch back to default layout.")
}
},
},
},
}.Create()
if layoutPresent {
mw.Synchronize(loadLanguage) // Load new layout in main GUI thread.
}
ic, _ := walk.NewIconFromResource("kasahorow")
mw.SetIcon(ic)
mw.Run()
}
示例2: 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()
}
示例3: main
//.........這裏部分代碼省略.........
}, MaxSize: Size{0, 20},
},
HSplitter{
AssignTo: &lusr,
Children: []Widget{
Label{Text: "路由用戶名", MaxSize: Size{60, 20}},
LineEdit{Text: Bind("RouterUser"), AssignTo: &rusr, MaxSize: Size{0, 20}},
}, MaxSize: Size{0, 20},
},
HSplitter{
AssignTo: &lpwd,
Children: []Widget{
Label{Text: "路由密碼", MaxSize: Size{60, 20}},
LineEdit{Text: Bind("RouterPwd"), AssignTo: &rpwd, MaxSize: Size{0, 20}, PasswordMode: true,
OnMouseDown: func(x, y int, button walk.MouseButton) {
rpwd.SetPasswordMode(false)
},
OnMouseUp: func(x, y int, button walk.MouseButton) {
rpwd.SetPasswordMode(true)
},
},
}, MaxSize: Size{0, 20},
},
HSplitter{
Children: []Widget{
PushButton{
AssignTo: &lb,
Text: "開始連接",
OnClicked: func() {
if mode.Text() == "10.0.x.x(手動填寫)" {
walk.MsgBox(mw, "請填寫IP", "手動填寫需要自己獲取IP 你可在路由器中自己查找 本地撥號請用local", walk.MsgBoxOK)
return
}
lb.SetText("連接中...")
lb.SetEnabled(false)
rb.SetEnabled(false)
go func() {
d := netdialer.NewDialer(usr.Text(), pwd.Text())
d.UserIP = selectMode(mode.Text())
if d.UserIP == "" {
walk.MsgBox(mw, "連接失敗", "請檢查設置", walk.MsgBoxOK)
d = nil
return
}
d.ConnectDirect()
mw.SetTitle(TITLE + " [" + d.UserIP + "]")
d = nil
lb.SetEnabled(true)
rb.SetEnabled(true)
lb.SetText("開始連接")
if err == nil {
walk.MsgBox(mw, "連接成功", "感謝使用", walk.MsgBoxOK)
util.INFO.Log("連接成功: 感謝使用")
} else {
walk.MsgBox(mw, "連接失敗", err.Error(), walk.MsgBoxOK)
util.INFO.Log("連接失敗: ", err.Error())
}
}()
},
},
PushButton{
AssignTo: &rb,
Text: "斷開連接",
OnClicked: func() {
if mode.Text() == "10.0.x.x(手動填寫)" {
walk.MsgBox(mw, "請填寫IP", "手動填寫需要自己獲取IP 你可在路由器中自己查找", walk.MsgBoxOK)
示例4: 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()
}
示例5: main
//.........這裏部分代碼省略.........
OnTriggered: mw.showAboutBoxAction_Triggered,
},
},
},
},
ToolBarItems: []MenuItem{
ActionRef{&openAction},
Menu{
Text: "New A",
Image: "../img/document-new.png",
Items: []MenuItem{
Action{
Text: "A",
OnTriggered: mw.newAction_Triggered,
},
Action{
Text: "B",
OnTriggered: mw.newAction_Triggered,
},
Action{
Text: "C",
OnTriggered: mw.newAction_Triggered,
},
},
OnTriggered: mw.newAction_Triggered,
},
Separator{},
Menu{
Text: "View",
Image: "../img/document-properties.png",
Items: []MenuItem{
Action{
Text: "X",
OnTriggered: mw.changeViewAction_Triggered,
},
Action{
Text: "Y",
OnTriggered: mw.changeViewAction_Triggered,
},
Action{
Text: "Z",
OnTriggered: mw.changeViewAction_Triggered,
},
},
},
Separator{},
Action{
Text: "Special",
Image: "../img/system-shutdown.png",
Enabled: Bind("isSpecialMode && enabledCB.Checked"),
OnTriggered: mw.specialAction_Triggered,
},
},
ContextMenuItems: []MenuItem{
ActionRef{&showAboutBoxAction},
},
MinSize: Size{300, 200},
Layout: VBox{},
Children: []Widget{
CheckBox{
Name: "enabledCB",
Text: "Open / Special Enabled",
Checked: true,
},
CheckBox{
Name: "openVisibleCB",
Text: "Open Visible",
Checked: true,
},
PushButton{
AssignTo: &toggleSpecialModePB,
Text: "Enable Special Mode",
OnClicked: func() {
isSpecialMode.SetSatisfied(!isSpecialMode.Satisfied())
if isSpecialMode.Satisfied() {
toggleSpecialModePB.SetText("Disable Special Mode")
} else {
toggleSpecialModePB.SetText("Enable Special Mode")
}
},
},
},
}.Create()); err != nil {
log.Fatal(err)
}
addRecentFileActions := func(texts ...string) {
for _, text := range texts {
a := walk.NewAction()
a.SetText(text)
a.Triggered().Attach(mw.openAction_Triggered)
recentMenu.Actions().Add(a)
}
}
addRecentFileActions("Foo", "Bar", "Baz")
mw.Run()
}
示例6: 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()
}