Fyne Golang – Change line position horizontal & vertical
Fyne Golang – Change line position horizontal & vertical
Source Code
<div> <div>package main</div> <div>import (</div> <div> "image/color"</div> <div> "fyne.io/fyne/v2"</div> <div> "fyne.io/fyne/v2/app"</div> <div> "fyne.io/fyne/v2/canvas"</div> <div> "fyne.io/fyne/v2/container"</div> <div>)</div> <div>// main func</div> <div>func main() {</div> <div> // New app</div> <div> a := app.New()</div> <div> // new window</div> <div> w := a.NewWindow("Change position of line horizontal & vertical")</div> <div> // set windows size</div> <div> w.Resize(fyne.NewSize(400, 400))</div> <div> // lets create our first line</div> <div> line1 := canvas.NewLine(color.RGBA{R: 255, G: 0, B: 0, A: 255})</div> <div> // lets setup line positions</div> <div> line1.Position1 = fyne.NewPos(20, 40) // x= 20, y= 40</div> <div> line1.Position2 = fyne.NewPos(120, 40) // x= 20, y= 140</div> <div> // change the values and make it horizontal</div> <div> // lets make it thick</div> <div> line1.StrokeWidth = 5</div> <div> // without using container you can't change orientation</div> <div> // lets create a container</div> <div> c := container.NewWithoutLayout(line1) // container will hold the widget</div> <div> // set content</div> <div> // now put container in the content</div> <div> w.SetContent(c) // we will place widgets here</div> <div> // show and run my app</div> <div> w.ShowAndRun()</div> <div>}</div> </div>