本文整理汇总了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)
}
开发者ID:starmoonlove,项目名称:packutil,代码行数:82,代码来源:projectview.go
示例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{
//.........这里部分代码省略.........
开发者ID:Fruchtgummi,项目名称:walk,代码行数:101,代码来源:databinding.go
示例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()
//.........这里部分代码省略.........
开发者ID:starmoonlove,项目名称:packutil,代码行数:101,代码来源:versionview.go
示例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
})
}
开发者ID:JSchwehn,项目名称:walk,代码行数:83,代码来源:dialog.go
示例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"
//.........这里部分代码省略.........
开发者ID:tinycedar,项目名称:lily,代码行数:101,代码来源:toolbar.go
注:本文中的github.com/lxn/walk.Dialog类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论