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


Golang walk.TableView類代碼示例

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


在下文中一共展示了TableView類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Create

func (tvc TableViewColumn) Create(tv *walk.TableView) error {
	w := walk.NewTableViewColumn()

	if err := w.SetAlignment(walk.Alignment1D(tvc.Alignment)); err != nil {
		return err
	}
	w.SetDataMember(tvc.DataMember)
	if tvc.Format != "" {
		if err := w.SetFormat(tvc.Format); err != nil {
			return err
		}
	}
	if err := w.SetPrecision(tvc.Precision); err != nil {
		return err
	}
	if err := w.SetTitle(tvc.Title); err != nil {
		return err
	}
	if err := w.SetVisible(!tvc.Hidden); err != nil {
		return err
	}
	if err := w.SetWidth(tvc.Width); err != nil {
		return err
	}

	return tv.Columns().Add(w)
}
開發者ID:2105666566,項目名稱:walk,代碼行數:27,代碼來源:tableviewcolumn.go

示例2: CreateProj_Query

/**
** 查看所有項目的方法
**/
func CreateProj_Query(owner walk.Form) {
	var dlg *walk.Dialog
	var tv *walk.TableView
	var dialog = Dialog{}
	model := xorm.NewProjectModel()

	dialog.AssignTo = &dlg
	dialog.Title = "項目管理"
	dialog.Layout = VBox{}
	dialog.MinSize = Size{650, 300}
	dialog.Children = []Widget{
		TableView{
			AssignTo:              &tv,
			AlternatingRowBGColor: walk.RGB(255, 255, 224),
			ColumnsOrderable:      true,
			Columns: []TableViewColumn{
				{Title: "編號", Width: 50},
				{Title: "名稱"},
				{Title: "創建者"},
				{Title: "創建時間", Format: "2006-01-02 15:04:05", Width: 130},
				{Title: "描述", Width: 200},
			},
			Model: model,
		},
		Composite{
			Layout: HBox{},
			Children: []Widget{
				HSpacer{},
				PushButton{
					Text: "創建",
					OnClicked: func() {
						CreateProj_Triggered(owner, model)
					},
				},
				PushButton{
					Text: "刪除",
					OnClicked: func() {
						indexs := tv.SelectedIndexes()
						if indexs.Len() == 0 {
							walk.MsgBox(owner, "提示", "請選擇要刪除的數據", walk.MsgBoxIconError)
							return
						}
						walk.MsgBox(owner, "提示", "確認是否刪除此工程", walk.MsgBoxOKCancel)

						obj := model.GetItemByindex(int64(indexs.At(0)))
						xorm.DeleteProjectByObj(obj)
						model.ResetRows()
					},
				},
			},
		},
	}
	dialog.Run(owner)
}
開發者ID:starmoonlove,項目名稱:packutil,代碼行數:57,代碼來源:projectview.go

示例3: main

func main() {
	rand.Seed(time.Now().UnixNano())

	model := NewFooModel()

	var tv *walk.TableView

	MainWindow{
		Title:  "Walk TableView Example",
		Size:   Size{800, 600},
		Layout: VBox{MarginsZero: true},
		Children: []Widget{
			PushButton{
				Text:      "Reset Rows",
				OnClicked: model.ResetRows,
			},
			PushButton{
				Text: "Select first 5 even Rows",
				OnClicked: func() {
					tv.SetSelectedIndexes([]int{0, 2, 4, 6, 8})
				},
			},
			TableView{
				AssignTo:              &tv,
				AlternatingRowBGColor: walk.RGB(255, 255, 224),
				CheckBoxes:            true,
				ColumnsOrderable:      true,
				MultiSelection:        true,
				Columns: []TableViewColumn{
					{Title: "#"},
					{Title: "Bar"},
					{Title: "Baz", Format: "%.2f", Alignment: AlignFar},
					{Title: "Quux", Format: "2006-01-02 15:04:05", Width: 150},
				},
				Model: model,
				OnSelectedIndexesChanged: func() {
					fmt.Printf("SelectedIndexes: %v\n", tv.SelectedIndexes())
				},
			},
		},
	}.Run()
}
開發者ID:Ryanker,項目名稱:walk,代碼行數:42,代碼來源:tableview.go

示例4: main

func main() {
	var mainWindow *walk.MainWindow
	var treeView *walk.TreeView
	var tableView *walk.TableView
	var webView *walk.WebView

	treeModel, err := NewDirectoryTreeModel()
	if err != nil {
		log.Fatal(err)
	}
	tableModel := NewFileInfoModel()

	if err := (MainWindow{
		AssignTo: &mainWindow,
		Title:    "Walk File Browser Example",
		MinSize:  Size{600, 400},
		Size:     Size{800, 600},
		Layout:   HBox{},
		Children: []Widget{
			HSplitter{
				Children: []Widget{
					TreeView{
						AssignTo: &treeView,
						Model:    treeModel,
						OnCurrentItemChanged: func() {
							dir := treeView.CurrentItem().(*Directory)
							if err := tableModel.SetDirPath(dir.Path()); err != nil {
								walk.MsgBox(
									mainWindow,
									"Error",
									err.Error(),
									walk.MsgBoxOK|walk.MsgBoxIconError)
							}
						},
					},
					TableView{
						AssignTo: &tableView,
						Columns: []TableViewColumn{
							TableViewColumn{
								Title:      "Name",
								DataMember: "Name",
								Width:      200,
							},
							TableViewColumn{
								Title:      "Size",
								DataMember: "Size",
								Format:     "%d",
								Alignment:  AlignFar,
								Width:      80,
							},
							TableViewColumn{
								Title:      "Modified",
								DataMember: "Modified",
								Format:     "2006-01-02 15:04:05",
								Width:      120,
							},
						},
						Model: tableModel,
						OnCurrentIndexChanged: func() {
							var url string
							if index := tableView.CurrentIndex(); index > -1 {
								name := tableModel.items[index].Name
								dir := treeView.CurrentItem().(*Directory)
								url = filepath.Join(dir.Path(), name)
							}

							webView.SetURL(url)
						},
					},
					WebView{
						AssignTo: &webView,
					},
				},
			},
		},
	}.Create()); err != nil {
		log.Fatal(err)
	}

	mainWindow.Run()
}
開發者ID:richardjoo,項目名稱:walk,代碼行數:81,代碼來源:filebrowser.go

示例5: Create

func (tv TableView) Create(builder *Builder) error {
	var w *walk.TableView
	var err error
	if tv.NotSortableByHeaderClick {
		w, err = walk.NewTableViewWithStyle(builder.Parent(), win.LVS_NOSORTHEADER)
	} else {
		w, err = walk.NewTableView(builder.Parent())
	}
	if err != nil {
		return err
	}

	return builder.InitWidget(tv, w, func() error {
		for i := range tv.Columns {
			if err := tv.Columns[i].Create(w); err != nil {
				return err
			}
		}

		if err := w.SetModel(tv.Model); err != nil {
			return err
		}

		if tv.AlternatingRowBGColor != 0 {
			w.SetAlternatingRowBGColor(tv.AlternatingRowBGColor)
		}
		w.SetCheckBoxes(tv.CheckBoxes)
		w.SetItemStateChangedEventDelay(tv.ItemStateChangedEventDelay)
		if err := w.SetLastColumnStretched(tv.LastColumnStretched); err != nil {
			return err
		}
		if err := w.SetSingleItemSelection(tv.SingleItemSelection); err != nil {
			return err
		}

		if tv.OnCurrentIndexChanged != nil {
			w.CurrentIndexChanged().Attach(tv.OnCurrentIndexChanged)
		}
		if tv.OnSelectedIndexesChanged != nil {
			w.SelectedIndexesChanged().Attach(tv.OnSelectedIndexesChanged)
		}
		if tv.OnItemActivated != nil {
			w.ItemActivated().Attach(tv.OnItemActivated)
		}

		if tv.AssignTo != nil {
			*tv.AssignTo = w
		}

		return nil
	})
}
開發者ID:kolkov,項目名稱:walk,代碼行數:52,代碼來源:tableview.go

示例6: main

func main() {
	font := Font{
		Family:    "Times New Roman",
		PointSize: 13,
		Bold:      true,
	}
	usr, _ := user.Current()
	usrModel := env.NewModel(0)
	sysModel := env.NewModel(1)
	var usrTableView, sysTableView *walk.TableView
	var mw *walk.MainWindow
	MainWindow{
		Title:    "Enviroment Variable",
		Size:     Size{600, 700},
		Layout:   VBox{},
		AssignTo: &mw,
		Font:     font,
		Children: []Widget{
			VSplitter{
				Children: []Widget{
					GroupBox{
						Title:  "User variables for " + usr.Username,
						Font:   font,
						Layout: VBox{},
						Children: []Widget{
							TableView{
								AssignTo:              &usrTableView,
								AlternatingRowBGColor: walk.RGB(255, 255, 224),
								ColumnsOrderable:      true,
								Columns: []TableViewColumn{
									{Title: "name", Width: 200},
									{Title: "value"},
								},
								LastColumnStretched: true,
								Model:               usrModel,
								OnItemActivated: func() {
									index := usrTableView.CurrentIndex()
									if index != -1 {
										EditVariable(mw, usrModel, usrModel.GetVariable(index).Name, usrModel.GetVariable(index).Value)
									}
								},
							},
							Composite{
								Layout: HBox{},
								Children: []Widget{
									HSpacer{},
									PushButton{
										Text: "New...",
										OnClicked: func() {
											NewVariable(mw, usrModel)
										},
									},
									PushButton{
										Text: "Edit...",
										OnClicked: func() {
											index := usrTableView.CurrentIndex()
											if index != -1 {
												EditVariable(mw, usrModel, usrModel.GetVariable(index).Name, usrModel.GetVariable(index).Value)
											}
										},
									},
									PushButton{
										Text: "Delete",
										OnClicked: func() {
											index := usrTableView.CurrentIndex()
											if index != -1 {
												DeleteVariable(mw, usrModel, usrModel.GetVariable(index).Name)
											}
										},
									},
								},
							},
						},
					},
					GroupBox{
						Title:  "System variables",
						Font:   font,
						Layout: VBox{},
						Children: []Widget{
							TableView{
								AssignTo:              &sysTableView,
								AlternatingRowBGColor: walk.RGB(255, 255, 224),
								ColumnsOrderable:      true,
								Columns: []TableViewColumn{
									{Title: "Variable", Width: 200},
									{Title: "Value"},
								},
								LastColumnStretched: true,
								Model:               sysModel,
								OnItemActivated: func() {
									index := sysTableView.CurrentIndex()
									if index != -1 {
										EditVariable(mw, sysModel, sysModel.GetVariable(index).Name, sysModel.GetVariable(index).Value)
									}
								},
							},
							Composite{
								Layout: HBox{},
								Children: []Widget{
									HSpacer{},
//.........這裏部分代碼省略.........
開發者ID:ZhuBicen,項目名稱:EnvSetting,代碼行數:101,代碼來源:main.go

示例7: main

func main() {
	model := NewFooModel("img")
	foo := &TableViewColumnFormat{Title: "創建時間", Format: "2006-01-02", Width: 150}
	var tv *walk.TableView
	MainWindow{
		Title:  "TableView",
		Size:   Size{800, 600},
		Layout: VBox{},
		DataBinder: DataBinder{
			DataSource: foo,
			AutoSubmit: true,
			OnSubmitted: func() {
				fmt.Println(foo)
			},
		},
		Children: []Widget{
			Composite{
				Layout: HBox{},
				Children: []Widget{
					RadioButtonGroup{
						DataMember: "Alignment",
						Buttons: []RadioButton{
							RadioButton{
								Name:  "leftAlign",
								Text:  "左對齊",
								Value: AlignFar,
								OnClicked: func() {
									tv.Columns().Add(walk.NewTableViewColumn())
									model.PublishRowsReset()
								},
							},
							RadioButton{
								Name:  "leftAlign",
								Text:  "居中",
								Value: AlignCenter,
								OnClicked: func() {
									tv.Columns().At(4).SetAlignment(walk.AlignCenter)
									model.PublishRowsReset()
								},
							},
							RadioButton{
								Name:  "leftAlign",
								Text:  "右對齊",
								Value: AlignNear,
								OnClicked: func() {
									tv.Columns().At(4).SetAlignment(walk.AlignFar)
									//tv.Columns().Clear()
									model.PublishRowsReset()
								},
							},
						},
					},
				},
			},

			TableView{
				AssignTo:              &tv,
				AlternatingRowBGColor: walk.RGB(183, 208, 65),
				CheckBoxes:            true,
				ColumnsOrderable:      true,
				Columns: []TableViewColumn{
					{Title: "#"},
					{Title: "原文件名"},
					{Title: "類型"},
					{Title: "新文件名"},
					{Title: "創建時間", Format: "2006-01-02 15:04:05", Width: 150, Alignment: foo.Alignment, DataMember: "", Hidden: false, Precision: 2},
					{Title: "修改時間", Format: "2006-01-02 15:04:05", Width: 150, DataMember: "", Alignment: foo.Alignment},
				},
				Model: model,
			},
		},
	}.Run()
}
開發者ID:sunclx,項目名稱:walk,代碼行數:73,代碼來源:table.go


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