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


Golang walk.WebView類代碼示例

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


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

示例1: main

func main() {
	var le *walk.LineEdit
	var wv *walk.WebView

	MainWindow{
		Title:   "Walk WebView Example",
		MinSize: Size{800, 600},
		Layout:  VBox{MarginsZero: true},
		Children: []Widget{
			LineEdit{
				AssignTo: &le,
				Text:     Bind("wv.URL"),
				OnKeyDown: func(key walk.Key) {
					if key == walk.KeyReturn {
						wv.SetURL(le.Text())
					}
				},
			},
			WebView{
				AssignTo: &wv,
				Name:     "wv",
				URL:      "http://golang.org",
			},
		},
	}.Run()
}
開發者ID:Fruchtgummi,項目名稱:walk,代碼行數:26,代碼來源:webview.go

示例2: WebviewWindow

// Spawns a window containing a webview pointed at the given URL, and waits for
// it to be closed. If the webview cannot be opened, returns an error
// immediately.
func WebviewWindow(serverURL string) (e error) {
	var mainWindow *walk.MainWindow
	var webView *walk.WebView

	log.Print("Starting to create webview window")
	if err := (declarative.MainWindow{
		AssignTo: &mainWindow,
		Title:    "WebCmd Webview",
		MinSize:  declarative.Size{600, 400},
		Size:     declarative.Size{800, 600},
		Visible:  true,
		Layout:   declarative.HBox{},
		Children: []declarative.Widget{
			declarative.WebView{
				AssignTo: &webView,
			},
		},
	}.Create()); err != nil {
		log.Println("Error while creating window. Usually happens when " +
			"compiled without -ldflags=\"-Hwindowsgui\" or a manifest. " +
			"see make.bat to compile with window support on windows.")
		return errors.New("Unable to create webview window")
	}
	log.Print("Create complete, initializing webView with URL ", serverURL)
	webView.SetURL(serverURL)

	mainWindow.Run()
	log.Print("Webview closed.")
	return nil
}
開發者ID:EricBurnett,項目名稱:WebCmd,代碼行數:33,代碼來源:webview_windows.go

示例3: osOpenWindow

func osOpenWindow(window *Window, url string, styleFlags int) {

	fmt.Println("osOpenWindow: ", window, url, styleFlags)

	var dia *walk.Dialog
	var le *walk.LineEdit
	var wv *walk.WebView

	windowStore[window.handle] = dia

	Dialog{
		AssignTo: &dia,
		Title:    "Window Title",
		MinSize:  Size{800, 600},
		Layout:   VBox{MarginsZero: true},
		Children: []Widget{
			LineEdit{
				AssignTo: &le,
				Text:     Bind("wv.URL"),
				OnKeyDown: func(key walk.Key) {
					if key == walk.KeyReturn {
						wv.SetURL(le.Text())
					}
				},
			},
			WebView{
				AssignTo: &wv,
				Name:     "wv",
				URL:      url,
			},
		},
	}.Run(mainWindow)
}
開發者ID:xinhuang327,項目名稱:goui,代碼行數:33,代碼來源:goui_windows.go

示例4: main

func main() {
	walk.Initialize(walk.InitParams{PanicOnError: true})
	defer walk.Shutdown()

	mw, _ := walk.NewMainWindow()
	mw.SetTitle("Walk WebView Example")
	mw.SetLayout(walk.NewVBoxLayout())
	mw.SetMinMaxSize(walk.Size{600, 400}, walk.Size{})
	mw.SetSize(walk.Size{800, 600})

	var webView *walk.WebView

	urlLineEdit, _ := walk.NewLineEdit(mw)
	urlLineEdit.ReturnPressed().Attach(func() {
		webView.SetURL(urlLineEdit.Text())
	})

	webView, _ = walk.NewWebView(mw)
	webView.SetURL("http://golang.org")

	mw.Show()
	mw.Run()
}
開發者ID:etel,項目名稱:walk,代碼行數:23,代碼來源:webview.go

示例5: main

func main() {
	var le *walk.LineEdit
	var wv *walk.WebView

	MainWindow{
		Title:   "Walk WebView Example",
		MinSize: Size{800, 600},
		Layout:  VBox{},
		Children: []Widget{
			LineEdit{
				AssignTo: &le,
				Text:     Bind("wv.URL"),
				OnReturnPressed: func() {
					wv.SetURL(le.Text())
				},
			},
			WebView{
				AssignTo: &wv,
				Name:     "wv",
				URL:      "http://golang.org",
			},
		},
	}.Run()
}
開發者ID:Robin3D,項目名稱:walk,代碼行數:24,代碼來源:webview.go

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


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