如何在FYNE GUI中显示GO代码?

huangapple go评论83阅读模式
英文:

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

问题

我正在构建一个简单的GUI,并找到了一个内置的GUI库来与我的GOLANG代码一起使用。我尝试运行go run main.go来测试功能,使用了他们的"Hello World"示例。但是遇到了一个问题,提示没有DISPLAY变量。然后我设置了这个变量,现在又遇到了这个问题。请帮助解决!

错误信息在这里:ERROR

英文:

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 如何在FYNE GUI中显示GO代码?

答案1

得分: 1

经过大量的工作和几天的完全沮丧,我找到了答案。首先,与您的IP地址一起设置正确的显示。

export DISPLAY=(您的IP地址):0.0,其中:0.0设置为您的默认显示。

然后按照以下信息进行操作:

设置您的第一个入站规则
如何在FYNE GUI中显示GO代码?

按照以下列表设置3个规则
如何在FYNE GUI中显示GO代码?

可以根据需要对它们进行命名。只需确保在协议下设置了TCP和UDP以及ALL类别。当我尝试仅设置一个带有所有类别的协议时,我的设置只有在设置了所有3个规则时才起作用。

英文:

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
如何在FYNE GUI中显示GO代码?

set 3 of these as listed here
如何在FYNE GUI中显示GO代码?

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.)

答案2

得分: 1

你需要在我们的代码中导入 fyne.io/fyne/v2,像这样:

package main

import (
    "fyne.io/fyne/v2"  // 在你的代码中添加这一行
    "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()
}
英文:

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()
}

答案3

得分: 0

听起来你正在使用运行Linux的Wayland设置。并非所有应用程序都支持这个设置,所以建议你切换到“xwayland”,它可以添加X11兼容性。

Fyne正在开发对Wayland的支持,你可以尝试使用“-tags wayland”构建参数进行测试。目前已经完成了大约95%,我们计划在今年晚些时候将其默认启用。

英文:

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.

huangapple
  • 本文由 发表于 2022年8月21日 21:26:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/73434862.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定