本文整理匯總了Golang中github.com/lxn/walk.Dialog類的典型用法代碼示例。如果您正苦於以下問題:Golang Dialog類的具體用法?Golang Dialog怎麽用?Golang Dialog使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Dialog類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: RunAnimalDialog
func RunAnimalDialog(owner walk.Form, animal *Animal) (int, error) {
var dlg *walk.Dialog
var db *walk.DataBinder
var ep walk.ErrorPresenter
var acceptPB, cancelPB *walk.PushButton
return Dialog{
AssignTo: &dlg,
Title: "Animal Details",
DefaultButton: &acceptPB,
CancelButton: &cancelPB,
DataBinder: DataBinder{
AssignTo: &db,
DataSource: animal,
ErrorPresenter: ErrorPresenterRef{&ep},
},
MinSize: Size{300, 300},
Layout: VBox{},
Children: []Widget{
Composite{
Layout: Grid{Columns: 2},
Children: []Widget{
Label{
Text: "Name:",
},
LineEdit{
Text: Bind("Name"),
},
Label{
Text: "Arrival Date:",
},
DateEdit{
Date: Bind("ArrivalDate"),
},
Label{
Text: "Species:",
},
ComboBox{
Value: Bind("SpeciesId", SelRequired{}),
BindingMember: "Id",
DisplayMember: "Name",
Model: KnownSpecies(),
},
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{
//.........這裏部分代碼省略.........
示例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()
//.........這裏部分代碼省略.........
示例4: Create
func (d Dialog) Create(owner walk.Form) error {
var w *walk.Dialog
var err error
if d.FixedSize {
w, err = walk.NewDialogWithFixedSize(owner)
} else {
w, err = walk.NewDialog(owner)
}
if err != nil {
return err
}
tlwi := topLevelWindowInfo{
Name: d.Name,
Font: d.Font,
ToolTipText: "",
MinSize: d.MinSize,
MaxSize: d.MaxSize,
ContextMenuItems: d.ContextMenuItems,
DataBinder: d.DataBinder,
Layout: d.Layout,
Children: d.Children,
OnKeyDown: d.OnKeyDown,
OnKeyPress: d.OnKeyPress,
OnKeyUp: d.OnKeyUp,
OnMouseDown: d.OnMouseDown,
OnMouseMove: d.OnMouseMove,
OnMouseUp: d.OnMouseUp,
OnSizeChanged: d.OnSizeChanged,
}
var db *walk.DataBinder
if d.DataBinder.AssignTo == nil {
d.DataBinder.AssignTo = &db
}
builder := NewBuilder(nil)
w.SetSuspended(true)
builder.Defer(func() error {
w.SetSuspended(false)
return nil
})
return builder.InitWidget(tlwi, w, func() error {
if err := w.SetTitle(d.Title); err != nil {
return err
}
if err := w.SetSize(d.Size.toW()); err != nil {
return err
}
if d.DefaultButton != nil {
if err := w.SetDefaultButton(*d.DefaultButton); err != nil {
return err
}
if db := *d.DataBinder.AssignTo; db != nil {
if db.DataSource() != nil {
(*d.DefaultButton).SetEnabled(db.CanSubmit())
}
db.CanSubmitChanged().Attach(func() {
(*d.DefaultButton).SetEnabled(db.CanSubmit())
})
}
}
if d.CancelButton != nil {
if err := w.SetCancelButton(*d.CancelButton); err != nil {
return err
}
}
if d.AssignTo != nil {
*d.AssignTo = w
}
return nil
})
}
示例5: 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"
//.........這裏部分代碼省略.........