我正在尝试调整此(列表)的大小,因为它只显示一行,第二个看到它需要向下滚动我想显示多行,这是代码:-
"fyne.io/fyne/v2/app" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/widget" type CustomList struct { Header fyne.CanvasObject List *widget.List } a := app.New() // Create a new window w := a.NewWindow("Resources Manager") // Create a list with five columns list = widget.NewList( func() int { return len(clientInfos) }, func() fyne.CanvasObject { return container.NewHBox(widget.NewIcon(nil), widget.NewLabel("")) }, func(index int, obj fyne.CanvasObject) { c := obj.(*fyne.Container) icon := c.Objects[0].(*widget.Icon) label := c.Objects[1].(*widget.Label) // load the image resource img, err := fyne.LoadResourceFromPath(clientInfos[index].Country) if err != nil { fmt.Println("Failed to load image", err) return } // set image to icon and text to label icon.SetResource(img) label.SetText(fmt.Sprintf("%s | %s | %s | %s | %s", clientInfos[index].AppName, clientInfos[index].Version, clientInfos[index].kerenl, clientInfos[index].Price, clientInfos[index].Size, )) label.TextStyle = fyne.TextStyle{Bold: true, Italic: false, Monospace: true} }, ) list.OnSelected = func(id int) { selectedID = id } customList := &CustomList{ Header: widget.NewLabel("Icon | AppName | kerenl | Price | Size | Status"), List: list, } customList.List.Resize(fyne.Size{Height: 434}) // Create a container for the buttons buttonContainer := container.NewVBox() buttonContainer.Add(widget.NewButton("Install", func() { // Handle button click })) buttonContainer.Add(widget.NewButton("download", func() { // Handle button click })) buttonContainer.Add(widget.NewButton("Upgrade", func() { // Handle button click })) buttonContainer.Add(widget.NewButton("Refresh", func() { list.Refresh() // Handle button click })) buttonContainer.Resize(fyne.NewSize(230, 300)) vbox := container.NewVBox( customList.Header, customList.List, ) vbox.Resize(fyne.NewSize(600, 320)) horizontalSplit := container.NewHSplit(vbox, buttonContainer) horizontalSplit.SetOffset(0.8) content := container.NewVBox(horizontalSplit, textArea) w.SetContent(content) w.Resize(fyne.NewSize(800, 270)) w.ShowAndRun()
还有其他用于 gui 的 Golang 库吗?因为看起来大多数都已经过时了,对吗?然而,我真的需要一些更简单的东西来构建一个 GUI,比如
正确答案
在 fyne 中,小部件被放入容器中,并且该容器通常具有布局。如果您进行了此设置,那么您对 Resize
的手动调用将被所选布局覆盖。
VBox 的使用正是这样做的,因为它的算法希望使每个项目尽可能短。
请改用边框,标题位于顶部,列表占用剩余空间。
Fyne 中的对象总是填充分配给它们的空间,但要使其执行您想要的操作,选择正确的容器/布局非常重要。 https://www.php.cn/link/4d6ce445727ef59cc07abb95d3e4a1d4
以上是golang fyne gui 无法调整列表大小的详细内容。更多信息请关注PHP中文网其他相关文章!

Toensureinitfunctionsareeffectiveandmaintainable:1)Minimizesideeffectsbyreturningvaluesinsteadofmodifyingglobalstate,2)Ensureidempotencytohandlemultiplecallssafely,and3)Breakdowncomplexinitializationintosmaller,focusedfunctionstoenhancemodularityandm

goisidealforbeginnersandsubableforforcloudnetworkservicesduetoitssimplicity,效率和concurrencyFeatures.1)installgromtheofficialwebsitealwebsiteandverifywith'.2)

开发者应遵循以下最佳实践:1.谨慎管理goroutines以防止资源泄漏;2.使用通道进行同步,但避免过度使用;3.在并发程序中显式处理错误;4.了解GOMAXPROCS以优化性能。这些实践对于高效和稳健的软件开发至关重要,因为它们确保了资源的有效管理、同步的正确实现、错误的适当处理以及性能的优化,从而提升软件的效率和可维护性。

Goexcelsinproductionduetoitsperformanceandsimplicity,butrequirescarefulmanagementofscalability,errorhandling,andresources.1)DockerusesGoforefficientcontainermanagementthroughgoroutines.2)UberscalesmicroserviceswithGo,facingchallengesinservicemanageme

我们需要自定义错误类型,因为标准错误接口提供的信息有限,自定义类型能添加更多上下文和结构化信息。1)自定义错误类型能包含错误代码、位置、上下文数据等,2)提高调试效率和用户体验,3)但需注意其复杂性和维护成本。

goisidealforbuildingscalablesystemsduetoitssimplicity,效率和建筑物内currencysupport.1)go'scleansyntaxandaxandaxandaxandMinimalisticDesignenhanceProductivityAndRedCoductivityAndRedCuceErr.2)ItSgoroutinesAndInesAndInesAndInesAndineSandChannelsEnablenableNablenableNableNablenableFifficConcurrentscorncurrentprogragrammentworking torkermenticmminging

Initfunctionsingorunautomationbeforemain()andareusefulforsettingupenvorments和InitializingVariables.usethemforsimpletasks,避免使用辅助效果,andbecautiouswithTestingTestingTestingAndLoggingTomaintAnainCodeCodeCodeClarityAndTestesto。

goinitializespackagesintheordertheordertheyimported,thenexecutesInitFunctionswithinApcageIntheirdeFinityOrder,andfilenamesdetermineTheOrderAcractacractacrosmultiplefiles.thisprocessCanbeCanbeinepessCanbeInfleccessByendercrededBydeccredByDependenciesbetenciesbetencemendencenciesbetnependendpackages,whermayleLeadtocomplexinitialitialializizesizization


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

DVWA
Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中

WebStorm Mac版
好用的JavaScript开发工具

Atom编辑器mac版下载
最流行的的开源编辑器

EditPlus 中文破解版
体积小,语法高亮,不支持代码提示功能

MinGW - 适用于 Windows 的极简 GNU
这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。