QR-Code Generator – Fyne Golang GUI Tutorial 64

QR-Code Generator – Fyne Golang GUI Tutorial 64

https://youtu.be/Gj8tQAWa3Y0

package main
// import fyne
import (
    "fmt"
    "strconv"
    "fyne.io/fyne/v2"
    "fyne.io/fyne/v2/app"
    "fyne.io/fyne/v2/container"
    "fyne.io/fyne/v2/widget"
    "github.com/skip2/go-qrcode"
)
func main() {
    // new app
    a := app.New()
    // title & window
    w := a.NewWindow("Qr code Generator")
    // resize
    w.Resize(fyne.NewSize(400, 400))
    // qrcode generator
    url := widget.NewEntry()
    url.SetPlaceHolder("Enter url ...")
    size := widget.NewEntry()
    size.SetPlaceHolder("Enter file size i.e 256 ...")
    size_1, _ := strconv.Atoi(size.Text)
    file_name := widget.NewEntry()
    file_name.SetPlaceHolder("Enter file name ...")
    btn := widget.NewButton("Create", func() {
        // we are going to use qrcode lib
        // go get -u github.com/skip2/go-qrcode/
        // install and use
        // file content
        // quality / resolution
        // size of image 256x256
        err1 := qrcode.WriteFile(
            url.Text,
            qrcode.Highest,
            size_1,
            fmt.Sprintf("%s.png", file_name.Text),
            // sprintf will add add suffix .png
        )
        if err1 != nil {
            fmt.Println(err1)
        }
    })
    w.SetContent(container.NewVBox(
        url,
        size,
        file_name,
        btn,
    ))
    w.ShowAndRun()
}

 

Download Code

Fyne Golang GUI Course

Tony BB
 

TonyBB is a Coach , marketer, hypnotist and a founder of RSKVF Production who specializes in providing simple, affordable, and easy to use solutions for Life.

Click Here to Leave a Comment Below 0 comments

Leave a Reply: