当前位置: 首页>>代码示例>>Golang>>正文


Golang DataBinder.SetAutoSubmit方法代码示例

本文整理汇总了Golang中github.com/lxn/walk.DataBinder.SetAutoSubmit方法的典型用法代码示例。如果您正苦于以下问题:Golang DataBinder.SetAutoSubmit方法的具体用法?Golang DataBinder.SetAutoSubmit怎么用?Golang DataBinder.SetAutoSubmit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/lxn/walk.DataBinder的用法示例。


在下文中一共展示了DataBinder.SetAutoSubmit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: NewElangGui

func NewElangGui() (this *ElangGui, err error) {
	this = &ElangGui{Data: &ElangGuiData{"我学会了新的姿势", "厘侥氏阻仟议徊米", Mode1}}
	var db *walk.DataBinder
	update := func() {
		src := this.mSrc.Text()
		switch this.Data.Mode {
		case Mode1:
			src = zhconv.EncodeString(src)
			src = elang.EncodeString(src)
			src = zhconv.EncodeString(src)
		case Mode2:
			src = zhconv.DecodeString(src)
			src = elang.DecodeString(src)
			src = zhconv.EncodeString(src)
		}
		this.mTar.SetText(src)
	}
	wmodel := MainWindow{
		AssignTo: &this.mw,
		Title:    "鹅语",
		MinSize:  Size{512, 450},
		Layout:   VBox{},
		DataBinder: DataBinder{
			AssignTo:   &db,
			DataSource: this.Data,
		},
		Children: []Widget{
			TextEdit{
				Text:     Bind("Src"),
				AssignTo: &this.mSrc,
			},
			RadioButtonGroupBox{
				Title:      "模式",
				AssignTo:   &this.mMode,
				Layout:     HBox{},
				DataMember: "Mode",
				Buttons: []RadioButton{
					{Text: "模式一", Value: Mode1, OnClicked: update},
					{Text: "模式二", Value: Mode2, OnClicked: update},
				},
			},
			TextEdit{
				Text:     Bind("Dst"),
				AssignTo: &this.mTar,
			},
		},
	}
	if err = wmodel.Create(); err != nil {
		walk.MsgBox(nil, "错误", "创建窗口失败", walk.MsgBoxOK|walk.MsgBoxIconError)
		return
	}
	if icon, err2 := walk.NewIconFromResource("ICON_MAIN"); err2 == nil {
		this.mw.SetIcon(icon)
	}
	this.mSrc.TextChanged().Attach(update)
	db.SetAutoSubmit(true)
	return
}
开发者ID:pa001024,项目名称:elang,代码行数:58,代码来源:elang-gui.go

示例2: main

func main() {
	fout, _ := os.Create("dialer.log")
	defer fout.Close()
	bo := bufio.NewWriter(fout)
	defer bo.Flush()
	util.INFO.SetOutput(bo)
	util.ERROR.SetOutput(bo)

	bin, err := ioutil.ReadFile("config.json")
	if err == nil {
		json.Unmarshal(bin, config)
	} else {
		util.ERROR.Log(err)
		err = nil
	}

	var usr, pwd *walk.LineEdit
	var raddr, rusr, rpwd *walk.LineEdit
	var lb, rb *walk.PushButton
	var mode *walk.ComboBox
	var mw *walk.MainWindow
	var db *walk.DataBinder
	var laddr, lusr, lpwd *walk.Splitter
	go func() {
		for mw == nil {
			runtime.Gosched()
		}
		ic, err := walk.NewIconFromResourceId(6)
		if err == nil {
			// func onLoad() {
			db.SetAutoSubmit(true)
			mw.SetIcon(ic)
			switch config.RouterType {
			case "hiwifi":
				laddr.SetVisible(true)
				lusr.SetVisible(false)
				lpwd.SetVisible(true)
			case "openwrt":
				laddr.SetVisible(true)
				lusr.SetVisible(true)
				lpwd.SetVisible(true)
			case "asus":
				laddr.SetVisible(true)
				lusr.SetVisible(true)
				lpwd.SetVisible(true)
			default:
				laddr.SetVisible(false)
				lusr.SetVisible(false)
				lpwd.SetVisible(false)
			}
			mw.SetSize(walk.Size{0, 0})
			// }
		}
	}()
	MainWindow{
		AssignTo: &mw,
		Title:    TITLE,
		MinSize:  Size{340, 0},
		Layout:   VBox{},
		DataBinder: DataBinder{
			AssignTo:   &db,
			DataSource: config,
		},
		Children: []Widget{
			HSplitter{
				Children: []Widget{
					Label{Text: "用户名", MaxSize: Size{60, 20}},
					LineEdit{Text: Bind("Username"), AssignTo: &usr, MaxSize: Size{0, 20}},
				}, MaxSize: Size{0, 20},
			},
			HSplitter{
				Children: []Widget{
					Label{Text: "密码", MaxSize: Size{60, 20}},
					LineEdit{Text: Bind("Password"), AssignTo: &pwd, MaxSize: Size{0, 20}, PasswordMode: true,
						OnMouseDown: func(x, y int, button walk.MouseButton) {
							pwd.SetPasswordMode(false)
						},
						OnMouseUp: func(x, y int, button walk.MouseButton) {
							pwd.SetPasswordMode(true)
						},
					},
				}, MaxSize: Size{0, 20},
			},
			HSplitter{
				Children: []Widget{
					Label{Text: "模式", MaxSize: Size{60, 20}},
					ComboBox{AssignTo: &mode,
						Editable: true, Value: Bind("RouterType"),
						Model:   []string{"local", "10.0.x.x(手动填写)", "openwrt", "hiwifi", "asus"},
						MaxSize: Size{0, 20},
						OnCurrentIndexChanged: func() {
							switch mode.CurrentIndex() {
							case 2: //"openwrt":
								laddr.SetVisible(true)
								lusr.SetVisible(true)
								lpwd.SetVisible(true)
							case 3: //"hiwifi":
								config.RouterAddr = "192.168.199.1"
								laddr.SetVisible(true)
								lusr.SetVisible(false)
//.........这里部分代码省略.........
开发者ID:pa001024,项目名称:netdialer,代码行数:101,代码来源:gui.go


注:本文中的github.com/lxn/walk.DataBinder.SetAutoSubmit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。