简体   繁体   中英

How can I get my display to show GO code with FYNE gui?

I am building a simple GUI, and found a built in one for use with my GOLANG code. I have tried to simply run a go run main.go with the example of their hello world just to test functionality. Got an issue that there was no DISPLAY variable. Then set the variable and now I'm getting this issue. Please assist!

package main

import (
    "fyne.io/fyne/v2/app"
    "fyne.io/fyne/v2/widget"
)

func main() {
    a := app.New()
    w := a.NewWindow("Hello World")

    w.SetContent(widget.NewLabel("Hello World!"))
    w.ShowAndRun()
}

Error is shown here错误

It sounds like you are running Linux with a Wayland setup. Not all apps support this yet, so it is recommended to switch on “xwayland” which adds X11 compatibility.

Fyne is working on wayland support and you can try it out using the “-tags wayland” build parameter. It is about 95% complete, we aim to have it enabled by default later this year.

After a ton of work, days of being completely frustrated. I found the answer. starting with setting the correct display in conjunction with your ipaddress.

export DISPLAY=(your IP address):0.0 the:0.0 sets to your default display.

You want to then follow this information ----> setting your first inbound rule , set 3 of these. as listed here----> vcxserv inbound , name them however you would like. Just ensure you have set TCP and UDP and an ALL category under the protocol. Mine only worked when setting all 3, (when I figured setting just 1 with all category would work for the protocol.)

You need to import fyne.io/fyne/v2 in our code like this:

package main

import (
    "fyne.io/fyne/v2"  // add this line to your code
    "fyne.io/fyne/v2/app"
    "fyne.io/fyne/v2/widget"
)

func main() {
    a := app.New()
    w := a.NewWindow("Hello World")

    w.SetContent(widget.NewLabel("Hello World!"))
    w.ShowAndRun()
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM