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


Golang walk.DataBinder类代码示例

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


在下文中一共展示了DataBinder类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

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

示例4: Run

func Run() {
	var mw *walk.MainWindow
	var db *walk.DataBinder
	var ep walk.ErrorPresenter
	var spiderMenu = NewSpiderMenu(spider.Menu)

	if err := (MainWindow{
		AssignTo: &mw,
		DataBinder: DataBinder{
			AssignTo:       &db,
			DataSource:     Input,
			ErrorPresenter: ErrorPresenterRef{&ep},
		},
		Title:   config.APP_NAME,
		MinSize: Size{1100, 700},
		Layout:  VBox{},
		Children: []Widget{
			// 任务列表
			HSplitter{
				Children: []Widget{
					TableView{
						MinSize:               Size{550, 400},
						AlternatingRowBGColor: walk.RGB(255, 255, 224),
						CheckBoxes:            true,
						ColumnsOrderable:      true,
						Columns: []TableViewColumn{
							{Title: "#", Width: 45},
							{Title: "任务", Width: 110 /*, Format: "%.2f", Alignment: AlignFar*/},
							{Title: "描述", Width: 370},
						},
						Model: spiderMenu,
					},
					// 关键词
					VSplitter{
						MinSize: Size{550, 400},

						Children: []Widget{
							VSplitter{
								Children: []Widget{
									Label{
										Text: "关键词:(多任务之间以 | 隔开,选填)",
									},
									LineEdit{
										Text: Bind("Keywords"),
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "采集页数:(选填)",
									},
									NumberEdit{
										Value:    Bind("MaxPage"),
										Suffix:   "",
										Decimals: 0,
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "*并发协程:(1~99999)",
									},
									NumberEdit{
										Value:    Bind("ThreadNum", Range{1, 99999}),
										Suffix:   "",
										Decimals: 0,
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "*分批输出大小:(1~5,000,000 条数据)",
									},
									NumberEdit{
										Value:    Bind("DockerCap", Range{1, 5000000}),
										Suffix:   "",
										Decimals: 0,
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "*间隔基准:",
									},
									ComboBox{
										Value:         Bind("BaseSleeptime", SelRequired{}),
										BindingMember: "Uint",
										DisplayMember: "Key",
										Model:         GUIOpt.SleepTime,
									},
								},
							},
//.........这里部分代码省略.........
开发者ID:zydudu,项目名称:pholcus,代码行数:101,代码来源:guimain.go

示例5: InitWidget

func (b *Builder) InitWidget(d Widget, w walk.Widget, customInit func() error) error {
	b.level++
	defer func() {
		b.level--
	}()

	var succeeded bool
	defer func() {
		if !succeeded {
			w.Dispose()
		}
	}()

	b.declWidgets = append(b.declWidgets, declWidget{d, w})

	// Widget
	name, _, _, font, toolTipText, minSize, maxSize, stretchFactor, row, rowSpan, column, columnSpan, contextMenuActions, onKeyDown, onMouseDown, onMouseMove, onMouseUp, onSizeChanged := d.WidgetInfo()

	w.SetName(name)

	if name != "" {
		b.name2Widget[name] = w
	}

	if toolTipText != "" {
		if err := w.SetToolTipText(toolTipText); err != nil {
			return err
		}
	}

	if err := w.SetMinMaxSize(minSize.toW(), maxSize.toW()); err != nil {
		return err
	}

	if len(contextMenuActions) > 0 {
		cm, err := walk.NewMenu()
		if err != nil {
			return err
		}
		if err := addToActionList(cm.Actions(), contextMenuActions); err != nil {
			return err
		}
		w.SetContextMenu(cm)
	}

	if onKeyDown != nil {
		w.KeyDown().Attach(onKeyDown)
	}

	if onMouseDown != nil {
		w.MouseDown().Attach(onMouseDown)
	}

	if onMouseMove != nil {
		w.MouseMove().Attach(onMouseMove)
	}

	if onMouseUp != nil {
		w.MouseUp().Attach(onMouseUp)
	}

	if onSizeChanged != nil {
		w.SizeChanged().Attach(onSizeChanged)
	}

	if p := w.Parent(); p != nil {
		switch l := p.Layout().(type) {
		case *walk.BoxLayout:
			if stretchFactor < 1 {
				stretchFactor = 1
			}
			if err := l.SetStretchFactor(w, stretchFactor); err != nil {
				return err
			}

		case *walk.GridLayout:
			cs := columnSpan
			if cs < 1 {
				cs = 1
			}
			rs := rowSpan
			if rs < 1 {
				rs = 1
			}
			r := walk.Rectangle{column, row, cs, rs}

			if err := l.SetRange(w, r); err != nil {
				return err
			}
		}
	}

	oldParent := b.parent

	// Container
	var db *walk.DataBinder
	if dc, ok := d.(Container); ok {
		if wc, ok := w.(walk.Container); ok {
			dataBinder, layout, children := dc.ContainerInfo()

//.........这里部分代码省略.........
开发者ID:Robin3D,项目名称:walk,代码行数:101,代码来源:builder.go

示例6: InitWidget


//.........这里部分代码省略.........
				l.SetRowStretchFactor(row, rsf)

				if rowSpan < 1 {
					rowSpan = 1
				}
				if columnSpan < 1 {
					columnSpan = 1
				}

				if b.columns > 0 && row == 0 && column == 0 {
					if b.col+columnSpan > b.columns {
						b.row++
						b.col = 0
					}

					row = b.row
					column = b.col

					b.col += columnSpan
				}

				r := walk.Rectangle{column, row, columnSpan, rowSpan}

				if err := l.SetRange(widget, r); err != nil {
					return err
				}
			}
		}
	}

	oldParent := b.parent

	// Container
	var db *walk.DataBinder
	if dc, ok := d.(Container); ok {
		if wc, ok := w.(walk.Container); ok {
			dataBinder, layout, children := dc.ContainerInfo()

			if layout != nil {
				l, err := layout.Create()
				if err != nil {
					return err
				}

				if err := wc.SetLayout(l); err != nil {
					return err
				}
			}

			b.parent = wc
			defer func() {
				b.parent = oldParent
			}()

			if g, ok := layout.(Grid); ok {
				columns := b.columns
				defer func() {
					b.columns, b.row, b.col = columns, row, column+columnSpan
				}()

				b.columns = g.Columns
				b.row = 0
				b.col = 0
			}

			for _, child := range children {
开发者ID:linhua55,项目名称:walk,代码行数:67,代码来源:builder.go

示例7: Create

func (d Dialog) Create(owner walk.Form) error {
	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 {
				(*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:2105666566,项目名称:walk,代码行数:73,代码来源:dialog.go

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

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

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

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

示例12: StartMF

/*初始化主窗口*/
func StartMF() {

	// var mainFrame *walk.MainWindow
	mw := new(TaxMainWindow)
	// 空集合
	var taxs []*modelp.TaxRecordRef
	// 如果库里有数据会优先展示库里的数据
	taxs = defaDisplayData()
	model = NewTaxRecModel(taxs)

	// 筛选参数绑定对象
	var binder *walk.DataBinder
	param := new(StatFilter)
	// 主菜单
	// var mainMenu *walk.Menu
	if _, err := (MainWindow{
		AssignTo: &mw.MainWindow,
		Title:    TITLE,
		MinSize:  Size{800, 600}, // 最小大小
		Layout:   VBox{},
		DataBinder: DataBinder{
			AssignTo:   &binder,
			DataSource: param,
		},
		Children: []Widget{
			// 表格部分
			TableView{
				Columns: []TableViewColumn{
					{Title: "序号"},
					{Title: "纳税人名称"},
					{Title: "纳税人识别号"},
					{Title: "行业"},
					{Title: "经营范围"},
					{Title: "法定代表人"},
					{Title: "开业日期", Format: "2006-01-02"},
					{Title: "生产经营地址"},
					{Title: "注册资本", Format: "%.2f", Alignment: AlignFar},
					{Title: "主管税务机关"},
					{Title: "是否出口企业"},
					{Title: "第一年应税收入", Format: "%.2f", Alignment: AlignFar},
					{Title: "第一年出口收入", Format: "%.2f", Alignment: AlignFar},
					{Title: "第一年增值税", Format: "%.2f", Alignment: AlignFar},
					{Title: "第一年所得税", Format: "%.2f", Alignment: AlignFar},
					{Title: "第一年税额合计", Format: "%.2f", Alignment: AlignFar},
					{Title: "第二年应税收入", Format: "%.2f", Alignment: AlignFar},
					{Title: "第二年出口收入", Format: "%.2f", Alignment: AlignFar},
					{Title: "第二年增值税", Format: "%.2f", Alignment: AlignFar},
					{Title: "第二年所得税", Format: "%.2f", Alignment: AlignFar},
					{Title: "第二年税额合计", Format: "%.2f", Alignment: AlignFar},
					{Title: "第三年应税收入", Format: "%.2f", Alignment: AlignFar},
					{Title: "第三年出口收入", Format: "%.2f", Alignment: AlignFar},
					{Title: "第三年增值税", Format: "%.2f", Alignment: AlignFar},
					{Title: "第三年所得税", Format: "%.2f", Alignment: AlignFar},
					{Title: "第三年税额合计", Format: "%.2f", Alignment: AlignFar},
					{Title: "三年缴纳税款总计", Format: "%.2f", Alignment: AlignFar},
					{Title: "稽查时间", Format: "2006-01-02"},
					{Title: "稽查年度"},
					{Title: "是否重点税源"},
				},
				Model: model,
			},
			GroupBox{
				Title:  "筛选数据",
				Layout: VBox{},
				Children: []Widget{
					Composite{
						Layout: HBox{},
						Children: []Widget{
							Label{
								Text: "行业:",
							},
							ComboBox{
								AssignTo:      &indusComb,
								Value:         Bind("OrgIndus"),
								BindingMember: "Val",
								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: "税收收入小于:",
//.........这里部分代码省略.........
开发者ID:LaughingVzr,项目名称:taxrecrd,代码行数:101,代码来源:mainfrm.go


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