-
-
Notifications
You must be signed in to change notification settings - Fork 35
FAQ
Frequently asked questions and answers regarding to Gowut.
1. How can I add/include my custom, external CSS file?
2. How can I periodically refresh a component?
3. How can I specify HTTP response headers that are sent with all responses?
There are 2 main ways to include custom CSS content.
-
If you have a short CSS code you want to include, you can include it with the
Window.AddHeadHTML()
method. For example to make all labels red by default:win.AddHeadHTML("<style>.gwu-Label{color:red}</style>")
-
If you have a long CSS code or you have it as an external file, then the recommended way is this to tell Gowut about the location of this (and other static files). You can do that with the
Server.AddStaticDir()
method. After that you can link to this file usingWindow.AddHeadHTML()
:serv.AddStaticDir("static", "/temp/staticfiles") win.AddHeadHTML(`<link rel="stylesheet" type="text/css" href="/appname/static/mystyle.css">`)
You can use the Timer
component to generate a series of events periodically, and add an event handler to it in which you can change the component and mark it dirty.
t := gwu.NewTimer(10 * time.Second)
t.AddEHandlerFunc(func(e gwu.Event) {
timelabel.SetText(time.Now().Format("15:04:05"))
e.MarkDirty(timelabel)
}, gwu.ETypeStateChange)
Gowut 1.0.0 added 2 new methods in Server: SetHeader()
and Header()
. Using SetHeader()
:
server.SetHeaders(map[string][]string{
"Gowut-Server": {gwu.GowutVersion},
})