本文整理汇总了Golang中github.com/lxn/walk.Dialog.Accept方法的典型用法代码示例。如果您正苦于以下问题:Golang Dialog.Accept方法的具体用法?Golang Dialog.Accept怎么用?Golang Dialog.Accept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/lxn/walk.Dialog
的用法示例。
在下文中一共展示了Dialog.Accept方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: CreateProj_Triggered
/**
*添加项目的方法
*/
func CreateProj_Triggered(owner walk.Form, model *xorm.ProjectModel) {
var dlg *walk.Dialog
var db *walk.DataBinder
var ep walk.ErrorPresenter
var project = new(xorm.Project)
var acceptPB, cancelPB *walk.PushButton
var dialog = Dialog{}
dialog.AssignTo = &dlg
dialog.Title = "创建工程"
dialog.DataBinder = DataBinder{
AssignTo: &db,
DataSource: project,
ErrorPresenter: ErrorPresenterRef{&ep},
}
dialog.MinSize = Size{300, 200}
dialog.Layout = VBox{}
dialog.DefaultButton = &acceptPB
dialog.CancelButton = &cancelPB
childrens := []Widget{
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.SaveProjectObject(*project)
model.ResetRows()
dlg.Accept()
},
},
PushButton{
AssignTo: &cancelPB,
Text: "取消",
OnClicked: func() { dlg.Cancel() },
},
},
},
}
dialog.Children = childrens
dialog.Run(owner)
}
示例2: 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()
//.........这里部分代码省略.........
示例3: RunAnimalDialog
//.........这里部分代码省略.........
Label{
Text: "Speed:",
},
Slider{
Value: Bind("Speed"),
},
RadioButtonGroupBox{
ColumnSpan: 2,
Title: "Sex",
Layout: HBox{},
DataMember: "Sex",
Buttons: []RadioButton{
{Text: "Male", Value: SexMale},
{Text: "Female", Value: SexFemale},
{Text: "Hermaphrodite", Value: SexHermaphrodite},
},
},
Label{
Text: "Weight:",
},
NumberEdit{
Value: Bind("Weight", Range{0.01, 9999.99}),
Suffix: " kg",
Decimals: 2,
},
Label{
Text: "Preferred Food:",
},
ComboBox{
Editable: true,
Value: Bind("PreferredFood"),
Model: []string{"Fruit", "Grass", "Fish", "Meat"},
},
Label{
Text: "Domesticated:",
},
CheckBox{
Checked: Bind("Domesticated"),
},
VSpacer{
ColumnSpan: 2,
Size: 8,
},
Label{
ColumnSpan: 2,
Text: "Remarks:",
},
TextEdit{
ColumnSpan: 2,
MinSize: Size{100, 50},
Text: Bind("Remarks"),
},
Label{
ColumnSpan: 2,
Text: "Patience:",
},
LineEdit{
ColumnSpan: 2,
Text: Bind("PatienceField"),
},
LineErrorPresenter{
AssignTo: &ep,
ColumnSpan: 2,
},
},
},
Composite{
Layout: HBox{},
Children: []Widget{
HSpacer{},
PushButton{
AssignTo: &acceptPB,
Text: "OK",
OnClicked: func() {
if err := db.Submit(); err != nil {
log.Print(err)
return
}
dlg.Accept()
},
},
PushButton{
AssignTo: &cancelPB,
Text: "Cancel",
OnClicked: func() { dlg.Cancel() },
},
},
},
},
}.Run(owner)
}
示例4: 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"
//.........这里部分代码省略.........