<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## 安裝 ``` go mod init fyneDemo go get fyne.io/fyne ``` ## 各種軟件包說明 ### fyne 1. 用途:提供所有fyne代碼中共有的基本定義,包含數據類型和接口 | 命令 | 說明 | | ------------ | ------------ | | `fyne.NewSize(200, 400)` | 設置應用的寬高,需配合`widget`使用 | | `fyne.NewPos(20, 20)` | 設置一個偏移量 | | `container := fyne.NewContainer(text1, text2, text3)` | 新建一個容器 | ### app 1. 用途:提供用于啟動新應用程序的api 2. | 命令 | 說明 | | ------------ | ------------ | | `myApp := app.New()` | 新建一個應用 | | `myWindow := myApp.NewWindow("hello")` | 新建一個窗口 | | `myWindow.ShowAndRun()` | 顯示窗口,并運行,等同于`myWindow.Show()`和`myApp.Run()`,若有第二個窗口,則第二個窗口只可調用`myWindow.Show()`方法 | | `myWindow.SetContent()` | 給窗口設置內容 | ### widget 1. 用途:提供各種各樣的小部件(如按鈕、標簽等) | 命令 | 說明 | | ------------ | ------------ | | `w.Resize(fyne.NewSize(200, 400))` | 設置寬高 | | `widget.NewHyperlink("百度", url)` | 設置一個超鏈接,需配合`url, _ := url.Parse("http://www.baidu.com")`使用 | | `content := widget.NewLabel("text")` | 設置一段文字 | | `content := widget.NewButton("click me", clickFunc())` | 設置一個按鈕,`clickFunc()為點擊事件后進行的操作` | | `content := widget.NewButtonWithIcon("Home", theme.HomeIcon(), clickFunc())` | 設置一個帶圖標的點擊按鈕 | | `content := widget.NewVBox()` | 創建一個盒子 | | `content.Append()` | 追加元素 | | `input := widget.NewEntry()` | 設置一個輸入框 | | `textArea := widget.NewMultiLineEntry()` | 設置多行輸入框 | | `input.SetPlaceHolder("Enter text...")` | 設置輸入框的提示內容 | | `check := widget.NewCheck("Optional", test()` | 設置復選框 | | `radio := widget.NewRadio([]string{"Option 1", "Option 2"}, test())` | 設置單選框 | | `combo := widget.NewSelect([]string{"Option 1", "Option 2"}, test())` | 設置select選擇器| | `progress := widget.NewProgressBar()` | 設置進度條 | | `progress.SetValue(i)` | 設置進度 | | `infinite := widget.NewProgressBarInfinite()` | 設置無限進度條 | 設置一個表單 ``` form := &widget.Form{ Items: []*widget.FormItem{ // we can specify items in the constructor {"Entry", entry}}, OnSubmit: func() { // optional, handle form submission log.Println("Form submitted:", entry.Text) log.Println("multiline:", textArea.Text) myWindow.Close() }, } // we can also append items form.Append("Text", textArea) ``` 設置tab欄 ``` tabs := widget.NewTabContainer( widget.NewTabItem("Tab 1", widget.NewLabel("Hello")), widget.NewTabItem("Tab 2", widget.NewLabel("World!"))) tabs.SetTabLocation(widget.TabLocationLeading) // 設置為豎向的tab ``` 設置工具欄 ``` toolbar := widget.NewToolbar( widget.NewToolbarAction(theme.DocumentCreateIcon(), func() { log.Println("New document") }), widget.NewToolbarSeparator(), widget.NewToolbarAction(theme.ContentCutIcon(), func() {}), widget.NewToolbarAction(theme.ContentCopyIcon(), func() {}), widget.NewToolbarAction(theme.ContentPasteIcon(), func() {}), widget.NewToolbarSpacer(), widget.NewToolbarAction(theme.HelpIcon(), func() { log.Println("Display help") }), ) content := fyne.NewContainerWithLayout(layout.NewBorderLayout(toolbar, nil, nil, nil), toolbar, widget.NewLabel("Content")) ``` ### canvas 1. 用途:提供繪圖api | 命令 | 說明 | | ------------ | ------------ | | `myCanvas := myWindow.Canvas()` | 創建一個新畫布 | | `text := canvas.NewText("Text", color.White)` | 創建白色的文字 | | `text.TextStyle.Bold = true` | 設置文字的樣式 | | `text2.Move(fyne.NewPos(20, 20))` | 移動文字 | | `canvas.NewRectangle(color.Black)` | 創建一個矩形 | | `canvas.NewLine(color.Gray{0x66})` | 創建一條線段 | | `circle := canvas.NewCircle(color.White)` | 創建一個圓 | | `canvas.NewImageFromResource(theme.FyneLogo())` | 創建一個圖片資源 | | `myCanvas.SetContent(text)` | 將文字添加到畫布上 | ### dialog 1. 用途:處理彈出框 設置一個詢問按鈕 ``` dialog.NewConfirm("標題", "內容", func(checked bool) { fmt.Println("333") }, myWindow) ``` ### layout 1. 用途:提供各種布局使用的容器 設置grid布局 ``` text1 := canvas.NewText("1", color.White) text2 := canvas.NewText("2", color.White) text3 := canvas.NewText("3", color.White) grid := fyne.NewContainerWithLayout(layout.NewGridLayout(2), text1, text2, text3) ``` 設置`fixed`布局 ``` text1 := canvas.NewText("1", color.White) text2 := canvas.NewText("2", color.White) text3 := canvas.NewText("3", color.White) grid := fyne.NewContainerWithLayout(layout.NewFixedGridLayout(fyne.NewSize(50, 50)), text1, text2, text3) ``` 設置邊界布局 ``` top := canvas.NewText("top bar", color.White) left := canvas.NewText("left", color.White) middle := canvas.NewText("content", color.White) content := fyne.NewContainerWithLayout(layout.NewBorderLayout(top, nil, left, nil), top, left, middle) ``` 設置表單布局 ``` label1 := canvas.NewText("Label 1", color.Black) value1 := canvas.NewText("Value", color.White) label2 := canvas.NewText("Label 2", color.Black) value2 := canvas.NewText("Something", color.White) grid := fyne.NewContainerWithLayout(layout.NewFormLayout(), label1, value1, label2, value2) ``` 設置居中布局 ``` img := canvas.NewImageFromResource(theme.FyneLogo()) img.FillMode = canvas.ImageFillOriginal text := canvas.NewText("Overlay", color.Black) content := fyne.NewContainerWithLayout(layout.NewCenterLayout(), img, text) ``` 設置占滿布局 ``` img := canvas.NewImageFromResource(theme.FyneLogo()) text := canvas.NewText("Overlay", color.Black) content := fyne.NewContainerWithLayout(layout.NewMaxLayout(), img, text) ``` ### test 1. 用途:測試包
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看