纯go语言实现flutter风格桌面GUI框架ui1、支持windows、linux、unix、masOS、ios、android等操作系统2、代码风格和flutter基本差不多如果会flutter和go语言无缝切换上手如果熟悉go语言很快上手。3、框架有上100个组件足以绝大部复杂应用ui框架第1个组件button组件完整代码packagemainimport(fmtimagelogrender/layoutrender/widget/materialui)typeButtonDemostruct{app*ui.App counterintcounterLabel*ui.Label statusLabel*ui.Label}funcNewButtonDemo()*ButtonDemo{log.Println(count:,1)d:ButtonDemo{}d.appui.NewApp(Button 组件示例,500,600)d.counterLabelui.NewLabel(计数: 0).SetFontSize(24).SetBold()d.statusLabelui.NewLabel(点击按钮查看效果).SetFontSize(14).SetTextColor(ui.ColorHint)d.app.SetBgColor(ui.ColorBackground)returnd}func(d*ButtonDemo)Layout(gtx layout.Context,th*material.Theme)layout.Dimensions{log.Println(count:,2)ui.FillRect(gtx,image.Rect(0,0,gtx.Constraints.Max.X,gtx.Constraints.Max.Y),ui.ColorBackground.NRGBA())returnui.Column{Spacing:16,Children:[]ui.Widget{ui.NewTitleLabel(Button 组件示例),d.counterLabel,ui.NewLabel(实心按钮 (ElevatedButton)).SetFontSize(14).SetBold(),ui.NewButton(默认按钮,func(){d.counterd.counterLabel.Textfmt.Sprintf(计数: %d,d.counter)log.Println(fmt.Sprintf(点击了默认按钮:%d,d.counter))d.app.Refresh()}).SetID(btn_default).SetWidth(120).SetHeight(36),ui.NewButton(宽按钮,func(){d.counterd.counterLabel.Textfmt.Sprintf(计数: %d,d.counter)d.app.Refresh()}).SetID(btn_wide).SetWidth(200).SetHeight(36),ui.NewButton(圆角按钮,func(){d.counterd.counterLabel.Textfmt.Sprintf(计数: %d,d.counter)d.app.Refresh()}).SetID(btn_rounded).SetWidth(120).SetHeight(36).SetRadius(18),ui.NewLabel(描边按钮 (OutlinedButton)).SetFontSize(14).SetBold(),ui.NewOutlinedButton(描边按钮,func(){d.counterd.counterLabel.Textfmt.Sprintf(计数: %d,d.counter)d.app.Refresh()}).SetID(btn_outlined).SetWidth(120).SetHeight(36),ui.NewLabel(文本按钮 (TextButton)).SetFontSize(14).SetBold(),ui.NewTextButton(文本按钮,func(){d.counterd.counterLabel.Textfmt.Sprintf(计数: %d,d.counter)d.app.Refresh()}).SetID(btn_text),ui.NewLabel(自定义样式).SetFontSize(14).SetBold(),ui.NewButton(红色按钮,func(){d.counterd.counterLabel.Textfmt.Sprintf(计数: %d,d.counter)d.app.Refresh()}).SetID(btn_red).SetWidth(120).SetHeight(36).SetBackground(ui.ColorError).SetTextColor(ui.Color{R:0xFF,G:0xFF,B:0xFF,A:255}),ui.NewLabel(图标按钮 (IconButton)).SetFontSize(14).SetBold(),ui.Row{Spacing:8,Children:[]ui.Widget{ui.NewIconButton(ui.NewIcon(ui.IconHome),func(){d.statusLabel.Text点击了 Home 图标按钮d.app.Refresh()}).SetID(btn_home),ui.NewIconButton(ui.NewIcon(ui.IconFavorite).SetColor(ui.ColorError),func(){d.statusLabel.Text点击了 Favorite 图标按钮d.app.Refresh()}).SetID(btn_favorite),ui.NewIconButton(ui.NewIcon(ui.IconSettings).SetColor(ui.ColorPrimary),func(){d.statusLabel.Text点击了 Settings 图标按钮d.app.Refresh()}).SetID(btn_settings),ui.NewIconButton(ui.NewIcon(ui.IconDelete).SetColor(ui.ColorError),func(){d.statusLabel.Text点击了 Delete 图标按钮d.app.Refresh()}).SetID(btn_delete),ui.NewIconButton(ui.NewIcon(ui.IconSearch).SetColor(ui.ColorHint),func(){d.statusLabel.Text点击了 Search 图标按钮d.app.Refresh()}).SetID(btn_search),ui.NewIconButton(ui.NewCustomIcon(ui.ShowImage(D:\\project\\ui\\example\\button\\baseline_add_home_black_18dp.png).SetWidth(24).SetHeight(24)),func(){d.statusLabel.Text点击了自定义图标按钮d.app.Refresh()},).SetID(btn_star),},},ui.NewLabel(浮动按钮 (FloatingButton)).SetFontSize(14).SetBold(),ui.Row{Spacing:12,Children:[]ui.Widget{ui.NewFloatingButton(ui.NewIcon(ui.IconAdd).SetColor(ui.ColorOnPrimary),func(){d.counterd.counterLabel.Textfmt.Sprintf(计数: %d,d.counter)d.app.Refresh()}).SetID(btn_add),ui.NewFloatingButton(ui.NewIcon(ui.IconEdit).SetColor(ui.ColorOnPrimary),func(){d.statusLabel.Text点击了编辑浮动按钮d.app.Refresh()}).SetID(btn_edit),ui.NewFloatingButton(ui.NewCustomIcon(ui.NewLabel(♥).SetFontSize(18).SetTextColor(ui.ColorOnPrimary)),func(){d.statusLabel.Text点击了自定义心形浮动按钮d.app.Refresh()},).SetID(btn_heart),ui.NewFloatingButton(ui.NewCustomIcon(ui.NewLabel(★).SetFontSize(20).SetTextColor(ui.ColorOnPrimary)),func(){d.statusLabel.Text点击了自定义★形浮动按钮d.app.Refresh()},).SetID(btn_fav),},},ui.NewButton(长按事件,nil).SetOnLongPress(func(){d.statusLabel.Text点击了长按按钮d.app.Refresh()}).SetID(btn_longpress),d.statusLabel,ui.NewLabel(自适应长度按钮),ui.NewButton(自适应长度按钮,nil).SetID(btn_adaptive_1).SetWidth(-1).SetHeight(40),ui.NewButton(自适应长度按钮,nil).SetID(btn_adaptive_2).SetWidth(150).SetHeight(-1),},}.Layout(gtx,th)}funcmain(){demo:NewButtonDemo()log.Println(count:,3)demo.app.SetRoot(demo)log.Println(count:,4)demo.app.Run()}效果