當前位置: 首頁>>代碼示例>>Golang>>正文


Golang DataBinder.Submit方法代碼示例

本文整理匯總了Golang中github.com/lxn/walk.DataBinder.Submit方法的典型用法代碼示例。如果您正苦於以下問題:Golang DataBinder.Submit方法的具體用法?Golang DataBinder.Submit怎麽用?Golang DataBinder.Submit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/lxn/walk.DataBinder的用法示例。


在下文中一共展示了DataBinder.Submit方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: Build

func (db *DialogBuilder) Build() error {
	var dataBinder *walk.DataBinder
	var errorPresenter walk.ErrorPresenter
	var acceptPB, cancelPB *walk.PushButton

	onAcceptClicked := func() {
		if err := dataBinder.Submit(); err != nil {
			log.Fatal(err)
		}

		db.Dialog.Accept()
	}

	return Dialog{
		AssignTo:      db.Dialog,
		Title:         db.Title,
		DefaultButton: &acceptPB,
		CancelButton:  &cancelPB,
		MinSize:       db.MinSize,
		Size:          db.Size,
		DataBinder: DataBinder{
			AssignTo:       &dataBinder,
			DataSource:     db.DataSource,
			ErrorPresenter: ErrorPresenterRef{&errorPresenter},
		},
		Layout: VBox{},
		Children: []Widget{
			Composite{
				Layout:   Grid{},
				Children: db.Widgets,
			},
			Composite{
				Layout: VBox{Margins: Margins{9, 0, 9, 0}},
				Children: []Widget{
					LineErrorPresenter{AssignTo: &errorPresenter},
				},
			},
			Composite{
				Layout: HBox{},
				Children: []Widget{
					HSpacer{},
					PushButton{AssignTo: &acceptPB, Text: "OK", OnClicked: onAcceptClicked},
					PushButton{AssignTo: &cancelPB, Text: "Cancel", OnClicked: func() { db.Dialog.Cancel() }},
				},
			},
		},
	}.Create(db.Owner)
}
開發者ID:Robin3D,項目名稱:walk,代碼行數:48,代碼來源:declarative.go

示例3: Run


//.........這裏部分代碼省略.........
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "*間隔基準:",
									},
									ComboBox{
										Value:         Bind("BaseSleeptime", SelRequired{}),
										BindingMember: "Uint",
										DisplayMember: "Key",
										Model:         GUIOpt.SleepTime,
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "*隨機延遲:",
									},
									ComboBox{
										Value:         Bind("RandomSleepPeriod", SelRequired{}),
										BindingMember: "Uint",
										DisplayMember: "Key",
										Model:         GUIOpt.SleepTime,
									},
								},
							},

							RadioButtonGroupBox{
								ColumnSpan: 2,
								Title:      "*輸出方式",
								Layout:     HBox{},
								DataMember: "OutType",
								Buttons: []RadioButton{
									{Text: GUIOpt.OutType[0].Key, Value: GUIOpt.OutType[0].String},
									{Text: GUIOpt.OutType[1].Key, Value: GUIOpt.OutType[1].String},
									{Text: GUIOpt.OutType[2].Key, Value: GUIOpt.OutType[2].String},
								},
							},
						},
					},
				},
			},

			Composite{
				Layout: HBox{},
				Children: []Widget{

					// 必填項錯誤檢查
					LineErrorPresenter{
						AssignTo:   &ep,
						ColumnSpan: 2,
					},

					PushButton{
						Text:     "開始抓取",
						AssignTo: &toggleSpecialModePB,
						OnClicked: func() {
							if toggleSpecialModePB.Text() == "取消" {
								toggleSpecialModePB.SetEnabled(false)
								toggleSpecialModePB.SetText("取消中…")
								Stop()
							} else {
								if err := db.Submit(); err != nil {
									log.Print(err)
									return
								}
								Input.Spiders = spiderMenu.GetChecked()
								if len(Input.Spiders) == 0 {
									return
								}
								toggleSpecialModePB.SetText("取消")
								Start()
							}
						},
					},
				},
			},
		},
	}.Create()); err != nil {
		log.Fatal(err)
	}

	// 綁定log輸出界麵
	lv, err := NewLogView(mw)
	if err != nil {
		log.Fatal(err)
	}
	log.SetOutput(lv)

	if icon, err := walk.NewIconFromResource("ICON"); err == nil {
		mw.SetIcon(icon)
	}

	// 運行窗體程序
	mw.Run()
}
開發者ID:zydudu,項目名稱:pholcus,代碼行數:101,代碼來源:guimain.go

示例4: 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)
}
開發者ID:Fruchtgummi,項目名稱:walk,代碼行數:101,代碼來源:databinding.go

示例5: 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

示例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()
}
開發者ID:CodyGuo,項目名稱:Go-Cody,代碼行數:98,代碼來源:main.go

示例7: StartMF


//.........這裏部分代碼省略.........
								DisplayMember: "Name",
								Model:         modelp.ShowTestIndus(),
							},
							Label{
								Text: "經營範圍:",
							},
							LineEdit{
								Text: Bind("OrgBusScope"),
							},
						},
					},
					Composite{
						Layout: HBox{},
						Children: []Widget{
							Label{
								Text: "稅收收入大於:",
							},
							NumberEdit{
								Value:    Bind("StatTaxSumStart", Range{0.00, 99999999999999999.99}),
								Prefix:   "¥ ",
								Decimals: 2,
							},
							Label{
								Text: "稅收收入小於:",
							},
							NumberEdit{
								Value:    Bind("StatTaxSumEnd", Range{0.00, 99999999999999999.99}),
								Prefix:   "¥ ",
								Decimals: 2,
							},
						},
					},
					Composite{
						Layout: HBox{},
						Children: []Widget{
							CheckBox{
								Checked: Bind("IsImportant"),
							},
							Label{
								Text: "是否是重點稅源企業",
							},
							CheckBox{
								Checked: Bind("OrgIsExport"),
							},
							Label{
								Text: "是否是出口企業",
							},
							PushButton{
								Text: "抽查數據",
								OnClicked: func() {
									// 提交數據到綁定器
									if err := binder.Submit(); err != nil {
										log.Print(err)
										return
									}
									// 執行查詢並更新列表
									fmt.Println("Params:", param)
									model.RestRows(queryData(param))
								},
							},
							PushButton{
								Text: "導入數據",
								OnClicked: func() {
									mw.openFileAction()
								},
							},
							PushButton{
								Text: "刷新數據",
								OnClicked: func() {
									// 刷新行業列表
									getCombs()
									// 清空參數
									err := binder.Reset()
									if err != nil {
										fmt.Println(err)
									}
									// 刷新數據
									model.RestRows(defaDisplayData())
								},
							},
							PushButton{
								Text: "清空數據",
								OnClicked: func() {
									// 清空數據然後查詢展示空列表
									truncateData(vatTable)
									model.RestRows(defaDisplayData())
									walk.MsgBox(mw, "成功", "清空成功", walk.MsgBoxIconInformation)
								},
							},
						},
					},
				},
			},
		},
		// 這裏直接Run,否則碰到了莫名奇妙的二次才能響應的問題
	}.Run()); err != nil {
		fmt.Println(err)
	}
	// mw.MainWindow.Run()
}
開發者ID:LaughingVzr,項目名稱:taxrecrd,代碼行數:101,代碼來源:mainfrm.go


注:本文中的github.com/lxn/walk.DataBinder.Submit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。