增加此简单的go gui应用程序的默认字体大小 [英] Increasing default font size of this simple go gui application
问题描述
我正在使用以下简单的演示代码使用 Fyne 程序包创建GUI:>
package main
import (
"fyne.io/fyne/widget"
"fyne.io/fyne/app"
)
func main() {
app := app.New()
w := app.NewWindow("Hello")
w.SetContent(widget.NewVBox(
widget.NewLabel("Hello Fyne!"),
widget.NewButton("Quit", func() {
app.Quit()
}),
))
w.ShowAndRun()
}
它可以正常工作,但我想增加此GUI的默认字体大小(以便应在标签,按钮和可能添加到其中的其他小部件(如条目)中增加字体大小).
我看到有一个 theme
对象(使用TextSize()函数),但我无法使用它来增加字体大小.在type Driver interface
中也有一个RenderedTextSize(string, int, TextStyle) Size
.
如何在此简单的GUI应用程序中增加默认字体?感谢您的帮助.
您可以在主题内使用TextSize()-您需要提供一个自定义主题,该主题是使用myApp.Settings().SetTheme()设置的.>
但是,如果您只是希望使用更大的应用程序进行自己的设置,则应尝试将环境变量FYNE_SCALE设置为2.0之类的东西,这将扩展整个用户界面.这会更改计算机的大小,而在主题中设置TextSize会为每个人更改.
值得注意的是,这并不是琐碎的",因为Fyne小部件故意没有提供太多自定义功能.
I am using following simple demo code to create a GUI using Fyne package:
package main
import (
"fyne.io/fyne/widget"
"fyne.io/fyne/app"
)
func main() {
app := app.New()
w := app.NewWindow("Hello")
w.SetContent(widget.NewVBox(
widget.NewLabel("Hello Fyne!"),
widget.NewButton("Quit", func() {
app.Quit()
}),
))
w.ShowAndRun()
}
It works all right but I want to increase size default font of this GUI (so that font size should increase in label, button and any other widget like entry that may be added to it).
I see there is theme
object (with a TextSize() function) that can possibly be used but I am not able to use it to increase font size. There is a also RenderedTextSize(string, int, TextStyle) Size
in type Driver interface
.
How can I increase default font in this simple GUI application? Thanks for your help.
You can use TextSize() within theme - you would need to provide a custom theme as set it with myApp.Settings().SetTheme().
If, however, you just wish a larger application for your own setup then you should try setting the environment variable FYNE_SCALE to something like 2.0 which will scale the whole user interface. This changes the size for your computer whereas setting the TextSize in a theme would change it for everyone.
It’s worth noting that this is not "trivial" because Fyne widgets intentionally do not offer much customisation.
这篇关于增加此简单的go gui应用程序的默认字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!