示例#1
0
文件: example.go 项目: CodyGuo/skinh
func main() {
	skinh.Attach()
	skinh.SetAero(true)
	skinh.SetWinMovable(1, true)

	var te *walk.TextEdit

	if _, err := (MainWindow{
		Title:   "Walk Clipboard Example",
		MinSize: Size{300, 200},
		Layout:  VBox{},
		Children: []Widget{
			PushButton{
				Text: "Copy",
				OnClicked: func() {
					if err := walk.Clipboard().SetText(te.Text()); err != nil {
						log.Print("Copy: ", err)
					}
				},
			},
			PushButton{
				Text: "Paste",
				OnClicked: func() {
					if text, err := walk.Clipboard().Text(); err != nil {
						log.Print("Paste: ", err)
					} else {
						te.SetText(text)
					}
				},
			},
			TextEdit{
				AssignTo: &te,
			},
		},
	}).Run(); err != nil {
		log.Fatal(err)
	}
}
示例#2
0
文件: main.go 项目: CodyGuo/Go-Cody
func main() {
	skinh.Attach()
	mw := new(MyMainWindow)

	// 禁止最大化
	mw.SetMaximizeBox(false)

	// 禁止最小化
	mw.SetMinimizeBox(false)

	// 固定窗体大小
	mw.SetFixedSize(true)

	if err := (MainWindow{
		AssignTo: &mw.MainWindow,
		DataBinder: DataBinder{
			AssignTo:       &db,
			DataSource:     UserConfig,
			ErrorPresenter: ErrorPresenterRef{&ep},
		},
		Title:        "Cody - 测试程序",
		ScreenCenter: true, // 屏幕居中
		MinSize:      Size{300, 500},
		Layout:       VBox{Spacing: 2},
		Children: []Widget{
			Composite{
				Layout: Grid{Columns: 2, Spacing: 10},
				Children: []Widget{
					VSplitter{
						Children: []Widget{
							Label{
								MinSize: Size{18, 0},
								Text:    "用户名:",
							},
						},
					},
					VSplitter{
						Children: []Widget{

							LineEdit{
								AssignTo: &ltu,
								MinSize:  Size{160, 0},
								Text:     Bind("UserName", SelRequired{}),
							},
						},
					},

					VSplitter{
						Children: []Widget{
							Label{
								MinSize: Size{18, 0},
								Text:    "密码:",
							},
						},
					},
					VSplitter{
						Children: []Widget{

							LineEdit{
								AssignTo:     &ltu,
								PasswordMode: true,
								MinSize:      Size{160, 0},
								Text:         Bind("Password"),
							},
						},
					},

					VSplitter{
						Children: []Widget{
							Label{
								MinSize: Size{18, 0},
								Text:    "姓名:",
							},
						},
					},
					VSplitter{
						Children: []Widget{
							LineEdit{
								AssignTo: &ltu,
								MinSize:  Size{160, 0},
								Text:     Bind("Name"),
							},
						},
					},

					VSplitter{
						Children: []Widget{
							Label{
								MinSize: Size{18, 0},
								Text:    "工号:",
							},
						},
					},
					VSplitter{
						Children: []Widget{
							NumberEdit{
								AssignTo: &ltj,
								Value:    Bind("JobNumber", Range{1, 10}),
							},
						},
					},

					VSplitter{
						Children: []Widget{
							Label{
								MinSize: Size{18, 0},
								Text:    "邮箱:",
							},
						},
					},
					VSplitter{
						Children: []Widget{
							LineEdit{
								AssignTo: &lte,
								MinSize:  Size{160, 0},
								Text:     Bind("Email"),
							},
						},
					},

					VSplitter{
						Children: []Widget{
							Label{
								MinSize: Size{18, 0},
								Text:    "手机:",
							},
						},
					},
					VSplitter{
						Children: []Widget{

							LineEdit{
								AssignTo: &ltphone,
								MinSize:  Size{160, 0},
								Text:     Bind("Phone"),
							},
						},
					},

					// VSplitter{},
					VSplitter{
						ColumnSpan: 2,
						MinSize:    Size{100, 0},
						Children: []Widget{
							LineErrorPresenter{
								AssignTo:   &ep,
								ColumnSpan: 2,
							},

							PushButton{
								AssignTo:  &addUserBtn,
								MinSize:   Size{90, 0},
								Text:      "提交",
								OnClicked: mw.openAddd_Triggered,
							},
						},
					},
				},
			},
		},
	}.Create()); err != nil {
		// log.Fatal(err)
		fmt.Println("错误来了:", err)
		log.Println(err)
	}
	// addIpBtn.SetMinMaxSize(walk.Size{18, 18}, walk.Size{18, 18})

	lv, err := NewLogView(mw)
	if err != nil {
		log.Fatal(err)
	}

	lv.PostAppendText("Hello.\n")
	log.SetOutput(lv)
	log.Println("hi.")

	mw.Run()
	mw.Dispose()
}
示例#3
0
文件: main.go 项目: CodyGuo/Go-Cody
func main() {
	skinh.Attach()

	Input := new(Model)
	mw := new(MyMainWindow)

	date, _ := time.Parse("2006-02-03 03:04:05", "2016-01-01 08:08:08")

	if err := (MainWindow{
		AssignTo: &mw.MainWindow,
		DataBinder: DataBinder{
			AssignTo:       &db,
			DataSource:     Input,
			ErrorPresenter: ErrorPresenterRef{&ep},
		},
		Title:   "iMan - 测试程序",
		MinSize: Size{1100, 700},
		Layout:  VBox{},
		Children: []Widget{
			Composite{
				AssignTo: &setting,
				Layout:   Grid{Columns: 1},
				Children: []Widget{
					RadioButtonGroupBox{
						AssignTo:   &radioBtnGpBox,
						Title:      "注册模式",
						MinSize:    Size{0, 30},
						Layout:     HBox{},
						DataMember: "Int",
						Buttons: []RadioButton{
							{Text: iMode.RunMode[0].Key, Value: iMode.RunMode[0].Int},
							{Text: iMode.RunMode[1].Key, Value: iMode.RunMode[1].Int},
							{Text: iMode.RunMode[2].Key, Value: iMode.RunMode[2].Int},
						},
					},
				},
			},
			Composite{
				AssignTo: &setting,
				Layout:   Grid{Columns: 2},
				Children: []Widget{
					CheckBox{
						AssignTo:   &cBox1,
						Text:       "盒子",
						CheckState: walk.CheckUnchecked,
						Tristate:   true,
						OnClicked: func() {
							fmt.Println(cBox1.CheckState())
							if cBox1.CheckState() == 0 {
								mw.openAddd_Triggered("您关闭了盒子.")
							} else if cBox1.CheckState() == 1 {
								mw.openAddd_Triggered("您打开了盒子.")
							} else {
								mw.openAddd_Triggered("您的盒子是未知状态.")
							}
						},
						OnCheckedChanged: func() {
							mw.openAddd_Triggered("您修改了盒子的状态.")
						},
						OnCheckStateChanged: func() {
							mw.openAddd_Triggered("您的盒子状态被改变了...")
						},
						// CheckState: false,
					},

					DateEdit{
						AssignTo: &de1,
						// Format:   "Y-M-d H:m:s",
						Format:     "yyyy-MM-dd H:mm:ss",
						NoneOption: true,
						MinDate:    time.Now(),
						MaxDate:    time.Now().AddDate(1, 0, 0),
						Date:       date,
					},
					PushButton{
						AssignTo: &addIpBtn,
						Text:     "添加",
						OnClicked: func() {
							ok := mw.addAction_ServerIp()
							if ok == 0 {
								fmt.Println("添加服务器", "添加"+iplist.Ip+"成功.")
							}

							iplist.Ip = ""
							iplist.Remark = ""
						},
					},

					TableView{
						MinSize:                    Size{200, 100},
						MaxSize:                    Size{550, 450},
						AlternatingRowBGColor:      walk.RGB(255, 255, 224),
						CheckBoxes:                 true,
						ItemStateChangedEventDelay: 1,
						ColumnsOrderable:           false,
						ColumnsSizable:             false,
						SingleItemSelection:        false, // 单选
						LastColumnStretched:        false, // 显示最后一列
						Columns: []TableViewColumn{
							{Title: "序号"},
							{Title: "IP"},
							{Title: "备注"},
							{Title: "添加时间", Format: "2006-01-02 15:04:05", Width: 150},
						},

						Model: &model,
					},

					PushButton{
						AssignTo: &addIpBtn,
						Text:     "提交",
						MinSize:  Size{60, 80},
						MaxSize:  Size{100, 80},

						ToolTipText: "提示信息,请填写数字",
						OnClicked: func() {

							fmt.Println("-----ok----------")
							InputIp.ServerLists = model.GetChecked()
							var tmpListIp []string
							if len(InputIp.ServerLists) > 0 {
								fmt.Println("--------------------选中了哪个-----------")
								// fmt.Print(InputIp.ServerLists[0].Ip)
								for index, _ := range InputIp.ServerLists {
									tmpListIp = append(tmpListIp, InputIp.ServerLists[index].Ip)
									// if len(InputIp.ServerLists) == 1 {
									//     tmpListIp = InputIp.ServerLists[index].Ip
									// } else if len(InputIp.ServerLists) == 2 {
									//     tmpListIp = tmpListIp + " , " + InputIp.ServerLists[index].Ip
									// } else {
									//     tmpListIp = tmpListIp + " , " + InputIp.ServerLists[index].Ip
									// }

								}
								fmt.Println(tmpListIp)
								mw.openAddd_Triggered(strings.Join(tmpListIp, ", "))
							}
						},
					},
				},
			},
		},
	}.Create()); err != nil {
		// log.Fatal(err)
		fmt.Println("错误来了:", err)
		log.Println(err)
	}

	// addIpBtn.SetMinMaxSize(walk.Size{30, 50}, walk.Size{50, 60})
	// mw.SetPersistent(true)
	mw.Run()
}