Closed jilieryuyi closed 3 years ago
Update(true) 没有更新界面
English?
atfer call "Run" api, win.Show() win.Run() use root.Append(element), how to reflesh window? Update(true) not work!!
use golang Append element
Could you show your code?
Also, check examples: https://github.com/sciter-sdk/go-sciter/tree/master/examples
package main
import (
"fmt"
"github.com/sciter-sdk/go-sciter"
"github.com/sciter-sdk/go-sciter/window"
"log"
"time"
)
var (
win *window.Window
)
func tick() {
go func() {
startTime := time.Now()
tick := time.NewTicker(time.Second)
defer tick.Stop()
for {
select {
case <- tick.C:
root, err := win.GetRootElement()
if root == nil {
fmt.Println(err)
continue
}
t, err := root.SelectFirst("#timer")
if t == nil {
fmt.Println(err)
continue
}
t.SetText(fmt.Sprintf("%v", time.Since(startTime)))
t.Update(true)
}
}
}()
}
func main() {
defer func() {
if err := recover(); err != nil {
fmt.Println(err)
}
}()
var err error
sciter.SetOption(sciter.SCITER_SET_SCRIPT_RUNTIME_FEATURES, sciter.ALLOW_SYSINFO)
win, err = window.New(
sciter.SW_TITLEBAR|
sciter.SW_RESIZEABLE|
sciter.SW_CONTROLS|
sciter.SW_MAIN|
sciter.SW_ENABLE_DEBUG, &sciter.Rect{
Left: 0,
Top: 0,
Right: 500,
Bottom: 600,
})
if err != nil {
log.Fatal("Create Window Error: ", err)
}
win.SetTitle("some test")
win.LoadFile("index.html")
// UI will be blocked here. UI can't be displayed normally. Can I use the goroutine here?
go tick()
win.Show()
win.Run()
}
why ui block?
Because Run()
function is synchronous and it is a loop essentially.
Use events instead. Also, you can access the DOM after LoadFile()
but before Run()
: https://github.com/sciter-sdk/go-sciter/blob/master/examples/insert/insert.go#L19
Do you have any examples of using events?
Because
Run()
function is synchronous and it is a loop essentially.Use events instead. Also, you can access the DOM after
LoadFile()
but beforeRun()
: https://github.com/sciter-sdk/go-sciter/blob/master/examples/insert/insert.go#L19
Do you have any examples of using events?
Because
Run()
function is synchronous and it is a loop essentially.Use events instead. Also, you can access the DOM after
LoadFile()
but beforeRun()
: https://github.com/sciter-sdk/go-sciter/blob/master/examples/insert/insert.go#L19
how to use Task in UI multi-goroutine?
https://github.com/sciter-sdk/go-sciter/issues/133 I found this
求教,如题!