dtj4307 2019-08-25 12:23
浏览 291
已采纳

增加此简单的go gui应用程序的默认字体大小

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.

  • 写回答

1条回答 默认 最新

  • drsxzut183207938 2019-08-25 12:58
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置