使用go语言和webview编写桌面应用

栏目: Go · 发布时间: 6年前

内容简介:具体思路是使用http实现页面跳转,使用jsonrpc实现ui和go之间的数据通讯。golang版本的webview使用的是github.com/zserge/webview这个库,自己封装了一套Page,实现页面之间的跳转。具体使用

https://github.com/tenny1225/go-web-app

具体思路是使用http实现页面跳转,使用jsonrpc实现ui和 go 之间的数据通讯。

golang版本的webview使用的是github.com/zserge/webview这个库,自己封装了一套Page,实现页面之间的跳转。具体使用

package main

import "time"

func main() {
    StartWindow("golang html", 400, 400, true, func() {
        pager := NewPager(&MyPage{},&MyPageAction{})
        pager.StartPage(0)
    })

}



type MyPage struct {
    PageImpl
}
type MyPage1 struct {
    PageImpl
}
type MyPageAction struct {
    P *MyPage
    i int
}

func (t *MyPageAction) Add(i int,s *string) error {
    pager := NewPager(&MyPage1{},nil)
    pager.StartPage(0)
    *s = "success"
    return nil

}
func (p *MyPage) Stop() {

}
func (p*MyPage)Start()  {
    p.SetContentView("html/page1.html")


}
func (p *MyPage1) Stop() {

}
func (p*MyPage1)Start()  {
    p.SetContentView("html/page2.html")
    go func() {
        time.Sleep(5*time.Second)
        p.Window.Backup()
    }()

}

这里默认打开第一个页面,点击按钮跳转到第二个页面,五秒钟后页面返回。

使用go语言和webview编写桌面应用

2018-11-29 17-38-04屏幕截图.png

使用go语言和webview编写桌面应用

2018-11-29 17-38-22屏幕截图.png


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

JavaScript & jQuery

JavaScript & jQuery

David Sawyer McFarland / O Reilly / 2011-10-28 / USD 39.99

You don't need programming experience to add interactive and visual effects to your web pages with JavaScript. This Missing Manual shows you how the jQuery library makes JavaScript programming fun, ea......一起来看看 《JavaScript & jQuery》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

在线进制转换器
在线进制转换器

各进制数互转换器